def gdllval(uuin, vvin, lat, lon, nij, grtyp, refparam, xyAxis, hasAxis, ij0): """Interpolate scalar or vector fields to scattered (lat, lon) points vararg = Fstdc.gdllval(uuin, vvin, lat, lon, (ni, nj), grtyp, (grref, ig1, ig2, ig3, ig4), (xs, ys), hasAxis, (i0, j0)) @param (uuin, vvin): Fields to interpolate from; if vvin is None then perform scalar interpolation @param lat, lon: Latitude and longitude coordinates for interpolation @param ni ... j0: grid definition parameters @return Zout or (UU, VV): scalar or tuple of grid-directed, vector-interpolated fields, as appropriate """ try: gid = _getGridHandle(nij[0], nij[1], grtyp, refparam[0], refparam[1], refparam[2], refparam[3], refparam[4], ij0[0], ij0[1], xyAxis[0], xyAxis[1]) except: raise error("gdllval: Invalid Grid Desc") try: if vvin == None: return _rmn.gdllsval(gid, lat, lon, uuin) else: return _rmn.gdllvval(gid, lat, lon, uuin, vvin) except: raise error("gdllval: Problem interpolating")
def test_gdllvval(self): gp1 = self.getGridParams_L() gid1 = rmn.ezqkdef(gp1) self.assertTrue(gid1>=0) zin = np.empty(gp1['shape'],dtype=np.float32,order='FORTRAN') zin2 = np.empty(gp1['shape'],dtype=np.float32,order='FORTRAN') for x in xrange(gp1['ni']): zin[:,x] = x zin2[:,x] = x+1 lat = np.array([gp1['lat0']+gp1['dlat']/2.],dtype=np.float32,order='FORTRAN') lon = np.array([(gp1['lon0']+gp1['dlon'])/2.],dtype=np.float32,order='FORTRAN') (zout,zout2) = rmn.gdllvval(gid1,lat,lon,zin,zin2) self.assertEqual(lat.shape,zout.shape) self.assertEqual(lat.shape,zout2.shape) self.assertTrue(abs((zin[0,0]+zin[1,1])/2. - zout[0]) < self.epsilon) self.assertTrue(abs((zin2[0,0]+zin2[1,1])/2. - zout2[0]) < self.epsilon) rmn.gdrls(gid1)
def test_gdllvval(self): gp1 = self.getGridParams_L() gid1 = rmn.ezqkdef(gp1) self.assertTrue(gid1>=0) zin = np.empty(gp1['shape'],dtype=np.float32,order='FORTRAN') zin2 = np.empty(gp1['shape'],dtype=np.float32,order='FORTRAN') for x in range(gp1['ni']): zin[:,x] = x zin2[:,x] = x+1 lat = np.array([gp1['lat0']+gp1['dlat']/2.],dtype=np.float32,order='FORTRAN') lon = np.array([(gp1['lon0']+gp1['dlon'])/2.],dtype=np.float32,order='FORTRAN') (zout,zout2) = rmn.gdllvval(gid1,lat,lon,zin,zin2) self.assertEqual(lat.shape,zout.shape) self.assertEqual(lat.shape,zout2.shape) self.assertTrue(abs((zin[0,0]+zin[1,1])/2. - zout[0]) < self.epsilon) self.assertTrue(abs((zin2[0,0]+zin2[1,1])/2. - zout2[0]) < self.epsilon) rmn.gdrls(gid1)