As an astronomer a fast an easy way to calculate the Julian date of an observation is always handy. As I'm currently doing a bunch of python demos and adding some new libraries to some of my tools I though I'd share this one. Oh and if the first sentence confused you: The Julain date or JD is the the interval of time in days and fractions of a day since January 1, 4713 BC Greenwich noon. Now this is how you calculate it:
def julian_date(YY,MM,DD,HR,Min,Sec,UTcor): return 367*YY - (7*(YY+((MM+9)/12))/4) + (275*MM/9)+ DD + 1721013.5 + UTcor/24 - 0.5*sign((100*YY)+MM-190002.5) + 0.5 + HR/24.0 + Min/(60.0*24.0) + Sec/(3600.0*24.0)
So all you need to do is supply the year (YY), month (MM), day (DD), hour (HR), minute (Min), Second (Sec) and the time difference from UT (UTcor) and their is your JD. So for example:
YY = 2011 #year MM = 9 # month DD = 7 #day UTcor = 0 #ut offset HR = 12 #hour Min = 53 #minute Sec = 0 LONG = 0 #degrees, -ve if West +ve if East latitude = 0 #The latitude of the telescope; a scalar JD = julian_date(YY,MM,DD,HR,Min,Sec,UTcor)
You can also grab the function from: jd.py.
I'm probably going to put a php version up on the webpage for people to use too...







