This Jupyter Notebook shows how to redecorate a transient variable that became a numpy array
In [7]:
# import modules
import MV2
import cdms2
import numpy
import cdat_info # for sample data
In [10]:
# open some data
f=cdms2.open(cdat_info.get_sampledata_path()+"/clt.nc")
s=f("clt")
print type(s)
In [9]:
# Now run an operation on this MV2 that turns it to munpy array
fft_s = numpy.fft.fft(s)
print type(fft_s) # numpy array
In [19]:
# now put back dimensions on it
fft_s = MV2.array(fft_s)
fft_s.setAxisList(s.getAxisList())
# Dimensions are back
print fft_s.getAxisIds()
In [17]:
# now puts the attributes on it
for a in s.attributes:
setattr(fft_s,a,getattr(s,a))
fft_s.info()