-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add 'unstructured_grid' support to write function #39
Comments
@guidocioni can you please check out branch https://github.com/ecmwf/cfgrib/tree/write-unstructured_grid and test if it writes a GRIB file of you liking. The change is trivial, if it works for you it'll go in the next release. |
ValueErrorTraceback (most recent call last)
<ipython-input-8-d316a23fef91> in <module>()
1 import cfgrib
----> 2 cfgrib.to_grib(ds_subset, 'out1.grib')
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/xarray_to_grib.py in to_grib(*args, **kwargs)
261
262 def to_grib(*args, **kwargs):
--> 263 return canonical_dataset_to_grib(*args, **kwargs)
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/xarray_to_grib.py in canonical_dataset_to_grib(dataset, path, mode, no_warn, grib_keys, **kwargs)
257 with open(path, mode=mode) as file:
258 for data_var in dataset.data_vars.values():
--> 259 canonical_dataarray_to_grib(data_var, file, grib_keys=real_grib_keys, **kwargs)
260
261
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/xarray_to_grib.py in canonical_dataarray_to_grib(data_var, file, grib_keys, default_grib_keys, **kwargs)
209 raise ValueError("required grib_key 'gridType' not passed nor auto-detected")
210
--> 211 template_message = make_template_message(merged_grib_keys, **kwargs)
212
213 coords_names, data_var = expand_dims(data_var)
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/xarray_to_grib.py in make_template_message(merged_grib_keys, template_path, sample_name)
179 if sample_name is None:
180 sample_name = detect_sample_name(merged_grib_keys)
--> 181 template_message = cfgrib.CfMessage.from_sample_name(sample_name)
182
183 for key in MESSAGE_DEFINITION_KEYS:
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/messages.pyc in from_sample_name(cls, sample_name, **kwargs)
62 @classmethod
63 def from_sample_name(cls, sample_name, **kwargs):
---> 64 codes_id = eccodes.codes_new_from_samples(sample_name.encode('ASCII'))
65 return cls(codes_id=codes_id, **kwargs)
66
/work/mh0731/m300382/conda_envs/my_base/lib/python2.7/site-packages/cfgrib/eccodes.pyc in codes_new_from_samples(samplename, product_kind)
590 handle = lib.codes_grib_handle_new_from_samples(ffi.NULL, samplename)
591 if handle == ffi.NULL:
--> 592 raise ValueError("sample not found: %r" % samplename)
593 return handle
594
ValueError: sample not found: 'unstructured_grid_sfc_grib2' |
Ok, it was not so trivial after all. Can I download a file with |
Sure, I'd choose something easy from the opendata of DWD, like a file here https://opendata.dwd.de/weather/nwp/icon/grib/00/qv_s/ |
@guidocioni cfgrib now falls back to use a basic template when it can't detect a better one. The downside is that you need to specify all necessary GRIB keys. This should be enough to save Please report back if current |
Sorry for the delay... I will try to test the behaviour in the following days. |
Currently
cfgrib
can handle thegridType
unstructured_grid
when reading files (see #28). However, when writing a GRIB file using this data an error is raisedNotImplementedError: Unsupported 'gridType': u'unstructured_grid'
. Is it to difficult to implement this feature?The text was updated successfully, but these errors were encountered: