Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

time decoding error in reading CESM outputs (netCDF files)

Ali

Ali Fallahmaraghi
New Member
Hi,

I am trying to use xarray to open CESM outputs in netCDF format.
Here is the error:
ValueError: unable to decode time units 'common_year since 1-1-1 0:0:0' with "calendar 'noleap'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

Apparently this is a common issue:

And I took their advice this way:
ds = xr.open_dataset('some_CESM_output_file.nc', decode_times=False)
ds.time_bound.attrs['calendar'] = ds.time.attrs['calendar']
ds = xr.decode_cf(ds, use_cftime=True)

However, still struggling with:
ValueError: zero not allowed as a reference year, does not exist in Julian or Gregorian calendars

I wonder if there is any trick to resolve this issue.

Thanks in advance for your suggestion,
Ali
 

strandwg

Moderator
Staff member
Hi,

I am trying to use xarray to open CESM outputs in netCDF format.
Here is the error:
ValueError: unable to decode time units 'common_year since 1-1-1 0:0:0' with "calendar 'noleap'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

Apparently this is a common issue:

And I took their advice this way:
ds = xr.open_dataset('some_CESM_output_file.nc', decode_times=False)
ds.time_bound.attrs['calendar'] = ds.time.attrs['calendar']
ds = xr.decode_cf(ds, use_cftime=True)

However, still struggling with:
ValueError: zero not allowed as a reference year, does not exist in Julian or Gregorian calendars

I wonder if there is any trick to resolve this issue.

Thanks in advance for your suggestion,
Ali

It appears you're looking at output from the land ice model, CISM?
 

Ali

Ali Fallahmaraghi
New Member
It appears you're looking at output from the land ice model, CISM?
Well I am not quite sure this error is exactly related to which subdirectory. But it happened when I was trying to use xarray this way:
xr.open_mfdataset("/glade/scratch/afallah/CESM2_C4MIP/cesm2_1_0.B1850.f09_g17.CMIP6-piControl.001.uga_extension/arc/*/*/*.nc")

Even I tried to open smaller volume of data, but this also show another error!
MergeError: conflicting values for variable 'time_bnds' on objects to be combined. You can skip this check by specifying compat='override'.
xr.open_mfdataset("/glade/scratch/afallah/CESM2_C4MIP/cesm2_1_0.B1850.f09_g17.CMIP6-piControl.001.uga_extension/arc/atm/hist/*.nc")
 

strandwg

Moderator
Staff member
Well I am not quite sure this error is exactly related to which subdirectory. But it happened when I was trying to use xarray this way:
xr.open_mfdataset("/glade/scratch/afallah/CESM2_C4MIP/cesm2_1_0.B1850.f09_g17.CMIP6-piControl.001.uga_extension/arc/*/*/*.nc")

Even I tried to open smaller volume of data, but this also show another error!
MergeError: conflicting values for variable 'time_bnds' on objects to be combined. You can skip this check by specifying compat='override'.
xr.open_mfdataset("/glade/scratch/afallah/CESM2_C4MIP/cesm2_1_0.B1850.f09_g17.CMIP6-piControl.001.uga_extension/arc/atm/hist/*.nc")

The first error you noticed is from CISM output files, under glc/hist/*nc.

The second error probably comes from the "cam.i." files under atm/hist/*nc, which aren't model output history files.
 
  • Like
Reactions: Ali

Ali

Ali Fallahmaraghi
New Member
The first error you noticed is from CISM output files, under glc/hist/*nc.

The second error probably comes from the "cam.i." files under atm/hist/*nc, which aren't model output history files.
The second error is actually related to xr.open_mfdataset and could be resolved by adding this part: ,compat="override", data_vars='minimal', coords='minimal'

And for the first error, I can skip glc.
 
Top