add variable to existing netCDF file

From: David B. Reusch <dreusch_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 27 2013 - 12:56:24 MST

I would like to add a simple scalar value (e.g., an average for an
existing variable) to an existing netCDF dataset. I've been using the
super-easy approach of adding the netCDF file with mode "w", then doing
something like "ncfile->tas_avg = x". The "problem" I'm seeing is that
even though the new variable x is a scalar in NCL, the variable is
defined in the netCDF file with a NCL-generated new dimension (e.g.,
ncl3). I was hoping to find a way to avoid this since I get a new
dimension with each scalar I'm adding (which gets kind of messy pretty
quickly). Plus it seems more "elegant" to not have dimensions when the
data are actually scalar.

In case it helps, here are some captures from ncdump of what I'm seeing
and what, ideally, I'd like to see:
1) what I get
dimensions:
         lon = 512 ;
         lat = 50 ;
         time = UNLIMITED ; // (1 currently)
         ncl3 = 1 ;
float tas_avg(ncl3) ;

2) what I'd like
        float tas_avg ;
i.e., no dimension is associated with this var

Maybe it just isn't possible with the simple approach and/or I'm using
the wrong tool, but I figured it wouldn't hurt to check with the experts
first.

Thanks,
Dave

-- 
Associate Research Professor of Climatology
Dept of Earth and Environmental Science
MSEC 304; 801 Leroy Pl
New Mexico Tech
Socorro, NM 87801
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 27 12:56:44 2013

This archive was generated by hypermail 2.1.8 : Wed Dec 04 2013 - 20:42:38 MST