-
Notifications
You must be signed in to change notification settings - Fork 300
Description
Hi
I'm producing a cube of monthly mean climatology data from a multi-year time-series of monthly mean data values (ozone, as it happens). My sample netcdf dataset spans the 20 years 1990-01-16 to 2010-12-16. In reality the actual dataset will likely span >100 years.
I'm using iris.coord_categorisation to add a month number auxiliary coordinate. And then I'm calling cube.aggregated_by to aggregate across that coordinate, thus producing a resultant cube which contains 12 time coords, one for each month of the year. (The other dimensions of my data are latitude and height, but for the purposes of this issue I guess they could equally be some other axes.)
Now, if the time span of my sample data covers an odd number of years, then the dates written to the aggregated cube are as expected, e.g. YYYY-01-16, YYYY-02-16, …, YYYY-12-16, where YYYY is the mid-year of the input time-series.
But if the time span of my sample data covers an even number of years, then the dates written to the aggregated cube are rotated by 6 months, e.g. YYYY-07-16, YYYY-08-16, etc. Assuming that the cube data was written in this same order, I was sorting it to get it into the normal CF climatology order of Jan to Dec. However, it would appear that the data is in fact in the desired Jan-Dec order, but that the rotated datetimes are incorrect.
An examination of the time bounds (in the aggregated cube) would seem to corroborate this observation as they too run from Jan to Dec (although the upper bounds are not quite right, they should be one month later than the lower bound).
I have put together a small bit of test code (see this gist) which hopefully illustrates the scenario described above.
Phil