RE: Manipulating netCDF files (ncdigest V1 #922)

The replies are providing an interesting comparison of packages for
manipulating netCDF files.

Here is my solution using (and shameless plug for) NAP (a.k.a. tcl-nap),
whose home is
http://tcl-nap.sourceforge.net

I wrote the following shell script named 'change_nc_value':

$ cat change_nc_value   
#!/bin/sh
tclsh << END
nap "in = [nap_get netcdf $1 $2]"
[nap "in == $3 ? $4 : in"] netcdf $1 $2
END

I then tested it as follows:

$ ncdump G.nc
netcdf G {
dimensions:
        d = 8 ;
variables:
        float X(d) ;
data:

 X = 27, 32.5, 32, 30.1, 29, 40, 32, 45 ;
}
$ change_nc_value G.nc X 32 45
$ ncdump G.nc
netcdf G {
dimensions:
        d = 8 ;
variables:
        float X(d) ;
data:

 X = 27, 32.5, 45, 30.1, 29, 40, 45, 45 ;
}

Harvey Davies, CSIRO Marine and Atmospheric Research,
Private Bag No. 1, Aspendale 3195
E-mail: harvey.davies@xxxxxxxx
Office: 03 9239 4556
Mobile: 04 2241 7563

  > -----Original Message-----
  > From: owner-ncdigest@xxxxxxxxxxxxxxxx [mailto:owner-
  > ncdigest@xxxxxxxxxxxxxxxx]
  > Sent: Saturday, 12 November 2005 15:25
  > To: ncdigest@xxxxxxxxxxxxxxxx
  > Subject: ncdigest V1 #922
  > 
  > 
  > ncdigest           Friday, November 11 2005           Volume 01 :
Number
  > 922
  > 
  > 
  > 
  > Today's Topics:
  > Manipulating netCDF files
  > Re: Manipulating netCDF files
  > Re: Manipulating netCDF files
  > Re: Manipulating netCDF files
  > Re: Manipulating netCDF files
  > RE: Manipulating netCDF files
  > 
  >
----------------------------------------------------------------------
  > 
  > Date: Fri, 11 Nov 2005 07:32:16 -0600
  > From: "Waylon.Collins" <Waylon.Collins@xxxxxxxx>
  > Subject: Manipulating netCDF files
  > 
  > Dear group members,
  > 
  > After reviewed the Unidata list of software that manipulates netCDF
  > files, I have yet to find one that can perform the following task --
I
  > need command-line software (that can run in a Redhat Enterprise
Linux
  > environment) that will allow me to replace data values, associated
with
  > a particular variable, with values that I can specify. It needs to
allow
  > for a logical operation. For example, the software needs to be able
to
  > perform the following -- "Any datum of variable X, within netCDF
file
  > with filename F.nc, that equals 32, change it to the value 45. Thus,
the
  > original file F.nc is now altered, or the altered file is now named
  > G.nc". Any help will be greatly appreciated.
  > 
  > Sincerely,
  > 
  > Waylon
  > 
  > - --
  >
**********************************************************************
  > * Waylon G. Collins                  Voice: (361)289-0959
*
  > * NOAA/National Weather Service      E-Mail: Waylon.Collins@xxxxxxxx
*
  > * 300 Pinson Drive
*
  > * Corpus Christi, TX 78406
*
  > * USA
*
  >
**********************************************************************


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: