Home > atmlab > time > dayofyear_inverse.m

dayofyear_inverse

PURPOSE ^

DAYOFYEAR_INVERSE if you have the day of year and want the month and day.

SYNOPSIS ^

function out = dayofyear_inverse(year,doy)

DESCRIPTION ^

 DAYOFYEAR_INVERSE if you have the day of year and want the month and day.

 IN: 
       year         %f
       doy          %f

 OUT: structure containing e.g.

  out =    yr: 2006
           mn: 10
          day: 27
    dayofyear: 300

 USAGE out =  dayofyear_inverse(2006,254)

      out = 
               year: 2006
              month: 9
                day: 11
          dayofyear: 254


 27/8-2010 Salomon Eliasson
 2010-10-11 Improved by Gerrit

 $Id: dayofyear_inverse.m 7219 2011-11-23 10:51:25Z seliasson $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

dayofyear_inverse.m

SOURCE CODE ^

0001 function out = dayofyear_inverse(year,doy)
0002 % DAYOFYEAR_INVERSE if you have the day of year and want the month and day.
0003 %
0004 % IN:
0005 %       year         %f
0006 %       doy          %f
0007 %
0008 % OUT: structure containing e.g.
0009 %
0010 %  out =    yr: 2006
0011 %           mn: 10
0012 %          day: 27
0013 %    dayofyear: 300
0014 %
0015 % USAGE out =  dayofyear_inverse(2006,254)
0016 %
0017 %      out =
0018 %               year: 2006
0019 %              month: 9
0020 %                day: 11
0021 %          dayofyear: 254
0022 %
0023 %
0024 % 27/8-2010 Salomon Eliasson
0025 % 2010-10-11 Improved by Gerrit
0026 %
0027 % $Id: dayofyear_inverse.m 7219 2011-11-23 10:51:25Z seliasson $
0028 
0029 errId = ['atmlab:' mfilename ':badInput'];
0030 assert(nargin==2 && isscalar(year) && isscalar(doy),...
0031     errId,'requires year and doy input as scalars')
0032 assert(doy<=daysinyear(year),errId, 'too many days')
0033 
0034 [yr mn day] = jd2date(date2jd(double(year), 1, 0) + double(doy));
0035 out.year = yr;
0036 out.month = mn;
0037 out.day = day;
0038 out.dayofyear = doy;

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