-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Hi Both!
Another minor issue - it arose when working with some datasets that use an auxiliary time axis, I have a work-around but I thought it was worth highlighting as it causes errors in collapse that are not captured.
If I create a field with 2 time points, but no bounds, then I create month-wide bounds using cf.M() and then add these to the field.
I get a cf.field that has a time coordinate that looks like this:
Dimension coordinate: time
calendar = '360_day'
long_name = 'Time axis'
standard_name = 'time'
time_origin = '1900-01-01 00:00:00'
units = 'seconds since 1900-01-01 00:00:00'
Data(time(2)) = [1851-06-01 00:00:00, 1852-06-01 00:00:00] 360_day
Bounds:calendar = '360_day'
Bounds:units = 'days since 1851-6-1'
Bounds:Data(time(2), 2) = [[1851-06-01 00:00:00, ..., 1852-07-01 00:00:00]] 360_day
As you can see, the time dimension has units of seconds, but the bounds has units of days.
If I do field.collapse('time: mean') I get:
Dimension coordinate: time
calendar = '360_day'
long_name = 'Time axis'
standard_name = 'time'
time_origin = '1900-01-01 00:00:00'
units = 'seconds since 1900-01-01 00:00:00'
Data(time(1)) = [1900-01-01 00:03:15] 360_day
Bounds:calendar = '360_day'
Bounds:units = 'seconds since 1900-01-01 00:00:00'
Bounds:Data(time(1), 2) = [[1900-01-01 00:00:00, 1900-01-01 00:06:30]] 360_day
Clearly something has gone wrong here!
It seems that the bounds data (in days) has been used, but the time units (seconds) have been retained:
time_mean.coord('time').array
array([195.])
The attached code reproduces this behaviour.
time_bounds_bug2.py.gz
This is probably not a major bug, most people are not going to create bounds like this! But I thought I'd draw it to you attention, just in case it might cause other problems.
Cheers,
Dan