Re: Manipulating netCDF files

Waylon -- As John Evans mentioned, you can use python and the nc module to create/manipulate netCDF files. All of our work at the Regional Climate Centers uses the python netCDF interface.

It is available here: http://www.nrcc.cornell.edu/noon/ncmodule.html

Here is a simple python example to do what you describe below:

import nc
F = nc.open('F.nc', nc.WRITE)
X = F.var('X')
for i in range(len(X)) :
    if X[i] == 32 : X[i] = 45
F.close()

This assumes that X has a single dimension.

Hope that helps.

--Bill Noon
Northeast Regional Climate Center
Cornell University


On Nov 11, 2005, at 8:32 AM, Waylon.Collins wrote:

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: