Re: cd_calendar with 360_day calendar

From: Brian Medeiros <brianpm_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 05 2012 - 18:14:38 MDT

Dennis,

Thanks for looking at this. I think my example had an "off-by-one" issue, but if you look at your output around the end of February, you see the problem:

            tcal yyyymmdd TCAL YYYYMMDD
(56) 0.158470 00000228 0.155738 00000227
(57) 0.161202 00000229 0.158470 00000228
(58) 0.000000 00000230 0.161202 00000229
(59) 0.163934 00000301 0.000000 00000230
(60) 0.166667 00000302 0.163934 00000301
(61) 0.169399 00000303 0.166667 00000302

So whatever day is interpreted as 30 February is being returned without a fractional year by the cd_calendar( time, 4 ) call, though it is useful to note that the cd_calendar(time, -2) seems to be working just fine.

.brian

On Jul 5, 2012, at 5:17 PM, Dennis Shea wrote:

> 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 18:06:28 2012

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