[AstroPy] Question on the coordinates of the sun: Hour angle instead of RA, how?

Paolo Sereni serenipaolo at yahoo.com
Tue Jan 2 11:23:53 EST 2024


Hello everyone,
first a couple of words about myself: I am a hobby astronomer and I'm presently teaching to future physics school-teachers. In my lesson I would like to introduce some very basics concepts of astronomy and I use Stellarium as additional tool. My goal is to develop enough material to be able to understand and build a sun dial. Since I'm also giving an introductory course in python programming, astropy seems to be the perfect library to perform some calculations.
Specifically, I would like to be able to calculate for any given day an time the *Hour Angle* and Declination of the Sun as seen from Salzburg, where I live and teach.
Looking at the impressive documentation of astropy I found two very promising examples, however both of them calculate RA (right ascension) and DEC instead of HA (Hour Angle) and DEC. I do not know how to solve this problem.
I do not know whether I have to use another "frame" (?) or if I have to "manually" correct using the Hour Angle of the first point of Aries (something like HA = HA_Aries + RA)...???? ( in this case where/how can I find HA_Aries?)  Here the code of the two examples:-------------------------------------------#Variant 1import astropy.units as u
from astropy.coordinates import AltAz, EarthLocation, SkyCoordfrom astropy.time import Timefrom astropy import coordinates
Salzburg = EarthLocation(lat=13.03333*u.deg, lon=47.8*u.deg, height=424*u.m)#Salzburg time is UTC +1 we need to correct ismy_time = "2023-12-30T12:00:00"my_t = Time(my_time)sun_coordinates = coordinates.get_sun(my_t)print(type(sun_coordinates))print(sun_coordinates)print("\n\nCoordinates of the sun:")print("\tright ascension:  " + str(sun_coordinates.ra))print("\tdeclination:     " + str(sun_coordinates.dec))print("\tdistance:         " + str(sun_coordinates.distance))
---------------------------------------------------#Variant 2from astropy.coordinates import EarthLocation, Longitude, SkyCoord, get_body, solar_system_ephemerisfrom astropy.time import Timeimport astropy.units as u
obs_time = Time('2023-12-30T12:00:00', format='isot', scale='utc')location=EarthLocation(lat=13.03333*u.deg, lon=47.8*u.deg, height=424*u.m)solar_system_ephemeris.set('de432s')sun = get_body('sun', obs_time, location)print("sun: " + str(sun))print("\n\n")aries = SkyCoord(0*u.deg, 0*u.deg, frame='geocentrictrueecliptic', obstime=obs_time, equinox=obs_time)RA = Longitude(sun.itrs.spherical.lon - aries.itrs.spherical.lon)print("RA ="  + str(RA))dec = sun.itrs.spherical.latprint("DEC = " + str(dec))
-------
Which variant would you recommend me? Any help for obtaining HA will be greatly appreciated.
Thank you very much and happy 2024!
Cheers, Paolo Sereni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20240102/092b5f9b/attachment.html>


More information about the AstroPy mailing list