I am trying to read a GRIB2 file using pygrib
. I manage to open files and read data without problem, but I need to automate the process, and unfortunately each file contains multiple very similar fields:
1:Total Cloud Cover:% (avg):regular_ll:unknown:level 0 214:fcst time 0-1 hrs (avg):from 201705200000
2:Total Cloud Cover:% (avg):regular_ll:unknown:level 0 224:fcst time 0-1 hrs (avg):from 201705200000
3:Total Cloud Cover:% (avg):regular_ll:unknown:level 0 234:fcst time 0-1 hrs (avg):from 201705200000
4:Total Cloud Cover:% (avg):regular_ll:unknown:level 0 10:fcst time 0-1 hrs (avg):from 201705200000
5:Total Cloud Cover:% (instant):regular_ll:unknown:level 0 244:fcst time 1 hrs:from 201705200000
6:Total Cloud Cover:% (avg):regular_ll:unknown:level 0 211:fcst time 0-1 hrs (avg):from 201705200000
The only difference (as seen by pygrib) for these file is the field typeOfFirstFixedSurface
, but I have no idea what this field (and cannot find the relevant information on the site where I got the grib2 files). I have looked at all the key/value parameters for every messages, and did not find any other useful information I could use to differentiate the fields....
However, when using Panoply, I see much more parameters, e.g.:
float Total_cloud_cover_convective_cloud(time=1, lat=721, lon=1440);
:long_name = "Total cloud cover @ Convective cloud layer";
:units = "%";
:abbreviation = "TCDC";
:missing_value = NaNf; // float
:grid_mapping = "LatLon_Projection";
:coordinates = "reftime time lat lon ";
:Grib_Variable_Id = "VAR_0-6-1_L244";
:Grib2_Parameter = 0, 6, 1; // int
:Grib2_Parameter_Discipline = "Meteorological products";
:Grib2_Parameter_Category = "Cloud";
:Grib2_Parameter_Name = "Total cloud cover";
:Grib2_Level_Type = "Convective cloud layer";
:Grib2_Generating_Process_Type = "Forecast";
I could definitively use the long_name
or Grib_Variable_Id
fields to differentiate between messages, but I cannot access these "parameters" using pygrib.
Is there a way to access these parameters using pygrib?
I had lots of problems with figuring out this particular format and tools which could help me with reading/parsing it... Eventually, I ended up with using IRIS which ended up in extremely messy setup. I did this a year and a half ago on Ubuntu machine with Python 2.7. I am pasting the steps I needed to do in order to install IRIS and all possible dependencies, hopefully this will be of some use to you although there are probably lots of outdated versions in the whole setup...
Good luck!