Re: cd_calendar with 360_day calendar

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 05 2012 - 17:17:52 MDT

Brian ...

The person who knows the most about cd_calendar
is not available.

It looks the returned day is 'off-by-one.'
A slight modification to your test script:

   time = ispan( 1, 360, 1)
   time@calendar = "360_day"
   time@units = "days since 0-01-01 00:00:00"

   TIME = time - 1
   TIME@calendar = time@calendar
   TIME@units = time@units

   tcal = cd_calendar(time, 4)
   ical = cd_calendar(time,-2)
   TCAL = cd_calendar(TIME, 4)
   ICAL = cd_calendar(TIME,-2)
   print("===")
   print(sprintf("%9.6f",tcal)+" "+sprinti("%8.8i",ical)+" "+ \
         sprintf("%9.6f",TCAL)+" "+sprinti("%8.8i",ICAL))

==============================================================
              tcal yyyymmdd TCAL YYYYMMDD
(0) 0.002732 00000102 0.000000 00000101
(1) 0.005464 00000103 0.002732 00000102
(2) 0.008197 00000104 0.005464 00000103
[snip]
(27) 0.076503 00000129 0.073770 00000128
(28) 0.079235 00000130 0.076503 00000129
(29) 0.084699 00000201 0.079235 00000130
(30) 0.087432 00000202 0.084699 00000201
(31) 0.090164 00000203 0.087432 00000202
[SNIP]
(326) 0.907104 00001128 0.904372 00001127
(327) 0.909836 00001129 0.907104 00001128
(328) 0.912568 00001130 0.909836 00001129
(329) 0.915301 00001201 0.912568 00001130
(330) 0.918033 00001202 0.915301 00001201
(331) 0.920765 00001203 0.918033 00001202
[snip]
(357) 0.991803 00001229 0.989071 00001228
(358) 0.994536 00001230 0.991803 00001229
(359) 1.000000 00010101 0.994536 00001230

On 7/5/12 11:33 AM, Brian Medeiros wrote:
> Hey NCLers,
>
> I tried to send this previously, but I think there was an email glitch
> on my end. Apologies if you've actually seen this before though.
>
> I frequently use cd_calendar to more intuitively deal with time series.
> Today I'm looking at a model data set that uses the "360_day" calendar,
> and I noticed what I suspect is a bug.
>
> In the "360_day" calendar, all months have 30 days, but when I use
> cd_calendar(time, 4) to get YYYY.fraction output, it gives a warning:
> >tcal = cd_calendar(time, 4)
> day_of_year: illegal arguments, year = 0, month = 2, day = 30
>
> Worse than the warning, I also see that it sets the output to the
> current year with no fractional amount at month=2, day=30.
>
> Here's the example script:
> time = ispan( 1, 360, 1)
> time@calendar = "360_day"
> time@units = "days since 0-01-01 00:00:00"
> tcal = cd_calendar(time, 4)
> print(tcal(57:59))
>
> I've checked this on NCL 6.0.0 and 6.1.0-beta (using mirage and my Mac,
> respectively).
>
> ** I also noted that if I change the year in the units attribute to a
> non-leap year, it also gives the same warning for month=2 day=29.
>
>
> If I'm misunderstanding this behavior, please let me know.
>
> .brian
>
>
> _______________
> Brian Medeiros
> Project Scientist
> NCAR/NESL/CGD/AMP
> brianpm@ucar.edu <mailto:brianpm@ucar.edu>
> http://www.cgd.ucar.edu/~brianpm
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 5 17:22:41 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT