ESMValGroup / ESMValTool

ESMValTool: A community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP
https://www.esmvaltool.org
Apache License 2.0
217 stars 126 forks source link

Fix for irregular grid of bcc-csm1-1(m) #760

Closed schlunma closed 5 years ago

schlunma commented 5 years ago

See #473:

Irregular regridding of tos of the models bcc-csm1-1 and bcc-csm1-1-m cause the following error:

Traceback (most recent call last):
  File "ESMValTool/esmvaltool/preprocessor/_regrid.py", line 209, in regrid                                   │
    result = _regrid_esmpy.regrid(src_cube, target_grid, scheme)                                                                         │
  File "ESMValTool/esmvaltool/preprocessor/_regrid_esmpy.py", line 349, in regrid                             │
    regridder = build_regridder(src_rep, dst_rep, method)                                                                                │
  File "/ESMValTool/esmvaltool/preprocessor/_regrid_esmpy.py", line 255, in build_regridder                    │
    regrid_method, mask_threshold)                                                                                                       │
  File "ESMValTool/esmvaltool/preprocessor/_regrid_esmpy.py", line 150, in build_regridder_2d                 │
    src_field = cube_to_empty_field(src_rep)                                                                                             │
  File "ESMValTool/esmvaltool/preprocessor/_regrid_esmpy.py", line 128, in cube_to_empty_field                │
    circular = is_lon_circular(lon)                                                                                                      │
  File "ESMValTool/esmvaltool/preprocessor/_regrid_esmpy.py", line 112, in is_lon_circular                    │
    seam = (lon.bounds[1:-1, -1, (1, 2)]                                                                                                 │
TypeError: 'NoneType' object is not subscriptable

The raw input file looks like this:

netcdf tos_Omon_bcc-csm1-1_historical_r1i1p1_185001-201212 {
dimensions:
        time = UNLIMITED ; // (1956 currently)
        rlat = 232 ;
        rlon = 360 ;
        bnds = 2 ;
variables:
        double time(time) ;
                time:bounds = "time_bnds" ;
                time:units = "days since 1850-01-01" ;
                time:calendar = "noleap" ;
                time:axis = "T" ;
                time:long_name = "time" ;
                time:standard_name = "time" ;
        double time_bnds(time, bnds) ;
        double rlat(rlat) ;
                rlat:bounds = "rlat_bnds" ;
                rlat:units = "degrees_north" ;
                rlat:axis = "Y" ;
                rlat:long_name = "latitude in rotated pole grid" ;
                rlat:standard_name = "grid_latitude" ;
        double rlat_bnds(rlat, bnds) ;
        double rlon(rlon) ;
                rlon:bounds = "rlon_bnds" ;
                rlon:units = "degrees_east" ;
                rlon:axis = "X" ;
                rlon:long_name = "longitude in rotated pole grid" ;
                rlon:standard_name = "grid_longitude" ;
        double rlon_bnds(rlon, bnds) ;
        float lat(rlat, rlon) ;
                lat:standard_name = "latitude" ;
                lat:long_name = "latitude coordinate" ;
                lat:units = "degrees_north" ;
        float lon(rlat, rlon) ;
                lon:standard_name = "longitude" ;
                lon:long_name = "longitude coordinate" ;
                lon:units = "degrees_east" ;
        float tos(time, rlat, rlon) ;
                tos:standard_name = "sea_surface_temperature" ;
                tos:long_name = "Sea Surface Temperature" ;
                tos:comment = "\"this may differ from \"\"surface temperature\"\" in regions of sea ice.\"" ;
                tos:units = "K" ;
                tos:original_name = "SST" ;
                tos:cell_methods = "time: mean" ;
                tos:cell_measures = "area: areacello" ;
                tos:missing_value = 1.e+20f ;
                tos:_FillValue = 1.e+20f ;
                tos:associated_files = "baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_ocean_fx_bcc-csm1-1_historical_r0i0p0.nc areacello: areacello_fx_bcc-csm1-1_historical_r0i0p0.nc" ;
                tos:coordinates = "lat lon" ;
}

Apparently there are no bounds for lat and lon, only rlat and rlon have them. How do I calculate them?

I will try to implement a fix file for this.

schlunma commented 5 years ago

I wrote a fix which seems to be working (as far as I can tell the preprocessed file looks file). I will push it tomorrow, maybe someone with more experience in the ocean domain can check it? (for example @ledm? :grin:)

mattiarighi commented 5 years ago

As a cross check, you can try to regrid the same model using cdo and see if you get a similar result (make sure you are using the same regridding method).

schlunma commented 5 years ago

Good idea, will do that tomorrow.