Overview
Example
This tutorial shows how to convert a netCDF file from the Global Land Data Assimilation System (GLDAS) Noah model to a GRIB1 file using CDO.
Estimated time to complete the following procedure: 25 minutes
Prerequisites
This tutorial was tested on a Unix system with CDO v1.9.7.1 and v1.9.9rc2.
The user must register with Earthdata to access the data.
Procedure
1. Download this sample data file.
2. Prepare a user-defined parameter table GLDAS_NOAH_parmtab.txt file for transforming data and metadata.
In this example, we follow the Parameter Table 130 and try to find the best match or workaround. Exceptions are for the soil moisture and soil temperature variables; we use 133-136 for soil moisture and 139-142 for soil temperature, corresponding to layer 1 thru 4, respectively, to avoid the difficulty of distinguishing the levels if we use the conventional parameter ID of 86 (soilm) and 85 (soiltemp). Some other variable names may not appear correctly with the National Centers for Environmental Prediction (NCEP) default GRIBTAB table, such as the following parameter IDs: 131 (Snow), 132 (Rain), 138 (Average skin temperature), and 70 (Rootzone Moisture).
The user-defined parameter table GLDAS_NOAH_parmtab.txt is included in the "Additional Info" section below.
3. Run cdo commands:
cdo -f grb copy GLDAS_NOAH025_3H.A20000101.0300.021.nc4 temporary.grb
cdo setpartabn,GLDAS_NOAH_parmtab.txt temporary.grb GLDAS_NOAH025_3H.A20000101.0300.021.grb
Shown below is the screen capture resulting when these commands are run.
++cdo -f grb copy GLDAS_NOAH025_3H.A20000101.0300.021.nc4 temporary.grb cdo copy: Processed 36 variables over 1 timestep [2.29s 158MB]. ++ cdo setpartabn,GLDAS_NOAH_parmtab.txt temporary.grb GLDAS_NOAH025_3H.A20000101.0300.021.grb cdo setpartabn: Processed 36 variables over 1 timestep [0.41s 21MB].
When done, the GRIB file GLDAS_NOAH025_3H.A20000101.0300.021.grb has been generated.
4. View the metadata using wgrib
- Create a GRIBTAB file GLDAS_NOAH_GRIBTAB.txt for GLDAS_NOAH025_3H.A20000101.0300.021.grb.
- The GRIBTAB file GLDAS_NOAH_GRIBTAB.txt is included in the "Additional Info" section below.
export GRIBTAB=GLDAS_NOAH_GRIBTAB.txt
wgrib GLDAS_NOAH025_3H.A20000101.0300.021.grb
5. View the GRIB file using Grid Analysis and Display System (GrADS).
- Create a GrADS control file by using grib2ctl, and then generate GRIBMAP index file by using gribmap.
grib2ctl GLDAS_NOAH025_3H.A20000101.0300.021.grb>GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl
gribmap -0 -i GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl
The sample ctl file is included in the "Additional Info" section below.
The screen capture for this operation is shown below.
++gribmap -0 -i GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl gribmap: opening GRIB file GLDAS_NOAH025_3H.A20000101.0300.021.grb gribmap: reached end of files gribmap: writing the GRIB1 index file (version 5)
Subsequently, run GrADS commands to view the GRIB file and plot a variable.
grads
Below is the screen capture resulting from running the GrADS commands (bolded font).
Welcome to the OpenGrADS Bundle Distribution
--------------------------------------------
For additional information enter "grads -h".
Starting "/opt/grads-2.1.a2.oga.1/Linux/Versions/2.1.a2.oga.1/x86_64/grads " ...
Grid Analysis and Display System (GrADS) Version 2.1.a2.oga.1
Copyright (c) 1988-2013 by the Institute for Global Environment and Society (IGES)
GrADS comes with ABSOLUTELY NO WARRANTY
See file COPYRIGHT for more information
Config: v2.1.a2.oga.1 little-endian readline grib2 netcdf hdf4-sds hdf5 opendap-grids,stn athena geotiff shapefile cairo
Issue 'q config' command for more detailed configuration information
Loading User Defined Extensions table </opt/grads-2.1.a2.oga.1/Linux/Versions/2.1.a2.oga.1/x86_64/gex/udxt> ... ok.
Landscape mode? ('n' for portrait):
GX Package Initialization: Size = 11 8.5
ga-> open GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl
Scanning description file: GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl
Data file GLDAS_NOAH025_3H.A20000101.0300.021.grb is open as file 1
LON set to 0 360
LAT set to -59.875 89.875
LEV set to 1 1
Time values set: 2000:1:1:3 2000:1:1:3
E set to 1 1
ga-> q file
File 1 : GLDAS_NOAH025_3H.A20000101.0300.021.grb
Descriptor: GLDAS_NOAH025_3H.A20000101.0300.021.grb.ctl
Binary: GLDAS_NOAH025_3H.A20000101.0300.021.grb
Type = Gridded
Xsize = 1440 Ysize = 600 Zsize = 1 Tsize = 1 Esize = 1
Number of Variables = 36
albedosfc 0 84 ** surface Surface Albedo, All Wavelengths -
avgsurftsfc 0 138 ** surface Average Surface Temperature K
canopintsfc 0 223 ** surface Plant canopy surface water kg/m^2
ecanopsfc 0 200 ** surface Canopy water evaporation W/m^2
esoilsfc 0 199 ** surface Bare soil evaporation W/m^2
evapsfc 0 57 ** surface Total Evapotranspiration kg/m^2/s
lwdownfsfc 0 205 ** surface Downward longwave radiation flux W/m^2
lwnetsfc 0 112 ** surface Net Longwave Radiation W/m^2
psurffsfc 0 1 ** surface Surface pressure Pa
potevapsfc 0 145 ** surface Potential evaporation W/m^2
qairfsfc 0 51 ** surface Near surface specific humidity kg/kg
qgsfc 0 155 ** surface Ground Heat Flux W/m^2
qhsfc 0 122 ** surface Sensible Heat Flux W/m^2
qlesfc 0 121 ** surface Latent Heat Flux W/m^2
qssfc 0 235 ** surface Surface Runoff kg/m^2/s
qsbsfc 0 234 ** surface Subsurface Runoff kg/m^2/s
qsmsfc 0 99 ** surface Snowmelt kg/m^2/s
rainfsfc 0 132 ** surface Rainfall rate kg/m^2/s
rainffsfc 0 59 ** surface Total precipitation rate kg/m^2/s
rootmoistsfc 0 70 ** surface Root zone soil moisture kg/m^2
swesfc 0 65 ** surface Snow Water Equivalent kg/m^2
swdownfsfc 0 204 ** surface Downward shortwave radiation flux W/m^2
swnetsfc 0 111 ** surface Net Shortwave Radiation W/m^2
snowdepthsfc 0 66 ** surface Snow Depth m
snowfsfc 0 131 ** surface Snowfall rate kg/m^2/s
soilmoist1sfc 0 133 ** surface Average layer 1 Soil moisture content kg/m^2
soilmoist2sfc 0 134 ** surface Average layer 2 Soil moisture content kg/m^2
soilmoist3sfc 0 135 ** surface Average layer 3 Soil moisture content kg/m^2
soilmoist4sfc 0 136 ** surface Average layer 4 Soil moisture content kg/m^2
soiltemp1sfc 0 139 ** surface Average layer 1 Soil temperature K
soiltemp2sfc 0 140 ** surface Average layer 2 Soil temperature K
soiltemp3sfc 0 141 ** surface Average layer 3 Soil temperature K
soiltemp4sfc 0 142 ** surface Average layer 4 Soil temperature K
tvegsfc 0 210 ** surface Vegetation transpiration W/m^2
tairfsfc 0 11 ** surface Temperature K
windfsfc 0 32 ** surface Wind speed m/s
ga-> set gxout shaded
ga-> d soilmoist1sfc
Contouring: 10 to 100 interval 10
ga-> run cbarn.gs
ga-> draw title "surface Average layer 1 Soil moisture content kg/m^2\GLDAS_NOAH025_3H.A20000101.0300.021.grb
ga-> printim GLDAS_NOAH025_3H.A20000101.0300.021_soilmoist1.png white
Created PNG file GLDAS_NOAH025_3H.A20000101.0300.021_soilmoist1.png
ga-> quit