Thread Subject:
read_grib.m Stage IV meteorological data

Subject: read_grib.m Stage IV meteorological data

From: Eric Bryant

Date: 18 Jun, 2012 23:40:08

Message: 1 of 3

Hi -

I have been trying to read National Stage IV QPE (WMO GRIB1, i believe) dada using read_grib.m, which I downloaded from http://www.renci.org/~bblanton/files/ReadGrib/read_grib.html.

I have been confused by the following output

>> grib_struct=read_grib('/home/ecb27/Test/hello',-1)
Searching for first GRIB marker...
  GRiB Record marker "GRIB" found at chars 1-4
GRiB header =
GRIB
Error using get_gds (line 143)
DRT 5 not yet coded.

Error in extract_grib (line 22)
   gds_struct=get_gds(fid,lengds);

Error in read_grib (line 318)
      [pds_struct,gds_struct,bms_struct,bds_struct,dataarray]=...
 
Could someone clue me in? Appreciated if possible,

Eric


*************************************
This is the data product:

http://www.emc.ncep.noaa.gov/mmb/ylin/pcpanl/stage4/

When I run wgrib (from the command line), this is what I get:

$ wgrib -V ~/Test/ST4.2007010101.01h.grb
rec 1:0:date 2007010100 APCP kpds5=61 kpds6=1 kpds7=0 levels=(0,0) grid=255 sfc 0-1hr acc: bitmap: 324979 undef
  APCP=Total precipitation [kg/m^2]
  timerange 4 P1 0 P2 1 TimeU 1 nx 1121 ny 881 GDS grid 5 num_in_ave 0 missing 0
  center 7 subcenter 4 process 182 Table 2 scan: WE:SN winds(grid)
  polar stereo: Lat1 23.117000 Long1 -119.023000 Orient -105.000000
     north pole (1121 x 881) Dx 4763 Dy 4763 scan 64 mode 8
  min/max data 0 322.13 num bits 15 BDS_Ref 0 DecScale 2 BinScale 0

In contrast, this wgrib output for a file that I got working with read_grib.m:

$ wgrib -V ~/Test/NARR.200701010.grb
rec 53:6237000:date 2007010100 ULWRF kpds5=212 kpds6=1 kpds7=0 levels=(0,0) grid=221 sfc 3hr fcst: bitmap: 1648 undef
  ULWRF=Upward long wave radiation flux [W/m^2]
  timerange 0 P1 3 P2 0 TimeU 1 nx 349 ny 277 GDS grid 3 num_in_ave 0 missing 0
  center 7 subcenter 15 process 140 Table 131 scan: WE:SN winds(N/S)
  Lambert Conf: Lat1 1.000000 Lon1 -145.500000 Lov -107.000000
      Latin1 50.000000 Latin2 50.000000 LatSP 0.000000 LonSP 0.000000
      North Pole (349 x 277) Dx 32.463000 Dy 32.463000 scan 64 mode 0
  min/max data 147.562 497.812 num bits 13 BDS_Ref 147.562 DecScale 0 BinScale -4

Subject: read_grib.m Stage IV meteorological data

From: TideMan

Date: 19 Jun, 2012 01:35:58

Message: 2 of 3

On Tuesday, June 19, 2012 11:40:08 AM UTC+12, Eric Bryant wrote:
> Hi -
>
> I have been trying to read National Stage IV QPE (WMO GRIB1, i believe) dada using read_grib.m, which I downloaded from http://www.renci.org/~bblanton/files/ReadGrib/read_grib.html.
>
> I have been confused by the following output
>
> >> grib_struct=read_grib('/home/ecb27/Test/hello',-1)
> Searching for first GRIB marker...
> GRiB Record marker "GRIB" found at chars 1-4
> GRiB header =
> GRIB
> Error using get_gds (line 143)
> DRT 5 not yet coded.
>
> Error in extract_grib (line 22)
> gds_struct=get_gds(fid,lengds);
>
> Error in read_grib (line 318)
> [pds_struct,gds_struct,bms_struct,bds_struct,dataarray]=...
>
> Could someone clue me in? Appreciated if possible,
>
> Eric
>
>
> *************************************
> This is the data product:
>
> http://www.emc.ncep.noaa.gov/mmb/ylin/pcpanl/stage4/
>
> When I run wgrib (from the command line), this is what I get:
>
> $ wgrib -V ~/Test/ST4.2007010101.01h.grb
> rec 1:0:date 2007010100 APCP kpds5=61 kpds6=1 kpds7=0 levels=(0,0) grid=255 sfc 0-1hr acc: bitmap: 324979 undef
> APCP=Total precipitation [kg/m^2]
> timerange 4 P1 0 P2 1 TimeU 1 nx 1121 ny 881 GDS grid 5 num_in_ave 0 missing 0
> center 7 subcenter 4 process 182 Table 2 scan: WE:SN winds(grid)
> polar stereo: Lat1 23.117000 Long1 -119.023000 Orient -105.000000
> north pole (1121 x 881) Dx 4763 Dy 4763 scan 64 mode 8
> min/max data 0 322.13 num bits 15 BDS_Ref 0 DecScale 2 BinScale 0
>
> In contrast, this wgrib output for a file that I got working with read_grib.m:
>
> $ wgrib -V ~/Test/NARR.200701010.grb
> rec 53:6237000:date 2007010100 ULWRF kpds5=212 kpds6=1 kpds7=0 levels=(0,0) grid=221 sfc 3hr fcst: bitmap: 1648 undef
> ULWRF=Upward long wave radiation flux [W/m^2]
> timerange 0 P1 3 P2 0 TimeU 1 nx 349 ny 277 GDS grid 3 num_in_ave 0 missing 0
> center 7 subcenter 15 process 140 Table 131 scan: WE:SN winds(N/S)
> Lambert Conf: Lat1 1.000000 Lon1 -145.500000 Lov -107.000000
> Latin1 50.000000 Latin2 50.000000 LatSP 0.000000 LonSP 0.000000
> North Pole (349 x 277) Dx 32.463000 Dy 32.463000 scan 64 mode 0
> min/max data 147.562 497.812 num bits 13 BDS_Ref 147.562 DecScale 0 BinScale -4

In the old days, I used to use read_grib for accessing .grb files, but now I've found I can read them using netCDF routines (they have a Java backend).
If you have a modern Matlab, the netCDF routines are built-in.
If you have an old version as I have (R2006a), you'd need to install snctools and mexcdf.
e.g., here's how to read in significant wave height for all the time data for a particular location from an MWW3 grib file using snctools:
Hs=nc_varget(grbfile,...
   'Significant_height_of_combined_wind_waves_and_swell',...
    [ilon ilat 0],[1 1 nt]);

Subject: read_grib.m Stage IV meteorological data

From: John

Date: 19 Jun, 2012 13:06:06

Message: 3 of 3

TideMan <mulgor@gmail.com> wrote in message <1d65667d-f0df-4721-92ac-25c6e3f99763@googlegroups.com>...
> On Tuesday, June 19, 2012 11:40:08 AM UTC+12, Eric Bryant wrote:
>
> In the old days, I used to use read_grib for accessing .grb files, but now I've found I can read them using netCDF routines (they have a Java backend).
> If you have a modern Matlab, the netCDF routines are built-in.
> If you have an old version as I have (R2006a), you'd need to install snctools and mexcdf.
> e.g., here's how to read in significant wave height for all the time data for a particular location from an MWW3 grib file using snctools:
> Hs=nc_varget(grbfile,...
> 'Significant_height_of_combined_wind_waves_and_swell',...
> [ilon ilat 0],[1 1 nt]);

One slight clarification there, one would still need snctools to read GRIB files locally, even for newest versions of matlab. The netcdf-java backend used by snctools for GRIB files isn't actually part of official MATLAB.

However, if the GRIB file is on an OPeNDAP server and you have R2012a, then yes, the built-in routines will work (whether you use them with snctools or not) because the built-in routines in R2012a have OPeNDAP support, which makes it all look like netcdf to the client.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
meteorology Eric Bryant 18 Jun, 2012 19:44:10
read_gribm Eric Bryant 18 Jun, 2012 19:44:10
read_grib Eric Bryant 18 Jun, 2012 19:44:10
forcing data Eric Bryant 18 Jun, 2012 19:44:10
rssFeed for this Thread

Contact us