ecmwf / cfgrib

A Python interface to map GRIB files to the NetCDF Common Data Model following the CF Convention using ecCodes
Apache License 2.0
400 stars 77 forks source link

Hi, here I have the same issue. I am really new to this. How did you solve it? I need to get it working urgently... Thanks #125

Open holaaam opened 4 years ago

holaaam commented 4 years ago

Hi, here I have the same issue. I am really new to this. How did you solve it? I need to get it working urgently... Thanks

Originally posted by @holaaam in https://github.com/ecmwf/cfgrib/issues/90#issuecomment-591427363

Adamsim33 commented 3 years ago

I am also having this same issue. I noticed that the Eccodes error that says it cannot start the kernel is pointing to the D drive, yet my machine does not have a D drive. Is there a way to change where my Spyder session points to properly run Eccodes?

Here is my error:

ECCODES ERROR : Unable to find boot.def. Context path=D:/bld/eccodes_1603124531359/_h_env/Library/share/eccodes/definitions

Possible causes: ‑ The software is not correctly installed ‑ The environment variable ECCODES_DEFINITION_PATH is defined but incorrect

ecCodes assertion failed: `0' in D:\bld\eccodes_1603124531359\work\src\grib_context.c:226

iainrussell commented 3 years ago

I can't say anything specifically about Spyder or running on Windows, but it looks like you need to set the environment variable "ECCODES_DEFINITION_PATH" to the location where the ecCodes definition files are. If you can find where ecCodes is installed, then the path should be there, but deeper down, into "share/eccodes/definitions/" (I'm using UNIX path separators here, of course Windows uses backslash normally). I hope this helps, but I don't have this environment, so I probably can't comment further.

Adamsim33 commented 3 years ago

I can't say anything specifically about Spyder or running on Windows, but it looks like you need to set the environment variable "ECCODES_DEFINITION_PATH" to the location where the ecCodes definition files are. If you can find where ecCodes is installed, then the path should be there, but deeper down, into "share/eccodes/definitions/" (I'm using UNIX path separators here, of course Windows uses backslash normally). I hope this helps, but I don't have this environment, so I probably can't comment further.

Thank you, Iain. I will look into it.

openSourcerer9000 commented 2 years ago

EDIT - my issue was simply a bad grib file lol nothing to see here

conda install -c conda-forged cfgrib. It was working fine for a few months until today

---------------------------------------------------------------------------
EOFError                                  Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19092/615376279.py in <module>
      1 if fillradar:
      2     #read them in
----> 3     radr = xr.open_mfdataset(fillradar,engine='cfgrib',
      4         preprocess=timeKeepsOnSlipping,
      5         parallel=True,

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\xarray\backends\api.py in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs)
    914         # calling compute here will return the datasets/file_objs lists,
    915         # the underlying datasets will still be stored as dask arrays
--> 916         datasets, closers = dask.compute(datasets, closers)
    917 
    918     # Combine all datasets, closing them in case of a ValueError

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\dask\base.py in compute(traverse, optimize_graph, scheduler, get, *args, **kwargs)
    569         postcomputes.append(x.__dask_postcompute__())
    570 
--> 571     results = schedule(dsk, keys, **kwargs)
    572     return repack([f(r, *a) for r, (f, a) in zip(results, postcomputes)])
    573 

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\client.py in get(self, dsk, keys, workers, allow_other_workers, resources, sync, asynchronous, direct, retries, priority, fifo_timeout, actors, **kwargs)
   2723                     should_rejoin = False
   2724             try:
-> 2725                 results = self.gather(packed, asynchronous=asynchronous, direct=direct)
   2726             finally:
   2727                 for f in futures.values():

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\client.py in gather(self, futures, errors, direct, asynchronous)
   1978             else:
   1979                 local_worker = None
-> 1980             return self.sync(
   1981                 self._gather,
   1982                 futures,

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\client.py in sync(self, func, asynchronous, callback_timeout, *args, **kwargs)
    866             return future
    867         else:
--> 868             return sync(
    869                 self.loop, func, *args, callback_timeout=callback_timeout, **kwargs
    870             )

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\utils.py in sync(loop, func, callback_timeout, *args, **kwargs)
    330     if error[0]:
    331         typ, exc, tb = error[0]
--> 332         raise exc.with_traceback(tb)
    333     else:
    334         return result[0]

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\utils.py in f()
    313             if callback_timeout is not None:
    314                 future = asyncio.wait_for(future, callback_timeout)
--> 315             result[0] = yield future
    316         except Exception:
    317             error[0] = sys.exc_info()

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\tornado\gen.py in run(self)
    760 
    761                     try:
--> 762                         value = future.result()
    763                     except Exception:
    764                         exc_info = sys.exc_info()

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\distributed\client.py in _gather(self, futures, errors, direct, local_worker)
   1843                             exc = CancelledError(key)
   1844                         else:
-> 1845                             raise exception.with_traceback(traceback)
   1846                         raise exc
   1847                     if errors == "skip":

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\dask\utils.py in apply()
     35 def apply(func, args, kwargs=None):
     36     if kwargs:
---> 37         return func(*args, **kwargs)
     38     else:
     39         return func(*args)

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\xarray\backends\api.py in open_dataset()
    493 
    494     overwrite_encoded_chunks = kwargs.pop("overwrite_encoded_chunks", None)
--> 495     backend_ds = backend.open_dataset(
    496         filename_or_obj,
    497         drop_variables=drop_variables,

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\xarray_plugin.py in open_dataset()
     98     ) -> xr.Dataset:
     99 
--> 100         store = CfGribDataStore(
    101             filename_or_obj,
    102             indexpath=indexpath,

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\xarray_plugin.py in __init__()
     38         else:
     39             opener = dataset.open_fieldset
---> 40         self.ds = opener(filename, **backend_kwargs)
     41 
     42     def open_store_variable(self, var: dataset.Variable,) -> xr.Variable:

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\dataset.py in open_file()
    760 
    761     index_keys = compute_index_keys(time_dims, extra_coords)
--> 762     index = open_fileindex(stream, indexpath, index_keys, filter_by_keys=filter_by_keys)
    763 
    764     return open_from_index(index, read_keys, time_dims, extra_coords, **kwargs)

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\dataset.py in open_fileindex()
    739 ) -> messages.FileIndex:
    740     index_keys = sorted(set(index_keys) | set(filter_by_keys))
--> 741     index = messages.FileIndex.from_indexpath_or_filestream(
    742         stream, index_keys, indexpath=indexpath, computed_keys=computed_keys
    743     )

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\messages.py in from_indexpath_or_filestream()
    547             log.exception("Can't read index file %r", indexpath)
    548 
--> 549         return cls.from_fieldset(filestream, index_keys, computed_keys)
    550 
    551     def source(self) -> str:

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\messages.py in from_fieldset()
    364         else:
    365             iteritems = enumerate(fieldset)
--> 366         return cls.from_fieldset_and_iteritems(fieldset, iteritems, index_keys, computed_keys)
    367 
    368     @classmethod

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\messages.py in from_fieldset_and_iteritems()
    377         index_keys = list(index_keys)
    378         header_values_cache = {}  # type: T.Dict[T.Tuple[T.Any, type], T.Any]
--> 379         for field_id, raw_field in iteritems:
    380             field = ComputedKeysAdapter(raw_field, computed_keys)
    381             header_values = []

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\messages.py in __iter__()
    277         old_offset = -1
    278         count = 0
--> 279         for message in self.itervalues():
    280             offset = message.message_get("offset", int)
    281             if offset == old_offset:

c:\Users\seanm\Anaconda3\envs\raz\lib\site-packages\cfgrib\messages.py in itervalues()
    263                     except EOFError:
    264                         if not valid_message_found:
--> 265                             raise EOFError("No valid message found: %r" % self.filestream.path)
    266                         break
    267                     except Exception:

EOFError: No valid message found: 'C:\\Users\\...\\RadarOnly_QPE_01H_00.00_20201022-000000.grib2'

I find eccodes under the conda env's site-packages, but no business about "share/eccodes/definitions/". Where would this be inside a conda env? There's a share folder at the env's root level but no eccodes folder. Also, as a Windows user would I set this in system env variables alongside PATH etc or from within python at runtime?

iainrussell commented 2 years ago

Ok, no problem @openSourcerer9000 , glad you found the cause!