SciTools / iris-grib

GRIB interface for Iris.
https://iris-grib.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
22 stars 43 forks source link

Grid definition template 32769 is not supported #335

Open kuchaale opened 1 year ago

kuchaale commented 1 year ago

Similarly to Herbie#28, I cannot read the full-grid RAP files, like wrfprs using iris.load_cube. Is this definition template on your roadmap?

You can find example files here and additional information about the grid here.

Details

ECCODES ERROR : Unable to find template gridDefinitionSection from grib2/template.3.32769.def ECCODES ERROR : grib_handle_new_from_message: No final 7777 in message! --------------------------------------------------------------------------- TranslationError Traceback (most recent call last) Cell In[3], line 1 ----> 1 main_data = iris.load_cube(infile) 2 main_data File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/__init__.py:333, in load_cube(uris, constraint, callback) 330 if len(constraints) != 1: 331 raise ValueError("only a single constraint is allowed") --> 333 cubes = _load_collection(uris, constraints, callback).cubes() 335 try: 336 cube = cubes.merge_cube() File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/__init__.py:270, in _load_collection(uris, constraints, callback) 268 try: 269 cubes = _generate_cubes(uris, callback, constraints) --> 270 result = _CubeFilterCollection.from_cubes(cubes, constraints) 271 except EOFError as e: 272 raise iris.exceptions.TranslationError( 273 "The file appears empty or incomplete: {!r}".format(str(e)) 274 ) File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/cube.py:115, in _CubeFilterCollection.from_cubes(cubes, constraints) 113 pairs = [_CubeFilter(constraint) for constraint in constraints] 114 collection = _CubeFilterCollection(pairs) --> 115 for cube in cubes: 116 collection.add_cube(cube) 117 return collection File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/__init__.py:255, in _generate_cubes(uris, callback, constraints) 253 if scheme == "file": 254 part_names = [x[1] for x in groups] --> 255 for cube in iris.io.load_files(part_names, callback, constraints): 256 yield cube 257 elif scheme in ["http", "https"]: File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/io/__init__.py:209, in load_files(filenames, callback, constraints) 207 yield cube 208 else: --> 209 for cube in handling_format_spec.handler(fnames, callback): 210 yield cube File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/fileformats/rules.py:449, in load_cubes(filenames, user_callback, loader, filter_function) 446 return result 448 all_fields_and_filenames = _generate_all_fields_and_filenames() --> 449 for cube, field in _load_pairs_from_fields_and_filenames( 450 all_fields_and_filenames, 451 converter=loader.converter, 452 user_callback_wrapper=loadcubes_user_callback_wrapper, 453 ): 454 yield cube File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/fileformats/rules.py:370, in _load_pairs_from_fields_and_filenames(fields_and_filenames, converter, user_callback_wrapper) 367 results_needing_reference = [] 368 for field, filename in fields_and_filenames: 369 # Convert the field to a Cube, passing down the 'converter' function. --> 370 cube, factories, references = _make_cube(field, converter) 372 # Post modify the new cube with a user-callback. 373 # This is an ordinary Iris load callback, so it takes the filename. 374 cube = iris.io.run_callback( 375 user_callback_wrapper, cube, field, filename 376 ) File ~/.conda/envs/moje/lib/python3.9/site-packages/iris/fileformats/rules.py:308, in _make_cube(field, converter) 306 def _make_cube(field, converter): 307 # Convert the field to a Cube. --> 308 metadata = converter(field) 310 cube_data = field.core_data() 311 cube = iris.cube.Cube( 312 cube_data, 313 attributes=metadata.attributes, (...) 316 aux_coords_and_dims=metadata.aux_coords_and_dims, 317 ) File ~/.conda/envs/moje/lib/python3.9/site-packages/iris_grib/_load_convert.py:2636, in convert(field) 2633 metadata['aux_coords_and_dims'] = [] 2635 # Convert GRIB2 message to cube metadata. -> 2636 grib2_convert(field, metadata) 2638 result = ConversionMetadata._make(metadata.values()) 2639 else: File ~/.conda/envs/moje/lib/python3.9/site-packages/iris_grib/_load_convert.py:2585, in grib2_convert(field, metadata) 2582 rt_coord = reference_time_coord(field.sections[1]) 2584 # Section 3 - Grid Definition Section (Grid Definition Template) -> 2585 grid_definition_section(field.sections[3], metadata) 2587 # Section 4 - Product Definition Section (Product Definition Template) 2588 product_definition_section(field.sections[4], metadata, 2589 field.sections[0]['discipline'], 2590 field.sections[1]['tablesVersion'], 2591 rt_coord) File ~/.conda/envs/moje/lib/python3.9/site-packages/iris_grib/_load_convert.py:1371, in grid_definition_section(section, metadata) 1369 else: 1370 msg = 'Grid definition template [{}] is not supported'.format(template) -> 1371 raise TranslationError(msg) TranslationError: Grid definition template [32769] is not supported

ESadek-MO commented 1 year ago

TranslationError: Grid definition template [32769] is not supported

ECCODES ERROR : Unable to find template gridDefinitionSection from grib2/template.3.32769.def

Hey @kuchaale, these lines indicate that the grib file is not correctly formatted. 32769 is not a valid template number, and suggests a bug in the file. As such nothing will be able to load in this file.

kuchaale commented 1 year ago

Hi @ESadek-MO, thanks for your prompt response. Nevertheless, is there any way how to generate the RAP full North American domain (also known as an “Arakawa staggered E-grid on rotated latitude/longitude grid”) in iris?

ESadek-MO commented 1 year ago

Would you be able to clarify what you mean by "generate"? Is that during loading, or just within Iris in general? Please accept our apologies if there's a delay in replying!

kuchaale commented 1 year ago

I mean whether, in general, you can define such a grid using corner points etc. (see here).

acchamber commented 1 year ago

I mean whether, in general, you can define such a grid using corner points etc. (see here).

Iris can read in rotated pole data fine - it's a common feature in meteorological models so its important for iris to handle and plot it. If the data you are trying to load is on a rotated pole and CF-compliant then iris should be able to try it. But iris isn't in the business of generating grid definitions from scratch - you may be able to do it but there's probably better tools for that need.