-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
netCDF time encoding challenges #1203
Comments
From my point of view, I would prefer if MOM6 did the following:
|
CF compliance and the details of file format are, for the most part, handled by FMS. All of our output passes through FMS's diag_manager . To fix this requires a change to FMS. We've traced the source of the "THIRTY_DAY_MONTHS" to https://github.com/NOAA-GFDL/FMS/blob/master/time_manager/time_manager.F90#L3275 . A simple fix is to change: valid_calendar_types = 'THIRTY_DAY_MONTHS ' valid_calendar_types = '360_DAY ' which I've suggested as a temporary work around to @neerajabhamidipati . I've submitted PR NOAA-GFDL/FMS#574 but there's no telling how long it will take to make it into a tagged branch. |
I agree that where there is a unit such as "days since ..." on a time-like variable then the |
So in this case, we probably need to make xarray a bit smarter about how how it decodes timelike variables. Since pydata/xarray#2571 (see v0.11.1 release notes), xarray has done this correctly for I'll open some kind of xarray issue to work out that case. |
In the case of |
average_t1, _t2, and _dt are GFDLisms and not part of CF. They allow you to perform time averaging where end intervals that are shared across two averaging periods can be half-weighted. |
Does anyone foresee any downside in adding a calendar and other related attributes to these variables? |
It is hard to imagine a downside to adding these attributes. The reason I haven't rushed in yet (apart from being busy) is I suspect this would require somewhat more code than the one line change in the above PR. |
I think the primary risk is that putting metadata in multiple places introduces a risk that it can become inconsistent, either through a later change to MOM and/or FMS, or through some post-processing tool manipulating the metadata in one place and not the other. Quoting myself from an xarray issue, the CF conventions section on the
So CF recommends that Also note that CF has nothing to say regarding I think the problem in this xarray issue arose because a tool in the user's workflow messed up the metadata. I recall looking into it and concluding that the culprit was CDO. I experimented with CDO and found that it could alter the value of time.attrs.bounds but not rename the variable with that name, breaking the metadata connection. Tools doing such things is unfortunate. |
I am working with @neerajabhamidipati to create some analysis-ready MOM6 data for the Ocean Eddy CPT.
I have noticed some issues with time encoding in MOM6 files. To summarize, they are the following:
time
itself) use a non-cf-compliantcalendar
attribute:THIRTY_DAY_MONTHS
. The standards state it should be360_day
.average_T1
,average_T2
,time_bnds
) do not have thecalendar
attribute set, but the do have timelikeunits
:days since 0001-01-01 00:00:00
. This leads to problems decoding the variable with cftime inside xarray. This could be considered an xarray bug, since perhaps xarray should "know" to propagate thetime
attributes to other timelike variables. But currently, these variables can't be decoded.A workaround to decode times in xarray is as follows:
Note you need cftime installed for this to work.
The text was updated successfully, but these errors were encountered: