[AstroPy] RA/Dec to Alt/Az

Eric Jensen ejensen1 at swarthmore.edu
Tue Mar 24 08:37:42 EDT 2020


Hi Peter,

You could try the get_sun function in astropy to be sure you’ve got accurate coordinates for the Sun, and go from there. 

How are you judging true north / south?  If using a compass, be sure to correct for magnetic vs. true north. 

Note that the apparent position of the Sun in the sky gets shifted by atmospheric refraction when it is low in the sky, but I think that effect is too small to explain what you’re seeing (and would be mostly in altitude). 

Good luck,

Eric

P.S. The “Eastern Daylight Time” comment in your code confused me for a bit - might want to change that, as it looks like you’re in Melbourne...

>> On Mar 24, 2020, at 6:14 AM, Peter <pslowater at gmail.com> wrote:
> 
> I am using Stellarium to point a custom mount at the selected object which at this time I am just testing rotation and using the sun & shadow.
> Using the code below from samples it receives the dec/asc and calculates the alt/az.
> The problem I have is that when the sun is northish the az is close to what Stellarium shows but when east or west then the az is about 8 Deg or more off in the calculation compared to Stellarium and the Shadow also is not correct.
> I assume it's the way I am doing the calc, does what I have look correct?
> The RA/DEC from Stellarium is J2000 from what I can work out.
> 
> Peter..
> 
>            dec_in = float(vals[2])
>            asc_in= float(vals[1])
>            M42 = SkyCoord(ra=float(vals[1])*u.degree, dec=float(vals[2])*u.degree, frame='icrs') 
>            home = EarthLocation(lat=-38.06395*u.deg, lon=145.28455*u.deg, height=40*u.m)
>            utcoffset = +11*u.hour  # Eastern Daylight Time
>            time = Time(datetime.datetime.now())
>            print("Time           :",time)
>            time = Time(datetime.datetime.now())- utcoffset
>            print("Time UTC       :",time)
>            m33altaz = M42.transform_to(AltAz(obstime=time,location=home))
>            print(dec_in," : ",asc_in)
>            print("Postion to move:",numpy.around((m33altaz.alt*u.deg).value,3),"  : ",numpy.around((m33altaz.az*u.deg).value,3))
>            print("====")
>            rotation = numpy.around((m33altaz.az*u.deg).value,3)
>            angle = numpy.around((m33altaz.alt*u.deg).value,3)
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20200324/f14d7b25/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2275 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20200324/f14d7b25/attachment.bin>


More information about the AstroPy mailing list