This is easy with netCDF4-python. For example, suppose nc
is your netCDF file, the variable is named var
, and the index of the cell you want to change is (0,0,0)
. Then:
from netCDF4 import Dataset
new_value = -999
nc.variables['var'][0,0,0] = new_value
netCDF4 represents all netCDF arrays using numpy, which enables their powerful manipulation using numpy's slicing and other capabilities.