Skip to content

Use cftime to support forcing processing past 2262 CE - #1005

Open
hollyhan wants to merge 1 commit into
MPAS-Dev:mainfrom
hollyhan:landice/ismip7_forcing_fix_time_decoding
Open

hollyhan wants to merge 1 commit into
MPAS-Dev:mainfrom
hollyhan:landice/ismip7_forcing_fix_time_decoding

Conversation

@hollyhan

Copy link
Copy Markdown
Contributor

Problem

ISMIP7 ocean and atmosphere forcing processing fails for 2015-2300
experiments (ssp126, ssp585, ctrl) with:

AttributeError: 'DataArray' object has no attribute 'dt'

With default decoding, xarray uses datetime64[ns] for dates up to about
2262 and cftime objects beyond that. When the raw files for one
experiment straddle 2262, open_mfdataset mixes both types, so
ds.time.dt.year and date.dt.year break. Experiments ending in 2100
(e.g. ssp370) are not affected.

Fix

Pass use_cftime=True to xr.open_mfdataset in:

  • ocean_thermal/process_thermal_forcing.py (3D and 2D combine)
  • atmosphere/process_smb.py, process_smb_gradient.py,
    process_temperature.py, process_temperature_gradient.py,
    process_runoff.py

Testing

Ran ocean thermal forcing for an MRI-ESM2-0 ssp126 case (2015-2300) and
an ssp370 case (2015-2100). Compared the output files: same variables,
dtypes and dimension order, xtime is the same text format, and the
2300 case's xtime runs from 2015-01-01 to 2300-01-01 with no Time
coordinate, as in the 2100 case.

It is unclear if the Atmosphere test case also needs the same fix. However, since it doesn't hurt, the fix has been incorporated in the test cases, and processing the 285-run projection files C005-C010 all succeeded.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant