Last active
March 4, 2016 04:25
-
-
Save rlafferty1/9de8952e508f9a6e1379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from math import * | |
#result in hours | |
def get_LST(datestr,long): | |
dt1 = datetime.strptime(datestr,"%Y %m %d %H %M %S") | |
dd=dt1-datetime(2000,1,1,0,0,0) | |
utc = dt1.hour+dt1.minute/60.0+dt1.second/(3600.0) | |
return ((100.46+0.985647*dd.total_seconds()/(86400.0)+long)/15.0 +utc)%24 | |
#result in hours | |
def HA_from_RA(datestr,long,ra): | |
return (get_LST(datestr,long)-ra)%24 | |
def get_az(datestr,long,lat,ra,dec): | |
ha = HA_from_RA(datestr,long,ra) | |
return ((180.0/pi)*atan((cos(ha*pi/12.0)*sin(lat*pi/180.0)-tan(dec*pi/180.0)*cos(lat*pi/180.0))/sin(ha*pi/12.0)))%360 | |
def get_alt(datestr,long,lat,ra,dec): | |
ha = HA_from_RA(datestr,long,ra) | |
return ((180.0/pi)*asin(sin(lat*pi/180.0)*sin(dec*pi/180.0)+cos(lat*pi/180.0)*cos(dec*pi/180.0)*cos(ha*pi/12.0)))%360 | |
ds = "2015 02 07 01 00 00" | |
print(get_LST(ds, -76.6125)) | |
print(HA_from_RA(ds, -76.6125,18.6156)) | |
print(get_az(ds, -76.6125,39.2902778,18.6156,38.783)) | |
print(get_alt(ds, -76.6125,39.2902778,18.6156,38.783)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment