ut_calendar and negative times

From: Ian Harris <i.harris_at_nyahnyahspammersnyahnyah>
Date: Wed Jan 13 2010 - 11:09:44 MST

Hi,

Leaving my 64-bit issues aside for the moment and returning to my trusty G5 Mac, still running NCL 5.1.1 though.

I've found what may be a bug in ut_calendar (or may be my idiocy of course).

I found that when it encountered negative values in the time field, it gave false results.

Here is an example.

We have a monthly 'time' variable, the first element and attributes are as follows:

ncl 6> print (time(0))

Variable: time (subsection)
Type: float
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 5
  time : -39615
  axis : T
  calendar : 360_day
  units : days since 1970-01-01 00:00:0
  long_name : Time
(0) -39615

So we see it's 360 day years (that's not unusual for climate model work). The reference day is Jan 1st 1970, and the first time point is -39615.

Remember it's monthly data, that's why the number ends in '15' (months are usually represented by a day roughly in the middle of the month).

If you examine -39615, it turns out to be 110 years and 15 days (in 360-day years). So the first datum represents Jan 15th 1860, or 'January 1860', which is as expected.

But what happens when we give ut_calendar this?

ncl 9> date = ut_calendar(time(0),-1)
ncl 10> print(date)

Variable: date
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 1
  calendar : 360_day
(0) 172201

The date returned is January 1722.

So, is this a known problem? Or have UKMO crash-tested ut_calendar with their archiving of the HadGEM model output?

Or am I being an idiot again? :)

Cheers

Harry

Ian "Harry" Harris
Climatic Research Unit
School of Environmental Sciences
University of East Anglia
Norwich NR4 7TJ
United Kingdom

IMPORTANT NOTICE - This email is intended for the named recipient only. It may contain privileged and confidential information. If you are not the intended recipient, notify the sender immediately and destroy this email. You must not copy, distribute or take action in reliance upon it. Whilst all efforts are made to safeguard emails, The School of Environmental Sciences cannot guarantee that attachments are virus free or compatible with your systems and does not accept liability in respect of viruses or computer problems experienced.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 13 11:10:32 2010

This archive was generated by hypermail 2.1.8 : Thu Feb 18 2010 - 10:33:29 MST