DamienIrving / climate-analysis

Code used for the analysis and visualisation of climate data during my PhD
MIT License
40 stars 19 forks source link

Writing files with cdms2 #22

Closed DamienIrving closed 9 years ago

DamienIrving commented 9 years ago

I had iris updated on vortex the other day and it appears something has regressed because I can no longer write output files using cdms2 with /usr/local/anaconda/bin/python:

Traceback (most recent call last):
  File "/home/STUDENT/dbirving/climate-analysis/data_processing/calc_composite.py", line 201, in <module>
    main(args)
  File "/home/STUDENT/dbirving/climate-analysis/data_processing/calc_composite.py", line 149, in main
    outvar_axes_list)
  File "/home/STUDENT/dbirving/climate-analysis/modules/netcdf_io.py", line 926, in write_netcdf
    outfile.write(var)  
  File "/usr/local/anaconda/lib/python2.7/site-packages/cdms2/dataset.py", line 1505, in write
    v[:] = var.astype(v.dtype)
  File "/usr/local/anaconda/lib/python2.7/site-packages/cdms2/fvariable.py", line 118, in __setslice__
    value.set_fill_value(saveFill)
  File "/usr/local/anaconda/lib/python2.7/site-packages/cdms2/tvariable.py", line 482, in set_fill_value
    AbstractVariable.setMissing(self, value)
  File "/usr/local/anaconda/lib/python2.7/site-packages/cdms2/avariable.py", line 357, in setMissing
    self.missing_value = value
  File "/usr/local/anaconda/lib/python2.7/site-packages/numpy/ma/core.py", line 3394, in set_fill_value
    _fill_value[()] = target
TypeError: 'numpy.float32' object does not support item assignment

From /usr/local/anaconda/lib/python2.7/site-packages/cdms2/fvariable.py it appears that if the variable in question is a masked numpy array then it tries to write the fill value and fails.

The problem doesn't happen when I use /usr/local/uvcdat/1.3.0/bin/python, but so far as I can tell it has exactly the same version of numpy and numpy.ma as /usr/local/anaconda/bin/python. (Which contradicts this person.

DamienIrving commented 9 years ago

I fixed this problem by rewriting all netCDF handling with xray.