[gradsusr] reading NCAR .nc files

Charles Seman Charles.Seman at noaa.gov
Thu Oct 20 17:26:12 EDT 2011


Alan,

In experience with GFDL NOLEAP calendar model output files, it was found 
that a simple data descriptor file for use with "xdfopen" worked.  To 
start, you could try a data descriptor file with a name like 
mycase.5.cam2.h1.1902-01-01-00000.xdf with the following 3 lines in it:
---
dset ^mycase.5.cam2.h1.1902-01-01-00000.nc
options 365_day_calendar
tdef time "nt" linear "t0" "dt"
---
where here nt=365 (taken from the ncdump output below), "t0" would be a 
GrADS format date corresponding to t=1, and "dt" would be the time 
increment between time-steps.  Finding "t0" is the most difficult part 
(using the "days since ..." attribute).  For a one-time calculation, you 
could dump out the values of the time variable and do a conversion by 
hand.  (We have a set of C-Shell scripts to automate the construction of 
the XDF data descriptor file.  Please let me know if you would be 
interested in getting these scripts.)

Then in GrADS:
xdfopen mycase.5.cam2.h1.1902-01-01-00000.xdf

Please let me know if this does not work (there are a number of 
different coordinate systems in your file, so you may not be able to 
view all variables at all levels with the simple xdfopen data descriptor 
file shown above).

Hope this helps,
Chuck

Alan Robock wrote:
> Dear All,
> 
> I have run an NCAR GCM, and want to read the output with GrADS.  When I 
> tried, I got:
> 
> Config: v2.0.a9 little-endian readline printim grib2 netcdf hdf4-sds 
> hdf5 opendap-grids,stn geotiff shapefile
> Issue 'q config' command for more detailed configuration information
> Landscape mode? ('n' for portrait):
> GX Package Initialization: Size = 11 8.5
> ga-> sdfopen mycase.5.cam2.h1.1902-01-01-00000.nc
> Scanning self-describing file:  mycase.5.cam2.h1.1902-01-01-00000.nc
> SDF Error: 365 day calendars are no longer supported by sdfopen.
>    To open this file with GrADS, use a descriptor file with
>    a complete TDEF entry and OPTIONS 365_day_calendar.
>    Documentation is at http://iges.org/grads/gadoc/SDFdescriptorfile.html
> 
> I can try to figure out how detailed a data descriptor file to write on 
> my own, but if someone has already done this, could you send it to me?  
> I want to find out if I need only TDEF and OPTIONS, or do I need to make 
> it complete with all the dimensions and variables.
> 
> Also, once I create the .ddf file, do I use sdfopen, xdfopen, or open?
> 
> Thanks.
> 
> ncdump gives me:
> 
> /ptmp/robock/archive/mycase.5/atm/hist|32> ncdump  
> mycase.5.cam2.h1.1902-01-01-00000.nc
> netcdf mycase.5.cam2.h1.1902-01-01-00000 { // format variant: 64bit
> dimensions:
>          lat = 192 ;
>          lon = 288 ;
>          slat = 191 ;
>          slon = 288 ;
>          lev = 26 ;
>          ilev = 27 ;
>          isccp_prs = 7 ;
>          isccp_tau = 7 ;
>          isccp_prstau = 49 ;
>          time = UNLIMITED ; // (365 currently)
>          tbnd = 2 ;
>          chars = 8 ;
> variables:
>          double P0 ;
>                  P0:long_name = "reference pressure" ;
>                  P0:units = "Pa" ;
>          double lat(lat) ;
>                  lat:long_name = "latitude" ;
>                  lat:units = "degrees_north" ;
>          double lon(lon) ;
>                  lon:long_name = "longitude" ;
>                  lon:units = "degrees_east" ;
>          double slat(slat) ;
>                  slat:long_name = "staggered latitude" ;
>                  slat:units = "degrees_north" ;
>          double slon(slon) ;
>                  slon:long_name = "staggered longitude" ;
>                  slon:units = "degrees_east" ;
>          double w_stag(slat) ;
>                  w_stag:long_name = "staggered latitude weights" ;
>          double lev(lev) ;
>                  lev:long_name = "hybrid level at midpoints (1000*(A+B))" ;
>                  lev:units = "level" ;
>                  lev:positive = "down" ;
>                  lev:standard_name = 
> "atmosphere_hybrid_sigma_pressure_coordinate" ;
>                  lev:formula_terms = "a: hyam b: hybm p0: P0 ps: PS" ;
>          double ilev(ilev) ;
>                  ilev:long_name = "hybrid level at interfaces 
> (1000*(A+B))" ;
>                  ilev:units = "level" ;
>                  ilev:positive = "down" ;
>                  ilev:standard_name = 
> "atmosphere_hybrid_sigma_pressure_coordinate" ;
>                  ilev:formula_terms = "a: hyai b: hybi p0: P0 ps: PS" ;
>          double isccp_prs(isccp_prs) ;
>                  isccp_prs:long_name = "Mean ISCCP pressure" ;
>                  isccp_prs:units = "mb" ;
>                  isccp_prs:isccp_prs_bnds = 0., 180., 310., 440., 560., 
> 680., 800., 1000. ;
>          double isccp_tau(isccp_tau) ;
>                  isccp_tau:long_name = "Mean ISCCP optical depth" ;
>                  isccp_tau:units = "unitless" ;
>                  isccp_tau:isccp_tau_bnds = 0., 0.3, 1.3, 3.6, 9.4, 23., 
> 60., 379. ;
>          double isccp_prstau(isccp_prstau) ;
>                  isccp_prstau:long_name = "Mean pressure (mb).mean 
> optical depth (unitless)/1000" ;
>                  isccp_prstau:units = "mixed" ;
>          double time(time) ;
>                  time:long_name = "time" ;
>                  time:units = "days since 1900-01-01 00:00:00" ;
>                  time:calendar = "noleap" ;
>                  time:bounds = "time_bnds" ;
>          double time_bnds(time, tbnd) ;
>                  time_bnds:long_name = "time interval endpoints" ;
>          char date_written(time, chars) ;
>          char time_written(time, chars) ;
>          int ntrm ;
>                  ntrm:long_name = "spectral truncation parameter M" ;
>          int ntrn ;
>                  ntrn:long_name = "spectral truncation parameter N" ;
>          int ntrk ;
>                  ntrk:long_name = "spectral truncation parameter K" ;
>          int ndbase ;
>                  ndbase:long_name = "base day" ;
>          int nsbase ;
>                  nsbase:long_name = "seconds of base day" ;
>          int nbdate ;
>                  nbdate:long_name = "base date (YYYYMMDD)" ;
>          int nbsec ;
>                  nbsec:long_name = "seconds of base date" ;
>          int mdt ;
>                  mdt:long_name = "timestep" ;
>                  mdt:units = "s" ;
>          int nlon(lat) ;
>                  nlon:long_name = "number of longitudes" ;
>          int wnummax(lat) ;
>                  wnummax:long_name = "cutoff Fourier wavenumber" ;
>          double hyai(ilev) ;
>                  hyai:long_name = "hybrid A coefficient at layer 
> interfaces" ;
>          double hybi(ilev) ;
>                  hybi:long_name = "hybrid B coefficient at layer 
> interfaces" ;
>          double hyam(lev) ;
>                  hyam:long_name = "hybrid A coefficient at layer 
> midpoints" ;
>          double hybm(lev) ;
>                  hybm:long_name = "hybrid B coefficient at layer 
> midpoints" ;
>          double gw(lat) ;
>                  gw:long_name = "gauss weights" ;
>          int ndcur(time) ;
>                  ndcur:long_name = "current day (from base day)" ;
>          int nscur(time) ;
>                  nscur:long_name = "current seconds of current day" ;
>          int date(time) ;
>                  date:long_name = "current date (YYYYMMDD)" ;
>          double co2vmr(time) ;
>                  co2vmr:long_name = "co2 volume mixing ratio" ;
>          double ch4vmr(time) ;
>                  ch4vmr:long_name = "ch4 volume mixing ratio" ;
>          double n2ovmr(time) ;
>                  n2ovmr:long_name = "n2o volume mixing ratio" ;
>          double f11vmr(time) ;
>                  f11vmr:long_name = "f11 volume mixing ratio" ;
>          double f12vmr(time) ;
>                  f12vmr:long_name = "f12 volume mixing ratio" ;
>          double sol_tsi(time) ;
>                  sol_tsi:long_name = "total solar irradiance" ;
>                  sol_tsi:units = "W/m2" ;
>          int datesec(time) ;
>                  datesec:long_name = "current seconds of current date" ;
>          int nsteph(time) ;
>                  nsteph:long_name = "current timestep" ;
>          float MSKtem(time, lat, lon) ;
>                  MSKtem:units = "unitless" ;
>                  MSKtem:long_name = "TEM mask" ;
>                  MSKtem:cell_methods = "time: mean" ;
>          float PRECC(time, lat, lon) ;
>                  PRECC:units = "m/s" ;
>                  PRECC:long_name = "Convective precipitation rate (liq + 
> ice)" ;
>                  PRECC:cell_methods = "time: mean" ;
>          float PRECL(time, lat, lon) ;
>                  PRECL:units = "m/s" ;
>                  PRECL:long_name = "Large-scale (stable) precipitation 
> rate (liq + ice)" ;
>                  PRECL:cell_methods = "time: mean" ;
>          float PSL(time, lat, lon) ;
>                  PSL:units = "Pa" ;
>                  PSL:long_name = "Sea level pressure" ;
>                  PSL:cell_methods = "time: mean" ;
>          float TREFHT(time, lat, lon) ;
>                  TREFHT:units = "K" ;
>                  TREFHT:long_name = "Reference height temperature" ;
>                  TREFHT:cell_methods = "time: mean" ;
>          float TREFHTMN(time, lat, lon) ;
>                  TREFHTMN:units = "K" ;
>                  TREFHTMN:long_name = "Minimum reference height 
> temperature over output period" ;
>                  TREFHTMN:cell_methods = "time: minimum" ;
>          float TREFHTMX(time, lat, lon) ;
>                  TREFHTMX:units = "K" ;
>                  TREFHTMX:long_name = "Maximum reference height 
> temperature over output period" ;
>                  TREFHTMX:cell_methods = "time: maximum" ;
>          float UV2d(time, lat, lon) ;
>                  UV2d:units = "M2/S2" ;
>                  UV2d:long_name = "Meridional Flux of Zonal Momentum: 2D 
> prj of zon. mean" ;
>                  UV2d:cell_methods = "time: mean" ;
>          float UW2d(time, lat, lon) ;
>                  UW2d:units = "M2/S2" ;
>                  UW2d:long_name = "Vertical Flux of Zonal Momentum; 2D 
> prj of zon. mean" ;
>                  UW2d:cell_methods = "time: mean" ;
>          float VTH2d(time, lat, lon) ;
>                  VTH2d:units = "MK/S" ;
>                  VTH2d:long_name = "Meridional Heat Flux: 2D prj of zon. 
> mean" ;
>                  VTH2d:cell_methods = "time: mean" ;
>          float WTH2d(time, lat, lon) ;
>                  WTH2d:units = "MK/S" ;
>                  WTH2d:long_name = "Vertical Heat Flux: 2D prj of zon. 
> mean" ;
>                  WTH2d:cell_methods = "time: mean" ;
> 
> // global attributes:
>                  :Conventions = "CF-1.0" ;
>                  :source = "CAM" ;
>                  :case = "mycase.5" ;
>                  :title = "UNSET" ;
>                  :logname = "robock" ;
>                  :host = "be0501en.ucar.ed" ;
>                  :Version = "$Name$" ;
>                  :revision_Id = "$Id$" ;
>                  :initial_file = 
> "b40.lgm21ka.1deg.003.cam2.i.1900-01-01-00000.nc" ;
>                  :topography_file = 
> "/glade/home/robock/mycase.5/SourceMods/src.cam/topo_lgm21ka_remap_09x25.mod.110106.nc" 
> ;
> data:
> ...
> 
> 

-- 

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
  Charles Seman                                Charles.Seman at noaa.gov
  U.S. Department of Commerce / NOAA / OAR
  Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
  201 Forrestal Road                              fax: (609) 987-5063
  Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect any
official or unofficial position of the United States Federal Government,
the United States Department of Commerce, or NOAA."



More information about the gradsusr mailing list