BarocliniCplusplus
BarocliniCplusplus

Reputation: 283

How to dump values from a Grib1/.grb file

I am wondering, is there a way to dump values from a grib1 file? My end goal is to find values for individual messages at latitude and longitude, or at least a grid point. I am using a linux system. Wgrib seems to do nothing except read metadata about the messages, or reconstruct the messages.

I know a bit of python, so I can use pygrib, but I don't know how to pull the values out for a specific latitude and longitude.

Here are some .grb files for everyone to play around with. http://nomads.ncdc.noaa.gov/data/gfs-avn-hi/201402/20140218/

Thank you for your answers,

Upvotes: 1

Views: 1617

Answers (2)

luka
luka

Reputation: 132

You can use grib tools, specifically grib_ls and grib_get to get values from 1 grid point or 4 grid points nearest to specified latitude and longitude. So, you can use nearest neighbour or bilinear interpolation or whatever you like to get you value. Read this presentation, grib_ls starts at page 31:

http://nwmstest.ecmwf.int/services/computing/training/material/grib_api/grib_api_tools.pdf

When you install grib tools, you will get several tools to help you play around with GRIB files.

Upvotes: 0

Sean A.
Sean A.

Reputation: 682

If you are interested in data from NOMADS, I would suggest going through their THREDDS Data Server, which will allow you to access data by specifying a lat/lon, and you can get that data back as a csv file, if you wish. To do so, first visit the NOMADS TDS site:

http://nomads.ncdc.noaa.gov/thredds/catalog/catalog.html

The example data files you linked to can be found here:

http://nomads.ncdc.noaa.gov/thredds/catalog/gfs-003/201402/20140218/catalog.html

Find a grid that you are interested in, say the 18Z run analysis field:

http://nomads.ncdc.noaa.gov/thredds/catalog/gfs-003/201402/20140218/catalog.html?dataset=gfs-003/201402/20140218/gfs_3_20140218_1800_000.grb

Follow the link that says "NetcdfService":

http://nomads.ncdc.noaa.gov/thredds/ncss/grid/gfs-003/201402/20140218/gfs_3_20140218_1800_000.grb/dataset.html

Near the top of that page, click "As Point Dataset":

http://nomads.ncdc.noaa.gov/thredds/ncss/grid/gfs-003/201402/20140218/gfs_3_20140218_1800_000.grb/pointDataset.html

Then check the parameters you are interested in, the lat/lon (the closest grid point to that lat/lon will be chosen), and the output format type.

This web interface basically generates an access url, which if I want Temperature over Boulder, CO, returned in csv, this is what it looks like:

http://nomads.ncdc.noaa.gov/thredds/ncss/grid/gfs-003/201402/20140218/gfs_3_20140218_1800_000.grb?var=Temperature_surface&latitude=40&longitude=-105&temporal=all&accept=csv&point=true

As you can see from the above URL, you can generate these pretty easily and make the request without going through all the steps above.

This access method (NetcdfSubsetService) can be combined with Python easily. For an example, check out this ipython notebook:

http://nbviewer.ipython.org/github/Unidata/tds-python-workshop/blob/master/ncss.ipynb

Specifically, the first and second cells in the notebook.

Note that you can get recent GFS data, in which an entire model run is contained within one grib file, at:

http://thredds.ucar.edu/thredds/idd/modelsNcep.html

This would allow you to make a request, like the one above, but for multiple times using one request.

Cheers,

Sean

Upvotes: 4

Related Questions