You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a novice in computer science applied to meteorology.
I want to extract data from a GRIB2 file. I need to resize the files because I am downloading raw data from a global weather forecast model (ICON) and I just need a small footprint of the model. So I need to create a new GRIB2 file less heavy in storage with just the span I am interested in, that is France.
I saw that it was possible to use the "pygrib" package.
But I tried to write the script but it doesn't work.
The output GRIB2 file can't be opened on any software that processes GRIB2 data. I even have the impression that it does not resize. It just separated the timelines from the original grib2 file.
Below is the script I wrote in python language. Sorry for the formatting ! I don't know how to add code with a nice layout 👍 😎 !
Can anyone help me?
I thank you in advance for your help.
Bap250
import pygrib
grbs = pygrib.open('originalfile.grib2')
grbs.seek(2)
grbs.tell()
grb = grbs.read(1)[0]
grbs.tell()
you need a template file that is the same domain as the one you want to save, and then you can overwrite the data and change the metadata. Unfortunately, pygrib cannot create a grib2 file from scratch.
Hello !
I am a novice in computer science applied to meteorology.
I want to extract data from a GRIB2 file. I need to resize the files because I am downloading raw data from a global weather forecast model (ICON) and I just need a small footprint of the model. So I need to create a new GRIB2 file less heavy in storage with just the span I am interested in, that is France.
I saw that it was possible to use the "pygrib" package.
But I tried to write the script but it doesn't work.
The output GRIB2 file can't be opened on any software that processes GRIB2 data. I even have the impression that it does not resize. It just separated the timelines from the original grib2 file.
Below is the script I wrote in python language. Sorry for the formatting ! I don't know how to add code with a nice layout 👍 😎 !
Can anyone help me?
I thank you in advance for your help.
Bap250
import pygrib
grbs = pygrib.open('originalfile.grib2')
grbs.seek(2)
grbs.tell()
grb = grbs.read(1)[0]
grbs.tell()
grb = grbs.select(name='Total Precipitation')[0].data(lat1 = 43, lat2 = 51, lon1 = -4, lon2 = 8)
print(grb)
grbs.close()
grbout = open('outfile.grib2', 'wb')
grbout.write(grb[0])
grbout.close()`
The text was updated successfully, but these errors were encountered: