[AstroPy] Convert from AltAz to ICRS

Benjamin Weiner bjw at as.arizona.edu
Tue Nov 26 13:34:48 EST 2019


Hi Eric,

The precession that is causing this issue is the precession of the earth
relative to the axis of the ICRS coordinate system, which is within an
arcsec or so of J2000.  The example used July 2012 so the earth's axis is
12 years off the coordinate system axis.  Try the example again but with an
observation time in July 2000:

time2 = Time('2000-07-12 23:00:00') - utcoffset
m33altaz = m33.transform_to(AltAz(obstime=time2,location=bear_mountain))
new_altaz = SkyCoord(AltAz(obstime=time2 + 0.5*u.sday,
                    az=m33altaz.az,
                    alt=m33altaz.alt,
                   location=bear_mountain))
newradec = new_altaz.transform_to('icrs')
print(m33.to_string('hmsdms'))
print(newradec.to_string('hmsdms'))
# prints:
# 01h33m50.904s +30d39m35.79s
# 13h33m51.157s +30d39m20.5722s

These are much closer to 12 hours RA difference.

cheers,
Ben


On Tue, Nov 26, 2019 at 12:01 PM <astropy-request at python.org> wrote:

> Send AstroPy mailing list submissions to
>         astropy at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/astropy
> or, via email, send a message with subject or body 'help' to
>         astropy-request at python.org
>
> You can reach the person managing the list at
>         astropy-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of AstroPy digest..."
>
>
> Today's Topics:
>
>    1. Re: Convert from AltAz to ICRS (keithmclaurin at gmail.com)
>    2. Re: Convert from AltAz to ICRS (Eric Jensen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 26 Nov 2019 00:06:54 -0500
> From: keithmclaurin at gmail.com
> To: Astronomical Python mailing list <astropy at python.org>
> Subject: Re: [AstroPy] Convert from AltAz to ICRS
> Message-ID: <595E44E9-2129-41AB-BD32-A94D6BF77F43 at gmail.com>
> Content-Type: text/plain;       charset=utf-8
>
> The RA and dec changes mostly due to precession is my understanding.
>
> Sent from my iPhone
>
> > On Nov 23, 2019, at 15:20, Eric Jensen <ejensen1 at swarthmore.edu> wrote:
> >
> > Hi Franco,
> >
> > You can use the same transform_to method that is given in the example
> docs, just in the other direction, e.g.
> >
> > object_radec = object_altaz.transform_to(?icrs')
> >
> > Referring to the example here:
> >
> https://docs.astropy.org/en/stable/generated/examples/coordinates/plot_obs-planning.html#sphx-glr-generated-examples-coordinates-plot-obs-planning-py
> >
> > Here is some code based on that example, that extends it to show a
> transformation back to RA and Dec:
> >
> > import astropy.units as u
> > from astropy.time import Time
> > from astropy.coordinates import SkyCoord, EarthLocation, AltAz
> >
> > # Get M33's coordinates
> > m33 = SkyCoord.from_name('M33')
> >
> > # Define a location for observation:
> > bear_mountain = EarthLocation(lat=41.3*u.deg, lon=-74*u.deg,
> height=390*u.m)
> > utcoffset = -4*u.hour  # Eastern Daylight Time
> > time = Time('2012-07-12 23:00:00') - utcoffset
> >
> > # Find the alt/az at that time:
> > m33altaz = m33.transform_to(AltAz(obstime=time,location=bear_mountain))
> > print("M33's Altitude = {0.alt:.2f}, Azimuth = {0.az:
> .1f}".format(m33altaz))
> >
> > # prints:  M33's Altitude = 0.13 deg, Azimuth = 47.3 deg
> >
> > # Look at the same alt/az,
> > # but half a sidereal day later:
> > new_altaz = SkyCoord(AltAz(obstime=time + 0.5*u.sday,
> >                     az=m33altaz.az,
> >                     alt=m33altaz.alt,
> >                    location=bear_mountain))
> >
> > # Transform back to RA, Dec;
> > # should get the same Dec as before but RA 12 hours different:
> > newradec = new_altaz.transform_to('icrs')
> > print(m33.to_string('hmsdms'))
> > print(newradec.to_string('hmsdms?))
> >
> > # Prints
> > # 01h33m50.904s +30d39m35.79s
> > # 13h33m59.1873s +30d47m03.8071s
> >
> > Interestingly, the declination isn?t *exactly* the same and the RA
> doesn?t differ by exactly 12 hours - I wonder why?   But overall you can
> see the idea for doing what you want.
> >
> > Best,
> >
> > Eric
> >
> >
> >> On Nov 23, 2019, at 2:00 PM, franco basti <franco.basti at gmail.com>
> wrote:
> >>
> >>
> >> Can anyone help me converting from a alt az to ra,dec ?
> >> all I can find are examples that convert from ra,dec to alt,az
> >>
> >> Thx
> >> Franco
> >>
> >> _______________________________________________
> >> AstroPy mailing list
> >> AstroPy at python.org
> >> https://mail.python.org/mailman/listinfo/astropy
> >
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at python.org
> > https://mail.python.org/mailman/listinfo/astropy
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 26 Nov 2019 07:58:58 -0500
> From: Eric Jensen <ejensen1 at swarthmore.edu>
> To: Astronomical Python mailing list <astropy at python.org>
> Subject: Re: [AstroPy] Convert from AltAz to ICRS
> Message-ID: <6CE26C72-6BFE-437C-8DBB-B75A21C28B63 at swarthmore.edu>
> Content-Type: text/plain;       charset=utf-8
>
>
> > On Nov 26, 2019, at 12:06 AM, keithmclaurin at gmail.com wrote:
> >
> > The RA and dec changes mostly due to precession is my understanding.
>
> Thanks for responding.  A quick back-of-the-envelope calculation shows
> that precession (360 degrees in 26,000 years) should be less than 0.1
> arcsecond over 12 hours, whereas the difference here is quite a bit bigger,
> about 7.5 arcminutes.  So it must be something else - maybe some internal
> rounding or (more likely) some more subtle misunderstanding by me of some
> conversion / reference frame issue.  In any case, it?s not really germane
> to the original query, but still has my curiosity piqued.
>
> Eric
>
> >
> >> On Nov 23, 2019, at 15:20, Eric Jensen <ejensen1 at swarthmore.edu> wrote:
> >>
> >> Hi Franco,
> >>
> >> You can use the same transform_to method that is given in the example
> docs, just in the other direction, e.g.
> >>
> >> object_radec = object_altaz.transform_to(?icrs')
> >>
> >> Referring to the example here:
> >>
> https://docs.astropy.org/en/stable/generated/examples/coordinates/plot_obs-planning.html#sphx-glr-generated-examples-coordinates-plot-obs-planning-py
> >>
> >> Here is some code based on that example, that extends it to show a
> transformation back to RA and Dec:
> >>
> >> import astropy.units as u
> >> from astropy.time import Time
> >> from astropy.coordinates import SkyCoord, EarthLocation, AltAz
> >>
> >> # Get M33's coordinates
> >> m33 = SkyCoord.from_name('M33')
> >>
> >> # Define a location for observation:
> >> bear_mountain = EarthLocation(lat=41.3*u.deg, lon=-74*u.deg,
> height=390*u.m)
> >> utcoffset = -4*u.hour  # Eastern Daylight Time
> >> time = Time('2012-07-12 23:00:00') - utcoffset
> >>
> >> # Find the alt/az at that time:
> >> m33altaz = m33.transform_to(AltAz(obstime=time,location=bear_mountain))
> >> print("M33's Altitude = {0.alt:.2f}, Azimuth = {0.az:
> .1f}".format(m33altaz))
> >>
> >> # prints:  M33's Altitude = 0.13 deg, Azimuth = 47.3 deg
> >>
> >> # Look at the same alt/az,
> >> # but half a sidereal day later:
> >> new_altaz = SkyCoord(AltAz(obstime=time + 0.5*u.sday,
> >>                    az=m33altaz.az,
> >>                    alt=m33altaz.alt,
> >>                   location=bear_mountain))
> >>
> >> # Transform back to RA, Dec;
> >> # should get the same Dec as before but RA 12 hours different:
> >> newradec = new_altaz.transform_to('icrs')
> >> print(m33.to_string('hmsdms'))
> >> print(newradec.to_string('hmsdms?))
> >>
> >> # Prints
> >> # 01h33m50.904s +30d39m35.79s
> >> # 13h33m59.1873s +30d47m03.8071s
> >>
> >> Interestingly, the declination isn?t *exactly* the same and the RA
> doesn?t differ by exactly 12 hours - I wonder why?   But overall you can
> see the idea for doing what you want.
> >>
> >> Best,
> >>
> >> Eric
> >>
> >>
> >>> On Nov 23, 2019, at 2:00 PM, franco basti <franco.basti at gmail.com>
> wrote:
> >>>
> >>>
> >>> Can anyone help me converting from a alt az to ra,dec ?
> >>> all I can find are examples that convert from ra,dec to alt,az
> >>>
> >>> Thx
> >>> Franco
> >>>
> >>> _______________________________________________
> >>> AstroPy mailing list
> >>> AstroPy at python.org
> >>> https://mail.python.org/mailman/listinfo/astropy
> >>
> >> _______________________________________________
> >> AstroPy mailing list
> >> AstroPy at python.org
> >> https://mail.python.org/mailman/listinfo/astropy
> > _______________________________________________
> > AstroPy mailing list
> > AstroPy at python.org
> > https://mail.python.org/mailman/listinfo/astropy
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
>
> ------------------------------
>
> End of AstroPy Digest, Vol 158, Issue 4
> ***************************************
>


-- 
Benjamin Weiner
Staff Scientist / Associate Astronomer, MMT / Steward Observatory
bjw at as.arizona.edu
http://mingus.mmto.arizona.edu/~bjw/ <http://mingus.as.arizona.edu/~bjw/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20191126/76e5c1b9/attachment-0001.html>


More information about the AstroPy mailing list