Home > air_sea > julianmd.m

julianmd

PURPOSE ^

JULIANMD: converts Gregorian calendar time to decimal Julian day.

SYNOPSIS ^

function [j]=julianmd(y,m,d,h)

DESCRIPTION ^

 JULIANMD: converts Gregorian calendar time to decimal Julian day.
 [j]=JULIANMD(y,m,d,h) converts Gregorian calendar dates to corresponding
 Julian day numbers.  Although the formal definition holds that Julian 
 days start and end at noon, here Julian days start and end at midnight.
 In this convention, Julian day 2440000 began at 0000 UT, May 23, 1968.
 
   INPUT:  d -  day (1-31) component of Gregorian date
           m -  month (1-12) component
           y -  year (e.g., 1979) component
           h -  decimal hours (assumed 0 if absent)
   
   OUTPUT: j - decimal Julian day number (e.g., 0000 UT Jan 1 is 0.0)
 
   Usage:  [j]=julianmd(y,m,d,h)  (inputs scalars or matrices)
                  or     
           [j]=julianmd([y m d hr min sec])  (nx6 matrix input)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [j]=julianmd(y,m,d,h)
0002 % JULIANMD: converts Gregorian calendar time to decimal Julian day.
0003 % [j]=JULIANMD(y,m,d,h) converts Gregorian calendar dates to corresponding
0004 % Julian day numbers.  Although the formal definition holds that Julian
0005 % days start and end at noon, here Julian days start and end at midnight.
0006 % In this convention, Julian day 2440000 began at 0000 UT, May 23, 1968.
0007 %
0008 %   INPUT:  d -  day (1-31) component of Gregorian date
0009 %           m -  month (1-12) component
0010 %           y -  year (e.g., 1979) component
0011 %           h -  decimal hours (assumed 0 if absent)
0012 %
0013 %   OUTPUT: j - decimal Julian day number (e.g., 0000 UT Jan 1 is 0.0)
0014 %
0015 %   Usage:  [j]=julianmd(y,m,d,h)  (inputs scalars or matrices)
0016 %                  or
0017 %           [j]=julianmd([y m d hr min sec])  (nx6 matrix input)
0018 
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 % 8/28/98: version 1.1 (vectorized by RP)
0021 % 8/5/99: version 2.0
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023      
0024 if nargin==3,
0025       h=0.;
0026 elseif nargin==1,
0027       h=hms2h(y(:,4),y(:,5),y(:,6));
0028       d=y(:,3);
0029       m=y(:,2);
0030       y=y(:,1);
0031 end
0032 mo=m+9;
0033 yr=y-1;
0034 i=(m>2);
0035 mo(i)=m(i)-3;
0036 yr(i)=y(i); 
0037 c = floor(yr/100);
0038 yr = yr - c*100;
0039 j = floor((146097*c)/4) + floor((1461*yr)/4) + ...
0040            floor((153*mo +2)/5) +d +1721119;
0041 
0042 %     if you want Julian days to start and end at noon,
0043 %     replace the following line with:
0044 %     j=j+(h-12)/24;
0045  
0046 j=j+h/24;
0047

Generated on Thu 26-Apr-2007 12:23:13 by m2html © 2003