Uploaded image for project: 'JASMIN CIS'
  1. JASMIN CIS
  2. JASCIS-238

Crash reading NetCDF if a potential auxiliary vertical coordinate exists, but on a different grid

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0, 1.2
    • Fix Version/s: None
    • Component/s: Data Product
    • Labels:
      None

      Description

      If you try to plot a file constructed as below, on altitude levels with an air_pressure variable that's on a *different* set of vertical levels (as might occur with a staggered model grid, or if some variables are output on a reduced domain):

      ncgen -o test_aux_coord_on_other_grid.nc <<EOF
      netcdf test_aux_coord_on_other_grid {
      dimensions:
      time = UNLIMITED ;
      latitude = 2 ;
      longitude = 2 ;

      altitude = 3 ;
      alt_subset = 2 ;

      variables:
      float time(time) ;
      time:units = "days since 2000-01-01 00:00:00" ;
      time:calendar = "standard" ;
      time:standard_name = "time" ;
      float latitude(latitude) ;
      latitude:units = "degrees_north" ;
      latitude:standard_name = "latitude" ;
      float longitude(longitude) ;
      longitude:units = "degrees_east" ;
      longitude:standard_name = "longitude" ;

      float altitude(altitude) ;
      altitude:units = "km" ;
      altitude:standard_name = "altitude" ;
      float alt_subset(altitude) ;
      alt_subset:units = "km" ;
      alt_subset:standard_name = "altitude" ;

      float air_pressure(time, alt_subset, latitude, longitude) ;
      air_pressure:units = "hPa" ;
      air_pressure:standard_name = "air_pressure" ;

      float something(time, altitude, latitude, longitude) ;

      // global attributes:
      :Conventions = "CF-1.6" ;

      data:

      time = 0, 1 ;
      latitude = -30, 30 ;
      longitude = 0, 180 ;

      altitude = 1, 2, 3;
      alt_subset= 1, 2 ;

      air_pressure = 900, 900, 900, 900, 800, 800, 800, 800,
      900, 900, 900, 900, 800, 800, 800, 800 ;

      something = 1, 2, 3, 4, 5, 6, 7, 8,
      9, 10, 11, 12, 13, 14, 15, 16,
      17, 18, 19, 20, 21, 22, 23, 24 ;
      }
      EOF
      cis plot something:test_aux_coord_on_other_grid.nc

      you get an error like this:

      2015-03-11 10:43:05,826 - DEBUG - AProduct : 166 - Error in product plugin default_NetCDF:
      Traceback (most recent call last):
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/AProduct.py", line 163, in get_data
          data = product_cls().create_data_object(filenames, variable)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/products.py", line 424, in create_data_object
          cube = super(NetCDF_Gridded, self).create_data_object(filenames, variable)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/products.py", line 278, in create_data_object
          return self._create_cube(filenames, variable)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/products.py", line 312, in _create_cube
          self._add_available_aux_coords(cube, filenames)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/products.py", line 366, in _add_available_aux_coords
          cube.add_aux_coord(aux_coord, dims)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/Iris-1.8.0_DEV-py2.7.egg/iris/cube.py", line 847, in add_aux_coord
          self._add_unique_aux_coord(coord, data_dims)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/Iris-1.8.0_DEV-py2.7.egg/iris/cube.py", line 870, in _add_unique_aux_coord
          coord.shape[i]))
      ValueError: Unequal lengths. Cube dimension 1 => 3; coord 'air_pressure' dimension 1 => 2.

      2015-03-11 10:43:05,828 - DEBUG - cis : 312 - Traceback (most recent call last):
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/cis.py", line 309, in main
          parse_and_run_arguments()
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/cis.py", line 286, in parse_and_run_arguments
          cmd(arguments)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/cis.py", line 66, in plot_cmd
          data.append(read_data(datagroup['filenames'], datagroup['variables'], datagroup['product']))
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/read.py", line 23, in read_data
          return get_data(filenames, variable, product)
        File "/home/users/kipling/CISENV/lib/python2.7/site-packages/jasmin_cis-1.0.0-py2.7.egg/jasmin_cis/data_io/products/AProduct.py", line 169, in get_data
          % (product_cls.__name__, type(e).__name__, e.message), e)
      ProductPluginException: An error occurred retrieving data using the product default_NetCDF. Check that this is the correct product plugin for your chosen data. Exception was ValueError: Unequal lengths. Cube dimension 1 => 3; coord 'air_pressure' dimension 1 => 2..

      2015-03-11 10:43:05,828 - ERROR - cis : 313 - An error occurred retrieving data using the product default_NetCDF. Check that this is the correct product plugin for your chosen data. Exception was ValueError: Unequal lengths. Cube dimension 1 => 3; coord 'air_pressure' dimension 1 => 2.. - check cis.log for details


      The problem appears to be that CIS is not checking that "air_pressure" is on the same grid as "something" before trying to add it as an auxiliary coordinate.

      This causes particular problems when reading raw HadGEM output, where multiple grids are common.

        Attachments

          Activity

            People

            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: