Home > atmlab > time > mjd2doy.m

mjd2doy

PURPOSE ^

MJD2DOY Conversion of MJD to day of year

SYNOPSIS ^

function d = mjd2doy(mjd)

DESCRIPTION ^

 MJD2DOY   Conversion of MJD to day of year  

    Calculates the day of the year (DOY) by combining *mjd2date* and 
    *dayofyear*. The fractional part of DOY is kept.

    Note that DOY 1 starts 00:00 of January 1. The possible range of DOY is
    then [1,367[.

 FORMAT   d = mjd2doy(mjd)
        
 OUT   d     Day of year.
 IN    mjd   Modified julian date. Can be a tensor.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

mjd2doy.m

SOURCE CODE ^

0001 % MJD2DOY   Conversion of MJD to day of year
0002 %
0003 %    Calculates the day of the year (DOY) by combining *mjd2date* and
0004 %    *dayofyear*. The fractional part of DOY is kept.
0005 %
0006 %    Note that DOY 1 starts 00:00 of January 1. The possible range of DOY is
0007 %    then [1,367[.
0008 %
0009 % FORMAT   d = mjd2doy(mjd)
0010 %
0011 % OUT   d     Day of year.
0012 % IN    mjd   Modified julian date. Can be a tensor.
0013 
0014 % 2006-03-31   Created by Patrick Eriksson.
0015 
0016 function d = mjd2doy(mjd)
0017                                                                             %&%
0018 rqre_datatype( mjd, @isnumeric );                                           %&%
0019 
0020 %make sure the data is double
0021 mjd = double(mjd);
0022 
0023 [year, month, day, hour, minute, second] = mjd2date( mjd(:) );
0024 
0025 %= *dayofyear* does not handle column vectors
0026 %
0027 if dimens(year) < 2  & length(year) > 1
0028   year   = vec2row( year );
0029   month  = vec2row( month );
0030   day    = vec2row( day );
0031   hour   = vec2row( hour );
0032   minute = vec2row( minute );
0033   second = vec2row( second );
0034 end
0035 
0036 
0037 %- To ensure that d gets same size as mjd
0038 %
0039 d = zeros( size( mjd ) );
0040 
0041 
0042 d(:) = dayofyear( year, month, day, hour, minute, second );

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005