ESMValGroup / ESMValCore

ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.
https://www.esmvaltool.org
Apache License 2.0
41 stars 37 forks source link

Irregular regridding gives cube which is not correctly read by iris (for specific dataset) #479

Open schlunma opened 4 years ago

schlunma commented 4 years ago

Describe the bug For a specific dataset (see recipe below), the regridded cube cannot be correctly read by iris.

Recipe


preprocessors:
  regrid:
    regrid:
      target_grid: 2x2
      scheme: linear

diagnostics:
  diag_x_zhai:
    variables:
      tos:
        preprocessor: regrid
        exp: historical
        ensemble: r1i1p1
        project: CMIP5
        mip: Omon
        start_year: 1980
        end_year: 2004
        reference_dataset: ''
    additional_datasets:
       - {dataset: inmcm4}
    scripts: null

Output

This results in the following output fiile:

netcdf CMIP5_inmcm4_Omon_historical_r1i1p1_tos_1980-2004 {
dimensions:
        time = 300 ;
        lat = 40 ;
        lon = 180 ;
        bnds = 2 ;
variables:
        float tos(time, lat, lon) ;
                tos:_FillValue = 1.e+20f ;
                tos:standard_name = "sea_surface_temperature" ;
                tos:long_name = "Sea Surface Temperature" ;
                tos:units = "K" ;
                tos:cell_methods = "time: mean (interval: 1 month)" ;
                tos:grid_mapping = "rotated_latitude_longitude" ;
        int rotated_latitude_longitude ;
                rotated_latitude_longitude:grid_mapping_name = "rotated_latitude_longitude" ;
                rotated_latitude_longitude:grid_north_pole_latitude = 70. ;
                rotated_latitude_longitude:grid_north_pole_longitude = 100. ;
                rotated_latitude_longitude:north_pole_grid_longitude = -80. ;
        double time(time) ;
                time:axis = "T" ;
                time:bounds = "time_bnds" ;
                time:units = "days since 1850-1-1 00:00:00" ;
                time:standard_name = "time" ;
                time:long_name = "time" ;
                time:calendar = "365_day" ;
        double time_bnds(time, bnds) ;
        double lat(lat) ;
                lat:axis = "Y" ;
                lat:bounds = "lat_bnds" ;
                lat:units = "degrees_north" ;
                lat:standard_name = "latitude" ;
        double lat_bnds(lat, bnds) ;
        double lon(lon) ;
                lon:axis = "X" ;
                lon:bounds = "lon_bnds" ;
                lon:units = "degrees_east" ;
                lon:standard_name = "longitude" ;
        double lon_bnds(lon, bnds) ;

// global attributes:
                :_NCProperties = "version=2,netcdf=4.6.2,hdf5=1.10.5" ;
                :associated_files = "baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_fx_inmcm4_historical_r0i0p0.nc areacello: areacello_fx_inmcm4_historical_r0i0p0.nc" ;
                :branch_time = 0. ;
                :cmor_version = "2.0.0" ;
                :comment = "\"this may differ from \"\"surface temperature\"\" in regions of sea ice.\"" ;
                :contact = "Evgeny Volodin, volodin@inm.ras.ru,INM RAS, Gubkina 8, Moscow, 119333 Russia,+7-495-9383904" ;
                :experiment = "Historical" ;
                :experiment_id = "historical" ;
                :forcing = "N/A" ;
                :frequency = "mon" ;
                :initialization_method = 1 ;
                :institute_id = "INM" ;
                :institution = "INM (Institute for Numerical Mathematics,  Moscow, Russia)" ;
                :model_id = "inmcm4" ;
                :modeling_realm = "ocean" ;
                :original_name = "tos" ;
                :parent_experiment = "pre-industrial control" ;
                :parent_experiment_id = "piControl" ;
                :physics_version = 1 ;
                :product = "output" ;
                :project_id = "CMIP5" ;
                :realization = 1 ;
                :references = "Volodin, Diansky, Gusev 2010. Climate model INMCM4.0. Izvestia RAS. Atmospheric and oceanic physics, V.46, N4, in print." ;
                :source = "inmcm4 (2009)" ;
                :table_id = "Table Omon (12 May 2010) f2afe576fb73a3a11aaa3cc8f2e62cf3" ;
                :title = "inmcm4 model output prepared for CMIP5 Historical" ;
                :Conventions = "CF-1.7" ;

When read with iris, this gives

sea_surface_temperature / (K)       (time: 300; -- : 40; -- : 180)
     Dimension coordinates:
          time                           x         -        -
     Attributes:
          Conventions: CF-1.7
          associated_files: baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_fx_inmcm4_historical_r0i0p0.nc...
          branch_time: 0.0
          cmor_version: 2.0.0
          comment: "this may differ from ""surface temperature"" in regions of sea ice."
          contact: Evgeny Volodin, volodin@inm.ras.ru,INM RAS, Gubkina 8, Moscow, 119333 ...
          experiment: Historical
          experiment_id: historical
          forcing: N/A
          frequency: mon
          initialization_method: 1
          institute_id: INM
          institution: INM (Institute for Numerical Mathematics,  Moscow, Russia)
          model_id: inmcm4
          modeling_realm: ocean
          original_name: tos
          parent_experiment: pre-industrial control
          parent_experiment_id: piControl
          physics_version: 1
          product: output
          project_id: CMIP5
          realization: 1
          references: Volodin, Diansky, Gusev 2010. Climate model INMCM4.0. Izvestia RAS. Atmospheric...
          source: inmcm4 (2009)
          table_id: Table Omon (12 May 2010) f2afe576fb73a3a11aaa3cc8f2e62cf3
          title: inmcm4 model output prepared for CMIP5 Historical
     Cell methods:
          mean: time (1 month)

As you can see, the latitude and longitude coordinate are not present in the cube. I think the problem in the netcdf file is the rotated_latitude_longitude variable, which somehow tells iris to use a rotated grid, but it fails to do so because only a regular grid is present.

This is not also not an issue of the original data, which lives on a rotated grid. Also, iris needs the rotated_latitude_longitude variable in the original file to correctly read it in the first place.

Thus, it is necessary to somehow get rid of this variable after the irregular regridding.

bouweandela commented 4 years ago

@zklaus Is this a problem with this particular dataset or with the regridding preprocessor function?

zklaus commented 4 years ago

It's a problem with the preprocessor. The presence of a grid_mapping attribute needs to be detected and dealt with. I can take this on.