netCDF4 variable manipulation
d at davea.name
Mon Feb 20 23:52:51 CET 2012
On 02/20/2012 03:37 PM, Sheldon wrote:
> I'm trying to read a netCDF4 variable from a file (no problem) and
> then scale it before writing over the original variable in the file.
> I'm using python 2.7 and the latest netCDF4 module. It's not that I
> keep getting an error message but I want to do this without using for
> loops and all the manuals seems to be skipping this task as if it is
> never done. I'm new to python and coming over from matlab. Does anyone
> know how to modify the netCDF4 variable in python and then write it
> back without creating a new variable, or using for loops?
> Appreciate the help,
Are you using netcdf version 4, or is that name just a coincidence? If
you're using a 3rd party library, you really should say so, and post a
link, for those curious.
in any case, if you are, I can't help you. This is apparently some
special kind of variable similar to a numpy array.
On the other hand, you may just be asking how to update some bytes in a
file, in place. if you read the file in binary mode, then you can use
seek() to go back the appropriate distance, and simply write it.
More information about the Python-list