pygrib icon indicating copy to clipboard operation
pygrib copied to clipboard

Pygrib from conda-forge: segmentation fault

Open MorningGlory747 opened this issue 6 years ago • 3 comments

Greetings,

I'm currently trying to open .grib2 files downloaded from Environment Canada which are publicly available meteorological data. I've downloaded pygrib from the anaconda cloud (see link: https://anaconda.org/conda-forge/pygrib). For this installation, all I've did was to type the conda forge download command inside the anaconda prompt and it said that the module was downloaded without error.

However, when trying to manipulate the grib file in pyhton, I will get segmentation faults when executing commands that seem to require a lot of effort. For example, I can do without error: import pygrib grbs = pygrib.open(filename) grb = grbs.readline() lats,lons = grb.latlons()

But it will crash for commands such as data,lats,lons = grb.data(lat1=20,lat2=45,lon1=220,lon2=320) and maxt = grb.values

Would this be because I decided to use conda-forge to download pygrid instead of following the 'normal procedure' as instructed by what’s shown in here: https://github.com/jswhit/pygrib?

I'm using pygrib 2.0.2 on a python 3.6 which was loaded from anaconda 4.5.10 on a VM ubuntu.

Thank you!

MorningGlory747 avatar Aug 15 '18 16:08 MorningGlory747

Can you post the grib file and the sample script somewhere so we can try to reproduce the error? (If the file is small enough you can upload it here in a tar file)

jswhit avatar Aug 15 '18 20:08 jswhit

Hi all,

We encountered this same problem, albeit, this was not an issue with pygrib itself, but with ECCODES and/or a library on our system. The issue can be recreated with any hrdps file from Environment Canada on an intel-python3 docker image, with pygrib and eccodes installed via conda.

We discovered that while trying to read from the grib file, the stack filled up for the process and resulted in a segfault. Increasing the stack size ulimit solved our problem. We do NOT experience this issue with any other grib data, even data from the gem or rgem, it seems unique. Hopefully this helps!

weatherbell avatar Dec 11 '18 17:12 weatherbell

The solution to the Environment Canada GRB2 files is to use something like wgrib2 to -set_grib_type to "simple" or "jpeg" rather than "complex1" "complex2" or "complex3". Example: wgrib2 myfilewithsegfaulterror.grb2 -set_grib_type jpeg -grib_out mysuccess.grb2

fmetdotmetoc avatar Oct 30 '19 17:10 fmetdotmetoc