HOW TO READ GRIB2?

79 views
Skip to first unread message

Mohsen

unread,
Apr 16, 2014, 5:17:51 PM4/16/14
to ncto...@googlegroups.com
Hi,
I have a file in grib2 format for the temperature and I would like to read it. I don;t have any idea how to read the this format from the Canadian meteorological cenetre. (CMC).
The file is attached and the sources of the file is in:
http://dd.meteo.gc.ca/ensemble/cansips/grib2/forecast/raw/2014/04/
The data is around 4 MB and maybe I could the data in Excel format.
Regards


cansips_forecast_raw_latlon2.5x2.5_PRATE_SFC_0_2014-04_allmembers.grib2

Brian Schlining

unread,
Apr 16, 2014, 5:53:46 PM4/16/14
to ncto...@googlegroups.com, Mohsen

Are you using Matlab?

If so, you can install nctoolbox (See https://github.com/nctoolbox/nctoolbox) to read the grib file. Unfortunatly, the web server hosting the grib files is not configured to allow us to read the files on the server, so you’ll have to download them. Once you’ve downloaded the file you can read it in Matlab using commands like this:

>> d = cfdataset('cansips_forecast_raw_latlon2.5x2.5_PRATE_SFC_0_2014-04_allmembers.grib2');
>> nc.variables

ans =  

    'time_bounds'
    'Precipitation_rate_surface_1_Month_Average'
    'lat'
    'lon'
    'time'
    'ens0'

>> p = d.struct('Precipitation_rate_surface_1_Month_Average')

p =  

                                          time: [12x1 int32]
                                          ens0: [20x1 int32]
                                           lat: [73x1 single]
                                           lon: [145x1 single]
    Precipitation_rate_surface_1_Month_Average: [4-D single]

The above commands load the entire data file into a matlab structure for you to work with.

Hope that helps. Cheers
Brian

--
You received this message because you are subscribed to the Google Groups "nctoolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nctoolbox+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Brian Schlining

Mohsen

unread,
Apr 16, 2014, 8:14:47 PM4/16/14
to ncto...@googlegroups.com
Thank you Brian to responded me very soon,
I am not very familiar with Matlab but I am trying to use your instructure . I downloaded NCTOOLBOX  and I got "NCTOOLBOX added to Matlab path" so I think it works on my system now.
Also I downloaded one grib file like yours "cansips_forecast_raw_latlon2.5x2.5_PRATE_SFC_0_2014-04_allmembers.grib2"
But in second line which is "nc.variables" I got error as follow:
??? Undefined variable "nc" or function "nc.variables".
and it stopped here, so could you please let me know what can I do?
Reply all
Reply to author
Forward
0 new messages