Exemplo n.º 1
0
    def test_basic(self):
        # check inp2xsel
        xsel = Nio.inp2xsel(self.f, 'PT', 'time|i9 zc|i0 yc|i0 xc|i10:20:2')
        xsel = Nio.inp2xsel(self.f, 'PT', 'time|3600')

        xc_orig = self.f.variables['xc'][:]
        pt_orig = self.f.variables['PT'][:]
        if verbose: print('xc: ', xc_orig)
        if verbose: print('pt.shape: ', pt_orig.shape)
        if verbose: print()

        xsel_list = (5, slice(5, 8), slice(None), slice(None, None, 4))
        for xsel in xsel_list:
            if verbose: print('xsel: ', xsel)
            xc = self.f.variables['xc'][xsel]
            if verbose: print('xc[xsel]: ', xc)
            if verbose: print()
            assert_equal(xc, xc_orig[xsel])

        ptsel_list = ((1, 1, 1, 1), (1, slice(None), 0, 0),
                      (1, 3, slice(5, 8)), (slice(None), 3, slice(None), 1))
        for ptsel in ptsel_list:
            if verbose: print('ptsel: ', ptsel)
            pt = self.f.variables['PT'][ptsel]
            if verbose: print('pt[ptsel].shape: ', pt.shape)
            if verbose: print()
            assert_equal(pt.shape, pt_orig[ptsel].shape)
Exemplo n.º 2
0
    def test_basic(self):
        file = self.f

        # check inp2xsel
        xsel = Nio.inp2xsel(file, 'PT', 'time|i9 zc|i0 yc|i0 xc|i10:20:2')
        xsel = Nio.inp2xsel(file, 'PT', 'time|3600')

        xc_orig = file.variables['xc'][:]
        pt_orig = file.variables['PT'][:]
        if verbose: print 'xc: ', xc_orig
        if verbose: print 'pt.shape: ', pt_orig.shape
        if verbose: print

        xsel_list = (5, slice(5,8), slice(None), slice(None,None,4))
        for xsel in xsel_list:
            if verbose: print 'xsel: ', xsel
            xc = file.variables['xc'][xsel]
            if verbose: print 'xc[xsel]: ', xc
            if verbose: print
            assert_equal(xc, xc_orig[xsel])

        ptsel_list = ((1,1,1,1), (1,slice(None),0,0), (1,3,slice(5,8)), (slice(None),3,slice(None),1))
        for ptsel in ptsel_list:
            if verbose: print 'ptsel: ', ptsel
            pt = file.variables['PT'][ptsel]
            if verbose: print 'pt[ptsel].shape: ', pt.shape
            if verbose: print
            assert_equal(pt.shape, pt_orig[ptsel].shape)

        file.close()
Exemplo n.º 3
0
    def test_topo(self):
        file = self.f

        # basic case
        cstr_list = ('time|i0 zc|ZP|2500 yc|i5 xc|:', \
                'time|i0 zc|ZP|2500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1000,1500m yc|i5.5 xc|:')
        results = ((21, ), (21, ), (21, ), (2, 21))

        for (cstr, res) in zip(cstr_list, results):
            if verbose: print(cstr)
            print("in test_topo")
            xsel = Nio.inp2xsel(file, 'PT', cstr)
            pt = file.variables['PT'][cstr]
            #pt = file.variables['ZP'][:]
            if verbose: print(pt.shape)
            if verbose:
                if ma.isMA(pt):
                    print(N.asarray(pt.filled()))
                else:
                    print(pt)
            assert_equal(pt.shape, res)

        # ERROR:
        #cstr = 'xc|10k yc|i5.5:8:0.5i zc|ZP|2.5,3.5 time|i0:6:3'
        #if verbose: print cstr
        #pt = file.variables['PT'][cstr]
        #if verbose: print pt.shape

        file.close()
Exemplo n.º 4
0
    def test_topo(self):
        file = self.f

        # basic case
        cstr_list = ('time|i0 zc|ZP|2500 yc|i5 xc|:', \
                'time|i0 zc|ZP|2500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1000,1500m yc|i5.5 xc|:')
        results = ((21,), (21,), (21,), (2,21))

        for (cstr, res) in zip(cstr_list, results):
            if verbose: print cstr
            print "in test_topo"
            xsel = Nio.inp2xsel(file, 'PT', cstr)
            pt = file.variables['PT'][cstr]
            #pt = file.variables['ZP'][:]
            if verbose: print pt.shape
            if verbose: 
                if ma.isMA(pt):
                    print N.asarray(pt.filled())
                else:
                    print pt
            assert_equal(pt.shape, res)

        # ERROR:
        #cstr = 'xc|10k yc|i5.5:8:0.5i zc|ZP|2.5,3.5 time|i0:6:3'
        #if verbose: print cstr
        #pt = file.variables['PT'][cstr]
        #if verbose: print pt.shape

        file.close()
Exemplo n.º 5
0
    def test_topo(self):
        # basic case
        cstr_list = ('time|i0 zc|ZP|2500 yc|i5 xc|:', \
                'time|i0 zc|ZP|2500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1500m yc|i5 xc|:', \
                'time|i0 zc|ZP|1000,1500m yc|i5.5 xc|:')
        results = ((21, ), (21, ), (21, ), (2, 21))

        for (cstr, res) in zip(cstr_list, results):
            if verbose:
                print(cstr)
                print("in test_topo")
            xsel = Nio.inp2xsel(self.f, 'PT', cstr)
            pt = self.f.variables['PT'][cstr]
            #pt = self.f.variables['ZP'][:]
            if verbose: print(pt.shape)
            if verbose:
                if ma.isMA(pt):
                    print(N.asarray(pt.filled()))
                else:
                    print(pt)
            assert_equal(pt.shape, res)