MJD

From DavinciWiki
Jump to: navigation, search

Description

Converts input date and time to UTC Modified 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: MJD(year, month, day, hour, minute, second, time zone offset, cal=n) or MJD(clock(1), cal=n)

The Modified Julian Date is a continuous count of days since midnight UTC at the beginning of November 17, 1858 (in the Gregorian 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 midnight (UTC) at the beginning of the input date. Thus MJD(2009) returns the Modified Julian Date of midnight 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 Modified Julian Date, enter MJD(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 MJD'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 MJD() is entered without any arguments, it prints its description, as shown below.

Examples

dv> MJD()

Convert input date and time to UTC Modified Julian Date
MJD(year, month, day, hour, minute, second, time zone offset, cal=n)
 or MJD(clock(1), cal=n) returns the Modified Julian Date (number of
 days since midnight UTC at the beginning of November 17, 1858).
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 MJD'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 Modified Julian Date if given date and time,
 integer Modified Julian Day Number if only given date
Uses function JD for integer JDN calculation, then subtracts
This function therefore returns more precise values than JD for modern
 dates, although the difference is unimportant for most applications.
S.Marshall 04-10-2009

0
dv> MJD(2009)
54832
dv> MJD(2009, 1)
54832
dv> MJD(2009, 1, 1)
54832
dv> MJD(2009, 1, 1, 12)
54832.5000000000
dv> MJD(2009, 1, 1, 12, 0, 0, -7)
54832.7916666667
dv> clock(1)
7x1x1 array of double, bsq format [56 bytes]
2009.00000000000        12.0000000000000        15.0000000000000        12.0000000000000
49.0000000000000        38.7224850000000        -7.0000000000000
dv> MJD(clock(1))
55180.8261556510
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> MJD(2009, a, 1, 12)
12x1x1 array of double, bsq format [96 bytes]
54832.5000000000        54863.5000000000        54891.5000000000        54922.5000000000
54952.5000000000        54983.5000000000        55013.5000000000        55044.5000000000
55075.5000000000        55105.5000000000        55136.5000000000        55166.5000000000
dv> MJD(2009, a, 15, 12)
12x1x1 array of double, bsq format [96 bytes]
54846.5000000000        54877.5000000000        54905.5000000000        54936.5000000000
54966.5000000000        54997.5000000000        55027.5000000000        55058.5000000000
55089.5000000000        55119.5000000000        55150.5000000000        55180.5000000000
dv> MJD(1918, 11, 11)
Assuming Gregorian calendar
21908

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

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

All other topics

  • See navigation on the left

Major Sub-Functions

Recent Library Changes

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

Personal tools