mampisarkar111 / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

write data to existing file? #217

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I'm trying to edit the valus in an existing netcdf file, and write them 
back to the same file. I've read that netcdf4 is meant to be "clobbering", but 
it doesn't appear to be working in my case. I was expecting it to work as 
described in Issue 109, 
http://code.google.com/p/netcdf4-python/issues/detail?id=109 . Am I missing 
something obvious?

What steps will reproduce the problem?

1.I read in the existing file and modify a variable
file=netCDF4.Dataset('new_data.pval','r+')
file.variables['pressure'][1]=7
file.close()
2. I Reload the file to see if the variable has changed
test=netCDF4.Dataset('new_data.pval','r')
print file.variables['pressure'][1]

What is the expected output? What do you see instead?
expected, 7.0.
instead, the original value.

What version of the product are you using? On what operating system?
python2.6, netCDF4-1.0.8, netcdf-4.3.1, SUSE Linux.

Please provide any additional information below.
Also tried modifying all data in a variable 
i.e.file.variables['pressure'][:]=Newpressure. The file.variable['pressure'] 
has the correct values in the python interface but it is not written to the 
file.

Original issue reported on code.google.com by scott.k....@gmail.com on 20 Feb 2014 at 5:42

GoogleCodeExporter commented 8 years ago
After some additional debugging, I located a missing bracket in my original 
code.
The attached error was not working because print was pointing to the wrong 
variable.
This issue is solved. please remove it.

Original comment by scott.k....@gmail.com on 20 Feb 2014 at 6:38

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 21 Feb 2014 at 1:12