Пример #1
0
 def test_ezgkdef_fmem_YY_ezgxprm_supergrid(self):
     gp1 = self.getGridParams_ZEYY(0)
     gp2 = self.getGridParams_ZEYY(1)
     gid1 = rmn.ezgdef_fmem(gp1['ni'],gp1['nj'],gp1['grtyp'],gp1['grref'],
                            gp1['ig1ref'],gp1['ig2ref'],gp1['ig3ref'],gp1['ig4ref'],
                            gp1['ax'],gp1['ay'])        
     gid2 = rmn.ezgdef_fmem(gp2['ni'],gp2['nj'],gp2['grtyp'],gp2['grref'],
                            gp2['ig1ref'],gp2['ig2ref'],gp2['ig3ref'],gp2['ig4ref'],
                            gp2['ax'],gp2['ay'])
     self.assertTrue(gid1>=0)
     self.assertTrue(gid2>=0)
     subgridid = [gid1,gid2]
     gp12 = {
         'ni' : gp1['ni'],
         'nj' : 2*gp1['nj'],
         'grtyp' : 'U',
         'grref' : 'F',
         'vercode' : 1
         }
     gid12 = rmn.ezgdef_supergrid(gp12['ni'],gp12['nj'],
                                  gp12['grtyp'],gp12['grref'],
                                  gp12['vercode'],subgridid)
     self.assertTrue(gid12>=0)
     ng = rmn.ezget_nsubgrids(gid12)
     self.assertEqual(ng,2)
     subgid = rmn.ezget_subgridids(gid12)
     self.assertEqual(len(subgid),2)
     self.assertEqual(subgid[0],gid1)
     self.assertEqual(subgid[1],gid2)
Пример #2
0
 def test_ezgkdef_fmem_YY_ezgxprm_supergrid(self):
     gp1 = self.getGridParams_ZEYY(0)
     gp2 = self.getGridParams_ZEYY(1)
     gid1 = rmn.ezgdef_fmem(gp1['ni'],gp1['nj'],gp1['grtyp'],gp1['grref'],
                            gp1['ig1ref'],gp1['ig2ref'],gp1['ig3ref'],gp1['ig4ref'],
                            gp1['ax'],gp1['ay'])
     gid2 = rmn.ezgdef_fmem(gp2['ni'],gp2['nj'],gp2['grtyp'],gp2['grref'],
                            gp2['ig1ref'],gp2['ig2ref'],gp2['ig3ref'],gp2['ig4ref'],
                            gp2['ax'],gp2['ay'])
     self.assertTrue(gid1>=0)
     self.assertTrue(gid2>=0)
     subgridid = [gid1,gid2]
     gp12 = {
         'ni' : gp1['ni'],
         'nj' : 2*gp1['nj'],
         'grtyp' : 'U',
         'grref' : 'F',
         'vercode' : 1
         }
     gid12 = rmn.ezgdef_supergrid(gp12['ni'],gp12['nj'],
                                  gp12['grtyp'],gp12['grref'],
                                  gp12['vercode'],subgridid)
     self.assertTrue(gid12>=0)
     ng = rmn.ezget_nsubgrids(gid12)
     self.assertEqual(ng,2)
     subgid = rmn.ezget_subgridids(gid12)
     self.assertEqual(len(subgid),2)
     self.assertEqual(subgid[0],gid1)
     self.assertEqual(subgid[1],gid2)
Пример #3
0
def _getGridHandle(ni, nj, grtyp, grref, ig1, ig2, ig3, ig4, i0, j0, xs, ys):
    ## if (_isGridValid(ni, nj, grtyp, grref, ig1, ig2, ig3, ig4, i0, j0, xs, ys)>=0) #TODO
    gdid = -1
    i0b  = 0
    j0b  = 0
    grtypZ = "Z"
    grtypY = "Y"
    grtyp = grtyp.upper().strip()
    if grtyp == 'Z' or grtyp == '#':
        if grtyp == '#':
            i0b = i0-1
            j0b = j0-1
        gdid = _rmn.ezgdef_fmem(ni, nj, grtypZ, grref, ig1, ig2, ig3, ig4, xs[i0b:, 0], ys[0, j0b:]);
    elif grtyp == 'Y':
        gdid = _rmn.ezgdef_fmem(ni, nj, grtypY, grref, ig1, ig2, ig3, ig4, xs[i0b:, j0b:], ys[i0b:, j0b:]);
    else:
        gdid = _rmn.ezqkdef(ni, nj, grtyp, ig1, ig2, ig3, ig4);
    return gdid
Пример #4
0
def _getGridHandle(ni, nj, grtyp, grref, ig1, ig2, ig3, ig4, i0, j0, xs, ys):
    ## if (_isGridValid(ni, nj, grtyp, grref, ig1, ig2, ig3, ig4, i0, j0, xs, ys)>=0) #TODO
    gdid = -1
    i0b  = 0
    j0b  = 0
    grtypZ = "Z"
    grtypY = "Y"
    grtyp = grtyp.upper().strip()
    if grtyp == 'Z' or grtyp == '#':
        if grtyp == '#':
            i0b = i0-1
            j0b = j0-1
        gdid = _rmn.ezgdef_fmem(ni, nj, grtypZ, grref, ig1, ig2, ig3, ig4, xs[i0b:, 0], ys[0, j0b:]);
    elif grtyp == 'Y':
        gdid = _rmn.ezgdef_fmem(ni, nj, grtypY, grref, ig1, ig2, ig3, ig4, xs[i0b:, j0b:], ys[i0b:, j0b:]);
    else:
        gdid = _rmn.ezqkdef(ni, nj, grtyp, ig1, ig2, ig3, ig4);
    return gdid
Пример #5
0
 def test_ezgkdef_fmem_ezgxprm(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     gp['id'] = gid1
     gprm = rmn.ezgxprm(gid1)
     for k in gprm.keys():
         self.assertEqual(gp[k],gprm[k],'(%s) Expected: %s, Got: %s :: %s' % (k,repr(gp[k]),repr(gprm[k]),repr(gprm)))
     rmn.gdrls(gid1)
Пример #6
0
 def test_ezgkdef_fmem_ezgxprm(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     gp['id'] = gid1
     gprm = rmn.ezgxprm(gid1)
     for k in gprm.keys():
         self.assertEqual(gp[k],gprm[k],'(%s) Expected: %s, Got: %s :: %s' % (k,repr(gp[k]),repr(gprm[k]),repr(gprm)))
     rmn.gdrls(gid1)
Пример #7
0
 def test_ezgkdef_fmem_gdgaxes(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     gp['id'] = gid1
     axes = rmn.gdgaxes(gid1)
     self.assertEqual(axes['ax'].shape,gp['ax'].shape)
     self.assertEqual(axes['ay'].shape,gp['ay'].shape)
     for i in xrange(gp['ni']):
         self.assertTrue(abs(axes['ax'][i,0]-gp['ax'][i,0])<self.epsilon)
     for j in xrange(gp['nj']):
         self.assertTrue(abs(axes['ay'][0,j]-gp['ay'][0,j])<self.epsilon)
     rmn.gdrls(gid1)
Пример #8
0
 def test_ezgkdef_fmem_gdgaxes(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     gp['id'] = gid1
     axes = rmn.gdgaxes(gid1)
     self.assertEqual(axes['ax'].shape,gp['ax'].shape)
     self.assertEqual(axes['ay'].shape,gp['ay'].shape)
     for i in range(gp['ni']):
         self.assertTrue(abs(axes['ax'][i,0]-gp['ax'][i,0])<self.epsilon)
     for j in range(gp['nj']):
         self.assertTrue(abs(axes['ay'][0,j]-gp['ay'][0,j])<self.epsilon)
     rmn.gdrls(gid1)
Пример #9
0
 def test_ezgkdef_fmem_gdllfxy(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     xx = np.array([1.,2.],dtype=np.float32,order='FORTRAN')
     yy = np.array([1.,3.],dtype=np.float32,order='FORTRAN')
     llpts = rmn.gdllfxy(gid1, xx, yy)
     self.assertEqual(llpts['x'].shape,xx.shape)
     self.assertEqual(llpts['y'].shape,xx.shape)
     self.assertTrue(abs(llpts['lon'][0]-gp['ax'][0,0])<self.epsilon)
     self.assertTrue(abs(llpts['lat'][0]-gp['ay'][0,0])<self.epsilon)
     self.assertTrue(abs(llpts['lon'][1]-gp['ax'][1,0])<self.epsilon)
     self.assertTrue(abs(llpts['lat'][1]-gp['ay'][0,2])<self.epsilon)
     rmn.gdrls(gid1)
Пример #10
0
 def test_ezgkdef_fmem_gdxyfll(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     lat = np.array([gp['ay'][0,0],gp['ay'][0,1]],dtype=np.float32,order='FORTRAN')
     lon = np.array([gp['ax'][0,0],gp['ax'][1,0]],dtype=np.float32,order='FORTRAN')
     xypts = rmn.gdxyfll(gid1, lat, lon)
     self.assertEqual(xypts['x'].shape,lat.shape)
     self.assertEqual(xypts['y'].shape,lat.shape)
     self.assertTrue(abs(xypts['x'][0]-1.)<self.epsilon)
     self.assertTrue(abs(xypts['y'][0]-1.)<self.epsilon)
     self.assertTrue(abs(xypts['x'][1]-2.)<self.epsilon)
     self.assertTrue(abs(xypts['y'][1]-2.)<self.epsilon)
     rmn.gdrls(gid1)
Пример #11
0
 def test_ezgkdef_fmem_gdllfxy(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     xx = np.array([1.,2.],dtype=np.float32,order='FORTRAN')
     yy = np.array([1.,3.],dtype=np.float32,order='FORTRAN')
     llpts = rmn.gdllfxy(gid1, xx, yy)
     self.assertEqual(llpts['x'].shape,xx.shape)
     self.assertEqual(llpts['y'].shape,xx.shape)
     self.assertTrue(abs(llpts['lon'][0]-gp['ax'][0,0])<self.epsilon)
     self.assertTrue(abs(llpts['lat'][0]-gp['ay'][0,0])<self.epsilon)
     self.assertTrue(abs(llpts['lon'][1]-gp['ax'][1,0])<self.epsilon)
     self.assertTrue(abs(llpts['lat'][1]-gp['ay'][0,2])<self.epsilon)
     rmn.gdrls(gid1)
Пример #12
0
 def test_ezgkdef_fmem_gdxyfll(self):
     gp = self.getGridParams_ZE()
     gid1 = rmn.ezgdef_fmem(gp['ni'],gp['nj'],gp['grtyp'],gp['grref'],
                            gp['ig1ref'],gp['ig2ref'],gp['ig3ref'],gp['ig4ref'],
                            gp['ax'],gp['ay'])
     self.assertTrue(gid1>=0)
     lat = np.array([gp['ay'][0,0],gp['ay'][0,1]],dtype=np.float32,order='FORTRAN')
     lon = np.array([gp['ax'][0,0],gp['ax'][1,0]],dtype=np.float32,order='FORTRAN')
     xypts = rmn.gdxyfll(gid1, lat, lon)
     self.assertEqual(xypts['x'].shape,lat.shape)
     self.assertEqual(xypts['y'].shape,lat.shape)
     self.assertTrue(abs(xypts['x'][0]-1.)<self.epsilon)
     self.assertTrue(abs(xypts['y'][0]-1.)<self.epsilon)
     self.assertTrue(abs(xypts['x'][1]-2.)<self.epsilon)
     self.assertTrue(abs(xypts['y'][1]-2.)<self.epsilon)
     rmn.gdrls(gid1)