This Jupyter Notebook shows how to redecorate a transient variable that became a numpy array
The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux. This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.
# import modules
import MV2
import cdms2
import numpy
import cdat_info # for sample data
# open some data
f=cdms2.open(cdat_info.get_sampledata_path()+"/clt.nc")
s=f("clt")
print(type(s))
# 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
# now put back dimensions on it
fft_s = MV2.array(fft_s)
fft_s.setAxisList(s.getAxisList())
# Dimensions are back
print(fft_s.getAxisIds())
# now puts the attributes on it
for a in s.attributes:
setattr(fft_s,a,getattr(s,a))
fft_s.info()