JD

From DavinciWiki
Jump to: navigation, search

Description

Converts input date and time to UTC Julian Date

Arguments and Return Values

Parameters: Numeric arrays specifying the year, month, day, hour, minute, second, time zone offset, and calendar mode. The calendar mode must be passed by reference, with the name cal.

Return Value: A double-format numeric array with the same organization as the inputs

Usage

Syntax: JD(year, month, day, hour, minute, second, time zone offset, cal=n) or JD(clock(1), cal=n)

The Julian Date is a continuous count of days since noon UTC on January 1, 4713 BCE in the proleptic Julian calendar.

The inputs specifying year, month, day, hour, minute, second, and time zone offset must be in that order. They can be scalar, or they can be (multi-element) arrays. Scalars and arrays can be mixed, but any arrays used must have the same dimensions.

Time zone offset is (local time in hours) - (UTC time in hours). Most time zone offsets are integers. Eastern Standard Time is -5, and Mountain Standard Time is -7. The time zone offset is assumed to be zero (UTC) if not specified.

The only required input is the year. Any omitted parts of the date are set to one, and the time, if omitted, defaults to noon (UTC). Thus JD(2009) returns the Julian Date of noon UTC on January 1, 2009. If the hour is given but minutes and seconds are omitted, minutes and seconds default to zero. If the hour and minute are given but seconds are omitted, seconds default to zero.

For years before 1, use astronomical numbering, e.g. 4713 BCE = -4712. (There was no year 0.)

This function also accepts date and time arrays in the format returned by the clock function. To quickly get the current Julian Date, enter JD(clock(1)).

If the calendar mode is specified, it must be passed by reference, with the name cal and a value of 0 or 1. All other inputs should be passed by value. (See the examples.)

If the calender mode is omitted, the function will guess, based on the latest input date. For (latest) input dates between October 15, 1582 and December 31, 1919 (when both calendar systems were in use), the function will print a warning about guessing the calendar mode. (Latest) dates before October 15, 1582 use the Julian calendar. (Latest) dates after that use the Gregorian (modern) calendar. This reflects the first changeover date. However, different countries changed at different times. See http://www.tondering.dk/claus/cal/node3.html

The function cannot switch modes midway - it will compute using one calendar system OR the other for ALL members of an input array. If you want to find some JD's for some dates in the Julian calendar and some in the Gregorian calendar, you must enter them separately (that is, first enter the dates from the Julian calendar, then enter the dates from the Gregorian calendar, specifying modes).

The formulae used here are from http://en.wikipedia.org/wiki/Julian_day and have been checked extensively against USNO calculator at http://aa.usno.navy.mil/data/docs/JulianDate.php

The returned value is an integer if only the date (no time) is input. It is a double if any part of the time is input.

When JD() is entered without any arguments, it prints its description, as shown below.

Examples

dv> JD()

Convert input date and time to UTC Julian Date
JD(year, month, day, hour, minute, second, time zone offset, cal=n)
 or JD(clock(1), cal=n) returns the Julian Date (number of days
 since noon UTC on January 1, 4713 BC in the Julian calendar).
The dates/times must be entered in the given order.
For BCE, use astronomical year numbering, e.g. 4713 BCE = -4712
Works for array inputs
cal (sets calendar mode) must be passed by reference
 cal=0 for Julian calendar; cal=1 for Gregorian (modern) calendar
 If cal is omitted, the function will guess, based on the date.
  (Latest) dates before October 15, 1582 use Julian calendar
  (Latest) dates after that use Gregorian calendar
  This reflects the first changeover date. However, different
   countries changed at different times. See
   http://www.tondering.dk/claus/cal/node3.html
 The function cannot switch modes midway - it will compute using
  one calendar system OR the other for ALL members of an input
  array. If you want to find some JD's for some dates in the Julian
  calendar and some in the Gregorian calendar, you must enter them
  separately (e.g. first enter the dates from Julian calendar, then
  enter the dates from the Gregorian calendar, specifying modes).
Returns double-precision Julian Date if given date and time,
 integer Julian Day Number if only given date
Formulae from http://en.wikipedia.org/wiki/Julian_day
Checked extensively against USNO calculator at
 http://aa.usno.navy.mil/data/docs/JulianDate.php
S.Marshall 04-10-2009

0
dv> JD(2009)
2454833
dv> JD(2009, 1)
2454833
dv> JD(2009, 1, 1)
2454833
dv> JD(2009, 1, 1, 12)
2454833.00000000
dv> JD(2009, 1, 1, 12, 0)
2454833.00000000
dv> JD(2009, 1, 1, 12, 0, 0)
2454833.00000000
dv> JD(2009, 1, 1, 12, 0, 0, -7)
2454833.29166667
dv> clock(1)
7x1x1 array of double, bsq format [56 bytes]
2009.00000000000        12.0000000000000        15.0000000000000        11.0000000000000
57.0000000000000        11.5374530000000        -7.0000000000000
dv> JD(clock(1))
2455181.28976402
dv> a = create(12, start=1)
12x1x1 array of int, bsq format [48 bytes]
1       2       3       4       5       6       7       8       9       10      11      12
dv> JD(2009, a)
12x1x1 array of int, bsq format [48 bytes]
2454833 2454864 2454892 2454923 2454953 2454984 2455014 2455045 2455076 2455106 2455137 2455167
dv> JD(2009, a, 1)
12x1x1 array of int, bsq format [48 bytes]
2454833 2454864 2454892 2454923 2454953 2454984 2455014 2455045 2455076 2455106 2455137 2455167
dv> JD(2009, a, 15)
12x1x1 array of int, bsq format [48 bytes]
2454847 2454878 2454906 2454937 2454967 2454998 2455028 2455059 2455090 2455120 2455151 2455181
dv> JD(1918, 11, 11)
Assuming Gregorian calendar
2421909

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Recent Library Changes

Created On: 11-18-2009
Modified On: 05-07-2010

Personal tools