title: Changing value of a netcdf file for a variable
body: <p>I have a large netcdf file which is three dimensional. I want to replace for the variable <code>LU_INDEX</code> in the netcdf file all the values 10 with 2. </p>
  
  <p>I wrote this python script to do so but it does not seem to work. </p>
  
  <pre><code>filelocation = 'D:/dataset.nc'
  
  ncdataset = nc.Dataset(filelocation,'r')
  lat           = ncdataset.variables['XLAT_M'][0,:,:]
  lon           = ncdataset.variables['XLONG_M'][0,:,:]
  lu_index     = ncdataset.variables['LU_INDEX'][0,:,:]
  lu_index_new = lu_index
  ncdataset.close()
  
  nlat,nlon=lat.shape
  
  for ilat in range(nlat):
      for ilon in range(lon):
          if lu_index == 10:
            lu_index_new[ilat,ilon] = 2
  
  newfilename = 'D:/dataset.new.nc'
  copyfile(ncdataset,newfilename)
  
  
  newfile     = nc.Dataset(newfilename,'r+')
  newfile.variables['LU_INDEX'][0,:,:]   = lu_index_new
  newfile.close()
  </code></pre>
  
  <p>I get the error: </p>
  
  <pre><code>The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  </code></pre>
  
  <p>I am not a very experienced with python, so if there is a more easier way to do this you are very welcome to comment. </p>