[Met_help] Reading a netcdf for grid-stat

John Halley Gotway johnhg at ucar.edu
Mon Oct 26 08:24:59 MDT 2009


Cristian,

Unfortunately, METv2.0 is not really compatible with NetCDF data in a general sense.  However, the MET tools are able to read the output of the PCP-Combine tool which is, in fact, a NetCDF file.
Therefore, if you were to make your files look like the  output of the PCP-Combine tool, Grid-Stat should be able to read it.

For the next release, we're working to provide more general support for NetCDF files, specifically those following the NetCDF CF-convention.

For now if you'd like to tweak your NetCDF files to look like the output of Grid-Stat, here's what I'd recommend...

(1) First, you're not trying to read the NetCDF output of WRF directly into MET are you?  If that's the case, you'll need to run your data through the WRF-PostProcessor, available for download here:
http://www.dtcenter.org/wrf-nmm/users/downloads/index.php
WPP writes out GRIB files, which is what MET was designed to read.

(2) Second, if you haven't already, go into the "METv2.0/scripts" directory and run the "test_all.sh" script in there.  This will run each of the MET tools at least once, including the PCP-Combine tool.

(3) Go into the "METv2.0/out/pcp_combine" directory and use the "ncdump -h" utility to view the contents of those NetCDF files.  This is what you'll have to make your files look like.  Specifically,
note the following:
   - Each variable should be indexed by dimensions named "lat" and "lon".
   - Each variable should be named using the GRIB code abbreviations defined on this page: http://www.nco.ncep.noaa.gov/pmb/docs/on388/table2.html
     For example, temperature is GRIB code 11 and should be named "TMP".  Accumulated precip is a special case.  It's GRIB code 61 and should be named "APCP_HH" where HH is the number of hours of
accumulation.
   - The units you use should match the units defined in the GRIB table above.  MET assumes that the data is in those units.
   - For each NetCDF variable, you must define the following variable attributes:
     level, init_time_ut, valid_time_ut, accum_time (I believe that's all that MET actually reads, but you could put the rest of them to be safe).
     In these "_ut" stands for unixtime, the number of seconds since 1/1/1970.  You can use the unix date command to compute unix time.  For example, "date +%s" gives you the current unixtime.  The
"accum_time" attribute should be in seconds.
   - The projection information must be provided in the global attributes section.  The PCP-Combine output contains an example of the Lambert Conformal projection.  If your data is on a different
projection, send me a sample data file, and I'll be happy to help you figure out what to put there.

As you can see, our support for NetCDF is currently VERY limited.  We're working to expand it in future releases.

Thanks,
John Halley Gotway
johnhg at ucar.edu


Cristian Gonzal Muñoz Castillo wrote:
> Hi,
> 
> Which attributes are needed from a netcdf file to be used in the grid-stat
> tool? i'm using netcdf files created by matlab but i think i'm not writing
> down the necessary attributes for it. Could you please advise me on this.
> 
> Thanks
> 
> PS: when i run grid-stat i get "NetCDF: Attribute not found"
> 
> 


More information about the Met_help mailing list