Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing field to file in GRIB with grib_decoder.save() doesn't work for GRIB1 fields #45

Open
ninaburg opened this issue Oct 2, 2024 · 0 comments

Comments

@ninaburg
Copy link
Contributor

ninaburg commented Oct 2, 2024

  • meteodata-lab version: v0.2.0-rc3
  • grib_decoder.save() causes an issue

Description

Applying the flexpart operator on data which contain many params in GRIB1 and writing back to a file in GRIB raises the error that the forecasTime key is not found (it corresponds to the lead_time):

2024-10-01 21:06:39.092     INFO 1 --- [     MainThread] flexprep.domain.processing._save_output : Writing GRIB field sp to /tmp/tmppfypudxroutput_dispf2024093000003 with dimensions: ('ref_time', 'lead_time', 'y', 'x')
ECCODES ERROR   :  grib_set_values[1] forecastTime (type=double) failed: Key/value not found
2024-10-01 21:06:39.094    ERROR 1 --- [     MainThread] earthkit.data.utils.message.set_multiple: Error setting: {'indicatorOfUnitOfTimeRange': 0, 'forecastTime': 180.0, 'dataDate': '20240930', 'dataTime': '0000'}
2024-10-01 21:06:39.094    ERROR 1 --- [     MainThread] earthkit.data.utils.message.set_multiple: Key/value not found
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/earthkit/data/utils/message.py", line 196, in set_multiple
    eccodes.codes_set_key_vals(self._handle, values)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 1741, in grib_set_key_vals
    GRIB_CHECK(err)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 226, in GRIB_CHECK
    errors.raise_grib_error(errid)
  File "/usr/local/lib/python3.11/site-packages/gribapi/errors.py", line 381, in raise_grib_error
    raise ERROR_MAP[errid](errid)
gribapi.errors.KeyValueNotFoundError: Key/value not found
2024-10-01 21:06:39.124    ERROR 1 --- [     MainThread] flexprep.domain.processing._save_output : Failed to save or upload output file: Key/value not found
Traceback (most recent call last):
  File "/src/flexprep/domain/processing.py", line 131, in _save_output
    grib_decoder.save(field, output_file)
  File "/usr/local/lib/python3.11/site-packages/meteodatalab/grib_decoder.py", line 434, in save
    metadata = md.override(to_grib(loc))
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/earthkit/data/readers/grib/metadata.py", line 257, in override
    handle.set_multiple(d)
  File "/usr/local/lib/python3.11/site-packages/earthkit/data/utils/message.py", line 196, in set_multiple
    eccodes.codes_set_key_vals(self._handle, values)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 1741, in grib_set_key_vals
    GRIB_CHECK(err)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 226, in GRIB_CHECK
    errors.raise_grib_error(errid)
  File "/usr/local/lib/python3.11/site-packages/gribapi/errors.py", line 381, in raise_grib_error
    raise ERROR_MAP[errid](errid)
gribapi.errors.KeyValueNotFoundError: Key/value not found
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/src/flexprep/__main__.py", line 59, in <module>
    launch_pre_processing(ifs_forecast_obj)
  File "/src/flexprep/domain/prepare_processing.py", line 70, in launch_pre_processing
    Processing().process(process_items)
  File "/src/flexprep/domain/processing.py", line 38, in process
    self._save_output(
  File "/src/flexprep/domain/processing.py", line 131, in _save_output
    grib_decoder.save(field, output_file)
  File "/usr/local/lib/python3.11/site-packages/meteodatalab/grib_decoder.py", line 434, in save
    metadata = md.override(to_grib(loc))
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/earthkit/data/readers/grib/metadata.py", line 257, in override
    handle.set_multiple(d)
  File "/usr/local/lib/python3.11/site-packages/earthkit/data/utils/message.py", line 196, in set_multiple
    eccodes.codes_set_key_vals(self._handle, values)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 1741, in grib_set_key_vals
    GRIB_CHECK(err)
  File "/usr/local/lib/python3.11/site-packages/gribapi/gribapi.py", line 226, in GRIB_CHECK
    errors.raise_grib_error(errid)
  File "/usr/local/lib/python3.11/site-packages/gribapi/errors.py", line 381, in raise_grib_error
    raise ERROR_MAP[errid](errid)
gribapi.errors.KeyValueNotFoundError: Key/value not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant