Message Boards Message Boards

0
|
10912 Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Calculating Julian date

Posted 10 years ago

Folks,

I did not find julian date conversion in mathematica 10, so I did a very simple function to evaluate it, using http://scienceworld.wolfram.com/astronomy/JulianDate.html informations.

JD[houratu_, minutetu_, secondstu_, day_, month_, year_] := 
  N[367.*year - IntegerPart[7* (year + IntegerPart[(month + 9)/12.])/4] - 
    IntegerPart[3*(IntegerPart[((year + (month - 9)/7.)/100) + 1]/4)] + 
    IntegerPart[275.*month/9 ] + day + 
    1721028.5 + (hourtu/
      24.) + (minutetu/(24.*60)) + (secondstu/(24.*60*60)), 7];

The time is always calculated for universal time Local.

Ex.: Gregorian Calendar: 16/10/2014, 14:10:04 transform -> Julian date

JD[14, 10, 04, 16, 10, 2014]

2.456947090324074`*^6

POSTED BY: Marcelo De Cicco
7 Replies

Hello all, Just seen this post and this might be usefull. Let me know !

Robert

Attachments:
POSTED BY: Robert Pigeon

David,

Soon I will check your conclusion about the zero time, in the url navy.

Suggestion: Have mathematica ever think about integrate the astronomy catalogs as http://simbad.u-strasbg.fr/..etc.? it willi be a fantastic thing for us from astronomy community, as the Mathematica astronmical data is useful but lack many informations.

We have to deal with a lot of catalogs from simbad, vizier etc...

POSTED BY: Marcelo De Cicco

Hi guys!

Yang, the API converts hh:MM:ss,also?

POSTED BY: Marcelo De Cicco

Spoiler for a very lazy dude:

Because this conversion mechanism is available in the Wolfram Alpha, simply use the built-in API in the Wolfram Language desktop app to retrieve the Julian calendar result:

  1. Call the API from front end and click the pink plus sign: enter image description here

  2. In the pulldown menu choose the "Computable Data"

  3. You should have a WolframAlpha[...] template filled with your input and some options. You can use this expression just like anything else in the Wolfram Language. enter image description here

Boooommm! Done!

POSTED BY: Shenghui Yang

CalendarConvert (new in version 10: http://reference.wolfram.com/language/ref/CalendarConvert.html) will convert dates between different calendars. An example from the documentation of its use is

CalendarConvert[ DateObject[{2014, 10, 16, 14, 10, 4}, TimeZone -> 0], "Julian"]

POSTED BY: David Reiss

David,

for astronomy calculations, we need a number format like that 2.456947090324074`*^6;

POSTED BY: Marcelo De Cicco

Try

julianDate[date_DateObject] :=
 Module[{julian0},

  julian0 = 
   CalendarConvert[
    DateObject[{-4713, 1, 1, 1}, TimeZone -> 0, 
     CalendarType -> "Julian"], "Gregorian"];

  DateDifference[julian0, date]
  ]

then

julianDate[DateObject[{2014, 10, 16, 14, 10, 04}]]

gives

Quantity[2.456947715324074`*^6, "Days"] 

Note that I am using midnight as the reference time for the julian zero date. This URL says that it should be noon: http://aa.usno.navy.mil/data/docs/JulianDate.php but I set it to midnight to conform to your calculation, and the statement on that site is probably in error: midnight makes the most sense, of course.

(I fixed a small typo in the code of an earlier version of this post.)

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract