[AstroPy] using astropy.coordinates.angular_separation()
John Parejko
parejkoj at uw.edu
Thu Aug 10 13:32:13 EDT 2023
There are tools to help automatically transition code from 2 to 3. python2 is no longer supported, and no major projects are producing or updating libraries for python2, so you're just making your own life much more difficult. A few thousand lines of code should be quite easy to do: LSST transitioned about 300,000 lines of code in early 2018.
https://community.lsst.org/t/python-2-no-longer-supported/2845/2
Here is the official transition tool that will take care of most of the necessary changes:
https://docs.python.org/3/library/2to3.html
Note that 2to3 is will be removed in python 3.13, so I definitely recommend doing that transition now. It's probably less work than implementing your own separation code.
John
--
*************************
John Parejko
parejkoj at uw.edu
Rubin Observatory, DIRAC Fellow
http://staff.washington.edu/parejkoj/
Department of Physics and Astronomy
University of Washington, Seattle, WA
**************************
> On Aug 10, 2023, at 9:18 AM, Didelon Pierre <pierre.didelon at cea.fr> wrote:
>
> Hi John
>
> thank you for your very quick answer.
> I didn't notice the inappropriate version of the doc not corresponding to the astropy version I used.
> Unfortunately I will not migrate to Python 3, 'cause I don't want to "translate" more than a thousand line of code from python2 to 3 :-/
> I will use another way to calculate angular distance, at least approximately,
> and try to read the appropriate documentation from now on.
>
> Best
> Pierre
>
>
>
> De : AstroPy <astropy-bounces+pierre.didelon=cea.fr at python.org> de la part de John ZuHone <jzuhone at gmail.com>
> Envoyé : jeudi 10 août 2023 18:02
> À : Astronomical Python mailing list
> Objet : Re: [AstroPy] using astropy.coordinates.angular_separation()
> Hi Pierre,
>
> I should note that you are looking at the page for the "stable" version of AstroPy, which is 5.3.1, whereas you are using a very old version of AstroPy, for which the docs are here:
>
>
>
> Based on my casual look, this method is not in this old version. If you can, I highly recommend upgrading to the latest version, which also necessitates upgrading to Python 3.
>
> Best,
>
> John
>
>> On Aug 10, 2023, at 11:58 AM, Didelon Pierre <pierre.didelon at cea.fr> wrote:
>>
>>
>> Hi everyone
>>
>> I hope I am not disturbing you with a silly question :-/
>>
>> I try to use the astropy.coordinates.angular_separation() utility
>> (https://docs.astropy.org/en/stable/api/astropy.coordinates.angular_separation.html)
>> in python2.7 with astropy 2.0.16 but it seems not available :-/
>>
>> here is the code
>>
>> import astropy.coordinates as ac
>> ...angsep = ac.angular_separation (pix_c_coord[0]*pi/180.,pix_ra*pi/180.,pix_c_coord[1]*pi/180.,pix_dec*pi/180.) *180./pi
>>
>> and the error
>>
>> angsep = ac.angular_separation (pix_c_coord[0]*pi/180.,pix_ra*pi/180.,pix_c_coord[1]*pi/180.,pix_dec*pi/180.) *180./pi AttributeError: 'module' object has no attribute 'angular_separation'
>>
>> Did I miss something?
>>
>> Tank's in advance for any advice
>>
>> Pierre Didelon
>>
>> Astrophysic Department CEA Saclay
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
>
>
> <astropy_logo.ico>_______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/astropy__;!!K-Hz7m0Vt54!ifnTLYBvhdLDK2fGtbvr2KBZVF9Vhnm9D9PuvOdAg55kZqAp-Ztrmi7UHWtbNqG3-bJTttqINltnwS88_dDs0pSi$
More information about the AstroPy
mailing list