Skip to content

Dataset problem: Can't concatenate CESM2 historical and ssp245 because of different bounds_dtype in latitude and longitude. #576

Description

@npgillett

CESM2 monthly mean tas historical has bounds_dtype float32 and corresponding ssp245 file has bounds_dtype float64. I want to concatenate historical and ssp245 and this gives an error when trying to concatenate cubes. I tried to write a fix for this model, but apparently this attribute is read-only, so it's not possible simply to overwrite one of the attributes. How should I proceed?

  • Project (CMIP5/CMIP6/OBS/obs4mips/etc): CMIP6
  • Full dataset description (fill out as many as you know, please):
    • experiment: historical, ssp245
    • mip: cmip, scenariomip
    • grid: gn
    • version: See below for filepath.
    • variable used: tas
  • Problems encountered (please describe what the actual problems are: e.g. wrong standard name, issue with dimensions):
    Fails with this message:
  File "/home/rng/miniconda3/envs/esmvaltool2/lib/python3.7/site-packages/iris/_concatenate.py", line 480, in match
    raise iris.exceptions.ConcatenateError(msgs)
iris.exceptions.ConcatenateError: failed to concatenate into a single cube.
  Dimension coordinates metadata differ: latitude, longitude != latitude, longitude

The dim_metadata which are compared and which lead to the above failure are the following:

**** 1 [_CoordMetaData(defn=CoordDefn(standard_name='time', long_name=None, var_name='time', units=Unit('days since 1850-1-1 00:00:00', calendar='365_day'), attributes={'title': 'time', 'type': 'double'}, coord_system=None), dims=(0,), points_dtype=dtype('float64'), bounds_dtype=dtype('float64'), kwargs={'scalar': False, 'circular': False, 'order': 1}), _CoordMetaData(defn=CoordDefn(standard_name='latitude', long_name=None, var_name='lat', units=Unit('degrees_north'), attributes={'title': 'Latitude', 'type': 'double', 'valid_max': 90.0, 'valid_min': -90.0}, coord_system=None), dims=(1,), points_dtype=dtype('float64'), bounds_dtype=dtype('float32'), kwargs={'scalar': False, 'circular': False, 'order': 1}), _CoordMetaData(defn=CoordDefn(standard_name='longitude', long_name=None, var_name='lon', units=Unit('degrees_east'), attributes={'title': 'Longitude', 'type': 'double', 'valid_max': 360.0, 'valid_min': 0.0}, coord_system=None), dims=(2,), points_dtype=dtype('float64'), bounds_dtype=dtype('float32'), kwargs={'scalar': False, 'circular': True, 'order': 1})]

**** 2 [_CoordMetaData(defn=CoordDefn(standard_name='time', long_name=None, var_name='time', units=Unit('days since 1850-1-1 00:00:00', calendar='365_day'), attributes={'title': 'time', 'type': 'double'}, coord_system=None), dims=(0,), points_dtype=dtype('float64'), bounds_dtype=dtype('float64'), kwargs={'scalar': False, 'circular': False, 'order': 1}), _CoordMetaData(defn=CoordDefn(standard_name='latitude', long_name=None, var_name='lat', units=Unit('degrees_north'), attributes={'title': 'Latitude', 'type': 'double', 'valid_max': 90.0, 'valid_min': -90.0}, coord_system=None), dims=(1,), points_dtype=dtype('float64'), bounds_dtype=dtype('float64'), kwargs={'scalar': False, 'circular': False, 'order': 1}), _CoordMetaData(defn=CoordDefn(standard_name='longitude', long_name=None, var_name='lon', units=Unit('degrees_east'), attributes={'title': 'Longitude', 'type': 'double', 'valid_max': 360.0, 'valid_min': 0.0}, coord_system=None), dims=(2,), points_dtype=dtype('float64'), bounds_dtype=dtype('float64'), kwargs={'scalar': False, 'circular': True, 'order': 1})]

Note that bounds_type is different for latitude and longitude for the two files.

I tried adding the following to cesm2.py to overwrite bounds_dtype:

            latitude = cube.coord('latitude')
            latitude.bounds_dtype=np.dtype('float64')
            longitude = cube.coord('longitude')
            longitude.bounds_dtype=np.dtype('float64')

But that gave the following error:

  File "/home/rng/miniconda3/envs/esmvaltool2/lib/python3.7/site-packages/esmvalcore/cmor/_fixes/cmip6/cesm2.py", line 30, in fix_metadata
    latitude.bounds_dtype=np.dtype('float64')
AttributeError: can't set attribute

This seems to be because bounds_dtype is read-only (see e.g. here https://scitools.org.uk/iris/docs/latest/whatsnew/2.0.html)

test-cesm.yml.txt

main_log_debug.txt

  • Pointer to existing copy of data :
CMIP6/CMIP/NCAR/CESM2/historical/r1i1p1f1/Amon/tas/gn/v20190308/tas_Amon_CESM2_historical_r1i1p1f1_gn_185001-201412.nc
CMIP6/ScenarioMIP/NCAR/CESM2/ssp245/r1i1p1f1/Amon/tas/gn/v20190730/tas_Amon_CESM2_ssp245_r1i1p1f1_gn_201501-206412.nc

Metadata

Metadata

Type

No type

Fields

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