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

Eric LN Jensen ejensen1 at swarthmore.edu
Tue Jan 2 12:56:31 EST 2024


Hi Paolo, 

Michael has already given a good answer about how to get hour angle directly with astropy routines, but as you’re hoping to teach some of this material, it might also be helpful to point out that it’s straightforward to calculate HA from the RA you’re already getting from the examples you show, plus the related concept of local sidereal time (LST).  

LST at any given location gives the RA that is currently on the meridian, whereas the hour angle of an object is the amount of time until (or since) the object crosses the meridian.  Thus, if you calculate LST from astropy routines (e.g. https://docs.astropy.org/en/stable/api/astropy.time.Time.html#astropy.time.Time.sidereal_time), you can easily find HA from

HA_Sun = LST – RA_Sun

Hope this helps, 

Eric


> On Jan 2, 2024, at 11:23 AM, Paolo Sereni via AstroPy <astropy at python.org> wrote:
> 
> 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 1
> import astropy.units as u
> from astropy.coordinates import AltAz, EarthLocation, SkyCoord
> from astropy.time import Time
> from 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 is
> my_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 2
> from astropy.coordinates import EarthLocation, Longitude, SkyCoord, get_body, solar_system_ephemeris
> from astropy.time import Time
> import 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.lat
> print("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
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy

––––
Eric Jensen (he/him)
Professor of Astronomy
Walter Kemp Professor of the Natural Sciences
Interim Dean of Academic Success
Swarthmore College
Parrish E108, 610-328-8249




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20240102/c7f86050/attachment-0001.html>


More information about the AstroPy mailing list