[ncl-talk] Write grib2 to netcdf

Partha Bhattacharjee pbhatta2 at jhu.edu
Wed Oct 8 13:55:03 MDT 2014


​Thanks Dennis.


Partha

________________________________
From: Dennis Shea <shea at ucar.edu>
Sent: Wednesday, October 8, 2014 3:37 PM
To: Partha Bhattacharjee
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Write grib2 to netcdf

If you want a time dimension

%> ncl_convert2nc  aod.2014100400.grb -itime

or, more elaborate, change NCL's dimension name

%> ncl_convert2nc aod.2014100400.grb -itime -u initial_time0_hours -U time

Ignore any warning message .. not important

%> ncdump -h aod.2014100400.nc<http://aod.2014100400.nc>


etcdf aod.2014100400 {
dimensions:
        time = UNLIMITED ; // (1 currently)
        lat_0 = 181 ;
        lon_0 = 360 ;
        ncl_strlen_0 = 18 ;
variables:
        float AOTK_P48_GLL0(time, lat_0, lon_0) ;
                AOTK_P48_GLL0:forecast_time_units = "hours" ;
                AOTK_P48_GLL0:forecast_time = 0 ;
                AOTK_P48_GLL0:parameter_template_discipline_category_number = 48, 0, 20, 102 ;
                AOTK_P48_GLL0:parameter_discipline_and_category = "Meteorological products, Atmospheric chemical constituents" ;
                AOTK_P48_GLL0:grid_type = "Latitude/longitude" ;
                AOTK_P48_GLL0:_FillValue = 1.e+20f ;
                AOTK_P48_GLL0:units = "Numeric" ;
                AOTK_P48_GLL0:long_name = "Aerosol optical thickness" ;
                AOTK_P48_GLL0:production_status = "Operational products" ;
                AOTK_P48_GLL0:center = "US National Weather Service - NCEP (WMC)" ;
        double time(time) ;
                time:units = "hours since 1800-01-01 00:00" ;
                time:long_name = "initial time" ;
        double initial_time0_encoded(time) ;
                initial_time0_encoded:units = "yyyymmddhh.hh_frac" ;
                initial_time0_encoded:long_name = "initial time encoded as double" ;
        float lat_0(lat_0) ;
                lat_0:La1 = 90.f ;
                lat_0:Lo1 = 0.f ;
                lat_0:La2 = -90.f ;
                lat_0:Lo2 = 359.f ;
                lat_0:Di = 1.f ;
                lat_0:Dj = 1.f ;
                lat_0:units = "degrees_north" ;
                lat_0:grid_type = "Latitude/Longitude" ;
                lat_0:long_name = "latitude" ;
        float lon_0(lon_0) ;
                lon_0:La1 = 90.f ;
                lon_0:Lo1 = 0.f ;
                lon_0:La2 = -90.f ;
                lon_0:Lo2 = 359.f ;
                lon_0:Di = 1.f ;
                lon_0:Dj = 1.f ;
                lon_0:units = "degrees_east" ;
                lon_0:grid_type = "Latitude/Longitude" ;
                lon_0:long_name = "longitude" ;
        char initial_time0(time, ncl_strlen_0) ;
                initial_time0:NCL_converted_from_type = "string" ;
                initial_time0:units = "mm/dd/yyyy (hh:mm)" ;
                initial_time0:long_name = "Initial time of first record" ;

// global attributes:
                :creation_date = "Wed Oct  8 13:35:24 MDT 2014" ;
                :NCL_Version = "6.2.0" ;
                :system = "Darwin sheamac.cgd.ucar.edu<http://sheamac.cgd.ucar.edu> 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64" ;
                :Conventions = "None" ;
                :grib_source = "aod.2014100400.grb" ;
                :title = "NCL: convert-GRIB-to-netCDF" ;

On Wed, Oct 8, 2014 at 12:41 PM, Partha Bhattacharjee <pbhatta2 at jhu.edu<mailto:pbhatta2 at jhu.edu>> wrote:

​Thanks Dave. It worked.


Partha

________________________________
From: David Brown <dbrown at ucar.edu<mailto:dbrown at ucar.edu>>
Sent: Wednesday, October 8, 2014 2:29 PM
To: Partha Bhattacharjee
Cc: ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] Write grib2 to netcdf

If you use ncl_filedump on your GRIB2 file you will see that it has no time dimension. There is only a lat and a lon dimension. The script you are using is trying to read a time dimension that does not exist -- therefore the error. The simplest and most general way to convert any GRIB file to NetCDF is to use the script ncl_convert2nc, which is supplied with every NCL installation. If the 'ncl' binary is in your PATH then ncl_convert2nc will be as well, assuming you have a standard installation.
 -dave


On Wed, Oct 8, 2014 at 10:41 AM, Partha Bhattacharjee <pbhatta2 at jhu.edu<mailto:pbhatta2 at jhu.edu>> wrote:

​Forgot to add information about my earlier question. I am using NCL 6.2.1.


Partha

________________________________
From: ncl-talk-bounces at ucar.edu<mailto:ncl-talk-bounces at ucar.edu> <ncl-talk-bounces at ucar.edu<mailto:ncl-talk-bounces at ucar.edu>> on behalf of Partha Bhattacharjee <pbhatta2 at jhu.edu<mailto:pbhatta2 at jhu.edu>>
Sent: Wednesday, October 8, 2014 11:39 AM
To: ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
Subject: [ncl-talk] Write grib2 to netcdf


I was using slightly modified form of an example in NCL page https://www.ncl.ucar.edu/Applications/gribeff.shtml to convert grib2 file to netcdf. However, ncl cannot read the time information from input grib2 file and stops where "initial_time​" is mentioned. Grib2 file and ncl code are attached. Any help is appreciated.


 Thanks.

 Partha

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141008/99697f60/attachment.html 


More information about the ncl-talk mailing list