I’ve posted this to stackoverflow, but if anyone here has an answer, I’d be truly grateful:
I am trying to calculate the zenith equatorial coordinates (right ascension & declination) for a given latitude, longitude, and observing time. Using astropy
in python
, I have the following:
from datetime import datetime
from astropy.coordinates import EarthLocation, SkyCoord, AltAz
from astropy.time import Time
from astropy.io import fits
from astropy import units as u
# coordinates on Earth
lat, long = 40, 120
lat, long = lat * u.deg, long * u.deg
altitude = 14756 * u.m
# location of obervations
obs_location = EarthLocation.from_geodetic(lat=lat, lon=long, height=altitude)
# observation time, corresponding to 2022-12-08 at 03:22:37.000969
obs_time = Time(datetime([2022,12,8,3,22,37,969]),scale='utc',location=obs_location)
# RIGHT ASCENSION AND DECLINATION at zenith for given lat, long
right_ascension_z = obs_time.sidereal_time('mean','greenwich').to('deg')
declination_z = lat
>> right_ascension_z = <Longitude 127.52856085 deg>, declination_z = <Quantity 40. deg>
Now, the calculated RA and DEC should translate back to an altitude of 90 deg (pointing zenith) for that given observing time and observing location – or at least so I thought. Going backwards:
aa = AltAz(location=obs_location, obstime=obs_time)
coord_zenith = SkyCoord(ra=right_ascension_z,dec=declination_z,frame='icrs',unit=u.deg)
altaz_coord = coord_zenith.transform_to(aa)
print(altaz_coord)
>> <SkyCoord (AltAz: obstime=2022-12-08 03:22:37.000969, location=(-2452005.67593768, 4246998.41117133, 4087470.54616891) m, pressure=0.0 hPa, temperature=0.0 deg_C, relative_humidity=0.0, obswl=1.0 micron): (az, alt) in deg
(317.79729856, 7.01695887)>
The altitude coordinates using AltAz
should be 90 deg. What am I missing?