« Supernova in Ursa Major! | Main | Supernova.. now in colour »

Python: Julian date

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...

TrackBack

TrackBack URL for this entry:
http://krioma.net/cgi-bin/MT-3.38/mt-tb.cgi/544

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on September 12, 2011 7:58 AM.

The previous post in this blog was Supernova in Ursa Major!.

The next post in this blog is Supernova.. now in colour.

Many more can be found on the main index page or by looking through the archives.

Get Firefox! Valid XHTML 1.0! Valid CSS! RSS Feed BlogUniverse - listed Powered by Apache Creative Commons License ringsofsaturnrock's Most Interesting Photos on Flickriver

Powered by
Movable Type 3.38