I ran into a trouble with a python script that downloads recent weather data from a weather model (GFS) in grib2 format. It used to work but now it doesn't anymore (i.e. with the recent files for download on the GFS server). Trying to access the data, I get a segmentation fault and I don't even know where to start. The two examples (working and not working) are below. I run linux mint cinnamon. I have python-grib and python3-grib installed (Version: 1.9.8-1build2, via software manager).
Any suggestions would be much appreciated.
Ps: an example of a file that gives me the segmenation fault is here: http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2015013000/ filename: gfs.t00z.master.grbf003.10m.uv.grib2
The older files aren't kept on that server, I think. An example can be found here, though: http://grib.virtual-loup-de-mer.org/archives/2014/0130/ filename: gfs.t00z.master.grbf03.10m.uv.grib2
Pps: apologies for taking so long. I have installed pygrib version 2.0, from 1.98, and it does work now. Arghh, it's taken me a long time, to try this (and to actually install it properly). But that's it. In any case, a big 'merci' to everyone for all the answers, laetitia
/usr/bin/python3.4
:
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
Working script:
import pygrib
grbs = pygrib.open('winddata1.grib2')
for grb in grbs:
... grb
...
1:10 metre U wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201411041200
2:10 metre V wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201411041200
grb = grbs.message(1)
wind = grb.data(lat1=20,lat2=70,lon1=220,lon2=320)
quit()
/usr/bin/python3.4
:
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
Failing script:
import pygrib
grbs = pygrib.open('winddata2.grib2')
for grb in grbs:
... grb
...
1:10 metre U wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201501220600
2:10 metre V wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201501220600
grb = grbs.message(1)
wind = grb.data(lat1=20,lat2=70,lon1=220,lon2=320)
Error:
Segmentation fault
Edit (hope this makes sense)
running (as script testing.py) gives me:
gdb -ex r --args /usr/bin/python3.4 testing.py
GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/python3.4...(no debugging symbols found)...done.
Starting program: /usr/bin/python3.4 testing.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
1:10 metre U wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201501220600
2:10 metre V wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201501220600
Program received signal SIGSEGV, Segmentation fault.
0x000000000053b684 in PyLong_AsVoidPtr ()
(gdb) bt
#0 0x000000000053b684 in PyLong_AsVoidPtr ()
#1 0x00007ffff5968da7 in ?? () from /usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-34m-x86_64-linux-gnu.so
#2 0x0000000000533cd2 in PyObject_AsReadBuffer ()
#3 0x00007ffff21c9f00 in ?? () from /usr/lib/python3/dist-packages/g2clib.cpython-34m-x86_64-linux-gnu.so
#4 0x000000000057bf33 in PyEval_EvalFrameEx ()
#5 0x000000000057d3d3 in PyEval_EvalCodeEx ()
#6 0x000000000057df80 in ?? ()
#7 0x000000000043810a in PyObject_Call ()
#8 0x00000000004d3745 in ?? ()
#9 0x000000000043810a in PyObject_Call ()
#10 0x00007ffff677669c in ?? () from /usr/lib/python3/dist-packages/pygrib.cpython-34m-x86_64-linux-gnu.so
#11 0x000000000043810a in PyObject_Call ()
#12 0x00007ffff675788a in ?? () from /usr/lib/python3/dist-packages/pygrib.cpython-34m-x86_64-linux-gnu.so
#13 0x00007ffff6762ece in ?? () from /usr/lib/python3/dist-packages/pygrib.cpython-34m-x86_64-linux-gnu.so
#14 0x000000000057bf33 in PyEval_EvalFrameEx ()
#15 0x000000000057d3d3 in PyEval_EvalCodeEx ()
#16 0x000000000060ba83 in PyRun_FileExFlags ()
#17 0x000000000060bc85 in PyRun_SimpleFileExFlags ()
#18 0x000000000060d3ac in Py_Main ()
#19 0x000000000041ec0d in main ()
What version of the pygrib library are you running? The release notes at http://pygrib.googlecode.com/svn/trunk/Changelog describe several cases where a new release was made to handle a problem that resulted in a segfault error. I'd pull down the very latest and see if the bug still exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With