5

I have downloaded grib1 model data from GFS, I am using a Mac OS X and was able to build the wgrib2 file from NOAA but was unable to extract the data. I have not found a grib1 utility for MAC.

Then I run to this program http://www.giss.nasa.gov/tools/panoply/ that was able to read the file and can see the data but I have some issues with it.

  1. the values comes in other units (like K for temp and other different from mm in rainfall)
  2. I am able to export CSV but only the values not the coordinates

What I want to do is :

  1. extract data from grib file via the command line via latitude longitude
  2. extract data an move to a MySQL database to be able to do some data aggregation (sum, max, min) etc
  3. be able to plot / map data (I would probably use CartoDB service)

I already can extract grib or can download from certain region, I would like that data to be able to see on a spreadsheet for example latitude, longitude, temperature, rainfall, wind etc... then from there I can take it to a database, or sum /avg etc or manipulate data.

Sample grib data file: https://dl.dropboxusercontent.com/u/104462/neavilag_rain_wind_pressure.grb

Based on my scenario what is the best approach to handle my needs? Can you suggest me what to do?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
neavilag
  • 609
  • 1
  • 8
  • 20
  • By 'MAC' you mean `Mac OS X`? What's `lat lon`? What database will you use (Oracle, PostgreSQL, Progress OpenEdge..)? What language/tool for plotting the data will you use? If you're looking for a script to transform the data from one format to another then providing a data samples would help – xmojmr Jan 05 '15 at 16:03
  • Hi, yes i mean Mac OS X, lat is latitude and lon is longitude. I will like to use mySQL, For plotting maybe use cartodb service but can be other you can suggest.. I already can extract grib or can download from certain region, I would like that data to be able to see on a spreadsheet for example latitude, longitude, temperature, rainfall, wind etc... then from there I can take it to a database, or sum /avg etc or manipulate data. Maybe you can suggest me what to do. thanks... – neavilag Jan 05 '15 at 21:35
  • here is a link to some data [link] (https://dl.dropboxusercontent.com/u/104462/neavilag_rain_wind_pressure.grb) – neavilag Jan 05 '15 at 21:44
  • 1
    Stack Overflow is for programmers to ask reasonably sized programming questions and find their answers. To keep your question [on-topic](http://stackoverflow.com/help/on-topic) consider splitting it into smaller concrete questions each one tagged with a programming language. For complex orchestration you'll probably need to learn/use some Mac-friendly scripting language. Also consider using [Geographic Information Systems Stack Exchange](http://gis.stackexchange.com/) site. I've no `gis` nor `macosx` experience so I won't help you any further – xmojmr Jan 06 '15 at 06:44

2 Answers2

6

I recommend to use cfgrib which is a python based grib reader based on python project xarray and the eccodes software by the ECMWF.

It is very easy to use:

import cfgrib
cfgrib.open_datasets('your_grib_data.grib2')

And xarray comes with a lot of helpful built-in functions. Have fun!

dl.meteo
  • 1,658
  • 15
  • 25
1

If I do this kind of manipulation I usually use CDO, as it handles all kinds of native grids correctly. If you want to calculate the sum or mean of a field over a certain area for example, it is not correct to simply calculate the arithmetic mean with a regular lat-lon or reduced Gaussian grid as it does not account account for the changing grid-cell sizes as you move towards the poles.

I would therefore select an area with

cdo -f nc sellonlatbox,lon1,lon2,lat1,lat2 in.grb out.nc

Here I am converting to netcdf at the same time with the "-f nc" option. Many software packages read netcdf easily to create plots (ncl, gdl/idl, grads, R, python, panoply etc etc).

To calculate field statistics for the files it is as straightforward as

cdo fldmean in.nc out.nc
cdo fldmax in.nc out.nc
cdo fldsum in.nc out.nc 

To give some of the examples you request. You may also make stats in the time dimension (timmean etc). Check out the CDO help pages for details. I installed CDO on my MAC using macports.

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86