Example #1
0
 def test_defGrid_L(self):
     params = rmn.defGrid_L(90,45,0.,180.,1.,0.5)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k],params2[k])
     params3 = rmn.decodeGrid(params)
     for k in params.keys():
         self.assertEqual(params[k],params3[k])
Example #2
0
 def test_defGrid_L(self):
     params = rmn.defGrid_L(90, 45, 0., 180., 1., 0.5)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k], params2[k])
     params3 = rmn.decodeGrid(params)
     for k in params.keys():
         self.assertEqual(params[k], params3[k])
Example #3
0
    def test_13(self):
        """
        Interpolating Data

        Interpolating data to/from known FSTD grids is made easy with the Ezscint package.
        There are a few exceptions though
        * you can only interpolate to a Y grid, not from it.
        * multi-parts grids (Yin-Yang, ...) have to be dealth with in a special way (see below)
        In this example we'll interpolate forecast data onto the analysis grid to make some computations
        
        See also:
        """
        import os
        import rpnpy.librmn.all as rmn
 
        ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES')
        fileName0 = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk/2009042700_000')  #Analysis
        fileName1 = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk/2009042700_012')  #Forecast
 
        # Get data and grid definition for P0 in the 1st FSTD file
        try:
            fileId   = rmn.fstopenall(fileName0, rmn.FST_RO)
            p0Data1  = rmn.fstlir(fileId, nomvar='P0')  # Get the record data and metadata along with partial grid info
            p0Data1['iunit'] = fileId
            p0GridId = rmn.ezqkdef(p0Data1)             # use ezscint to retreive a grid id
            p0Grid1  = rmn.decodeGrid(p0GridId)         # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError("Problem getting P0 record grid meta from file: %s" % fileName0)
 
        # Get data and grid definition for P0 in the 2nd FSTD file
        try:
            fileId   = rmn.fstopenall(fileName1, rmn.FST_RO)
            p0Data2  = rmn.fstlir(fileId, nomvar='P0', ip2=12)  # Get the record data and metadata along with partial grid info
            p0Data2['iunit'] = fileId
            p0GridId = rmn.ezqkdef(p0Data2)                     # use ezscint to retreive a grid id
            p0Grid2  = rmn.decodeGrid(p0GridId)                 # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError("Problem getting P0 record grid meta from file: %s " % fileName1)
 
        # Make a cubic interpolation of p0Data2 onto p0Grid1 with extrapolated values set to Minvalue of the field
        rmn.ezsetopt(rmn.EZ_OPT_EXTRAP_DEGREE, rmn.EZ_EXTRAP_MIN)
        rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR)
        p0Data2_onGrid1 = rmn.ezsint(p0Grid1['id'], p0Grid2['id'], p0Data2['d'])
 
        # Make some computation
        p0Diff = p0Data2_onGrid1 - p0Data1['d']
Example #4
0
 def test_defGrid_diezeE2(self):
     ## params = rmn.defGrid_diezeE(90,45,11.,12.,1.,0.5,0.,180.,1.,270.,lni=10,lnj=15,i0=12,j0=13)
     params = rmn.defGrid_diezeE(90,
                                 45,
                                 11.,
                                 12.,
                                 1.,
                                 0.5,
                                 35.,
                                 230.,
                                 0.,
                                 320.,
                                 lni=10,
                                 lnj=15,
                                 i0=12,
                                 j0=13)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         #Note: gdef_fmem ceash with #... faked as Z grid until fix in librmn
         if k not in ('i0', 'j0', 'lni', 'lnj', 'grtyp', 'lshape'):
             if isinstance(params[k], np.ndarray):
                 ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
                 ## if ok: print k,params[k],params2[k]
                 self.assertFalse(ok)
             elif isinstance(params[k], float):
                 ok = (abs(params[k] - params2[k]) > self.epsilon)
                 self.assertFalse(
                     ok, 'defGrid_diezeE: %s, expected: %s,  got: %s' %
                     (k, str(params[k]), str(params2[k])))
             else:
                 ## if params[k] != params2[k]: print k,params[k],params2[k]
                 self.assertEqual(
                     params[k], params2[k],
                     'defGrid_diezeE: %s, expected: %s,  got: %s' %
                     (k, str(params[k]), str(params2[k])))
Example #5
0
 def test_defGrid_YY(self):
     params = rmn.defGrid_YY(31, 1.5)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         if k == 'subgrid':
             pass
         elif isinstance(params[k], np.ndarray):
             ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
             self.assertFalse(ok)
         elif isinstance(params[k], float):
             self.assertTrue(abs(params[k] - params2[k]) < self.epsilon)
         else:
             self.assertEqual(
                 params[k], params2[k], 'For k=%s, expected:%s, got:%s' %
                 (k, str(params[k]), str(params2[k])))
     for i in (0, 1):
         p0 = params['subgrid'][i]
         p2 = params2['subgrid'][i]
         for k in p0.keys():
             if isinstance(p0[k], np.ndarray):
                 ok = np.any(np.abs(p0[k] - p2[k]) > self.epsilon)
                 self.assertFalse(ok)
             elif isinstance(p0[k], float):
                 self.assertTrue(abs(p0[k] - p2[k]) < self.epsilon)
             else:
                 self.assertEqual(
                     p0[k], p2[k],
                     'sugridid=%d, For k=%s, expected:%s, got:%s' %
                     (i, k, str(p0[k]), str(p2[k])))
Example #6
0
def getGrid(dataKey):

    fileMeta = rmn.fstprm(dataKey)
    fileMeta['iunit'] = fileID #add to dictionary as key,val pair
    gridData = rmn.ezqkdef(fileMeta)
    gridDecode = rmn.decodeGrid(gridData) #use this for information, not really needed if just getting all lat lon values, but can get bottom left corner if needed for something else
    llGridData = rmn.gdll(gridData) # is a dictionary of two arrays for lat and lon
    latData = llGridData['lat']
    lonData = llGridData['lon']
    return latData, lonData
Example #7
0
 def test_defGrid_ZL2(self):
     params = rmn.defGrid_ZL(90, 45, 10., 11., 1., 0.5)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k], np.ndarray):
             ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
             ## print k,not ok,np.max(np.abs(params[k]-params2[k])),np.max(params[k])
             self.assertFalse(ok)
         else:
             ## print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k], params2[k])
Example #8
0
 def test_defGrid_ZL2(self):
     params = rmn.defGrid_ZL(90,45,10.,11.,1.,0.5)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k],np.ndarray):
             ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
             ## print k,not ok,np.max(np.abs(params[k]-params2[k])),np.max(params[k])
             self.assertFalse(ok)
         else:
             ## print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k],params2[k])
Example #9
0
 def test_defGrid_PS_S(self):
     params = rmn.defGrid_PS(90,
                             45,
                             north=False,
                             pi=45,
                             pj=30,
                             d60=5000.,
                             dgrw=270.)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k], params2[k])
Example #10
0
    def test_12(self):
        """
        Defining Grids

        Grids can be defined from
        * a record in a FSTD file or
        * directly by providing parameters.
        These grids parameters can be used to geolocate the data points and
        for interpolation operations (see below).

        See also:
        """
        import os
        import rpnpy.librmn.all as rmn

        ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES')
        fileName = os.path.join(ATM_MODEL_DFILES.strip(),
                                'bcmk/2009042700_012')

        # Define a grid from parameters, a cylindrical equidistant (LatLon) grid with 0.5 deg spacing.
        paramsL = {
            'grtyp': 'L',  # Cylindrical equidistant projection
            'ni': 90,  # Grid dimension: 90 by 45 points
            'nj': 45,
            'lat0':
            0.,  # Grid lower-left (south-west) corner (point 1,1) is located at 0N, 180E
            'lon0': 180.,
            'dlat':
            0.5,  # The grid has a resolution (grid spacing) of 0.5 deg. on both axes
            'dlon': 0.5
        }
        try:
            gridL = rmn.encodeGrid(paramsL)
        except:
            raise rmn.FSTDError(
                "Problem defining a grid with provided parameters: %s " %
                str(paramsL))

        # Get a grid definition from a record in a FSTD file
        try:
            fileId = rmn.fstopenall(fileName, rmn.FST_RO)
            prKey = rmn.fstinf(fileId, nomvar='PR')['key']
            prMeta = rmn.fstprm(
                prKey)  # Get the record metadata along with partial grid info
            prMeta['iunit'] = fileId
            prGrid0 = rmn.ezqkdef(
                prMeta)  # use ezscint to retreive full grid info
            prGrid = rmn.decodeGrid(
                prGrid0)  # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError(
                "Problem getting PR record grid meta from file: %s" % fileName)
Example #11
0
def getGrid(dataKey, fileID):
    """ Get the grid details in form of lon/lat of the FST file. """

    # Get the file metadata, then add on the keypair for 'iunit'
    fileMeta = rmn.fstprm(dataKey)
    fileMeta['iunit'] = fileID
    # Get the grid data and decode it
    gridData = rmn.ezqkdef(fileMeta)
    gridDecode = rmn.decodeGrid(gridData)
    llGridData = rmn.gdll(gridData)
    latData = llGridData['lat']
    lonData = llGridData['lon']
    return {'gridll':llGridData,'gridID':gridData, 'latData':latData,'lonData':lonData}
Example #12
0
 def test_defGrid_diezeL(self):
     params = rmn.defGrid_diezeL(90,45,11.,12.,1.,0.5,lni=90,lnj=45,i0=1,j0=1)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         #Note: gdef_fmem ceash with #... faked as Z grid until fix in librmn
         if k not in ('i0','j0','lni','lnj','grtyp','ig3','ig4','lshape'):
             if isinstance(params[k],np.ndarray):
                 ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
                 ## if ok: print k,params[k],params2[k]
                 self.assertFalse(ok)
             else:
                 ## if params[k] != params2[k]: print k,params[k],params2[k]
                 self.assertEqual(params[k],params2[k])
Example #13
0
 def test_defGrid_diezeE2(self):
     ## params = rmn.defGrid_diezeE(90,45,11.,12.,1.,0.5,0.,180.,1.,270.,lni=10,lnj=15,i0=12,j0=13)
     params = rmn.defGrid_diezeE(90,45,11.,12.,1.,0.5,35.,230.,0.,320.,lni=10,lnj=15,i0=12,j0=13)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         #Note: gdef_fmem ceash with #... faked as Z grid until fix in librmn
         if k not in ('i0','j0','lni','lnj','grtyp','lshape'):
             if isinstance(params[k],np.ndarray):
                 ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
                 ## if ok: print k,params[k],params2[k]
                 self.assertFalse(ok)
             else:
                 ## if params[k] != params2[k]: print k,params[k],params2[k]
                 self.assertEqual(params[k],params2[k],'defGrid_diezeE: %s, expected: %s,  got: %s' % (k,str(params[k]),str(params2[k])))
Example #14
0
 def test_defGrid_YL2(self):
     params0 = { \
         'ax'    : ( 45.,  46.5),\
         'ay'    : (273., 273. )\
         }
     params = rmn.defGrid_YL(params0)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k], np.ndarray):
             ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
             ## print k,not ok,np.max(np.abs(params[k]-params2[k])),np.max(params[k])
             self.assertFalse(ok)
         else:
             ## print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k], params2[k])
Example #15
0
 def test_defGrid_ZE2(self):
     ## params = rmn.defGrid_ZE(90,45,10.,11.,1.,0.5,0.,180.,1.,270.)
     params = rmn.defGrid_ZE(90,45,10.,11.,1.,0.5,35.,230.,0.,320.)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k],np.ndarray):
             ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
             #print k,not ok,np.max(np.abs(params[k]-params2[k])),np.min(params[k]),np.max(params[k])
             self.assertFalse(ok,(k,np.max(np.abs(params[k]-params2[k]))))
         elif isinstance(params[k],float):
             ok = abs(params[k]-params2[k]) > self.epsilon
             self.assertFalse(ok,(k,params[k]-params2[k]))
         else:
             #print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k],params2[k])
Example #16
0
 def test_defGrid_YL2(self):
     params0 = { \
         'ax'    : ( 45.,  46.5),\
         'ay'    : (273., 273. )\
         }
     params = rmn.defGrid_YL(params0)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k],np.ndarray):
             ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
             ## print k,not ok,np.max(np.abs(params[k]-params2[k])),np.max(params[k])
             self.assertFalse(ok)
         else:
             ## print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k],params2[k])
Example #17
0
 def test_defGrid_ZE2(self):
     ## params = rmn.defGrid_ZE(90,45,10.,11.,1.,0.5,0.,180.,1.,270.)
     params = rmn.defGrid_ZE(90, 45, 10., 11., 1., 0.5, 35., 230., 0., 320.)
     params2 = rmn.decodeGrid(params)
     for k in params.keys():
         if isinstance(params[k], np.ndarray):
             ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
             #print k,not ok,np.max(np.abs(params[k]-params2[k])),np.min(params[k]),np.max(params[k])
             self.assertFalse(ok,
                              (k, np.max(np.abs(params[k] - params2[k]))))
         elif isinstance(params[k], float):
             ok = abs(params[k] - params2[k]) > self.epsilon
             self.assertFalse(ok, (k, params[k] - params2[k]))
         else:
             #print k,params[k] == params2[k],params[k],params2[k]
             self.assertEqual(params[k], params2[k])
Example #18
0
    def test_12(self):
        """
        Defining Grids

        Grids can be defined from
        * a record in a FSTD file or
        * directly by providing parameters.
        These grids parameters can be used to geolocate the data points and
        for interpolation operations (see below).

        See also:
        """
        import os
        import rpnpy.librmn.all as rmn
 
        ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES')
        fileName = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk/2009042700_012')
 
        # Define a grid from parameters, a cylindrical equidistant (LatLon) grid with 0.5 deg spacing.
        paramsL = {
            'grtyp' : 'L', # Cylindrical equidistant projection
            'ni'   :  90,  # Grid dimension: 90 by 45 points
            'nj'   :  45,
            'lat0' :   0., # Grid lower-left (south-west) corner (point 1,1) is located at 0N, 180E
            'lon0' : 180.,
            'dlat' :   0.5,# The grid has a resolution (grid spacing) of 0.5 deg. on both axes
            'dlon' :   0.5
            }
        try:
            gridL = rmn.encodeGrid(paramsL)
        except:
            raise rmn.FSTDError("Problem defining a grid with provided parameters: %s " % str(paramsL))
 
        # Get a grid definition from a record in a FSTD file
        try:
            fileId = rmn.fstopenall(fileName, rmn.FST_RO)
            prKey  = rmn.fstinf(fileId, nomvar='PR')['key']
            prMeta = rmn.fstprm(prKey)              # Get the record metadata along with partial grid info
            prMeta['iunit'] = fileId
            prGrid0 = rmn.ezqkdef(prMeta)           # use ezscint to retreive full grid info
            prGrid  = rmn.decodeGrid(prGrid0)       # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError("Problem getting PR record grid meta from file: %s" % fileName)
Example #19
0
def getMeta(filePath, level, spc):
    try:
        fileID = rmn.fstopenall(filePath,rmn.FST_RO)
        dataKey = rmn.fstinf(fileID,nomvar=spc,ip1=level)['key']
        dataRec = rmn.fstluk(dataKey)
        # get the concentration data
        concData = dataRec['d']
        fileMeta = rmn.fstprm(dataKey)
        fileMeta['iunit'] = fileID
        gridData = rmn.ezqkdef(fileMeta)
        gridDecode = rmn.decodeGrid(gridData)
        # get the lonlat data
        llGridData = rmn.gdll(gridData)
        latData = llGridData['lat']
        lonData = llGridData['lon']
        return concData, lonData.tolist(), latData.tolist()
    except:
        print('Could not read file.')
        pass
Example #20
0
def readRec(fname, nomvar):
    """
    Read specified record data from file and get its grid definition

    Args:
       fname  (str): Filename to read from
       nomvar (str): Record varname to read
    Returns:
       rec : Record meta, data and grid definition
    """
    print("+ Read %s from: %s" % (nomvar, fname))

    # Open File
    try:
        funit = rmn.fstopenall(fname, rmn.FST_RO)
    except:
        raise rmn.FSTDError("Problem Opening file: %s" % fname)

    # Read Record data and meta
    try:
        rec = rmn.fstlir(funit, nomvar=nomvar)
    except:
        raise rmn.FSTDError("Problem Reading %s record" % nomvar)

    # Get associated grid
    try:
        rec['iunit'] = funit
        rec_gridid = rmn.ezqkdef(rec)  # use ezscint to get grid id
        rec['grid'] = rmn.decodeGrid(rec_gridid)
        del (rec['iunit']
             )  # iunit will be irrelevant after file is closed below
    except:
        sys.stderr.write('Error: Problem getting grid info for ' + nomvar +
                         ' in file: ' + fname + '\n')
        sys.exit(1)

    # Close File
    rmn.fstcloseall(funit)

    return rec
Example #21
0
def readRec(fname, nomvar):
    """
    Read specified record data from file and get its grid definition

    Args:
       fname  (str): Filename to read from
       nomvar (str): Record varname to read
    Returns:
       rec : Record meta, data and grid definition
    """
    print("+ Read %s from: %s" % (nomvar, fname))
    
    # Open File
    try:
        funit = rmn.fstopenall(fname, rmn.FST_RO)
    except:
        raise rmn.FSTDError("Problem Opening file: %s" % fname)
    
    # Read Record data and meta
    try:
        rec = rmn.fstlir(funit, nomvar=nomvar)
    except:
        raise rmn.FSTDError("Problem Reading %s record" % nomvar)
    
    # Get associated grid
    try:
        rec['iunit'] = funit
        rec_gridid   = rmn.ezqkdef(rec)  # use ezscint to get grid id
        rec['grid']  = rmn.decodeGrid(rec_gridid)
        del(rec['iunit']) # iunit will be irrelevant after file is closed below
    except:
        sys.stderr.write('Error: Problem getting grid info for '+nomvar+' in file: '+fname+'\n')
        sys.exit(1)
        
    # Close File
    rmn.fstcloseall(funit)
    
    return rec
Example #22
0
 def test_defGrid_diezeL(self):
     params = rmn.defGrid_diezeL(90,
                                 45,
                                 11.,
                                 12.,
                                 1.,
                                 0.5,
                                 lni=90,
                                 lnj=45,
                                 i0=1,
                                 j0=1)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         #Note: gdef_fmem ceash with #... faked as Z grid until fix in librmn
         if k not in ('i0', 'j0', 'lni', 'lnj', 'grtyp', 'ig3', 'ig4',
                      'lshape'):
             if isinstance(params[k], np.ndarray):
                 ok = np.any(np.abs(params[k] - params2[k]) > self.epsilon)
                 ## if ok: print k,params[k],params2[k]
                 self.assertFalse(ok)
             else:
                 ## if params[k] != params2[k]: print k,params[k],params2[k]
                 self.assertEqual(params[k], params2[k])
Example #23
0
 def test_defGrid_YY(self):
     params = rmn.defGrid_YY(31,1.5)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         if k == 'subgrid':
             pass
         elif isinstance(params[k],np.ndarray):
             ok = np.any(np.abs(params[k]-params2[k]) > self.epsilon)
             self.assertFalse(ok)
         elif isinstance(params[k],float):
             self.assertTrue(abs(params[k]-params2[k]) < self.epsilon)
         else:
             self.assertEqual(params[k],params2[k], 'For k=%s, expected:%s, got:%s' % (k, str(params[k]), str(params2[k])))
     for i in (0,1):
         p0 = params['subgrid'][i]
         p2 = params2['subgrid'][i]
         for k in p0.keys():
             if isinstance(p0[k],np.ndarray):
                 ok = np.any(np.abs(p0[k]-p2[k]) > self.epsilon)
                 self.assertFalse(ok)
             elif isinstance(p0[k],float):
                 self.assertTrue(abs(p0[k]-p2[k]) < self.epsilon)
             else:
                 self.assertEqual(p0[k],p2[k],'sugridid=%d, For k=%s, expected:%s, got:%s' % (i, k, str(p0[k]), str(p2[k])))
Example #24
0
    def test_13(self):
        """
        Interpolating Data

        Interpolating data to/from known FSTD grids is made easy with the Ezscint package.
        There are a few exceptions though
        * you can only interpolate to a Y grid, not from it.
        * multi-parts grids (Yin-Yang, ...) have to be dealth with in a special way (see below)
        In this example we'll interpolate forecast data onto the analysis grid to make some computations
        
        See also:
        """
        import os
        import rpnpy.librmn.all as rmn

        ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES')
        fileName0 = os.path.join(ATM_MODEL_DFILES.strip(),
                                 'bcmk/2009042700_000')  #Analysis
        fileName1 = os.path.join(ATM_MODEL_DFILES.strip(),
                                 'bcmk/2009042700_012')  #Forecast

        # Get data and grid definition for P0 in the 1st FSTD file
        try:
            fileId = rmn.fstopenall(fileName0, rmn.FST_RO)
            p0Data1 = rmn.fstlir(
                fileId, nomvar='P0'
            )  # Get the record data and metadata along with partial grid info
            p0Data1['iunit'] = fileId
            p0GridId = rmn.ezqkdef(
                p0Data1)  # use ezscint to retreive a grid id
            p0Grid1 = rmn.decodeGrid(
                p0GridId)  # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError(
                "Problem getting P0 record grid meta from file: %s" %
                fileName0)

        # Get data and grid definition for P0 in the 2nd FSTD file
        try:
            fileId = rmn.fstopenall(fileName1, rmn.FST_RO)
            p0Data2 = rmn.fstlir(
                fileId, nomvar='P0', ip2=12
            )  # Get the record data and metadata along with partial grid info
            p0Data2['iunit'] = fileId
            p0GridId = rmn.ezqkdef(
                p0Data2)  # use ezscint to retreive a grid id
            p0Grid2 = rmn.decodeGrid(
                p0GridId)  # Decode all the grid parameters values
            rmn.fstcloseall(fileId)
        except:
            raise rmn.FSTDError(
                "Problem getting P0 record grid meta from file: %s " %
                fileName1)

        # Make a cubic interpolation of p0Data2 onto p0Grid1 with extrapolated values set to Minvalue of the field
        rmn.ezsetopt(rmn.EZ_OPT_EXTRAP_DEGREE, rmn.EZ_EXTRAP_MIN)
        rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR)
        p0Data2_onGrid1 = rmn.ezsint(p0Grid1['id'], p0Grid2['id'],
                                     p0Data2['d'])

        # Make some computation
        p0Diff = p0Data2_onGrid1 - p0Data1['d']
Example #25
0
 def test_defGrid_PS_S(self):
     params = rmn.defGrid_PS(90,45,north=False,pi=45,pj=30,d60=5000.,dgrw=270.)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k],params2[k])
Example #26
0
 def test_defGrid_G_S(self):
     params = rmn.defGrid_G(90,45,glb=False,north=False,inverted=False)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k],params2[k])
Example #27
0
 def test_defGrid_G_S(self):
     params = rmn.defGrid_G(90, 45, glb=False, north=False, inverted=False)
     params2 = rmn.decodeGrid(params['id'])
     for k in params.keys():
         self.assertEqual(params[k], params2[k])
Example #28
0
def plotConc(prtype = defaultProjection, gridID, lonData, latData, concDiff, removed=0, cmapType=defaultCmap, minVal=None, maxVal=None, extension=defaultExt):
    gridDecode = rmn.decodeGrid(gridID)
Example #29
0
495624
>>> len(ylist)
495624
>>>


>>> fileMeta = rmn.fstprm(dataKey)
>>> fileMeta['iunit']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'iunit'
>>> fileMeta['iunit']=fileID
>>> gridData = rmn.ezqkdef(fileMeta)
Read(999) ^^   X  GM_DEV           1   642     1  363996800       60193   56056     1        0        0  E 32  E  1470   560 54400 46560
Read(999) >>   X  GM_DEV         772     1     1  363996800       60193   56056     1        0        0  E 32  E  1470   560 54400 46560
>>> gridDecode = rmn.decodeGrid(gridData)
>>> gridDecode
{'tag1': 40749, 'tag2': 67634, 'xlon1': 250.0, 'xlon2': 291.0, 'ig2ref': 560, 'shape': (772, 642), 'grref': 'E', 'xlat1': 57.0, 'ax': array([[ 148.05000305],
       [ 148.13999939],
       [ 148.22999573],
       [ 148.32000732],
       [ 148.41000366],
       [ 148.5       ],
       [ 148.58999634],
       [ 148.68000793],
       [ 148.77000427],
       [ 148.86000061],
       [ 148.94999695],
       [ 149.04000854],
       [ 149.13000488],
       [ 149.22000122],