[SciPy-User] updating netcdf file in scipy.io.netcdf

Don Batchelor batchelordb at ornl.gov
Mon Jan 10 12:19:02 EST 2011


How does one read in a netcdf file, modify some variables, and write 
out the updated file using scipy.io.netcdf?  In the old 
Scientific.IO.NetCDF there is the file open mode 'r+' that allows to 
both read and write to a file.  I don't see an equivalent 
functionality in scipy.io.netcdf.

I have tried just opening the file with mode 'r', modifying some 
netcdf variables, and doing a file close to see what would happen. 
But when I try to change the netcdf variables I get "RuntimeError: 
array is not writeable".  See below.  It never reaches the 'close' 
statement.   It must be possible to do this.  Otherwise how could one 
make use of a record variable?

Traceback (most recent call last):
   File "netcdf_python_example.py", line 61, in <module>
     Te[:] = radius[:]
   File "/Users/dbh/Python_scripts/netcdf.py", line 677, in __setitem__
     self.data[index] = data
RuntimeError: array is not writeable



-- 
Donald B. Batchelor
Plasma Theory Group

Phone: (865) 574-1288
Fax:   (865) 576-7926
E-mail: batchelordb at ornl.gov

Oak Ridge National Laboratory
Fusion Energy Division
P. O. Box 2008
Oak Ridge, TN 37831-6169



More information about the SciPy-User mailing list