## Automatically adapted for numpy.oldnumeric Aug 01, 2007 by import numpy import cdms2, os, sys from cdms2.tvariable import TransientVariable as TV import MV2 print 'Test 11: MV module (transient variable arithmetic) ... ', from markError import NTIME, NLAT, NLON, x, clearError, markError, reportError clearError() pth = os.path.dirname(os.path.abspath(__file__)) d = cdms2.open(os.path.join(pth, 'test.xml')) ud = d['u'] vd = d['v'] udat = ud[:] vdat = vd[:] ulat = ud.getLatitude() if not isinstance(udat, TV): markError('Slice does not return TV') f = cdms2.open(os.path.join(pth, 'u_2000.nc')) uf = f['u'] vel = MV2.sqrt(ud * ud + vd * vd) vel.id = 'velocity' vel2 = MV2.sqrt(udat * udat + vdat * vdat) vel2.id = 'velocity' vel2.units = ud.units if not MV2.allequal(vel, vel2): markError('Slice operators do not compare') x1 = uf + 1.0
#!/usr/bin/env python # Test extended wraparound print 'Test 12: Extended wraparound ... ', import cdms2,os,sys from markError import clearError,markError,reportError clearError() def testwrap(lon,coord,index): ci = (coord[0],coord[1]) if len(coord)==2: indic = 'ccn' else: indic = coord[2] inter = lon.mapIntervalExt(ci,indic) if inter is not None: if inter[2]==-1: result = inter else: result = (inter[0],inter[1]) else: result = inter if result!=index: markError("%s ==> %s, not %s"%(`coord`,`result`,`index`)) pth = os.path.dirname(os.path.abspath(__file__)) f = cdms2.open(os.path.join(pth,'test.xml')) lon = f['longitude']