Skip to content

Fix for auxiliary coordinate variables with missing values but no corresponding attributes  #94

@sol1105

Description

@sol1105
  • dachar version:
  • Python version:
  • Operating System:

Description

Some submitted CMIP6 data has missing_values in their auxiliary coordinate variables but without defined "_FillValue" or "missing_value" variable attributes. This is a problem when trying to remap the data (allowed lon/lat ranges are exceeded) and likely also for other operations.

Two examples of affected datasets are:

  • CMIP6/CMIP/NCAR/CESM2-FV2/historical/r1i1p1f1/Omon/tos/gn/v20191120/tos_Omon_CESM2-FV2_historical_r1i1p1f1_gn_200001-201412.nc
  • CMIP6/OMIP/NOAA-GFDL/GFDL-OM4p5B/omip1/r1i1p1f1/Omon/thetao/gn/v20180701/thetao_Omon_GFDL-OM4p5B_omip1_r1i1p1f1_gn_170801-172712.nc

What I Did

>>>ds=xr.open_dataset("tos_Omon_CESM2-FV2_historical_r1i1p1f1_gn_200001-201412.nc").isel(time=0)
>>>float(ds.lat.max())
9.969209968386869e+36
>>> ds.lat.encoding
{'zlib': True, 'shuffle': True, 'complevel': 2, 'fletcher32': False, 'contiguous': False, 'chunksizes': (384, 320), 'source': '/home/k204212/tos_Omon_CESM2-FV2_historical_r1i1p1f1_gn_200001-201412.nc', 'original_shape': (384, 320), 'dtype': dtype('float64')}

# Defining a _FillValue and missing_value attribute does not fix the problem
# Setting the missing data to np.nan lets us operate on the data but is probably not enough
#  for when we want to create a new netCDF-file out of the result?
>>> ds.lat.data = xr.where(ds.lat.data>100, np.nan, ds.lat.data)
>>> float(ds.lat.max())
89.70640964187461

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions