Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Structure of CAM output file(s)

Hello all,
Could someone please show me the meaning of some variables in netCDF output file of CAM. How I can convert data, for example, PSL or T from netCDF to ASCII form. Do I need use the following variable(s) to calculate ?
Thank you in advance.

double co2vmr(time) ;
co2vmr:long_name = "co2 volume mixing ratio" ;
int date(time) ;
date:long_name = "current date (YYYYMMDD)" ;
char date_written(time, chars) ;
int datesec(time) ;
datesec:long_name = "current seconds of current date" ;
double gw(lat) ;
gw:long_name = "gauss weights" ;
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_prstau(isccp_prstau) ;
isccp_prstau:long_name = "Mean pressure (mb).mean optical depth (unitless)/1000" ;
isccp_prstau:units = "mixed" ;
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. ;
int mdt ;
mdt:long_name = "timestep" ;
mdt:units = "s" ;
int nbdate ;
nbdate:long_name = "base date (YYYYMMDD)" ;
int nbsec ;
nbsec:long_name = "seconds of base date" ;
int ndbase ;
ndbase:long_name = "base day" ;
int ndcur(time) ;
ndcur:long_name = "current day (from base day)" ;
int nlon(lat) ;
nlon:long_name = "number of longitudes" ;
int nsbase ;
nsbase:long_name = "seconds of base day" ;
int nscur(time) ;
nscur:long_name = "current seconds of current day" ;
int nsteph(time) ;
nsteph:long_name = "current timestep" ;
int ntrk ;
ntrk:long_name = "spectral truncation parameter K" ;
int ntrk ;
ntrk:long_name = "spectral truncation parameter K" ;
int ntrm ;
ntrm:long_name = "spectral truncation parameter M" ;
int ntrn ;
ntrn:long_name = "spectral truncation parameter N" ;
double time(time) ;
time:long_name = "time" ;
time:units = "days since 1870-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 time_written(time, chars) ;
int wnummax(lat) ;
wnummax:long_name = "cutoff Fourier wavenumber" ;
 
Hi,

You don't need to use some variables for calculating PSL, T, etc.
CAM default output (NetCDF file) has PSL, T, etc with vertical level.

There are two way how to convert NetCDF to ASCII (or binary).

1. Using NCL
Please visit NCL homepage (if you are familiar with NCL).
Uing NCL is the best way to control NetCDF files and to draw some figures.

http://www.ncl.ucar.edu/Applications/index.shtml


2. Using GrADS
Just use sdfopen command in GrADS to open NC file and to see some fields.
You can use GrADS script (gs) to extract some data.
The following is an example of gs file to extract binary data.
After getting binary, you can convert binary to ASCII (using FORTRAN or any kinds of software).

filename : test.gs
$VAR : variable name in NetCDF

'reinit'
'sdfopen CAM.T42.CONT.cam2.h0.1991-01.nc'
'set fwrite CAM.T42.$VAR.199101.bin'
'set gxout fwrite'
'set t 1'
'set z 1'
y=1
while(y
 

hannay

Cecile Hannay
AMWG Liaison
Staff member
The variables you see are metadata , variables have dimentions as time, lat,lon etc, dimentions are defined seperately .These variables have attributes like say long_name which gives full name of variables, units tells about units of variable... so you can define such attributes to a variable as to facilitate easy understanding for users.
for more details check http://www.unidata.ucar.edu/software/netcdf/
To convert them to ascii you have to use some code/software which can read such metadata.
easy way is to use ncdump or any other viewer and pipe it to a file (but difficult) .
but a better way is to use a standard software like Matlab(with mexcdf) , NCL,
ferret, grads etc.... to read the netcdf file and write it properly to a ascii file.


tanpv2000 said:
Hello all,
Could someone please show me the meaning of some variables in netCDF output file of CAM. How I can convert data, for example, PSL or T from netCDF to ASCII form. Do I need use the following variable(s) to calculate ?
Thank you in advance.

double co2vmr(time) ;
co2vmr:long_name = "co2 volume mixing ratio" ;
int date(time) ;
date:long_name = "current date (YYYYMMDD)" ;
char date_written(time, chars) ;
int datesec(time) ;
datesec:long_name = "current seconds of current date" ;
double gw(lat) ;
gw:long_name = "gauss weights" ;
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_prstau(isccp_prstau) ;
isccp_prstau:long_name = "Mean pressure (mb).mean optical depth (unitless)/1000" ;
isccp_prstau:units = "mixed" ;
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. ;
int mdt ;
mdt:long_name = "timestep" ;
mdt:units = "s" ;
int nbdate ;
nbdate:long_name = "base date (YYYYMMDD)" ;
int nbsec ;
nbsec:long_name = "seconds of base date" ;
int ndbase ;
ndbase:long_name = "base day" ;
int ndcur(time) ;
ndcur:long_name = "current day (from base day)" ;
int nlon(lat) ;
nlon:long_name = "number of longitudes" ;
int nsbase ;
nsbase:long_name = "seconds of base day" ;
int nscur(time) ;
nscur:long_name = "current seconds of current day" ;
int nsteph(time) ;
nsteph:long_name = "current timestep" ;
int ntrk ;
ntrk:long_name = "spectral truncation parameter K" ;
int ntrk ;
ntrk:long_name = "spectral truncation parameter K" ;
int ntrm ;
ntrm:long_name = "spectral truncation parameter M" ;
int ntrn ;
ntrn:long_name = "spectral truncation parameter N" ;
double time(time) ;
time:long_name = "time" ;
time:units = "days since 1870-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 time_written(time, chars) ;
int wnummax(lat) ;
wnummax:long_name = "cutoff Fourier wavenumber" ;
 
Hi all,
Thank you very much for your advices. I used PyNGL to extract data.
I have more question: Are the vertical levels specified by (hyai, hybi) variables corresponding to the pressure levels defined by ilev variable. And the same as (hyam, hybm) lev ?
Thank you in advancd.
Tan
 

hannay

Cecile Hannay
AMWG Liaison
Staff member
This is correct:
"lev" is hybrid level at the midpoints
"ilev" is hybrid level at the interfaces

hybam and hybm are the hybrid coefficients corresponding to "lev"
hybai and hybi are the hybrid coefficients corresponding to "ilev"
 
Top