def testNewReadPutChar(self): vgd0ptr = self._newReadBcmk() v1 = C_MKSTR('PRES') quiet = ct.c_int(0) ok = vgd.c_vgd_put_char(vgd0ptr, _C_WCHAR2CHAR('ETIK'), v1) self.assertEqual(ok, vgd.VGD_OK) v2 = C_MKSTR(' ' * vgd.VGD_MAXSTR_NOMVAR) ok = vgd.c_vgd_get_char(vgd0ptr, _C_WCHAR2CHAR('ETIK'), v2, quiet) self.assertEqual(ok, vgd.VGD_OK) self.assertEqual(_C_CHAR2WCHAR(v2.value).strip(), 'PRES')
def testFree(self): vgd0ptr = self._newReadBcmk() vgd.c_vgd_free(vgd0ptr) v1 = C_MKSTR(' ' * vgd.VGD_MAXSTR_NOMVAR) quiet = ct.c_int(0) ok = vgd.c_vgd_get_char(vgd0ptr, _C_WCHAR2CHAR('RFLD'), v1, quiet) self.assertEqual(ok, vgd.VGD_ERROR)
def testDiag_withref8_3d(self): ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() fileName = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') fileId = rmn.fstopenall(fileName, rmn.FST_RO) vgd0ptr = vgd.c_vgd_construct() ok = vgd.c_vgd_new_read(vgd0ptr,fileId,-1,-1,-1,-1) rfld_name = C_MKSTR(' '*vgd.VGD_MAXSTR_NOMVAR) quiet = ct.c_int(0) ok = vgd.c_vgd_get_char(vgd0ptr, _C_WCHAR2CHAR('RFLD'), rfld_name, quiet) rfld = rmn.fstlir(fileId, nomvar=_C_CHAR2WCHAR(rfld_name.value).strip())['d'] MB2PA = 100. rfld = rfld * MB2PA rmn.fstcloseall(fileId) ip1list = ct.POINTER(ct.c_int)() nip1 = ct.c_int(0) quiet = ct.c_int(0) ok = vgd.c_vgd_get_int_1d(vgd0ptr, _C_WCHAR2CHAR('VIPM'), ct.byref(ip1list), ct.byref(nip1), quiet) ni = rfld.shape[0] ; nj = rfld.shape[1] ; in_log = 0 levels8 = np.empty((ni, nj, nip1.value), dtype=np.float64, order='FORTRAN') rfld8 = np.empty((ni, nj), dtype=np.float64, order='FORTRAN') rfld8[:,:] = rfld[:,:] ok = vgd.c_vgd_diag_withref_8(vgd0ptr, ni, nj, nip1, ip1list, levels8, rfld8, in_log, vgd.VGD_DIAG_DPIS) self.assertEqual(ok,vgd.VGD_OK) self.assertEqual([int(x) for x in levels8[ni//2,nj//2,0:5]*10000.], [100000, 138425, 176878, 241408, 305980])
def testNewReadGetChar(self): vgd0ptr = self._newReadBcmk() #print vgd0ptr[0].ref_name v1 = C_MKSTR(' ' * vgd.VGD_MAXSTR_NOMVAR) quiet = ct.c_int(0) ok = vgd.c_vgd_get_char(vgd0ptr, _C_WCHAR2CHAR('RFLD'), v1, quiet) self.assertEqual(ok, vgd.VGD_OK) self.assertEqual(_C_CHAR2WCHAR(v1.value).strip(), 'P0')