[gradsusr] How to write a GrADS data descriptor (.ctl) file for NetCDF files with variables of multiple (>4) dimensions
Hailan Wang
hailanw at gmail.com
Tue Sep 25 10:25:33 EDT 2018
Dear all,
I am wondering if you have any suggestions on how to open and read NetCDF
files with variables of multiple dimensions (# of dimension > 4). Please
see below for an example of such NetCDF file (CldAll.nc):
netcdf CldAll {
dimensions:
sw_lw = 2 ;
up_down = 2 ;
time = UNLIMITED ; // (1 currently)
all_clear = 2 ;
latitude = 90 ;
longitude = 72 ;
pressure_level = 30 ;
hour = 8 ;
dX = 1 ;
aer_wavelength = 1 ;
aer_type = 7 ;
pressure_layer = 29 ;
cloud_condition = 12 ;
variables:
int time(time) ;
time:long_name = "Time in UNIX" ;
time:units = "Seconds since 1970-1-1 0:00:00 0:00" ;
time:comment = "15th day of the month" ;
float pressure_level(pressure_level) ;
pressure_level:long_name = "Level Pressure" ;
pressure_level:units = "mb" ;
float latitude(latitude) ;
latitude:long_name = "Latitude" ;
latitude:units = "degrees north" ;
float longitude(longitude) ;
longitude:long_name = "Longitude" ;
longitude:units = "degrees east" ;
double sfc_pressure(hour, latitude, longitude, time) ;
sfc_pressure:long_name = "Surface pressure" ;
sfc_pressure:units = "mb" ;
float hour(hour) ;
hour:units = "UTC" ;
hour:comment = ">=0 -> UTC hour; =-1 -> single mean value;
=-2 -> daytime mean; =-3 -> nighttime mean;" ;
hour:long_name = "Hour" ;
double dF_toa(dX, sw_lw, up_down, all_clear, hour, latitude,
longitude, time) ;
dF_toa:_FillValue = -9999. ;
dF_toa:long_name = "Partial derivative of the flux at the
top of the atmosphere" ;
dF_toa:units = "W/m^2" ;
double dF_sfc(dX, sw_lw, up_down, all_clear, hour, latitude,
longitude, time) ;
dF_sfc:_FillValue = -9999. ;
dF_sfc:long_name = "Partial derivative of the flux at the
surface" ;
dF_sfc:units = "W/m^2" ;
double dX01_aer_tau(aer_wavelength, aer_type, latitude, longitude,
time) ;
dX01_aer_tau:_FillValue = -9999. ;
dX01_aer_tau:long_name = "Partial derivative of the aerosol
optical depth" ;
dX01_aer_tau:units = "unitless" ;
double dX01_aer_vertdist(aer_type, pressure_layer, latitude,
longitude, time) ;
dX01_aer_vertdist:_FillValue = -9999. ;
dX01_aer_vertdist:long_name = "Partial derivative of the
aerosol vertical distribution" ;
dX01_aer_vertdist:units = "percent" ;
dX01_aer_vertdist:comment = "Fraction of aer_tau in each
layer" ;
double dX01_aer_vertdist_sfc(aer_type, latitude, longitude, time) ;
dX01_aer_vertdist_sfc:_FillValue = -9999. ;
dX01_aer_vertdist_sfc:long_name = "Partial derivative of
the aerosol vertical distribution in the layer adjacent to the surface" ;
dX01_aer_vertdist_sfc:units = "percent" ;
dX01_aer_vertdist_sfc:comment = "Fraction of aer_tau in the
layer adjacent to the surface" ;
double dX01_aer_rh(pressure_level, latitude, longitude, time) ;
dX01_aer_rh:_FillValue = -9999. ;
dX01_aer_rh:long_name = "Partial derivative of the relative
humidity for computing aerosol ssps" ;
dX01_aer_rh:units = "%" ;
double dX01_aer_sfc_rh(latitude, longitude, time) ;
dX01_aer_sfc_rh:_FillValue = -9999. ;
dX01_aer_sfc_rh:long_name = "Partial derivative of the
surface relative humidity for computing aerosol ssps" ;
dX01_aer_sfc_rh:units = "%" ;
// global attributes:
:_NCProperties =
"version=1|netcdflibversion=4.4.1|hdf5libversion=1.8.17" ;
:cloud_condition = "=1 -> High+Thin; =2 -> High+Medium; =3
-> High+Thick; =4 -> UpperMid+Thin; =5 -> UpperMid+Medium; =6 ->
UpperMid+Thick; =7 -> LowerMid+Thin; =8 -> LowerMid+Medium; =9 ->
LowerMid+Thick; =10 -> Low+Thin; =11 -> Low+Medium; =12 -> Low+Thick; " ;
:High = "50-300 mb" ;
:UpperMid = "300-500 mb" ;
:LowerMid = "500-700 mb" ;
:Low = "700 mb-Surface" ;
:Thin = "optical depth < 1" ;
:Medium = "optical depth 1-5" ;
:Thick = "optical depth > 5" ;
:contact = "Tyler Thorsen (tyler.thorsen at nasa.gov)" ;
:input_Month_file =
"/SCF5/ADF/tthorsen/data/hiatus/PRPIN/PRPIN-Month/CERES_PRPIN-Month_SYN3HR-GEOS3HR-MATCH-SZAGEOS3HR_Edition4_2x5/CERES_PRPIN-Month_SYN3HR-GEOS3HR-MATCH-SZAGEOS3HR_Edition4_2x5_201701.nc"
;
:start_date_for_climatology = 200007 ;
:end_date_for_climatology = 201706 ;
data:
time = 1484438400 ;
pressure_level = 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500,
450, 400, 350, 300, 250, 200, 150, 100, 70, 50, 30, 15, 7, 4, 2, 1, 0.7,
0.4, 0.1 ;
latitude = 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59,
57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23,
21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, -1, -3, -5, -7, -9, -11, -13,
-15,
-17, -19, -21, -23, -25, -27, -29, -31, -33, -35, -37, -39, -41, -43,
-45, -47, -49, -51, -53, -55, -57, -59, -61, -63, -65, -67, -69, -71,
-73, -75, -77, -79, -81, -83, -85, -87, -89 ;
longitude = -177.5, -172.5, -167.5, -162.5, -157.5, -152.5, -147.5, -142.5,
-137.5, -132.5, -127.5, -122.5, -117.5, -112.5, -107.5, -102.5, -97.5,
-92.5, -87.5, -82.5, -77.5, -72.5, -67.5, -62.5, -57.5, -52.5, -47.5,
-42.5, -37.5, -32.5, -27.5, -22.5, -17.5, -12.5, -7.5, -2.5, 2.5, 7.5,
12.5, 17.5, 22.5, 27.5, 32.5, 37.5, 42.5, 47.5, 52.5, 57.5, 62.5, 67.5,
72.5, 77.5, 82.5, 87.5, 92.5, 97.5, 102.5, 107.5, 112.5, 117.5, 122.5,
127.5, 132.5, 137.5, 142.5, 147.5, 152.5, 157.5, 162.5, 167.5, 172.5,
177.5 ;
hour = 0, 3, 6, 9, 12, 15, 18, 21 ;
}
I cannot directly open the NetCDF file using the command "sdfopen", with
the following error message:
ga-> sdfopen CldAll.nc
Scanning self-describing file: CldAll.nc
gadsdf: SDF file has no discernable X coordinate.
To open this file with GrADS, use a descriptor file with an XDEF entry.
Documentation is at http://iges.org/grads/gadoc/SDFdescriptorfile.html
In order to open the NetCDF file, I need to write a GrADS data descriptor
(.ctl) file for it. Here I only need to extract the sw (Shortwave) and lw
(Longwave) components of "dF_toa". My current .ctl file reads:
dset ^CldAll.nc
title test
dtype netcdf
UNDEF -9999.
options yrev
xdef 72 linear -177.5 5.0
ydef 90 linear -89 2
zdef 1 linear 1 1
tdef 8 linear 0z1jan2001 3hr
edef 2 names sw lw
vars 1
dF_toa=>p1 1 t,x,y,e p1
endvars
It apparently does not work – see below for the error message:
ga-> open aa.ctl
Scanning description file: aa.ctl
Data file CldAll.nc is open as file 1
LON set to 0 360
LAT set to -89 89
LEV set to 1 1
Time values set: 2001:1:1:0 2001:1:1:0
E set to 1 1
ga-> d p1
gancgrid error: nc_get_vara_double failed; NetCDF: Start+count exceeds
dimension bound
Data Request Error: Error for variable 'p1'
Error ocurred at column 1
DISPLAY error: Invalid expression
Expression = p1
Any suggestions on how to write the .ctl file are much appreciated!
Thanks,
Hailan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20180925/be8799a1/attachment-0001.html>
More information about the gradsusr
mailing list