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

How to avoid StopIteration Error? #34

Closed
meteoDaniel opened this issue Nov 22, 2018 · 1 comment
Closed

How to avoid StopIteration Error? #34

meteoDaniel opened this issue Nov 22, 2018 · 1 comment

Comments

@meteoDaniel
Copy link

Dear all,
in the last time i often receive the following Error:

  File "/app/src/modules/decoder/grib_decoder.py", line 18, in __init__
    self._data = xarray_store.open_dataset(str(file_name))
  File "/usr/local/lib/python3.6/site-packages/cfgrib/xarray_store.py", line 47, in open_dataset
    store = cfgrib_.CfGribDataStore(path, **real_backend_kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/cfgrib_.py", line 78, in __init__
    self.ds = cfgrib.open_file(filename, mode='r', **backend_kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 452, in open_file
    return Dataset.from_path(path, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 447, in from_path
    return cls(*build_dataset_components(stream, **flavour_kwargs))
  File "/usr/local/lib/python3.6/site-packages/cfgrib/dataset.py", line 395, in build_dataset_components
    index = stream.index(ALL_KEYS).subindex(filter_by_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 211, in index
    return FileIndex.from_filestream(filestream=self, index_keys=index_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 228, in from_filestream
    schema = make_message_schema(filestream.first(), index_keys)
  File "/usr/local/lib/python3.6/site-packages/cfgrib/messages.py", line 208, in first
    return next(iter(self))
StopIteration

Why cfgrib raise StopIteration Error? Whats wrong?

@alexamici
Copy link
Contributor

@meteoDaniel I think you attempted to open a file with no valid GRIB message in it and I agree that the error is totally confusing. I'm considering it a bug and fixing it in master. Thanks for reporting!

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

2 participants