def testMinMax(self): # Scalar xouter = MV2.outerproduct(MV2.arange(10), MV2.arange(10)) maxval = MV2.maximum(xouter) minval = MV2.minimum(xouter) self.assertEqual(maxval, 81) self.assertEqual(minval, 0) # Do an elementwise maximum xmax = MV2.maximum(self.u_file, self.v_file) xmin = MV2.minimum(self.u_file, self.v_file) self.assertTrue(((xmax - self.u_file) >= 0).all()) self.assertTrue(((xmax - self.v_file) >= 0).all()) self.assertTrue(((xmin - self.u_file) <= 0).all()) self.assertTrue(((xmin - self.v_file) <= 0).all()) # Reduce along axes slicer = [Ellipsis for i in range(len(self.u_file.shape))] for axis_index, axis_length in enumerate(self.u_file.shape): amax = MV2.maximum.reduce(self.u_file, axis=axis_index) amin = MV2.minimum.reduce(self.u_file, axis=axis_index) s = list(slicer) for i in range(axis_length): s[axis_index] = i ind_slice = self.u_file.subSlice(*s, squeeze=True) self.assertTrue(((ind_slice - amax) <= 0).all()) self.assertTrue(((ind_slice - amin) >= 0).all()) t1 = MV2.TransientVariable([1., 2.]) t2 = MV2.TransientVariable([1., 10.]) t3 = MV2.minimum.outer(t1, t2) self.assertTrue(MV2.allequal(t3, [[1, 1], [1, 2]])) t3 = MV2.maximum.outer(t1, t2) self.assertTrue(MV2.allequal(t3, [[1, 10], [2, 10]]))
def testContiguousRegridNANIssue(self): a = MV2.reshape(MV2.sin(MV2.arange(20000)), (2, 1, 100, 100)) lon = cdms2.createAxis(MV2.arange(100) * 3.6) lon.designateLongitude() lon.units = "degrees_east" lon.id = "longitude" lat = cdms2.createAxis(MV2.arange(100) * 1.8 - 90.) lat.id = "latitude" lat.designateLatitude() lat.units = "degrees_north" lev = cdms2.createAxis([1000.]) lev.id = "plev" lev.designateLevel() lev.units = "hPa" t = cdms2.createAxis([0, 31.]) t.id = "time" t.designateTime() t.units = "days since 2014" cdutil.setTimeBoundsMonthly(t) a.setAxisList((t, lev, lat, lon)) a = MV2.masked_less(a, .5) grd = cdms2.createGaussianGrid(64) a = a.ascontiguous() a = a.regrid(grd, regridTool="regrid2") a = cdutil.averager(a, axis='txy') self.assertEqual(a[0], 0.7921019540305255)
def test11(self): bg = True n = 4 self.M = EzTemplate.Multi( rows=1, columns=1, legend_direction='vertical', right_margin=.2, left_margin=.15, top_margin=.15, bottom_margin=.15) t = self.M.get() leg = t.legend tt = self.x.gettexttable(leg.texttable) to = self.x.gettextorientation(leg.textorientation) OD = EzTemplate.oneD(n=n, template=t) x = MV2.arange(0, 360) x = x / 180. * MV2.pi ax = cdms2.createAxis(x) self.x.portrait() for i in range(n): y = MV2.sin((i + 1) * x) y.setAxis(0, ax) yx = self.x.createyxvsx() yx.linecolor = 241 + i yx.datawc_y1 = -1. yx.datawc_y2 = 1. y.id = str(i) t = OD.get() self.x.plot(y, t, yx, bg=bg) self.checkImage('test_EzTemplate_11.png')
def testMaskingFunctions(self): xouter = MV2.outerproduct(MV2.arange(5.), [1] * 10) masked = MV2.masked_greater(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[2:], True)) self.assertTrue(MV2.allequal(masked.mask[:2], False)) masked = MV2.masked_greater_equal(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[1:], True)) self.assertTrue(MV2.allequal(masked.mask[:1], False)) masked = MV2.masked_less(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[:1], True)) self.assertTrue(MV2.allequal(masked.mask[1:], False)) masked = MV2.masked_less_equal(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[:2], True)) self.assertTrue(MV2.allequal(masked.mask[2:], False)) masked = MV2.masked_not_equal(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[1], False)) self.assertTrue(MV2.allequal(masked.mask[0], True)) self.assertTrue(MV2.allequal(masked.mask[2:], True)) masked = MV2.masked_equal(xouter, 1) self.assertTrue(MV2.allequal(masked.mask[1], True)) self.assertTrue(MV2.allequal(masked.mask[0], False)) self.assertTrue(MV2.allequal(masked.mask[2:], False)) masked = MV2.masked_outside(xouter, 1, 3) self.assertTrue(MV2.allequal(masked.mask[0:1], True)) self.assertTrue(MV2.allequal(masked.mask[1:4], False)) self.assertTrue(MV2.allequal(masked.mask[4:], True)) masked = MV2.masked_where( MV2.logical_or(MV2.greater(xouter, 3), MV2.less(xouter, 2)), xouter) self.assertTrue(MV2.allequal(masked.mask[0:2], True)) self.assertTrue(MV2.allequal(masked.mask[2:4], False)) self.assertTrue(MV2.allequal(masked.mask[4:], True))
def testReshapeMaskedAverage(self): a = MV2.arange(100) a = MV2.reshape(a, (10, 10)) self.assertEqual(a.shape, (10, 10)) self.assertEqual(len(a.getAxisList()), 2) a = MV2.masked_greater(a, 23) b = MV2.average(a, axis=0) c = a - b
def testAxisID(self): a = MV2.ones((12, 12)) ax = cdms2.createAxis(MV2.arange(12)) ax.id = "1234567890" * 26 a.setAxis(0, ax) with cdms2.open("bad.nc", "w") as f: f.write(a) f = cdms2.open("bad.nc") listdim = f.listdimension() self.assertEqual(listdim[0], ax.id[0:127]) f.close()
def testAverage(self): xav = MV2.average(self.ones, axis=1) self.assertTrue(MV2.allequal(xav, 1)) xav2 = MV2.average(self.u_file) xav3 = MV2.average(self.u_transient) xav4, wav4 = MV2.average( self.u_transient, weights=MV2.ones( self.u_transient.shape, numpy.float), returned=1) a = MV2.arange(5) b = 2 ** a av, wav = MV2.average(b, weights=a, returned=1) self.assertEqual(av, 9.8) self.assertEqual(wav, 10)
import cdms2,MV2,regrid2,cdutil a=MV2.reshape(MV2.sin(MV2.arange(20000)),(2,1,100,100)) lon=cdms2.createAxis(MV2.arange(100)*3.6) lon.designateLongitude() lon.units="degrees_east" lon.id="longitude" lat = cdms2.createAxis(MV2.arange(100)*1.8-90.) lat.id="latitude" lat.designateLatitude() lat.units="degrees_north" lev = cdms2.createAxis([1000.]) lev.id="plev" lev.designateLevel() lev.units="hPa" t=cdms2.createAxis([0,31.]) t.id="time" t.designateTime() t.units="days since 2014" cdutil.setTimeBoundsMonthly(t) a.setAxisList((t,lev,lat,lon)) a=MV2.masked_less(a,.5) grd=cdms2.createGaussianGrid(64) a=a.ascontiguous()
alongxy = hasattr(u, 'long_name') and 'x' in us.long_name.lower() if alongxy: uname, vname = 'ux10m', 'vy10m' else: uname, vname = 'u10m', 'v10m' format_var(u, uname, format_axes=format_axes) format_var(v, vname, format_axes=format_axes) # Compute zero = us.filled(1)==0. zero &= vs.filled(1)==0. uvsmod = (us**2+vs**2)**-0.25 uvsmod /= N.sqrt(rhoa*cd) u.assignValue(uvsmod*us) v.assignValue(uvsmod*vs) u.assignValue(MV2.where(zero, 0., u)) v.assignValue(MV2.where(zero, 0., v)) del uvsmod return u, v if __name__=='__main__': import MV2 u = MV2.arange(3.) v = 2*u us, vs = wind_stress(u, v) U, V = ws2w(us, vs) print u, v print U, V
ch_units(taxis, 'days since 2000-1-15 06', copy=0) # - after print taxis.units, taxis[0:2] print taxis.asComponentTime()[0:2] # -> days since 2000-1-15 06 [ 0. 2.] # -> [2000-1-15 6:0:0.0, 2000-1-17 6:0:0.0] # Matplotlib times taxis_mpl = mpl(taxis) print taxis_mpl[0], taxis_mpl.units # -> 730134.25 days since 0001 # Change the time units of a variable import MV2 var = MV2.array(MV2.arange(len(taxis)), dtype='f', axes=[taxis]) ch_units(var, 'hours since 2000-01-15 06') print var.getTime()[0:2] # -> [ 0. 48.] # Change time zone # - UTC time now t_utc = now(True) print strftime('%H:%M', t_utc), t_utc.hour # -> 15:54 15 # - Paris time t_paris = utc_to_paris(t_utc) print strftime('%H:%M', t_paris), t_paris.hour # -> 17:54 17 # - back to UTC print tz_to_tz(t_paris, 'Europe/Paris', 'UTC').hour
# %% Make fake data import MV2, numpy as N nt = 50 # - reference ref = MV2.sin(MV2.arange(nt, dtype='f'))*10. # - modele 1 model1 = ref+N.random.rand(nt)*10. model1.long_name = 'Model 1' # - modele 2 model2 = ref/2.+N.random.rand(nt)*15. model2.long_name = 'Model 2' # %% Plot from vacumm.misc.plot import taylor taylor([model1, model2], ref, figsize=(8, 8), label_size='large', size=15, labels = ['Good model', None], colors='cyan', title_size=18, savefigs=__file__, savefigs_pdf=True, show=False, close=True)
# - changement ch_units(taxis, 'days since 2000-1-15 06', copy=0) # - apres changement print taxis.units, taxis[0:2] print taxis.asComponentTime()[0:2] # -> days since 2000-1-15 06 [ 0. 2.] # -> [2000-1-15 6:0:0.0, 2000-1-17 6:0:0.0] # Le temps matplotlib taxis_mpl = mpl(taxis) print taxis_mpl[0], taxis_mpl.units # -> 730134.25 days since 0001 # Changer les unites de temps d'une variable import MV2 var = MV2.array(MV2.arange(len(taxis)), dtype='f', axes=[taxis]) ch_units(var, 'hours since 2000-01-15 06') print var.getTime()[0:2] # -> [ 0. 48.] # Changements de fuseau horaire # - maintenant a l'heure UTC t_utc = now(True) print strftime('%H:%M', t_utc), t_utc.hour # -> 15:54 15 # - heure de paris t_paris = utc_to_paris(t_utc) print strftime('%H:%M', t_paris), t_paris.hour # -> 17:54 17 # - retour en UTC
X = vcs.init() M = EzTemplate.Multi(rows=1, columns=1, legend_direction='vertical', right_margin=.15) t = M.get() leg = t.legend tt = X.gettexttable(leg.texttable) to = X.gettextorientation(leg.textorientation) to.list() tt.list() OD = EzTemplate.oneD(n=n, template=t) x = MV2.arange(0, 360) x = x / 180. * MV2.pi ax = cdms2.createAxis(x) X.portrait() for i in range(n): y = MV2.sin((i + 1) * x) y.setAxis(0, ax) yx = X.createyxvsx() yx.linecolor = 241 + i yx.datawc_y1 = -1. yx.datawc_y2 = 1. t = OD.get() X.plot(y, t, yx, bg=bg) vcs.test.support.check_plot(X)
def testOuterproduct(self): xouter = MV2.outerproduct(MV2.arange(3.), MV2.arange(5.)) self.assertEqual(xouter.shape, (3, 5)) for i in range(3): self.assertTrue(MV2.allequal(xouter[i], i * xouter[1]))
import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression x = regression.init() t = cdms2.createAxis(numpy.arange(120)) t.designateTime() t.id = "time" t.units = "months since 2014" data = MV2.arange(120,0,-1) data.id = "data" data.setAxis(0,t) x = regression.init() x.plot(data,bg=1) fnm = 'test_vcs_monotonic_decreasing_yxvsx_default.png' regression.run(x, fnm)
def testAxisConvert(self): gm = vcs.create1d() gm.yaxisconvert = "log10" data = MV2.arange(10) data_pow = MV2.power(10, data) data_pow.id = "test" self.x.plot(data_pow, gm, bg=self.bg) self.checkImage("test_vcs_yaxisconvert_log10.png") self.x.clear() gm.flip = True gm.yaxisconvert = "linear" gm.xaxisconvert = "log10" self.x.plot(data_pow, gm, bg=self.bg) self.checkImage("test_vcs_xaxisconvert_log10_flip.png") self.x.clear() gm.flip = False gm.xaxisconvert = "linear" gm.yaxisconvert = "ln" data_exp = MV2.exp(data) data_exp.id = "test" self.x.plot(data_exp, gm, bg=self.bg) self.checkImage("test_vcs_yaxisconvert_ln.png") self.x.clear() gm.flip = False gm.xaxisconvert = "area_wt" gm.yaxisconvert = "linear" data2 = self.clt("clt", time=slice(0, 1), longitude=slice(23, 24), squeeze=1) self.x.plot(data2, gm, bg=self.bg) self.checkImage("test_vcs_xaxisconvert_areawt.png") self.x.clear() gm.flip = True gm.yaxisconvert = "area_wt" gm.xaxisconvert = "linear" self.x.plot(data2, gm, bg=self.bg) self.checkImage("test_vcs_yaxisconvert_areawt_flip.png") self.x.clear() gm.flip = False gm.xaxisconvert = "log10" gm.yaxisconvert = "ln" self.x.plot(data_pow, data_exp, gm, bg=self.bg) self.checkImage("test_vcs_axisconvert_log10_ln.png") self.x.clear() #gm.flip = True data2[:] = MV2.power(10, MV2.arange(1, data2.shape[0] + 1)) data2 = data2[:10] gm.xaxisconvert = "area_wt" gm.yaxisconvert = "log10" self.x.plot(data2, gm, bg=self.bg) self.checkImage("test_vcs_axisconvert_area_log10.png") self.x.clear() gm.flip = True gm.yaxisconvert = "area_wt" gm.xaxisconvert = "log10" self.x.plot(data2, gm, bg=self.bg) self.checkImage("test_vcs_axisconvert_area_log10_flip.png") self.x.clear() gm.flip = False gm.xaxisconvert = "area_wt" gm.yaxisconvert = "log10" data_axis = MV2.array(data2.getAxis(0)[:]) data_axis.id = "test" self.x.plot(data_axis, data2, gm, bg=self.bg) self.checkImage("test_vcs_axisconvert_area_log10_2arrays.png") with self.assertRaises(RuntimeError): self.x.clear() gm.flip = True self.x.plot(data_axis, data2, gm, bg=self.bg) self.x.clear() gm.flip = False gm.xaxisconvert = "area_wt" gm.yaxisconvert = "log10" gm.xticlabels1 = {-90: "90S", -80: "80S", -70: "70S", -60: "60S"} gm.xticlabels2 = {-85: "85S", -75: "75S", -65: "65S", -55: "55S"} mtics = {} def func(x): mtics[x] = "" map(func, range(-90, -40, 10)) gm.xmtics2 = mtics mtics = {} map(func, range(-85, -40, 10)) gm.xmtics1 = mtics gm.yticlabels1 = {100: "hun"} gm.yticlabels2 = {1000: "thou"} gm.ymtics1 = {10: "", 1000: ""} gm.ymtics2 = {10000: "", 1000: ""} gm.list() tmpl = vcs.createtemplate() for num in ["1", "2"]: for loc in ["x", "y"]: for attr in ["mintic", "tic"]: filled_attr = "{}{}{}".format(loc, attr, num) print("PRIO FOR ATT:", filled_attr) obj = getattr(tmpl, filled_attr) obj.priority = 1 obj.list() tmpl.xlabel1.priority = 1 tmpl.xlabel2.priority = 1 tmpl.ylabel1.priority = 1 tmpl.ylabel2.priority = 1 self.x.plot(data_axis, data2, gm, tmpl, bg=self.bg) self.checkImage("test_vcs_axisconvert_area_log10_user_labels.png")
def testWhere(self): xouter = MV2.outerproduct(MV2.arange(3), MV2.arange(3)) xwhere = MV2.where(MV2.greater(xouter, 3), xouter, -123) self.assertEqual(xwhere[-1, -1], 4) xwhere.mask = xwhere == 4 self.assertTrue(MV2.allequal(xwhere, -123))
# Construction des jeux de donnees import MV2, numpy as N nt = 50 # - reference ref = MV2.sin(MV2.arange(nt, dtype="f")) * 10.0 # - modele 1 model1 = ref + N.random.rand(nt) * 10.0 model1.long_name = "Model 1" # - modele 2 model2 = ref / 2.0 + N.random.rand(nt) * 15.0 model2.long_name = "Model 2" # Plot from vacumm.misc.plot import taylor taylor( [model1, model2], ref, figsize=(8, 8), label_size="large", size=15, labels=["Good model", None], colors="cyan", title_size=18, savefigs=__file__, savefigs_pdf=True, show=False, )
import vcs.test.support bg= vcs.test.support.bg n = 4 X=vcs.init() M = EzTemplate.Multi(rows=1,columns=1,legend_direction='vertical',right_margin=.15) t=M.get() leg = t.legend tt=X.gettexttable(leg.texttable) to=X.gettextorientation(leg.textorientation) to.list() tt.list() OD = EzTemplate.oneD(n=n,template=t) x = MV2.arange(0,360) x = x/180.*MV2.pi ax = cdms2.createAxis(x) X.portrait() for i in range(n): y = MV2.sin((i+1)*x) y.setAxis(0,ax) yx = X.createyxvsx() yx.linecolor=241+i yx.datawc_y1=-1. yx.datawc_y2=1. t = OD.get() X.plot(y,t,yx,bg=bg) vcs.test.support.check_plot(X)
def testCount(self): xouter = MV2.outerproduct(MV2.arange(5.), [1] * 10) masked = MV2.masked_outside(xouter, 1, 3) self.assertEqual(MV2.count(masked), 30) self.assertTrue(MV2.allequal(MV2.count(masked, 0), 3)) self.assertTrue((MV2.count(masked, 1) == [0, 10, 10, 10, 0]).all())
x4 = 1.0+ud x5 = uf-1 x6 = ud*uf x7 = ud/x2 x8=1/uf x9 = 3*ud x10=uf**3 x13 = MV2.add.reduce(uf) x14 = MV2.add.reduce(ud) x15 = x9.astype(numpy.float32) if not x15.dtype.char==numpy.sctype2char(numpy.float32): markError('astype error') ## arrayrange(start, stop=None, step=1, typecode=None, axis=None, attributes=None, id=None) ## Just like range() except it returns a variable whose type can be specfied ## by the keyword argument typecode. The axis of the result variable may be specified. xarange = MV2.arange(16., axis=ulat) ## masked_array(a, mask=None, fill_value=None, axes=None, attributes=None, id=None) ## masked_array(a, mask=None) = ## array(a, mask=mask, copy=0, fill_value=fill_value) ## Use fill_value(a) if None. xmarray = MV2.masked_array(ud) ## masked_object(data, value, copy=1, savespace=0) ## Create array masked where exactly data equal to value ## masked_values(data, value, rtol=1.0000000000000001e-05, atol=1e-08, copy=1, savespace=0, axes=None, ## attributes=None, id=None) ## masked_values(data, value, rtol=1.e-5, atol=1.e-8) ## Create a masked array; mask is None if possible. ## May share data values with original array, but not recommended.
# Adapted for numpy/ma/cdms2 by convertcdms.py import vcs_legacy,cdms2 as cdms,MV2 as MV,sys,support,os bg=support.bg f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) s=f('clt',slice(0,5),latitude=(0.,0.,'cob'),squeeze=1) nt=s.shape[0] ax=MV.arange(nt,typecode='d') bounds=MV.zeros((nt,2),typecode='d') for i in range(nt): bounds[i,0]=ax[i] bounds[i,1]=ax[i]+1. ax=cdms.createAxis(ax) s.setAxis(0,ax) x=vcs_legacy.init() x.plot(s,bg=bg) support.check_plot(x) y=vcs_legacy.init() y.plot(s,ybounds=bounds,bg=bg) # instead of being halfway, bounds are from node to node support.check_plot(y)
# -*- coding: utf8 -*- from vacumm.misc.grid.regridding import regrid2d import MV2 from vacumm.misc.grid import create_grid from vacumm.misc.plot import map2 as map import pylab as P gmax=40 ggi = create_grid((0., gmax, 1.), (0., gmax, 1.)) ggo = create_grid((0.01, gmax, .5), (0.01, gmax, .5)) vari = MV2.reshape(MV2.arange(ggi.size(), dtype='f'), ggi.shape) vari.setGrid(ggi) varo = regrid2d(vari, ggo, 'bilinear') map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__)
import MV2 from markError import clearError, markError, reportError clearError() print 'Test 15: reshape and mask and average ...', a = MV2.arange(100) try: failed = False a.shape = (10, 10) except: failed = True a = MV2.reshape(a, (10, 10)) if failed is False: markError('shape should not have worked (protected attribute)') if len(a.getAxisList()) != 2: markError('reshape did not produce 2 axes') a = MV2.masked_greater(a, 23) b = MV2.average(a, axis=0) c = a - b reportError()
x5 = uf - 1 x6 = ud * uf x7 = ud / x2 x8 = 1 / uf x9 = 3 * ud x10 = uf ** 3 x13 = MV2.add.reduce(uf) x14 = MV2.add.reduce(ud) x15 = x9.astype(numpy.float32) if not x15.dtype.char == numpy.sctype2char(numpy.float32): markError("astype error") ## arrayrange(start, stop=None, step=1, typecode=None, axis=None, attributes=None, id=None) ## Just like range() except it returns a variable whose type can be specfied ## by the keyword argument typecode. The axis of the result variable may be specified. xarange = MV2.arange(16.0, axis=ulat) ## masked_array(a, mask=None, fill_value=None, axes=None, attributes=None, id=None) ## masked_array(a, mask=None) = ## array(a, mask=mask, copy=0, fill_value=fill_value) ## Use fill_value(a) if None. xmarray = MV2.masked_array(ud) ## masked_object(data, value, copy=1, savespace=0) ## Create array masked where exactly data equal to value ## masked_values(data, value, rtol=1.0000000000000001e-05, atol=1e-08, copy=1, savespace=0, axes=None, ## attributes=None, id=None) ## masked_values(data, value, rtol=1.e-5, atol=1.e-8) ## Create a masked array; mask is None if possible. ## May share data values with original array, but not recommended.
def testArange(self): test_range = MV2.arange(16, axis=self.u_lat) self.assertEqual(len(test_range), 16) self.assertIsNotNone(test_range.getLatitude())
import MV2 from markError import clearError,markError,reportError print 'Test 15: reshape and mask and average ...', a=MV2.arange(100) try: failed = False a.shape=(10,10) except: failed = True a = MV2.reshape(a,(10,10)) if failed is True: markError('shape should not have worked (protected attribute)') if len(a.getAxisList())!=2: markError('reshape did not produce 2 axes') a=MV2.masked_greater(a,23) b=MV2.average(a,axis=0) c=a-b
import os, sys, numpy, cdms2, MV2, vcs, vcs.testing.regression as regression x = regression.init() t = cdms2.createAxis(numpy.arange(120)) t.designateTime() t.id = "time" t.units = "months since 2014" data = MV2.arange(120,0,-1) data.id = "data" data.setAxis(0,t) x = regression.init() x.plot(data,bg=1) fnm = 'test_vcs_monotonic_decreasing_yxvsx_default.png' regression.run(x, fnm)
# -*- coding: utf8 -*- from vacumm.misc.grid.regridding import regrid2d import MV2 from vacumm.misc.grid import create_grid from vacumm.misc.plot import map2 as map import pylab as P gmax=40 ggi = create_grid((0., gmax, 1.), (0., gmax, 1.)) ggo = create_grid((0.01, gmax, .5), (0.01, gmax, .5)) vari = MV2.reshape(MV2.arange(ggi.size(), dtype='f'), ggi.shape) vari.setGrid(ggi) varo = regrid2d(vari, ggo, 'bilinear') map(varo, clabel_glow=True, resolution=None, show=False, savefigs=__file__, close=True)
x5 = uf - 1 x6 = ud * uf x7 = ud / x2 x8 = 1 / uf x9 = 3 * ud x10 = uf**3 x13 = MV2.add.reduce(uf) x14 = MV2.add.reduce(ud) x15 = x9.astype(numpy.float32) if not x15.dtype.char == numpy.sctype2char(numpy.float32): markError('astype error') ## arrayrange(start, stop=None, step=1, typecode=None, axis=None, attributes=None, id=None) ## Just like range() except it returns a variable whose type can be specfied ## by the keyword argument typecode. The axis of the result variable may be specified. xarange = MV2.arange(16., axis=ulat) ## masked_array(a, mask=None, fill_value=None, axes=None, attributes=None, id=None) ## masked_array(a, mask=None) = ## array(a, mask=mask, copy=0, fill_value=fill_value) ## Use fill_value(a) if None. xmarray = MV2.masked_array(ud) ## masked_object(data, value, copy=1, savespace=0) ## Create array masked where exactly data equal to value ## masked_values(data, value, rtol=1.0000000000000001e-05, atol=1e-08, copy=1, savespace=0, axes=None, ## attributes=None, id=None) ## masked_values(data, value, rtol=1.e-5, atol=1.e-8) ## Create a masked array; mask is None if possible. ## May share data values with original array, but not recommended.
# models=['GISS-E2-R','bcc-csm1-1','MPI-ESM-P','CCSM4','MIROC-ESM','FGOALS-gl','IPSL-CM5A-LR'] # models=['MPI-ESM-P','CCSM4','MIROC-ESM','FGOALS-gl','IPSL-CM5A-LR'] # models=['FGOALS-gl'] # models=['MPI-ESM-P'] # models=['GISS-E2-R','bcc-csm1-1'] models = os.listdir("/big_disk_1/pcmdi/ipcc/data/hist_rcp85/atm/mo/ts") rips = ["r1i1p", "r2i1p", "r3i1p", "r4i1p", "r5i1p", "r6i1p", "r7i1p", "r8i1p", "r9i1p", "r10i1p", "r11i1p", "r12i1p"] # rips=['r2i1p','r3i1p'] # rips=['r3i1p','r4i1p','r5i1p','r6i1p','r7i1p','r8i1p'] models.remove("PET0.ESMF_LogFile") models.remove("ts_hist_rcp85_all_runs_rmclimo0009_removed_lrmIcepoub.nc") # models=['giss_e2_r','bnu_esm','miroc_esm'] models = MV.arange(1, 101, 1) models = list(models) models = [0] # oexpt='past1000' ### because! oexpt = "hist_rcp85" ### because! # oexpt='historicalNat' ### because! rips = ["1"] for m in models: for rip in rips: varss = [var3] mmm = m pp = "1"