RPNPy Reference¶
Release: | 2.1 |
---|---|
Date: | Apr 27, 2020 |
Module librmn.fstd98 contains python wrapper to main librmn’s fstd98, convip C functions along with helper functions
Notes
The functions described below are a very close ‘’port’’ from the original librmn’s FSTD package. You may want to refer to the FSTD documentation for more details.
See also
rpnpy.librmn.base
rpnpy.librmn.interp
rpnpy.librmn.grids
rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
DecodeIp
(ip1, ip2, ip3)¶ Produce decoded (real value, kind) pairs from (ip1, ip2, ip3) encoded triplet
(rp1, rp2, rp3) = DecodeIp(ip1, ip2, ip3)
Parameters: Returns: - decoded ip1
a level (or a pair of levels) in the atmosphere
- rp2 (FLOAT_IP): decoded ip2
a time (or a pair of times)
- rp3 (FLOAT_IP): decoded ip3
may contain anything
Return type: rp1 (FLOAT_IP)
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– provided values cannot be converted
Example:
>>> import rpnpy.librmn.all as rmn >>> (ip1, ip2, ip3) = (6441456, 176280768, 66060288) >>> (rp1, rp2, rp3) = rmn.DecodeIp(ip1, ip2, ip3) >>> print("Level v1={0}, v2={1}, type={2}".format(rp1.v1, rp1.v2, rmn.kindToString(rp1.kind))) Level v1=1500.0, v2=1500.0, type= m
See also
EncodeIp
,ip1_val
,ip2_val
,ip3_val
,convertIp
,convertIPtoPK
,convertPKtoIP
,kindToString
rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
EncodeIp
(rp1, rp2, rp3)¶ Produce encoded (ip1, ip2, ip3) triplet from (real value, kind) pairs
(ip1, ip2, ip3) = EncodeIp(rp1, rp2, rp3)
Parameters: - rp1 (FLOAT_IP) – vertical level, real values & kind a level (or a pair of levels) in the atmosphere
- rp2 (FLOAT_IP) – forecast hour, real values & kind a time (or a pair of times)
- rp3 (FLOAT_IP) – user defined identifier, real values & kind may contain anything, RP3.hi will be ignored (if rp1 or rp2 contains a pair, rp3 is ignored)
Returns: encoded rp1, vertical level
ip2 (int): encoded rp2, forecast hour
ip3 (int): encoded rp3, user defined identifier
Return type: ip1 (int)
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– provided values cannot be converted
Examples:
Encode 500mb at 12h
>>> import rpnpy.librmn.all as rmn >>> # these ip1, ip2, ip3 can be used as search keys int fstinf, fstlir, ... >>> rp1a = rmn.FLOAT_IP(500., 500., rmn.LEVEL_KIND_PMB) >>> rp2a = rmn.FLOAT_IP( 12., 12., rmn.TIME_KIND_HR) >>> rp3a = rmn.FLOAT_IP( 0., 0., rmn.KIND_ARBITRARY) >>> (ip1, ip2, ip3) = rmn.EncodeIp(rp1a, rp2a, rp3a)
Decode and print
>>> (rp1, rp2, rp3) = rmn.DecodeIp(ip1, ip2, ip3) >>> print("Level v1={0}, v2={1}, type={2}".format(rp1.v1, rp1.v2, rmn.kindToString(rp1.kind))) Level v1=500.0, v2=500.0, type=mb >>> print("# Time v1={0}, v2={1}, type={2}".format(rp2.v1, rp2.v2, rmn.kindToString(rp2.kind))) Time v1=12.0, v2=12.0, type= H
See also
DecodeIp
,ip1_val
,ip2_val
,ip3_val
,convertIp
,convertIPtoPK
,convertPKtoIP
,kindToString
, rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
FLOATIPtoList
(rp1)¶ Decode values from FLOAT_IP type/struct
Parameters: rp1 (FLOAT_IP): encoded) – Returns: tuple containing: v1 (float): Level 1st value v2 (float): Level 2nd value, v2=v1 if not a range kind (int): level kind, one of FSTD ip accepted kindReturn type: (tuple) Example:
>>> import rpnpy.librmn.all as rmn >>> pk1 = rmn.listToFLOATIP((500., 500., rmn.KIND_PRESSURE)) >>> pk2 = rmn.listToFLOATIP((0., 0., rmn.KIND_HOURS)) >>> pk3 = rmn.listToFLOATIP((0., 0., 0)) >>> (ip1, ip2, ip3) = rmn.convertPKtoIP(pk1, pk2, pk3) >>> (rp1, rp2, rp3) = rmn.convertIPtoPK(ip1, ip2, ip3) >>> (v1, v2, kind) = rmn.FLOATIPtoList(rp1)
See also
listToFLOATIP
,convertPKtoIP
,convertIPtoPK
, rpnpy.librmn.proto.FLOAT_IP, rpnpy.librmn.const
-
exception
rpnpy.librmn.fstd98.
FSTDError
¶ General librmn.fstd98 module error/exception
Example:
>>> import rpnpy.librmn.all as rmn >>> try: ... pass #... an fst98 operation ... ... except(rmn.FSTDError): ... pass #ignore the error >>> #... >>> raise rmn.FSTDError() Traceback (most recent call last): File "/usr/lib/python2.7/doctest.py", line 1289, in __run compileflags, 1) in test.globs File "<doctest __main__.FSTDError[2]>", line 1, in <module> raise rmn.FSTDError() FSTDError
See also
rpnpy.librmn.RMNError
-
rpnpy.librmn.fstd98.
convertIPtoPK
(ip1, ip2, ip3)¶ Convert/decode ip1, ip2, ip3 to their kind + real value conterparts
(rp1, rp2, rp3) = convertIPtoPK(ip1, ip2, ip3)
Parameters: Returns: - decoded ip1
a level (or a pair of levels) in the atmosphere
- rp2 (FLOAT_IP): decoded ip2
a time (or a pair of times)
- rp3 (FLOAT_IP): decoded ip3
may contain anything
Return type: rp1 (FLOAT_IP)
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– provided values cannot be converted
Examples:
Encode 500mb at 12h
>>> import rpnpy.librmn.all as rmn >>> # these ip1, ip2, ip3 can be used as search keys int fstinf, fstlir, ... >>> pk1a = rmn.FLOAT_IP(500., 500., rmn.LEVEL_KIND_PMB) >>> pk2a = rmn.FLOAT_IP( 12., 12., rmn.TIME_KIND_HR) >>> pk3a = rmn.FLOAT_IP(0., 0., rmn.KIND_ARBITRARY) >>> (ip1, ip2, ip3) = rmn.convertPKtoIP(pk1a, pk2a, pk3a)
Decode and print
>>> (pk1, pk2, pk3) = rmn.convertIPtoPK(ip1, ip2, ip3) >>> print("Level v1={0}, v2={1}, type={2}".format(pk1.v1, pk1.v2, rmn.kindToString(pk1.kind))) Level v1=500.0, v2=500.0, type=mb >>> print("Time v1={0}, v2={1}, type={2}".format(pk2.v1, pk2.v2, rmn.kindToString(pk2.kind))) Time v1=12.0, v2=12.0, type= H
See also
ip1_val
,ip2_val
,ip3_val
,EncodeIp
,DecodeIp
,convertIp
,convertPKtoIP
,kindToString
, rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
convertIp
(mode, v, k=0)¶ Code/decode P, kind ↔ IP for IP1, IP2, IP3
If mode > 0: ip = convertIp(mode, p, kind)
If mode ≤ 0: (p, kind) = convertIp(mode, ip)
Parameters: - ip (int) – Encoded value
- p (float) – Real Value
- kind (int) –
Level encoding kind/code; can take the following values:
0, p is height (m) above sea level (-20 000 → 100 000) 1, p is sigma (0.0 → 1.0) 2, p is pressure (mb) (0 → 1100) 3, p is an arbitrary code (-4.8e8 → 1.0e10) 4, p est en hauteur (M) rel. au niveau du sol (-20, 000 → 100, 000) 5, p est en coordonnee hybride (0.0 → 1.0) 6, p est en coordonnee theta (1 → 200, 000) 10, p represente le temps en heure (0.0 → 1.0e10) 15, reserve (entiers) 17, p represente l’indice x de la matrice de conversion (1.0 → 1.0e10)(partagé avec kind=1 a cause du range exclusif
- mode (int) –
Conversion mode; can take the following values:
-1, IP to P 0, force conversion for ip to 31 bits (default = ip has 15 bits) (appel d’initialisation) 1, P to IP 2, P to IP with NEWSTYLE forced to true
Returns: int, ip Encoded value, if mode > 0
(float, int), (pvalue, kind) Decoded value, if mode <= 0
Raises: TypeError
– wrong input arg typesValueError
– on invalid input arg valueFSTDError
– any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> ip1 = rmn.convertIp(rmn.CONVIP_ENCODE_OLD, 500., rmn.KIND_PRESSURE) >>> ip1 = rmn.convertIp(rmn.CONVIP_ENCODE, 500., rmn.KIND_PRESSURE) >>> (val, kind) = rmn.convertIp(rmn.CONVIP_DECODE, ip1)
See also
ip1_val
,ip2_val
,ip3_val
,EncodeIp
,DecodeIp
,convertIPtoPK
,convertPKtoIP
,kindToString
rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
convertPKtoIP
(pk1, pk2, pk3)¶ Convert/encode kind + real value into ip1, ip2, ip3
(ip1, ip2, ip3) = convertPKtoIP(pk1, pk2, pk3)
Parameters: - pk1 – vertical level, real values & kind (FLOAT_IP) a level (or a pair of levels) in the atmosphere
- pk2 – forecast hour, real values & kind (FLOAT_IP) a time (or a pair of times)
- pk3 – user defined identifier, real values & kind (FLOAT_IP) may contain anything, PK3.hi will be ignored (if pk1 or pk2 contains a pair, pk3 is ignored)
Returns: encoded pk1, vertical level (int) ip2 : encoded pk2, forecast hour (int) ip3 : encoded pk3, user defined identifier (int)
Return type: ip1
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError when provided values cannot be converted
Example:
>>> import rpnpy.librmn.all as rmn >>> >>> # Encode 500mb at 12h, >>> # these ip1, ip2, ip3 can be used as search keys int fstinf, fstlir, ... >>> pk1a = rmn.FLOAT_IP(500., 500., rmn.LEVEL_KIND_PMB) >>> pk2a = rmn.FLOAT_IP( 12., 12., rmn.TIME_KIND_HR) >>> pk3a = rmn.FLOAT_IP( 0., 0., rmn.KIND_ARBITRARY) >>> (ip1, ip2, ip3) = rmn.convertPKtoIP(pk1a, pk2a, pk3a) >>> >>> # Decode and print >>> (pk1, pk2, pk3) = rmn.convertIPtoPK(ip1, ip2, ip3) >>> print("# Level v1={0}, v2={1}, type={2}" .format(pk1.v1, pk1.v2, rmn.kindToString(pk1.kind))) # Level v1=500.0, v2=500.0, type=mb >>> print("# Time v1={0}, v2={1}, type={2}" .format(pk2.v1, pk2.v2, rmn.kindToString(pk2.kind))) # Time v1=12.0, v2=12.0, type= H
See also
ip1_val ip2_val ip3_val EncodeIp DecodeIp convertIPtoPK convertIp kindToString rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
dtype_fst2numpy
(datyp, nbits=None)¶ Return the numpy dtype datyp for the given fst datyp
Parameters: fst_datyp –
RPN fst data type code (int)
0: binary, transparent 1: floating point 2: unsigned integer 3: character (R4A in an integer) 4: signed integer 5: IEEE floating point 6: floating point (16 bit, made for compressor) 7: character string 8: complex IEEE 130: compressed short integer (128+2) 133: compressed IEEE (128+5) 134: compressed floating point (128+6) +128 : second stage packer active +64 : missing value convention used
Returns: numpy.dtype
Raises: - TypeError on wrong input arg types
- FSTDError if no corresponding type found
Example:
>>> import rpnpy.librmn.all as rmn >>> fst_datyp = rmn.FST_DATYP_LIST['float_IEEE_compressed'] >>> numpy_dtype = rmn.dtype_fst2numpy(fst_datyp)
See also
dtype_numpy2fst rpnpy.librmn.const FSTDError
-
rpnpy.librmn.fstd98.
dtype_numpy2fst
(npdtype, compress=True, missing=False)¶ Return the fst datyp for the given numpy dtype
Optionally specify compression and missing value options.
Parameters: - numpy_dtype – numpy data type
- compress – define fst data type with 2nd stage compression
- missing – define fst data type with missing values
Returns: int, fst data type 0 if no corresponding data type found
Raises: TypeError on wrong input arg types
Example:
>>> import rpnpy.librmn.all as rmn >>> import numpy as np >>> numpy_dtype = np.float32 >>> fst_datyp = rmn.dtype_numpy2fst(numpy_dtype) >>> fst_datyp = rmn.dtype_numpy2fst(numpy_dtype, compress=False) >>> fst_datyp = rmn.dtype_numpy2fst(numpy_dtype, missing=True) >>> fst_datyp = rmn.dtype_numpy2fst(numpy_dtype, compress=True, missing=True)
See also
dtype_fst2numpy rpnpy.librmn.const FSTDError
-
rpnpy.librmn.fstd98.
fst_edit_dir
(key, datev=-1, dateo=-1, deet=-1, npas=-1, ni=-1, nj=-1, nk=-1, ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ', etiket=' ', grtyp=' ', ig1=-1, ig2=-1, ig3=-1, ig4=-1, datyp=-1, keep_dateo=False)¶ Edits the directory content of a RPN standard file. Only provided parameters with value different than default are updated.
Note: by default datev is kept constant unless dateo is specified or keep_dateo=True.
fst_edit_dir(key, … ) fst_edit_dir(rec, … ) fst_edit_dir(keylist, … )
Parameters: - key – Positioning information to the record. Obtained with fstinf or fstinl.
- dateo – date of origin (date time stamp) Cannot change dateo and datev.
- datev – date of validity (date time stamp) Cannot change dateo and datev.
- deet – Length of a time step in seconds datev constant unless keep_dateo
- npas – time step number datev constant unless keep_dateo
- ni – first dimension of the data field
- nj – second dimension of the data field
- nk – third dimension of the data field
- nbits – number of bits kept for the elements of the field
- datyp – data type of the elements
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field (forecast, analysis, climatology)
- nomvar – variable name
- etiket – label
- grtyp – type of geographical projection
- ig1 – first grid descriptor
- ig2 – second grid descriptor
- ig3 – third grid descriptor
- ig4 – fourth grid descriptor
- keep_dateo (bool) – By default datev is kept constant unless dateo is specified or keep_dateo=True (keep_dateo must be False is datev is provided).
- verion 2.0.rc1, this function can be called with a rec meta (From) –
- keylist instead of a simple key number (or) –
- rec (dict) – dictionary where key = rec[‘key’]
- keylist (list) – list of keys for records to edit
Returns: None
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– any other error
Example:
>>> import os, os.path, stat, shutil >>> import rpnpy.librmn.all as rmn >>> >>> # Copy a file locally to be able to edit it and set write permission >>> filename = 'geophy.fst' >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename0 = os.path.join(ATM_MODEL_DFILES,'bcmk',filename) >>> shutil.copyfile(filename0, filename) >>> st = os.stat(filename) >>> os.chmod(filename, st.st_mode | stat.S_IWRITE) >>> >>> # Open existing file in Rear/Write mode >>> funit = rmn.fstopenall(filename, rmn.FST_RW_OLD) >>> >>> # Get the list of all records in file and change the etiket for them all >>> mykeylist = rmn.fstinl(funit) >>> >>> # Iterate explicitely on list of records to change the etiket >>> for key in mykeylist: rmn.fst_edit_dir(key, etiket='MY_NEW_ETK') >>> >>> # Could also be written as one-line list comprehension: >>> # [rmn.fst_edit_dir(key, etiket='MY_NEW_ETK') for key in rmn.fstinl(funit)] >>> >>> # Iterate implicitly on list of records to change the etiket >>> rmn.fst_edit_dir(mykeylist, etiket='MY_NEW_ETK') >>> >>> # Properly close files, important when editing to avoid corrupted files >>> rmn.fstcloseall(funit)
See also
fstopenall
,fstcloseall
,fstinl
,fstinf
, rpnpy.librmn.const, http://collaboration.cmc.ec.gc.ca/science/si/eng/si/libraries/rmnlib/fstd/Notes
librmn_15.2 fst_edit_dir ignores ni,nj,nk,grtyp These parameters cannot thus be zapped. librmn_16 allows the edition of grtyp
-
rpnpy.librmn.fstd98.
fst_version
()¶ Returns package version number
fstd_version = fst_version()
Returns: int, fstd version number Example:
>>> import rpnpy.librmn.all as rmn >>> print("# Using fst_version={0}".format(rmn.fst_version())) # Using fst_version=200001
See also
fstopt
-
rpnpy.librmn.fstd98.
fstcloseall
(iunit, verbose=None)¶ Close all files associated with provided file unit number. Shortcut for fclos+fstfrm
Parameters: iunit – unit number(s) associated to the file obtained with fnom or fstopenall (int or list of int)
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> funit = rmn.fstopenall('mynewfile.fst', rmn.FST_RW) >>> #... >>> rmn.fstcloseall(funit) >>> os.unlink('mynewfile.fst') # Remove test file
See also
fstfrm fstopenall rpnpy.librmn.base.fclos rpnpy.librmn.const FSTDError
-
rpnpy.librmn.fstd98.
fstecr
(iunit, data, meta=None, rewrite=True)¶ Writes record to file previously opened with fnom+fstouv
fstecr(iunit, data, meta)
fstecr(iunit, data, meta, rewrite=True)
fstecr(iunit, rec)
Parameters: - iunit (int) – file unit number
- (numpy.ndarray (data) – data to be written FORTRAN order required
- meta (dict) – associated metadata Unspecified meta params will be set to their default value as in FST_RDE_META_DEFAULT. The list of known parameters is the same a the one returned by fstprm, see fstprm doc for details. You can force meta[‘datyp’] but for the sake of data/meta consistency, it is best not to specify meta[‘datyp’], data.dtype will be used instead
- rec – data + meta in a dict Option to provide data+meta in a single dict where data = rec[‘d’]
- rewrite – force to overwrite any other fields with same meta
Returns: None
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') >>> funitIn = rmn.fstopenall(filename) >>> funitOut = rmn.fstopenall('newfile.fst', rmn.FST_RW) >>> myrec = rmn.fstlir(funitIn, nomvar='P0') >>> >>> # Write the record specifying data and meta separately >>> rmn.fstecr(funitOut, myrec['d'], myrec) >>> >>> # Write the record specifying data and meta together >>> rmn.fstecr(funitOut, myrec) >>> >>> # Properly close files, important when writing to avoid corrupted files >>> rmn.fstcloseall(funitOut) >>> rmn.fstcloseall(funitIn)
See also
fstopenall
,fstcloseall
,fstlir
,fstprm
,fstluk
rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
fsteff
(key)¶ Deletes the record associated to handle.
fsteff(key) fsteff(rec) fsteff(keylist)
Parameters: - key – positioning information to the record, obtained with fstinf or fstinl, …
- verion 2.0.rc1, this function can be called with a rec meta (From) –
- keylist instead of a simple key number (or) –
- rec (dict) – dictionary where key = rec[‘key’]
- keylist (list) – list of keys for records to edit
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path, stat, shutil >>> import rpnpy.librmn.all as rmn >>> >>> # Copy a file locally to be able to edit it and set write permission >>> filename = 'geophy.fst' >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename0 = os.path.join(ATM_MODEL_DFILES,'bcmk',filename) >>> shutil.copyfile(filename0, filename) >>> st = os.stat(filename) >>> os.chmod(filename, st.st_mode | stat.S_IWRITE) >>> >>> # Open existing file in Rear/Write mode >>> funit = rmn.fstopenall(filename, rmn.FST_RW_OLD) >>> >>> # Find the record name ME and erase it from the file >>> key = rmn.fstinf(funit, nomvar='ME') >>> rmn.fsteff(key['key']) >>> >>> # Find the record name ME and erase it from the file, >>> # passing directly the dict returned by fstinf >>> key = rmn.fstinf(funit, nomvar='MG') >>> rmn.fsteff(key) >>> >>> # Find all record named VF and erase them >>> keylist = rmn.fstinl(funit, nomvar='VF') >>> rmn.fsteff(keylist)
>>> rmn.fstcloseall(funit) >>> os.unlink(filename) #Remove test file
See also
fstopenall fstcloseall fstinl fstinf rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
fstfrm
(iunit)¶ Close a RPN standard file
fstfrm(iunit)
Parameters: iunit – unit number associated to the file obtained with fnom+fstouv
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> funit = rmn.fnom('myfstfile.fst', rmn.FST_RW) >>> istat = rmn.fstouv(funit, rmn.FST_RW) >>> #... >>> istat = rmn.fstfrm(funit) >>> istat = rmn.fclos(funit) >>> os.unlink('myfstfile.fst') # Remove test file
See also
fstouv fstopenall fstcloseall rpnpy.librmn.base.fnom rpnpy.librmn.base.fclos
-
rpnpy.librmn.fstd98.
fstinf
(iunit, datev=-1, etiket=' ', ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ')¶ Locate the next record that matches the search keys.
Returns the key of the first record matching the selection criteria.
Only provided parameters with value different than default are used as selection criteria. Thus if you do not provide any other parameter that iunit, fstinf will return the key to the first record in the file.
recmatch = fstinf(iunit, … )
Parameters: - iunit – unit number associated to the file obtained with fnom+fstouv
- datev – valid date
- etiket – label
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field
- nomvar – variable name
Returns: None if no matching record, else:
{ 'key': key, # key/handle of the 1st matching record 'shape': (ni, nj, nk) # dimensions of the field }
Raises: TypeError
– wrong input arg typesValueError
– invalid input arg valueFSTDError
– any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find the record named P0 and read its metadata >>> key = rmn.fstinf(funit, nomvar='P0') >>> p0meta = rmn.fstprm(key['key']) >>> >>> rmn.fstcloseall(funit)
See also
fstinfx, fstinl, fstprm, fstluk, fstopenall, fstcloseall
-
rpnpy.librmn.fstd98.
fstinfx
(key, iunit, datev=-1, etiket=' ', ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ')¶ Locate the next record that matches the search keys.
Only provided parameters with value different than default are used as selection criteria. The search begins at the position given by key/handle obtained with fstinf or fstinl, …
recmatch = fstinfx(key, iunit, … )
Parameters: - key – record key/handle of the search start position (int or dict) if dict, must have key[‘key’]
- iunit – unit number associated to the file obtained with fnom+fstouv
- datev – valid date
- etiket – label
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field
- nomvar – variable name
Returns: None if no matching record, else:
{ 'key' : key, # key/handle of the 1st matching record 'shape' : (ni, nj, nk) # dimensions of the field }
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find the 1st record named P0 then the one follwoing it >>> # and read its metadata >>> key1 = rmn.fstinf(funit, nomvar='P0') >>> key2 = rmn.fstinfx(key1, funit, nomvar='P0') >>> p0meta = rmn.fstprm(key2) >>> >>> rmn.fstcloseall(funit)
See also
fstinf fstinl fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstinl
(iunit, datev=-1, etiket=' ', ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ', nrecmax=-1)¶ Locate all the record matching the research keys
Only provided parameters with value different than default are used as selection criteria
recmatchlist = fstinl(iunit, … )
Parameters: - iunit – unit number associated to the file obtained with fnom+fstouv
- datev – valid date
- etiket – label
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field
- nomvar – variable name
- nrecmax – maximum number or record to find (-1 = all)
Returns: list of matching records keys empty list ([]) if no matching record found
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find all records named VF and print the ip1 of the first 3 >>> keylist = rmn.fstinl(funit, nomvar='VF') >>> for key in keylist[0:3]: print("# VF ip1={0}".format(rmn.fstprm(key)['ip1'])) # VF ip1=1199 # VF ip1=1198 # VF ip1=1197 >>> >>> rmn.fstcloseall(funit)
See also
fstinf fstinfx fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstlir
(iunit, datev=-1, etiket=' ', ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ', dtype=None, rank=None, dataArray=None)¶ Reads the next record that matches the research keys
Only provided parameters with value different than default are used as selection criteria
record = fstlir(iunit, … )
Parameters: - iunit – unit number associated to the file obtained with fnom+fstouv
- datev – valid date
- etiket – label
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field
- nomvar – variable name
- dtype – array type of the returned data Default is determined from records’ datyp Could be any numpy.ndarray type See: http://docs.scipy.org/doc/numpy/user/basics.types.html
- rank – try to return an array with the specified rank
- dataArray (ndarray) – (optional) allocated array where to put the data
Returns: None if no matching record, else:
{ 'd' : data, # record data as a numpy.ndarray ... # same params list as fstprm }
- Raises:
TypeError on wrong input arg types ValueError on invalid input arg value FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find and read p0 meta and data, then print its min,max,mean values >>> p0rec = rmn.fstlir(funit, nomvar='P0') >>> print("# P0 ip2={0} min={1:7.3f} max={2:7.2f} avg={3:5.1f}" .format(p0rec['ip2'], float(p0rec['d'].min()), float(p0rec['d'].max()), float(p0rec['d'].mean()))) # P0 ip2=0 min=530.641 max=1039.64 avg=966.5 >>> rmn.fstcloseall(funit)
See also
fstlis fstlirx fstinf fstinl fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstlirx
(key, iunit, datev=-1, etiket=' ', ip1=-1, ip2=-1, ip3=-1, typvar=' ', nomvar=' ', dtype=None, rank=None, dataArray=None)¶ Reads the next record that matches the research keys
Only provided parameters with value different than default are used as selection criteria The search begins right after at the position given by record key/handle.
record = fstlirx(key, iunit, … )
Parameters: - key – key/handle from where to start the search
- iunit – unit number associated to the file obtained with fnom+fstouv
- datev – valid date
- etiket – label
- ip1 – vertical level
- ip2 – forecast hour
- ip3 – user defined identifier
- typvar – type of field
- nomvar – variable name
- dtype – array type of the returned data Default is determined from records’ datyp Could be any numpy.ndarray type See: http://docs.scipy.org/doc/numpy/user/basics.types.html
- rank – try to return an array with the specified rank
- dataArray (ndarray) – (optional) allocated array where to put the data
Returns: - {
‘d’ : data, # record data as a numpy.ndarray … # same params list as fstprm
}
Return type: None if no matching record, else
- Raises:
TypeError on wrong input arg types ValueError on invalid input arg value FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find and read the 2nd p0 meta and data, >>> # then print its min,max,mean values >>> key1 = rmn.fstinf(funit, nomvar='P0') >>> p0rec = rmn.fstlirx(key1, funit, nomvar='P0') >>> print("# P0 ip2={0} min={1:4.0f} max={2:4.0f} avg={3:4.0f}" ... .format(p0rec['ip2'], ... round(float(p0rec['d'].min())), ... round(float(p0rec['d'].max())), ... round(float(p0rec['d'].mean())))) # P0 ip2=12 min= 531 max=1038 avg= 966 >>> rmn.fstcloseall(funit)
See also
fstlis fstlir fstinf fstinl fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstlis
(iunit, dtype=None, rank=None, dataArray=None)¶ Reads the next record that matches the research criterias
record = fstlis(iunit, … )
Parameters: - iunit – unit number associated to the file obtained with fnom+fstouv
- dtype – array type of the returned data Default is determined from records’ datyp Could be any numpy.ndarray type See: http://docs.scipy.org/doc/numpy/user/basics.types.html
- rank – try to return an array with the specified rank
- dataArray (ndarray) – (optional) allocated array where to put the data
Returns: - {
‘d’ : data, # record data as a numpy.ndarray … # same params list as fstprm
}
Return type: None if no matching record, else
- Raises:
TypeError on wrong input arg types ValueError on invalid input arg value FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find and read the 2nd p0 meta and data, >>> # then print its min,max,mean values >>> key1 = rmn.fstinf(funit, nomvar='P0') >>> p0rec = rmn.fstlis(funit) >>> print("# P0 ip2={0} min={1:4.0f} max={2:4.0f} avg={3:4.0f}" ... .format(p0rec['ip2'], ... round(float(p0rec['d'].min())), ... round(float(p0rec['d'].max())), ... round(float(p0rec['d'].mean())))) # P0 ip2=12 min= 531 max=1038 avg= 966 >>> >>> rmn.fstcloseall(funit)
See also
fstlir fstlirx fstinf fstinl fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstlnk
(unitList)¶ Links a list of files together for search purpose
funit = fstlnk(unitList)
Parameters: unitList – list of previously opened (fnom+fstouv) file units (list or tuple)
Returns: File unit for the grouped unit
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Open several files >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename1 = os.path.join(ATM_MODEL_DFILES,'bcmk','2009042700_000') >>> funit1 = rmn.fnom(filename1, rmn.FST_RO) >>> istat = rmn.fstouv(funit1, rmn.FST_RO) >>> filename2 = os.path.join(ATM_MODEL_DFILES,'bcmk','2009042700_012') >>> funit2 = rmn.fnom(filename2, rmn.FST_RO) >>> istat = rmn.fstouv(funit2, rmn.FST_RO) >>> >>> # Link the file as one >>> funit = rmn.fstlnk((funit1, funit2)) >>> >>> # Use the linked files >>> for key in rmn.fstinl(funit, nomvar='P0'): print("# P0 ip2={0}".format(rmn.fstprm(key)['ip2'])) # P0 ip2=0 # P0 ip2=12 >>> >>> # Close all linked files >>> istat = rmn.fstfrm(funit1) >>> istat = rmn.fclos(funit1) >>> istat = rmn.fstfrm(funit2) >>> istat = rmn.fclos(funit2)
See also
fstopenall fstcloseall fstouv fstfrm rpnpy.librmn.base.fclos rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
fstluk
(key, dtype=None, rank=None, dataArray=None)¶ Read the record at position given by key/handle
record = fstluk(key) record = fstluk(key, dtype) record = fstluk(key, dtype, rank)
Parameters: - key – positioning information to the record, obtained with fstinf or fstinl, …
- dtype – array type of the returned data Default is determined from records’ datyp Could be any numpy.ndarray type See: http://docs.scipy.org/doc/numpy/user/basics.types.html
- rank – try to return an array with the specified rank
- dataArray (ndarray) – (optional) allocated array where to put the data
Returns: - {
‘d’ : data, # record data as a numpy.ndarray, FORTRAN order … # same params list as fstprm
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find record named P0 and read it meta + data >>> # then print its min,max,mean values >>> key = rmn.fstinf(funit, nomvar='P0') >>> p0rec = rmn.fstluk(key) >>> print("# P0 ip2={0} min={1:4.0f} max={2:4.0f} avg={3:4.0f}" ... .format(p0rec['ip2'], ... round(float(p0rec['d'].min())), ... round(float(p0rec['d'].max())), ... round(float(p0rec['d'].mean())))) # P0 ip2=0 min= 531 max=1040 avg= 966 >>> rmn.fstcloseall(funit)
See also
fstprm fstlir fstinf fstinl fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstnbr
(iunit)¶ Returns the number of records of the file associated with unit
nrec = fstnbr(iunit)
Parameters: iunit – unit number associated to the file obtained with fnom+fstouv
Returns: int, nb of records
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Notes
c_fstnbr on linked files returns only nrec on the first file fstnbr interface add results for all linked files
Examples: >>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv(‘ATM_MODEL_DFILES’).strip() >>> filename = os.path.join(ATM_MODEL_DFILES,’bcmk’,‘2009042700_000’) >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Print number of records >>> # then print its min,max,mean values >>> nrec = rmn.fstnbr(funit) >>> print(“# There are {0} records in the file”.format(nrec)) # There are 1083 records in the file >>> >>> rmn.fstcloseall(funit)
See also
fstnbrv fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstnbrv
(iunit)¶ Returns the number of valid records (excluding deleted records)
nrec = fstnbrv(iunit)
Parameters: iunit – unit number associated to the file obtained with fnom+fstouv
Returns: int, nb of valid records
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Notes
c_fstnbrv on linked files returns only nrec on the first file fstnbrv interface add results for all linked files
Examples: >>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv(‘ATM_MODEL_DFILES’).strip() >>> filename = os.path.join(ATM_MODEL_DFILES,’bcmk’,‘2009042700_000’) >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Print number of records >>> # then print its min,max,mean values >>> nrec = rmn.fstnbrv(funit) >>> print(“# There are {0} valid records in the file”.format(nrec)) # There are 1083 valid records in the file >>> >>> rmn.fstcloseall(funit)
See also
fstnbr fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstopenall
(paths, filemode='RND+R/O', verbose=None)¶ Open all fstfiles found in path. Shortcut for fnom+fstouv+fstlnk
Parameters: - paths – path/name of the file to open if paths is a list, open+link all files if path is a dir, open+link all fst files in dir A pattern can be used to match existing names
- filemode – a string with the desired filemode (see librmn doc) or one of these constants: FST_RW, FST_RW_OLD, FST_RO
Returns: int, file unit number associated with provided path None in ReadOnly mode if no FST file was found in path
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') >>> funit1 = rmn.fstopenall(filename) >>> funit2 = rmn.fstopenall('newfile.fst', rmn.FST_RW) >>> #... >>> rmn.fstcloseall(funit1) >>> rmn.fstcloseall(funit2) >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009*') >>> funit3 = rmn.fstopenall(filename, rmn.FST_RO) >>> #... >>> rmn.fstcloseall(funit3) >>> os.unlink('newfile.fst') # Remove test file
See also
fstouv fstlnk fstcloseall rpnpy.librmn.base.fnom rpnpy.librmn.const FSTDError
-
rpnpy.librmn.fstd98.
fstopt
(optName, optValue, setOget=0)¶ Set or print FST option.
fstopt(optName, optValue) fstopt(optName, optValue, setOget)
Parameters: - optName – name of option to be set or printed or one of these constants: FSTOP_MSGLVL, FSTOP_TOLRNC, FSTOP_PRINTOPT, FSTOP_TURBOCOMP FSTOP_FASTIO, FSTOP_IMAGE, FSTOP_REDUCTION32
- optValue –
value to be set (int or string) or one of these constants: for optName=FSTOP_MSGLVL:
FSTOPI_MSG_DEBUG, FSTOPI_MSG_INFO, FSTOPI_MSG_WARNING, FSTOPI_MSG_ERROR, FSTOPI_MSG_FATAL, FSTOPI_MSG_SYSTEM, FSTOPI_MSG_CATAST- for optName=FSTOP_TOLRNC:
- FSTOPI_TOL_NONE, FSTOPI_TOL_DEBUG, FSTOPI_TOL_INFO, FSTOPI_TOL_WARNING, FSTOPI_TOL_ERROR, FSTOPI_TOL_FATAL
- for optName=FSTOP_TURBOCOMP:
- FSTOPS_TURBO_FAST, FSTOPS_TURBO_BEST
- for optName=FSTOP_FASTIO, FSTOP_IMAGE, FSTOP_REDUCTION32:
- FSTOPL_TRUE, FSTOPL_FALSE
- setOget – define mode, set or print/get one of these constants: FSTOP_SET, FSTOP_GET default: set mode
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> # Restrict to the minimum the number of messages printed by librmn >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST)
See also
rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
fstouv
(iunit, filemode='RND+R/W')¶ Opens a RPN standard file
fstouv(iunit) fstouv(iunit, filemode)
Parameters: - iunit – unit number associated to the file obtained with fnom
- filemode – a string with the desired filemode (see librmn doc) or one of these constants: FST_RW, FST_RW_OLD, FST_RO
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os >>> import rpnpy.librmn.all as rmn >>> funit = rmn.fnom('myfstfile.fst', rmn.FST_RW) >>> istat = rmn.fstouv(funit, rmn.FST_RW) >>> #... >>> istat = rmn.fstfrm(funit) >>> istat = rmn.fclos(funit) >>> os.unlink('myfstfile.fst') # Remove test file
See also
fstfrm fstopenall fstcloseall rpnpy.librmn.base.fnom rpnpy.librmn.base.fclos
-
rpnpy.librmn.fstd98.
fstprm
(key)¶ Get all the description informations of the record.
params = fstprm(key)
Parameters: key – positioning information to the record, obtained with fstinf or fstinl, …
Returns: - key, # key/handle of the record
’shape’ : (ni, nj, nk) # dimensions of the field ‘dateo’ : date time stamp ‘datev’ : date of validity (dateo+ deet * npas)
Will be set to ‘-1’ if dateo invalid
’deet’ : length of a time step in seconds ‘npas’ : time step number ‘ni’ : first dimension of the data field
’nj’ : second dimension of the data field ‘nk’ : third dimension of the data field ‘nbits’ : number of bits kept for the elements of the field ‘datyp’ : data type of the elements ‘ip1’ : vertical level ‘ip2’ : forecast hour ‘ip3’ : user defined identifier ‘typvar’: type of field (forecast, analysis, climatology) ‘nomvar’: variable name ‘etiket’: label ‘grtyp’ : type of geographical projection ‘ig1’ : first grid descriptor ‘ig2’ : second grid descriptor ‘ig3’ : third grid descriptor ‘ig4’ : fourth grid descriptor ‘swa’ : starting word address ‘lng’ : record length ‘dltf’ : delete flag ‘ubc’ : unused bit count ‘xtra1’ : extra parameter ‘xtra2’ : extra parameter ‘xtra3’ : extra parameter
}
Return type: {‘key’
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Print name, ip1, ip2 of first record in file >>> key = rmn.fstinf(funit) >>> meta = rmn.fstprm(key['key']) >>> print("# {nomvar} ip1={ip1} ip2={ip2}".format(**meta)) # !! ip1=0 ip2=0 >>> >>> rmn.fstcloseall(funit)
See also
fstluk fstinf fstinl fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstsui
(iunit)¶ Finds the next record that matches the last search criterias
recmatch = fstsui(iunit)
Parameters: iunit – unit number associated to the file obtained with fnom+fstouv
Returns: None if no more matching record, else {
’key’ : key, # key/handle of the next matching record ‘shape’ : (ni, nj, nk) # dimensions of the field
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Find the 1st record named P0 then the one follwoing it >>> # and read its metadata >>> key1 = rmn.fstinf(funit, nomvar='P0') >>> key2 = rmn.fstsui(funit) >>> meta = rmn.fstprm(key2) >>> print("# {nomvar} ip1={ip1} ip2={ip2}".format(**meta)) # P0 ip1=0 ip2=12 >>> >>> rmn.fstcloseall(funit)
See also
fstinf fstinfx fstinl fstprm fstluk fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
fstvoi
(iunit, options=' ')¶ Prints out the directory content of a RPN standard file
fstvoi(iunit) fstvoi(iunit, options)
Parameters: - iunit – unit number associated to the file obtained with fnom+fstouv
- options – printing options a string with desired fields list, ‘+’ separated possible fields (keywords): NONOMV, NOTYPV, NOETIQ, NINJNK, DATEO, DATESTAMPO, DATEV, LEVEL, IPALL, IP1, NOIP23, NODEET, NONPAS, NODTY, GRIDINFO
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk','2009042700_000') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Print meta of all record in file >>> rmn.fstvoi(funit) >>> rmn.fstvoi(funit,'DATEV+LEVEL+NOTYPV+NOETIQ+NOIP23+NODEET+NONPAS+NODTY') >>> >>> rmn.fstcloseall(funit)
See also
fstopenall fstcloseall
-
rpnpy.librmn.fstd98.
ip1_all
(level, kind)¶ Generates all possible coded ip1 values for a given level
The next search (fstinf, fstinl, fstlir, …) will look for all prossible alternative encoding
ip1new = ip1_all(level, kind)
Parameters: Returns: int, ip1 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_p','anlp2015070706_000') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Look for TT at 500mb encoded old or new style >>> ip1new = rmn.ip1_all(500., rmn.LEVEL_KIND_PMB) >>> ttrec = rmn.fstlir(funit, nomvar='TT', ip1=ip1new) >>> print("# Looked for TT with ip1={0}, found ip1={1}".format(ip1new,ttrec['ip1'])) # Looked for TT with ip1=41394464, found ip1=500 >>> >>> rmn.fstcloseall(funit)
See also
ip1_val ip2_all ip3_all convertIp EncodeIp DecodeIp fstinf fstinl fstlir rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
ip1_val
(level, kind)¶ Generates coded ip1 value for a given level (shorthand for convip)
ip1new = ip1_val(level, kind)
Parameters: - level – float, level value
- kind – int, level kind
Returns: int, ip1 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> ip1new = rmn.ip1_val(500., rmn.LEVEL_KIND_PMB)
See also
ip1_all ip2_val ip3_val convertIp EncodeIp DecodeIp rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
ip2_all
(level, kind)¶ Generates all possible coded ip2 values for a given level
The next search (fstinf, fstinl, fstlir, …) will look for all prossible alternative encoding
ip2new = ip2_all(level, kind)
Parameters: - level – float, level value
- kind – int, level kind
Returns: int, ip2 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Look for TT at 500mb encoded old or new style >>> ip2new = rmn.ip2_all(0., rmn.TIME_KIND_HR) >>> ttrec = rmn.fstlir(funit, nomvar='TT', ip2=ip2new) >>> print("# Looked for TT with ip2={0}, found ip2={1}".format(ip2new, ttrec['ip2'])) # Looked for TT with ip2=183500800, found ip2=0 >>> >>> rmn.fstcloseall(funit)
See also
ip2_val ip1_all ip3_all convertIp EncodeIp DecodeIp fstinf fstinl fstlir rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
ip2_val
(level, kind)¶ Generates coded ip2 value for a given level (shorthand for convip)
ip2new = ip2_val(level, kind)
Parameters: - level – float, level value
- kind – int, level kind
Returns: int, ip2 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> ip2new = rmn.ip2_val(0., rmn.TIME_KIND_HR)
See also
ip2_all ip1_val ip3_val convertIp EncodeIp DecodeIp rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
ip3_all
(level, kind)¶ Generates all possible coded ip3 values for a given level
The next search (fstinf, fstinl, fstlir, …) will look for all prossible alternative encoding
ip3new = ip3_all(level, kind)
Parameters: - level – float, level value
- kind – int, level kind
Returns: int, ip3 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_p','anlp2015070706_000') >>> >>> # Open existing file in Rear Only mode >>> funit = rmn.fstopenall(filename, rmn.FST_RO) >>> >>> # Look for TT at 500mb encoded old or new style >>> ip3new = rmn.ip3_all(0., rmn.KIND_ARBITRARY) >>> ttrec = rmn.fstlir(funit, nomvar='TT', ip3=ip3new) >>> print("# Looked for TT with ip3={0}, found ip3={1}".format(ip3new, ttrec['ip3'])) # Looked for TT with ip3=66060288, found ip3=0 >>> >>> rmn.fstcloseall(funit)
See also
ip3_val ip1_all ip2_all convertIp EncodeIp DecodeIp fstinf fstinl fstlir rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
ip3_val
(level, kind)¶ Generates coded ip3 value for a given level (shorthand for convip)
ip3new = ip3_val(level, kind)
Parameters: - level – float, level value
- kind – int, level kind
Returns: int, ip3 value newcode style
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- FSTDError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> ip3new = rmn.ip3_all(0., rmn.KIND_ARBITRARY)
See also
ip3_all ip1_val ip2_val convertIp EncodeIp DecodeIp rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
isFST
(filename)¶ Return True if file is of RPN STD RND type
Parameters: filename – path/name of the file to examine (str)
Returns: True or False
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> filename = os.path.join(ATM_MODEL_DFILES,'bcmk_toctoc','2009042700_000') >>> isfst = rmn.isFST(filename)
See also
rpnpy.librmn.base.wkoffit
-
rpnpy.librmn.fstd98.
kindToString
(kind)¶ Translate kind integer code to 2 character string,
kind_str = kindToString(kind)
Parameters: kind – Level encoding kind/code (int) Returns: str, str repr of the kind code Example:
>>> import rpnpy.librmn.all as rmn >>> print('# '+rmn.kindToString(rmn.LEVEL_KIND_PMB)) # mb >>> print('# '+rmn.kindToString(rmn.TIME_KIND_HR)) # H
See also
ip1_val ip2_val ip3_val EncodeIp DecodeIp convertIp convertIPtoPK convertPKtoIP rpnpy.librmn.const
-
rpnpy.librmn.fstd98.
listToFLOATIP
(rp1)¶ Encode values in FLOAT_IP type/struct
floatip = listToFLOATIP(rp1)
Parameters: rp1 – (value, kind) or (value1, value2, kind) (list or tuple) kind is one of FSTD ip accepted kind Returns: FLOAT_IP Raises: TypeError on wrong input arg types Example:
>>> import rpnpy.librmn.all as rmn >>> pk1 = rmn.listToFLOATIP((500., 500., rmn.KIND_PRESSURE)) >>> pk2 = rmn.listToFLOATIP((0., 0., rmn.KIND_HOURS)) >>> pk3 = rmn.listToFLOATIP((0., 0., 0)) >>> (ip1, ip2, ip3) = rmn.convertPKtoIP(pk1, pk2, pk3)
See also
FLOATIPtoList convertPKtoIP rpnpy.librmn.proto.FLOAT_IP rpnpy.librmn.const
Librmn Fstd grid helper functions
Notes
The functions described below are a very close ‘’port’’ from the original [[librmn]]’s [[Librmn/FSTDfunctions|FSTD]] package.<br> You may want to refer to the [[Librmn/FSTDfunctions|FSTD]] documentation for more details.
See also
rpnpy.librmn.base rpnpy.librmn.fstd98 rpnpy.librmn.interp rpnpy.librmn.const
-
rpnpy.librmn.grids.
decodeGrid
(gid)¶ Produce grid params dict as defGrid* fn, decoded from provided ezscint Id
gridParams = decodeGrid(gid) gridParams = decodeGrid(params)
Parameters: Returns: - {
‘id’ : grid id, same as input arg ‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : first dimension of the grid ‘nj’ : second dimension of the grid ‘grtyp’ : type of geographical projection
(one of ‘Z’, ‘#’, ‘Y’, ‘U’)
’ig1’ : first grid descriptor ‘ig2’ : second grid descriptor ‘ig3’ : third grid descriptor ‘ig4’ : fourth grid descriptor ‘grref’ : grid ref type (one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’) ‘ig1ref’ : first grid descriptor of grid ref ‘ig2ref’ : second grid descriptor of grid ref ‘ig3ref’ : third grid descriptor of grid ref ‘ig4ref’ : fourth grid descriptor of grid ref … list of other parameters is grtyp dependent, See defGrid_* specific function for details
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> # Define a LatLon Grid >>> (lat0, lon0, dlat, dlon) = (0.,180.,1.,0.5) >>> (ni, nj) = (180, 60) >>> params = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> # Decode grid information >>> params2 = rmn.decodeGrid(params) >>> # Check that decoded values are identical to what we provided >>> x = [params[k] == params2[k] for k in ... ('shape', 'ni', 'nj', 'grtyp', 'ig1', 'ig2', 'ig3', 'ig4')] >>> y = [int(params[k]*1000.) == int(params2[k]*1000.) for k in ... ('lat0', 'lon0', 'dlat', 'dlon')] >>> if not (all(x) and all(y)): ... for k in params.keys(): ... if params[k] != params2[k]: ... print("Problem decoding grid param[{0}] : {1} != {2} " ... .format(k,str(params[k]),str(params2[k])))
See also
encodeGrid defGrid_PS defGrid_G defGrid_L defGrid_E defGrid_ZL defGrid_ZLaxes defGrid_ZE defGrid_ZEr defGrid_ZEraxes defGrid_diezeL defGrid_diezeE defGrid_YY defGrid_ZPS defGrid_ZPSaxes defGrid_ZPSfLL rpnpy.librmn.base.cigaxg rpnpy.librmn.base.cxgaig rpnpy.librmn.interp.ezgprm rpnpy.librmn.interp.ezgxprm rpnpy.librmn.interp.ezget_nsubgrids rpnpy.librmn.interp.ezget_subgridids
-
rpnpy.librmn.grids.
decodeIG2dict
(grtyp, ig1, ig2, ig3, ig4)¶ Decode encode grid values into a dict with meaningful labels
params = decodeIG2dict(grtyp, ig1, ig2, ig3, ig4)
Parameters: - grtyp – type of geographical projection (one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’)
- ig1 – first encode grid descriptor (int)
- ig2 – second encode grid descriptor (int)
- ig3 – third encode grid descriptor (int)
- ig4 – fourth encode grid descriptor (int)
Returns: - {
- ‘grtyp’ : type of geographical projection
(one of ‘Z’, ‘#’, ‘Y’, ‘U’)
’ig1’ : first encode grid descriptor (int) ‘ig2’ : second encode grid descriptor (int) ‘ig3’ : third encode grid descriptor (int) ‘ig4’ : fourth encode grid descriptor (int) ‘xg1’ : first decode grid descriptor (float) ‘xg2’ : second decode grid descriptor (float) ‘xg3’ : third decode grid descriptor (float) ‘xg4’ : fourth decode grid descriptor (float) … list of other parameters is grtyp dependent
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> # Encode a LatLon Grid parameters >>> grtyp = 'L' >>> (lat0, lon0, dlat, dlon) = (0.,180.,1.,0.5) >>> (ig1, ig2, ig3, ig4) = rmn.cxgaig(grtyp,lat0, lon0, dlat, dlon) >>> # Decode Grid parameters to generix xg1-4 values >>> params = rmn.decodeIG2dict(grtyp, ig1, ig2, ig3, ig4) >>> if ((int((params['xg1']-lat0)*1000.), int((params['xg2']-lon0)*1000.), ... int((params['xg3']-dlat)*1000.), int((params['xg4']-dlon)*1000.)) ... != (0, 0, 0, 0)): ... print("Problem decoding grid values. {} != {}" ... .format((lat0, lon0, dlat, dlon), ... (params['xg1'], params['xg2'], ... params['xg3'], params['xg4']) ... ))
See also
decodeXG2dict rpnpy.librmn.base.cigaxg rpnpy.librmn.base.cxgaig
-
rpnpy.librmn.grids.
decodeXG2dict
(grtyp, xg1, xg2, xg3, xg4)¶ Put decode grid values into a dict with meaningful labels
params = decodeXG2dict(grtyp, xg1, xg2, xg3, xg4)
Parameters: - grtyp – type of geographical projection (one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’)
- xg1 – first decode grid descriptor (float)
- xg2 – second decode grid descriptor (float)
- xg3 – third decode grid descriptor (float)
- xg4 – fourth decode grid descriptor (float)
Returns: - {
- ‘grtyp’ : type of geographical projection
(one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’)
’xg1’ : first decode grid descriptor (float) ‘xg2’ : second decode grid descriptor (float) ‘xg3’ : third decode grid descriptor (float) ‘xg4’ : fourth decode grid descriptor (float) … list of other parameters is grtyp dependent
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> # Encode a LatLon Grid parameters >>> grtyp = 'L' >>> (lat0, lon0, dlat, dlon) = (0.,180.,1.,0.5) >>> (ig1, ig2, ig3, ig4) = rmn.cxgaig(grtyp,lat0, lon0, dlat, dlon) >>> # Decode Grid parameters to generix xg1-4 values >>> params = rmn.decodeIG2dict(grtyp, ig1, ig2, ig3, ig4) >>> # Decode Grid parameters to grid specific parameters >>> params = rmn.decodeXG2dict(grtyp, params['xg1'], params['xg2'], ... params['xg3'], params['xg4']) >>> if ((int((params['lat0']-lat0)*1000.), int((params['lon0']-lon0)*1000.), ... int((params['dlat']-dlat)*1000.), int((params['dlon']-dlon)*1000.)) ... != (0, 0, 0, 0)): ... print("Problem decoding grid values. {} != {}" ... .format((lat0, lon0, dlat, dlon), ... (params['xg1'], params['xg2'], ... params['xg3'], params['xg4']) ... ))
See also
decodeIG2dict rpnpy.librmn.base.cigaxg rpnpy.librmn.base.cxgaig
-
rpnpy.librmn.grids.
defGrid_E
(ni, nj=None, xlat1=None, xlon1=None, xlat2=None, xlon2=None, setGridId=True)¶ Defines an FSTD Global, rotated, LatLon (cylindrical equidistant) Grid
gridParams = defGrid_E(ni, nj, xlat1, xlon1, xlat2, xlon2, setGridId) gridParams = defGrid_E(ni, nj, xlat1, xlon1, xlat2, xlon2) gridParams = defGrid_E(params, setGridId) gridParams = defGrid_E(params)
Parameters: - nj (ni,) – grid dims (int)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ig1’ : grid parameters, encoded (int) ‘ig2’ : grid parameters, encoded (int) ‘ig3’ : grid parameters, encoded (int) ‘ig4’ : grid parameters, encoded (int) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> (ni, nj) = (90,45) >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 1., 270.) >>> params = rmn.defGrid_E(ni, nj, xlat1, xlon1, xlat2, xlon2)
See also
decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_G
(ni, nj=None, glb=True, north=True, inverted=False, setGridId=True)¶ Provide grid parameters to define an FSTD Gaussian Grid
gridParams = gridParams_G(ni, nj, lat0, lon0, dlat, dlon, setGridId) gridParams = gridParams_G(ni, nj, lat0, lon0, dlat, dlon) gridParams = gridParams_G(params, setGridId) gridParams = gridParams_G(params)
Parameters: - nj (ni,) – grid dims (int)
- glb – True for Global grid coverage, False for Hemispheric
- north – (used only if glb==False) True for northern hemisphere, False for Southern
- inverted – False, South -> North (pt (1, 1) at grid bottom) True, North -> South (pt (1, 1) at grid top)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) ‘glb’ : True for Global grid coverage, False for Hemispheric ‘north’ : (used only if glb==False) True for northern hemisphere,
False for Southern
- ’inverted’ : False, South -> North (pt (1, 1) at grid bottom)
True, North -> South (pt (1, 1) at grid top)
’ig1’ : grid parameters, encoded (int) ‘ig2’ : grid parameters, encoded (int) ‘ig3’ : grid parameters, encoded (int) ‘ig4’ : grid parameters, encoded (int) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params = rmn.defGrid_G(90, 45, glb=True, north=True, inverted=False)
See also
decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_L
(ni, nj=None, lat0=None, lon0=None, dlat=None, dlon=None, setGridId=True)¶ Defines an FSTD LatLon (cylindrical equidistant) Grid (LAM)
gridParams = defGrid_L(ni, nj, lat0, lon0, dlat, dlon, setGridId) gridParams = defGrid_L(ni, nj, lat0, lon0, dlat, dlon) gridParams = defGrid_L(params, setGridId) gridParams = defGrid_L(params)
Parameters: - nj (ni,) – grid dims (int)
- lon0 (lat0,) – lat, lon of SW grid corner [deg] (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon axes [deg] (float)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘ig1’ : grid parameters, encoded (int) ‘ig2’ : grid parameters, encoded (int) ‘ig3’ : grid parameters, encoded (int) ‘ig4’ : grid parameters, encoded (int) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> (lat0, lon0, dlat, dlon) = (0.,180.,1.,0.5) >>> (ni, nj) = (180, 90) >>> params = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon)
See also
decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_PS
(ni, nj=None, north=True, pi=None, pj=None, d60=None, dgrw=0.0, setGridId=True)¶ Define a Polar stereographic grid for the northern or southern hemisphere
gridParams = defGrid_PS(ni, nj, north, pi, pj, d60, dgrw, setGridId) gridParams = defGrid_PS(ni, nj, north, pi, pj, d60, dgrw) gridParams = defGrid_PS(params, setGridId) gridParams = defGrid_PS(params)
Parameters: - nj (ni,) – grid dims (int)
- pi – Horizontal position of the pole, (float) in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
- pj – Vertical position of the pole, (float) in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
- d60 – grid length, in meters, at 60deg. of latitude. (float)
- dgrw – angle (between 0 and 360, +ve counterclockwise) between the Greenwich meridian and the horizontal axis of the grid. (float)
- north – True for northern hemisphere, False for Southern
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) ‘pi’ : Horizontal position of the pole, (float
in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
- ’pj’ : Vertical position of the pole, (float
in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
’d60’ : grid length, in meters, at 60deg. of latitude. (float) ‘dgrw’ : angle (between 0 and 360, +ve counterclockwise)
between the Greenwich meridian and the horizontal axis of the grid. (float)
- ’north’ : True for northern hemisphere,
False for Southern
’ig1’ : grid parameters, encoded (int) ‘ig2’ : grid parameters, encoded (int) ‘ig3’ : grid parameters, encoded (int) ‘ig4’ : grid parameters, encoded (int) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params = rmn.defGrid_PS(90, 45, north=True, pi=45, pj=30, d60=5000., dgrw=270.)
See also
defGrid_ZPS defGrid_ZPSaxes defGrid_ZPSfLL decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_PSstd
(north=True, dgrw=0.0)¶ Define a Standardized Polar stereographic grid for the northern or southern hemisphere with specifed DGRW
The Standardized grid is a 10x10 1km resolution with Pole located at the Lower-Left corner.
gridParams = defGrid_PSstd(north, dgrw) gridParams = defGrid_PSstd(dgrw) gridParams = defGrid_PSstd()
Parameters: - north – True for northern hemisphere, False for Southern
- dgrw – angle (between 0 and 360, +ve counterclockwise) between the Greenwich meridian and the horizontal axis of the grid. (float)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) ‘pi’ : Horizontal position of the pole, (float
in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
- ’pj’ : Vertical position of the pole, (float
in grid points, from bottom left corner (1, 1). (Fotran convention, first point start at index 1)
’d60’ : grid length, in meters, at 60deg. of latitude. (float) ‘dgrw’ : angle (between 0 and 360, +ve counterclockwise)
between the Greenwich meridian and the horizontal axis of the grid. (float)
- ’north’ : True for northern hemisphere,
False for Southern
’ig1’ : grid parameters, encoded (int) ‘ig2’ : grid parameters, encoded (int) ‘ig3’ : grid parameters, encoded (int) ‘ig4’ : grid parameters, encoded (int) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> params = rmn.defGrid_PSstd(dgrw=15.)
See also
defGrid_PS defGrid_ZPS defGrid_ZPSaxes defGrid_ZPSfLL decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_YL
(ax, ay=None, setGridId=True)¶ Defines a non uniform grid made of a cloud of points on a FSTD LatLon (cylindrical equidistant) Grid projection
gridParams = defGrid_YL(ax, ay, setGridId) gridParams = defGrid_YL(ax, ay) gridParams = defGrid_YL(params, setGridId=setGridId) gridParams = defGrid_YL(params)
Parameters: - ax – lon of the grid points [deg] (list, numpy.ndarray)
- ay – lat of the grid points [deg] (list, numpy.ndarray)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Y) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (L) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘ax’ : points longitude (numpy, ndarray) ‘ay’ : points latitudes (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'ax' : ( 45., 46.5), ... 'ay' : (273., 273. ) ... } >>> params = rmn.defGrid_YL(params0, setGridId=True)
See also
decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_YY
(nj, overlap=0.0, xlat1=0.0, xlon1=180.0, xlat2=0.0, xlon2=270.0, setGridId=True)¶ Defines a YIN/YAN grid composed of 2 rotated LatLon (cylindrical equidistant) Grids
gridParams = defGrid_YY(nj, overlap, xlat1, xlon1, xlat2, xlon2, setGridId) gridParams = defGrid_YY(nj, overlap, xlat1, xlon1, xlat2, xlon2) gridParams = defGrid_YY(params, setGridId) gridParams = defGrid_YY(params)
Parameters: - nj – YIN grid dims (int) ni = (nj-1)*3+1
- overlap – number of overlapping degree between the 2 grids (float)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator on the YIN grid The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 on the YIN grid (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘overlap’: number of overlapping degrees between the 2 grids (float) ‘grtyp’ : grid type (U) (str)
’tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int)
’grref’ : ref grid type (F) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘axy’ : positional record (‘^>’) (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int) ‘nsubgrids’ : number of subgrids =2 (int) ‘subgridid’ : list of ezscint subgrid-id if setGridId==True,
-1 otherwise (list of 2 int)
’subgrid’ : params for each subgrid (list of 2 dict)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params = rmn.defGrid_YY(31, overlap=1.5, xlat1=0., xlon1=180., ... xlat2=0., xlon2=270.)
See also
decodeGrid encodeGrid yyg_yangrot_py yyg_pos_rec
-
rpnpy.librmn.grids.
defGrid_ZE
(ni, nj=None, lat0=None, lon0=None, dlat=None, dlon=None, xlat1=None, xlon1=None, xlat2=None, xlon2=None, setGridId=True)¶ Defines an FSTD LAM, rotated, LatLon (cylindrical equidistant) Grid
- gridParams = defGrid_ZE(ni, nj, lat0, lon0, dlat, dlon,
- xlat1, xlon1, xlat2, xlon2, setGridId)
- gridParams = defGrid_ZE(ni, nj, lat0, lon0, dlat, dlon,
- xlat1, xlon1, xlat2, xlon2)
gridParams = defGrid_ZE(params, setGridId=setGridId) gridParams = defGrid_ZE(params)
Parameters: - nj (ni,) – grid dims (int)
- lon0 (lat0,) – lat, lon of SW grid corner [deg] (not rotated coor.) (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon on rotated axes [deg] (float)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘rlat0’ : lat of SW grid corner [deg] (rotated coor.) (float) ‘rlon0’ : lon of SW grid corner [deg] (rotated coor.) (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ax’ : points longitude, in rotated coor. (numpy, ndarray) ‘ay’ : points latitudes, in rotated coor. (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 1., ... 'xlon2' : 270. ... } >>> params = rmn.defGrid_ZE(params0)
See also
defGrid_E defGrid_ZEr defGrid_ZEraxes defGrid_L defGrid_Laxes decodeGrid encodeGrid egrid_ll2rll egrid_rll2ll
-
rpnpy.librmn.grids.
defGrid_ZEr
(ni, nj=None, rlat0=None, rlon0=None, dlat=None, dlon=None, xlat1=None, xlon1=None, xlat2=None, xlon2=None, setGridId=True)¶ Defines an FSTD LAM, rotated, LatLon (cylindrical equidistant) Grid
- gridParams = defGrid_ZEr(ni, nj, rlat0, rlon0, dlat, dlon,
- xlat1, xlon1, xlat2, xlon2, setGridId)
- gridParams = defGrid_ZEr(ni, nj, rlat0, rlon0, dlat, dlon,
- xlat1, xlon1, xlat2, xlon2)
gridParams = defGrid_ZEr(params, setGridId=setGridId) gridParams = defGrid_ZEr(params)
Parameters: - nj (ni,) – grid dims (int)
- rlon0 (rlat0,) – lat, lon of SW grid corner [deg] (rotated coor.) (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon on rotated axes [deg] (float)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘rlat0’ : lat of SW grid corner [deg] (rotated coor.) (float) ‘rlon0’ : lon of SW grid corner [deg] (rotated coor.) (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ax’ : points longitude, in rotated coor. [deg] (numpy, ndarray) ‘ay’ : points latitudes, in rotated coor. [deg] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'ni' : 90, ... 'nj' : 45, ... 'rlat0' : 10., ... 'rlon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 1., ... 'xlon2' : 270. ... } >>> params = rmn.defGrid_ZEr(params0)
See also
defGrid_E defGrid_ZE defGrid_ZEraxes decodeGrid encodeGrid egrid_ll2rll egrid_rll2ll
-
rpnpy.librmn.grids.
defGrid_ZEraxes
(ax, ay=None, xlat1=None, xlon1=None, xlat2=None, xlon2=None, setGridId=True)¶ Defines an FSTD LAM, rotated, LatLon (cylindrical equidistant) Grid from provided rotated axes
- gridParams = defGrid_ZEraxes(ax, ay, xlat1, xlon1,
- xlat2, xlon2, setGridId)
gridParams = defGrid_ZEraxes(ax, ay, xlat1, xlon1, xlat2, xlon2) gridParams = defGrid_ZEraxes(params, setGridId=setGridId) gridParams = defGrid_ZEraxes(params)
Parameters: - ax – longitude of the grid points [deg] (rotated coor.) (float)
- ay – latitudes of the grid points [deg] (rotated coor.) (float)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘rlat0’ : lat of SW grid corner [deg] (rotated coor.) (float) ‘rlon0’ : lon of SW grid corner [deg] (rotated coor.) (float) ‘dlat’ : avg grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : avg grid resolution/spacing along lon axe [deg] (float) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ax’ : points longitude, in rotated coor. [deg] (numpy, ndarray) ‘ay’ : points latitudes, in rotated coor. [deg] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> (ni, nj) = (90, 45) >>> (rlat0, rlon0) = (10., 11.) >>> (dlat, dlon) = (1., 0.5) >>> ax = [rlon0 + dlon*float(x) for x in range(ni)] >>> ay = ([rlat0 + dlat*float(x) for x in range(nj)]) >>> params0 = { … ‘ax’ : ax, … ‘ay’ : ay, … ‘xlat1’ : 0., … ‘xlon1’ : 180., … ‘xlat2’ : 1., … ‘xlon2’ : 270. … } >>> params = rmn.defGrid_ZEraxes(params0) >>> print(“ni, nj = {ni}, {nj}”.format(**params)) ni, nj = 90, 45 >>> (rlat0, rlon0) = (int(params[‘rlat0’]*10.), int(params[‘rlon0’]*10.)) >>> print(“rlat0, rlon0 = {}, {}”.format(rlat0, rlon0)) rlat0, rlon0 = 100, 110 >>> (dlat, dlon) = (int(params[‘dlat’]*10.), int(params[‘dlon’]*10.)) >>> print(“dlat, dlon = {}, {}”.format(dlat, dlon)) dlat, dlon = 10, 5
See also
defGrid_E defGrid_ZE defGrid_ZEr defGrid_L decodeGrid encodeGrid egrid_ll2rll egrid_rll2ll
-
rpnpy.librmn.grids.
defGrid_ZL
(ni, nj=None, lat0=None, lon0=None, dlat=None, dlon=None, setGridId=True)¶ Defines an FSTD LAM LatLon (cylindrical equidistant) Grid
gridParams = defGrid_ZL(ni, nj, lat0, lon0, dlat, dlon, setGridId) gridParams = defGrid_ZL(ni, nj, lat0, lon0, dlat, dlon) gridParams = defGrid_ZL(params, setGridId=setGridId) gridParams = defGrid_ZL(params)
Parameters: - nj (ni,) – grid dims (int)
- lon0 (lat0,) – lat, lon of SW grid corner [deg] (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon on rotated axes [deg] (float)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (L) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘ax’ : points longitude (numpy, ndarray) ‘ay’ : points latitudes (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5 ... } >>> params = rmn.defGrid_ZL(params0)
See also
defGrid_ZLaxes defGrid_ZE defGrid_ZEr defGrid_ZEraxes decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_ZLaxes
(ax, ay=None, setGridId=True)¶ Defines an FSTD LAM LatLon (cylindrical equidistant) Grid from provided axes
gridParams = defGrid_ZLaxes(ax, ay, setGridId) gridParams = defGrid_ZLaxes(ax, ay) gridParams = defGrid_ZLaxes(params, setGridId=setGridId) gridParams = defGrid_ZLaxes(params)
Parameters: - ax – longitude of the grid points [deg] (float)
- ay – latitudes of the grid points [deg] (float)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (L) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘dlat’ : avg grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : avg grid resolution/spacing along lon axe [deg] (float) ‘ax’ : points longitude [deg] (numpy, ndarray) ‘ay’ : points latitudes [deg] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> import rpnpy.librmn.all as rmn >>> (ni, nj) = (90, 45) >>> (lat0, lon0) = (10., 11.) >>> (dlat, dlon) = (1., 0.5) >>> ax = [lon0 + dlon*float(x) for x in range(ni)] >>> ay = ([lat0 + dlat*float(x) for x in range(nj)]) >>> params0 = { … ‘ax’ : ax, … ‘ay’ : ay, … ‘xlat1’ : 0., … ‘xlon1’ : 180., … ‘xlat2’ : 1., … ‘xlon2’ : 270. … } >>> params = rmn.defGrid_ZLaxes(params0) >>> print(“ni, nj = {ni}, {nj}”.format(**params)) ni, nj = 90, 45 >>> (lat0, lon0) = (int(params[‘lat0’]*10.), int(params[‘lon0’]*10.)) >>> print(“lat0, lon0 = {}, {}”.format(lat0, lon0)) lat0, lon0 = 100, 110 >>> (dlat, dlon) = (int(params[‘dlat’]*10.), int(params[‘dlon’]*10.)) >>> print(“dlat, dlon = {}, {}”.format(dlat, dlon)) dlat, dlon = 10, 5
See also
defGrid_ZL defGrid_ZE defGrid_ZEr defGrid_ZEraxes decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_ZPS
(ni, nj=None, x0=None, y0=None, dxy=None, north=True, dgrw=0.0, setGridId=True)¶ Define a Polar stereographic grid for the northern or southern hemisphere from provided parameters
gridParams = defGrid_ZPS(ni, nj, x0, y0, dxy, north, dgrw, setGridId) gridParams = defGrid_ZPS(ni, nj, x0, y0, dxy, dgrw) gridParams = defGrid_ZPS(params, setGridId=setGridId) gridParams = defGrid_ZPS(params)
Parameters: - nj (ni,) – grid dims (int)
- x0 – Horizontal position, in meters, of lower left corner (1,1) from the pole in grid points (float) (Fotran convention, first point start at index 1)
- y0 – Vertical position, in meters, of lower left corner (1,1) from the pole in grid points (float) (Fotran convention, first point start at index 1)
- dxy – grid spacing, in meters, at 60deg. of lat. (float)
- dgrw – angle (between 0 and 360, +ve counterclockwise) between the Greenwich meridian and the horizontal axis of the grid. (float)
- north – True for northern hemisphere, False for Southern
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘pi’ : ref grid Horizontal position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
- ’pj’ : ref grid Vertical position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
’d60’ : ref grid spacing, in meters [1000m], at 60deg. of lat. (float) ‘dxy’ : avg. grid spacing, in meters, at 60deg. of lat. (float) ‘x0’ : Horizontal position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’y0’ : Vertical position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’dgrw’ : angle (between 0 and 360, +ve counterclockwise)
between the Greenwich meridian and the horizontal axis of the grid. (float)
- ’north’ : True for northern hemisphere,
False for Southern
’grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’: ref grid parameters, encoded (int) ‘ig2ref’: ref grid parameters, encoded (int) ‘ig3ref’: ref grid parameters, encoded (int) ‘ig4ref’: ref grid parameters, encoded (int) ‘ax’ : points X positions [m*d60] (numpy, ndarray) ‘ay’ : points Y positions [m*d60] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> d60 = 1000. >>> params0 = { … ‘ni’ : 90, … ‘nj’ : 45, … ‘x0’ : -2000.*d60, … ‘y0’ : -7000.*d60, … ‘dxy’ : 4.8*d60, # 4.8km … ‘dgrw’ : 15. … } >>> params = rmn.defGrid_ZPS(params0) >>> print(“ni, nj = {ni}, {nj}”.format(**params)) ni, nj = 90, 45 >>> print(“x0, y0 = {}, {}”.format(int(params[‘x0’]), int(params[‘y0’]))) x0, y0 = -2000000, -7000000 >>> print(“dxy, d60 = {}, {}”.format(int(params[‘dxy’]), int(params[‘d60’]))) dxy, d60 = 4800, 1000
See also
defGrid_PS defGrid_ZPSfLL defGrid_ZPSaxes decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_ZPSaxes
(ax, ay=None, north=True, dgrw=0.0, setGridId=True)¶ Define a Polar stereographic grid for the northern or southern hemisphere from provided rotated axes
gridParams = defGrid_ZPSaxes(ax, ay, north, dgrw, setGridId) gridParams = defGrid_ZPSaxes(ax, ay, dgrw) gridParams = defGrid_ZPSaxes(params, setGridId=setGridId) gridParams = defGrid_ZPSaxes(params)
Parameters: - ax – X position of the grid points [m] (rotated coor.) (float)
- ay – Y position of the grid points [m] (rotated coor.) (float)
- dgrw – angle (between 0 and 360, +ve counterclockwise) between the Greenwich meridian and the horizontal axis of the grid. (float)
- north – True for northern hemisphere, False for Southern
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘pi’ : ref grid Horizontal position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
- ’pj’ : ref grid Vertical position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
’d60’ : ref grid spacing, in meters [1000m], at 60deg. of lat. (float) ‘dxy’ : avg. grid spacing, in meters, at 60deg. of lat. (float) ‘dxy2’ : avg. grid spacing, in meters, at 60deg. of lat. (float) ‘x0’ : Horizontal position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’y0’ : Vertical position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’dgrw’ : angle (between 0 and 360, +ve counterclockwise)
between the Greenwich meridian and the horizontal axis of the grid. (float)
- ’north’ : True for northern hemisphere,
False for Southern
’grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’: ref grid parameters, encoded (int) ‘ig2ref’: ref grid parameters, encoded (int) ‘ig3ref’: ref grid parameters, encoded (int) ‘ig4ref’: ref grid parameters, encoded (int) ‘ax’ : points X positions [m*d60] (numpy, ndarray) ‘ay’ : points Y positions [m*d60] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> (ni, nj) = (90, 45) >>> d60 = 1000. >>> (x0, y0) = (-2000.*d60, -7000.*d60) >>> dxy = 4.8*d60 # 4.8km >>> params0 = { … ‘ax’ : [(x0 + dxy*float(i))/d60 for i in range(ni)], … ‘ay’ : [(y0 + dxy*float(j))/d60 for j in range(nj)], … ‘dgrw’ : 15. … } >>> params = rmn.defGrid_ZPSaxes(params0) >>> print(“ni, nj = {ni}, {nj}”.format(**params)) ni, nj = 90, 45 >>> print(“x0, y0 = {}, {}”.format(int(params[‘x0’]), int(params[‘y0’]))) x0, y0 = -2000000, -7000000 >>> print(“dxy, d60 = {}, {}”.format(int(params[‘dxy’]), int(params[‘d60’]))) dxy, d60 = 4800, 1000
See also
defGrid_PS defGrid_ZPS defGrid_ZPSfLL decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_ZPSfLL
(ni, nj=None, lat0=None, lon0=None, dxy=None, north=True, dgrw=0.0, setGridId=True)¶ Define a Polar stereographic grid for the northern or southern hemisphere from provided parameters
gridParams = defGrid_ZPSfLL(ni, nj, lat0, lon0, dxy, north, dgrw, setGridId) gridParams = defGrid_ZPSfLL(ni, nj, lat0, lon0, dxy, dgrw) gridParams = defGrid_ZPSfLL(params, setGridId=setGridId) gridParams = defGrid_ZPSfLLfLL(params)
Parameters: - nj (ni,) – grid dims (int)
- lon0 (lat0,) – lat, lon of SW grid corner [deg] (float)
- dxy – grid spacing, in meters, at 60deg. of lat. (float)
- dgrw – angle (between 0 and 360, +ve counterclockwise) between the Greenwich meridian and the horizontal axis of the grid. (float)
- north – True for northern hemisphere, False for Southern
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘pi’ : ref grid Horizontal position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
- ’pj’ : ref grid Vertical position of the pole, (float)
in grid points, from bottom left corner (1, 1). [0.] (Fotran convention, first point start at index 1)
’d60’ : ref grid spacing, in meters [1000m], at 60deg. of lat. (float) ‘dxy’ : avg. grid spacing, in meters, at 60deg. of lat. (float) ‘x0’ : Horizontal position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’y0’ : Vertical position, in meters, of lower left corner (1,1)
from the pole in grid points (float) (Fotran convention, first point start at index 1)
- ’dgrw’ : angle (between 0 and 360, +ve counterclockwise)
between the Greenwich meridian and the horizontal axis of the grid. (float)
- ’north’ : True for northern hemisphere,
False for Southern
’grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : grid tag 3 (int) ‘ig4’ : grid tag 4, unused (set to 0) (int) ‘grref’ : ref grid type (E) (str) ‘ig1ref’: ref grid parameters, encoded (int) ‘ig2ref’: ref grid parameters, encoded (int) ‘ig3ref’: ref grid parameters, encoded (int) ‘ig4ref’: ref grid parameters, encoded (int) ‘ax’ : points X positions [m*d60] (numpy, ndarray) ‘ay’ : points Y positions [m*d60] (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> d60 = 1000. >>> params0 = { … ‘ni’ : 90, … ‘nj’ : 45, … ‘lat0’ : 27., … ‘lon0’ : 239., … ‘dgrw’ : 15., … ‘dxy’ : 4.8*d60 # 4.8km … } >>> params = rmn.defGrid_ZPSfLL(params0) >>> print(“ni, nj = {ni}, {nj}”.format(**params)) ni, nj = 90, 45 >>> print(“x0, y0 = {}, {}”.format(int(params[‘x0’]), int(params[‘y0’]))) x0, y0 = -2008085, -7003030 >>> print(“dxy, d60 = {}, {}”.format(int(params[‘dxy’]), int(params[‘d60’]))) dxy, d60 = 4800, 1000
See also
defGrid_PS defGrid_ZPS defGrid_ZPSaxes decodeGrid encodeGrid
-
rpnpy.librmn.grids.
defGrid_diezeE
(ni, nj=None, lat0=None, lon0=None, dlat=None, dlon=None, xlat1=None, xlon1=None, xlat2=None, xlon2=None, lni=None, lnj=None, i0=None, j0=None, setGridId=True)¶ Defines an FSTD LAM, rotated, LatLon (cylindrical equidistant) Grid
- gridParams = defGrid_diezeE(ni, nj, lat0, lon0, dlat, dlon, xlat1, xlon1,
- xlat2, xlon2, lni, lnj, i0, j0, setGridId)
- gridParams = defGrid_diezeE(ni, nj, lat0, lon0, dlat, dlon, xlat1, xlon1,
- xlat2, xlon2, lni, lnj, i0, j0)
gridParams = defGrid_diezeE(params, setGridId=setGridId) gridParams = defGrid_diezeE(params)
Parameters: - lnj (lni,) – local grid tile dims (int)
- j0 (i0,) – local tile position of first point in the full grid (int) (Fotran convention, first point start at index 1)
- nj (ni,) – Full grid dims (int)
- lon0 (lat0,) – lat, lon of SW Full grid corner [deg] (not rotated coor.) (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon on rotated axes [deg] (float)
- xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘lshape’ : (lni, lnj) # dimensions of the local grid tile ‘lni’ : local grid tile dim along the x-axis (int) ‘lnj’ : local grid tile dim along the y-axis (int) ‘i0’ : local tile x-position of first point
in the full grid (int) (Fotran convention, first point start at index 1)
- ’j0’ : local tile y-position of first point
in the full grid (int) (Fotran convention, first point start at index 1)
’shape’ : (ni, nj) # dimensions of the grid ‘ni’ : Full grid dim along the x-axis (int) ‘nj’ : Full grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : i0 ‘ig4’ : j0 ‘grref’ : ref grid type (E) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘rlat0’ : lat of SW grid corner [deg] (rotated coor.) (float) ‘rlon0’ : lon of SW grid corner [deg] (rotated coor.) (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘dlon’ : grid resolution/spacing along lon axe [deg] (float) ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ax’ : points longitude, in rotated coor. (numpy, ndarray) ‘ay’ : points latitudes, in rotated coor. (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'lni' : 180, ... 'lnj' : 90, ... 'i0' : 1, ... 'j0' : 1, ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 1., ... 'xlon2' : 270. ... } >>> params = rmn.defGrid_diezeE(params0)
See also
decodeGrid encodeGrid
Notes
Unfortunately, librmn’s ezscint does NOT allow defining a # grid from ezgdef_fmem. The grid is thus defined as a Z grid in ezscint and tile info are kept in the python dictionary. Decoding from the grid id or interpolating may not lead to the expected result.
-
rpnpy.librmn.grids.
defGrid_diezeL
(ni, nj=None, lat0=None, lon0=None, dlat=None, dlon=None, lni=None, lnj=None, i0=None, j0=None, setGridId=True)¶ Defines an FSTD LAM LatLon (cylindrical equidistant) Grid
- gridParams = defGrid_diezeL(ni, nj, lat0, lon0, dlat, dlon,
- lni, lnj, i0, j0, setGridId)
- gridParams = defGrid_diezeL(ni, nj, lat0, lon0, dlat, dlon,
- lni, lnj, i0, j0)
gridParams = defGrid_diezeL(params, setGridId=setGridId) gridParams = defGrid_diezeL(params)
Parameters: - lnj (lni,) – local grid tile dims (int)
- j0 (i0,) – local tile position of first point in the full grid (int) (Fotran convention, first point start at index 1)
- nj (ni,) – Full grid dims (int)
- lon0 (lat0,) – lat, lon of SW Full grid corner [deg] (float)
- dlon (dlat,) – grid resolution/spacing along lat, lon [deg] (float)
- setGridId – Flag for creation of gid, ezscint grid id (True or False)
- params – above parameters given as a dictionary (dict)
Returns: - {
‘lshape’ : (lni, lnj) # dimensions of the local grid tile ‘lni’ : local grid tile dim along the x-axis (int) ‘lnj’ : local grid tile dim along the y-axis (int) ‘i0’ : local tile x-position of first point
in the full grid (int) (Fotran convention, first point start at index 1)
- ’j0’ : local tile y-position of first point
in the full grid (int) (Fotran convention, first point start at index 1)
’shape’ : (ni, nj) # dimensions of the grid ‘ni’ : Full grid dim along the x-axis (int) ‘nj’ : Full grid dim along the y-axis (int) ‘grtyp’ : grid type (Z) (str) ‘tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘ig1’ : grid tag 1 (int), =tag1 ‘ig2’ : grid tag 2 (int), =tag2 ‘ig3’ : i0 ‘ig4’ : j0 ‘grref’ : ref grid type (L) (str) ‘ig1ref’ : ref grid parameters, encoded (int) ‘ig2ref’ : ref grid parameters, encoded (int) ‘ig3ref’ : ref grid parameters, encoded (int) ‘ig4ref’ : ref grid parameters, encoded (int) ‘lat0’ : lat of SW grid corner [deg] (float) ‘lon0’ : lon of SW grid corner [deg] (float) ‘dlat’ : grid resolution/spacing along lat axe [deg] (float) ‘ax’ : points longitude (numpy, ndarray) ‘ay’ : points latitudes (numpy, ndarray) ‘id’ : ezscint grid-id if setGridId==True, -1 otherwise (int)
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'lni' : 180, ... 'lnj' : 90, ... 'i0' : 1, ... 'j0' : 1, ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... } >>> params = rmn.defGrid_diezeL(params0)
See also
decodeGrid encodeGrid
Notes
Unfortunately, librmn’s ezscint does NOT allow defining a # grid from ezgdef_fmem. The grid is thus defined as a Z grid in ezscint and tile info are kept in the python dictionary. Decoding from the grid id or interpolating may not lead to the expected result.
-
rpnpy.librmn.grids.
egrid_ll2rll
(xlat1, xlon1, xlat2, xlon2, lat, lon)¶ Compute rotated lat-lon from non rotated lat-lon of a rotated cylindrical equidistent (E) grid
(rlat, rlon) = egrid_ll2rll(xlat1, xlon1, xlat2, xlon2, lat, lon)
Parameters: - xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- lon (lat,) – lat and lon on the not rotated grid referencial
Returns: (rlat, rlon)
Raises: TypeError on wrong input arg types
Example:
>>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (lat, lon) = (45., 271.) >>> (rlat, rlon) = egrid_ll2rll(xlat1, xlon1, xlat2, xlon2, lat, lon)
See also
egrid_ll2rll_rot egrid_rll2ll egrid_rll2ll_rot defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
egrid_ll2rll_rot
(rot, lat, lon)¶ Compute rotated lat-lon from non rotated lat-lon of a rotated cylindrical equidistent (E) grid
(rlat, rlon) = egrid_ll2rll(xlat1, xlon1, xlat2, xlon2, lat, lon)
Parameters: - xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- lon (lat,) – lat and lon on the not rotated grid referencial
Returns: (rlat, rlon)
Raises: TypeError on wrong input arg types
Examples: >>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (lat, lon) = (45., 271.) >>> (rlat, rlon) = egrid_ll2rll(xlat1, xlon1, xlat2, xlon2, lat, lon)
See also
egrid_ll2rll egrid_rll2ll egrid_rll2ll_rot defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
egrid_rll2ll
(xlat1, xlon1, xlat2, xlon2, rlat, rlon)¶ Compute lat-lon from rotated lat-lon of a rotated cylindrical equidistent (E) grid
(lat, lon) = egrid_rll2ll(xlat1, xlon1, xlat2, xlon2, rlat, rlon)
Parameters: - xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- rlon (rlat,) – lat and lon on the rotated grid referencial
Returns: (lat, lon)
Raises: TypeError on wrong input arg types
Example:
>>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (rlat, rlon) = (45., 271.) >>> (lat, lon) = egrid_rll2ll(xlat1, xlon1, xlat2, xlon2, rlat, rlon)
See also
egrid_rll2ll_rot egrid_ll2rll egrid_ll2rll_rot defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
egrid_rll2ll_rot
(rot, rlat, rlon)¶ Compute lat-lon from rotated lat-lon of a rotated cylindrical equidistent (E) grid
(lat, lon) = egrid_rll2ll_rot(rot, rlat, rlon)
Parameters: - rot – rotation matrix rot = egrid_rot_matrix(xlat1, xlon1, xlat2, xlon2)
- rlon (rlat,) – lat and lon on the rotated grid referencial
Returns: (lat, lon)
Raises: TypeError on wrong input arg types
Examples: >>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (rlat, rlon) = (45., 271.) >>> rot = egrid_rot_matrix(xlat1, xlon1, xlat2, xlon2) >>> (lat, lon) = egrid_rll2ll_rot(rot, rlat, rlon)
See also
egrid_rll2ll egrid_ll2rll egrid_ll2rllrot defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
egrid_rot_matrix
(xlat1, xlon1, xlat2, xlon2)¶ Compute the rotation for the Yang grid using the rotation from Yin
- (yanlat1, yanlon1, yanlat2, yanlon2) =
- yyg_yangrot_py(xlat1, xlon1, xlat2, xlon2)
Parameters: - xlon1 (xlat1,) – lat, lon of the grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- xlon2 (xlat2,) – lat, lon of a 2nd ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
Returns: (yanlat1, yanlon1, yanlat2, yanlon2)
Raises: TypeError on wrong input arg types
Example:
>>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (xlat1b, xlon1b,xlat2b, xlon2b) = rmn.yyg_yangrot_py(xlat1, xlon1, xlat2, xlon2)
See also
defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
encodeGrid
(params)¶ Define an FSTD grid with the provided parameters
gridParams = encodeGrid(params)
Parameters: params – grid parameters given as a dictionary (dict) at least ‘grtyp’ must be defined other parameters is grtyp dependent, See defGrid_* specific function for details
Returns: - {
‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : grid dim along the x-axis (int) ‘nj’ : grid dim along the y-axis (int) ‘grtyp’ : grid type (str) … list of other parameters is grtyp dependent, See defGrid_* specific function for details
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'grtyp' : 'Z', ... 'grref' : 'E', ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 1., ... 'xlon2' : 270. ... } >>> params = rmn.encodeGrid(params0)
See also
decodeGrid defGrid_PS defGrid_G defGrid_L defGrid_E defGrid_ZL defGrid_ZLaxes defGrid_ZE defGrid_ZEr defGrid_ZEraxes defGrid_diezeL defGrid_diezeE defGrid_YL defGrid_YY defGrid_ZPS defGrid_ZPSaxes defGrid_ZPSfLL
-
rpnpy.librmn.grids.
getIgTags
(params)¶ Use grid params and CRC to define 2 grid tags
(tag1, tag2) = setIgTags(params)
Parameters: - params –
- grid parameters given as a dictionary (dict)
- {
- ‘xlat1’ : lat of grid center [deg] (float) ‘xlon1’ : lon of grid center [deg] (float) ‘xlat2’ : lat of a 2nd ref. point [deg] (float) ‘xlon2’ : lon of a 2nd ref. point [deg] (float) ‘ax’ : grid x-axes (numpy.ndarray) ‘ay’ : grid y-axes (numpy.ndarray)
}
OR
- params –
- grid parameters given as a dictionary (dict)
- {
- ‘lat0’ : lat of grid lower-left corner [deg] (float) ‘lon0’ : lon of grid lower-left corner [deg] (float) ‘dlat’ : Grid lat resolution [deg] (float) ‘dlon’ : Grid lon resolution [deg] (float) ‘ax’ : grid x-axes (numpy.ndarray) ‘ay’ : grid y-axes (numpy.ndarray)
}
Returns: 2 grid tags
Return type: Raises: - TypeError on wrong input arg types
- RMNError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> # Define a Rotated LatLon Grid >>> (ni, nj) = (90,45) >>> (lat0, lon0, dlat, dlon) = (10., 11., 1., 0.5) >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 1., 270.) >>> params = rmn.defGrid_ZE(ni, nj, lat0, lon0, dlat, dlon, ... xlat1, xlon1, xlat2, xlon2) >>> (tag1, tag2) = rmn.getIgTags(params)
See also
defGrid_ZE defGrid_ZEr defGrid_ZEraxes rpnpy.librmn.base.crc32 defGrid_ZPS defGrid_ZPSaxes defGrid_ZPSfLL
- params –
-
rpnpy.librmn.grids.
readGrid
(funit, params)¶ Create a new grid with its parameters from provided params Read grid descriptors from file if need be
Parameters: Returns: - {
‘id’ : grid id, same as input arg ‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : first dimension of the grid ‘nj’ : second dimension of the grid ‘grtyp’ : type of geographical projection
(one of ‘Z’, ‘#’, ‘Y’, ‘U’)
’ig1’ : first grid descriptor ‘ig2’ : second grid descriptor ‘ig3’ : third grid descriptor ‘ig4’ : fourth grid descriptor ‘grref’ : grid ref type (one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’) ‘ig1ref’ : first grid descriptor of grid ref ‘ig2ref’ : second grid descriptor of grid ref ‘ig3ref’ : third grid descriptor of grid ref ‘ig4ref’ : fourth grid descriptor of grid ref … list of other parameters is grtyp dependent, See defGrid_* specific function for details
}
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(),'bcmk','geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> rec = rmn.fstlir(funit, nomvar='ME') >>> grid = rmn.readGrid(funit, rec) >>> rmn.fstcloseall(funit)
See also
writeGrid decodeGrid rpnpy.librmn.interp.ezqkdef rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall
-
rpnpy.librmn.grids.
writeGrid
(funit, params)¶ Write the grid descriptors to file if need be
Grid descriptors exists only for reference grids: Z, #, Y, U For other grid types, this function does nothing since the grid is already coded in the record metadata
Parameters: - funit (int) –
- params (dict) –
grid parameters given as a dictionary (dict) These grid params are the one returned by:
decodeGrid, readGrid, defGrid_*, encodeGridMinimally it needs (grtyp != Z, #, Y or U): { ‘grtyp’ : type of geographical projection ‘ig1’ : first grid descriptor (int) ‘ig2’ : second grid descriptor (int) ‘ig3’ : third grid descriptor (int) ‘ig4’ : fourth grid descriptor (int) } For ref grids (grtyp == Z, #, Y or U) it needs: { ‘grtyp’ : type of geographical projection
(one of ‘Z’, ‘#’, ‘Y’, ‘U’)’tag1’ : grid tag 1 (int) ‘tag2’ : grid tag 2 (int) ‘tag3’ : grid tag 3 (int) ‘grref’ : grid ref type
(one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’)’ig1ref’ : first grid descriptor of grid ref (int) ‘ig2ref’ : second grid descriptor of grid ref (int) ‘ig3ref’ : third grid descriptor of grid ref (int) ‘ig4ref’ : fourth grid descriptor of grid ref (int) } Additioannly for grtyp == Z, #, Y: { ‘ax’ : grid x-axes (numpy.ndarray) ‘ay’ : grid y-axes (numpy.ndarray) } Additioannly for grtyp == U: { ‘axy’ : positional record (‘^>’) (numpy, ndarray) }
Returns: None
Raises: - TypeError on wrong input arg types
- ValueError on invalid input arg value
- RMNError on any other error
Example:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(),'bcmk','geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> rec = rmn.fstlir(funit, nomvar='ME') >>> grid0 = rmn.readGrid(funit, rec) >>> rmn.fstcloseall(funit) >>> grid1 = rmn.defGrid_L(90,45,0.,180.,1.,0.5) >>> grid2 = rmn.defGrid_ZE(90,45,10.,11.,1.,0.5,0.,180.,1.,270.) >>> grid3 = rmn.defGrid_YY(31,5,0.,180.,1.,270.) >>> myfile = 'myfstfile.fst' >>> funit = rmn.fstopenall(myfile, rmn.FST_RW) >>> rmn.fstecr(funit,rec['d'],rec) >>> rmn.writeGrid(funit, grid0) >>> rmn.writeGrid(funit, grid1) >>> rmn.writeGrid(funit, grid2) >>> rmn.writeGrid(funit, grid3) >>> rmn.fstcloseall(funit) >>> os.unlink(myfile) # Remove test file
See also
readGrid encodeGrid decodeGrid rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstecr rpnpy.librmn.fstd98.fstcloseall
-
rpnpy.librmn.grids.
yyg_pos_rec
(yinlat1, yinlon1, yinlat2, yinlon2, ax, ay)¶ Pack grid description value into the ^> record descriptor of the YY grid
axy = yyg_pos_rec(yinlat1, yinlon1, yinlat2, yinlon2, ax, xy)
Parameters: - yinlon1 (yinlat1,) – lat, lon of the YIN grid center [deg] (float) This defines, in rotated coor., (rlat, rlon) = (0., 180.) on the rotated equator The grid is defined, in rotated coor on rlat: -90. to +90. degrees rlon: 0. to 360. degrees
- yinlon2 (yinlat2,) – lat, lon of a 2nd YIN ref. point [deg] (float) This point is considered to be on the rotated equator, east of xlat1, xlon1 (it thus defines the rotation)
- ax – points longitude of the YIN grid, in rotated coor.(numpy.ndarray)
- ay – points latitudes of the YIN grid, in rotated coor.(numpy.ndarray)
Returns: numpy.ndarray, positional record describing the yy-grid
Example:
>>> import rpnpy.librmn.all as rmn >>> params0 = { ... 'ni' : 90, ... 'nj' : 45, ... 'lat0' : 10., ... 'lon0' : 11., ... 'dlat' : 1., ... 'dlon' : 0.5, ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 1., ... 'xlon2' : 270. ... } >>> params = rmn.defGrid_ZE(params0) >>> axy = rmn.yyg_pos_rec(params['xlat1'], params['xlon1'], ... params['xlat2'], params['xlon2'], ... params['ax'],params['ay'])
See also
defGrid_YY decodeGrid encodeGrid
-
rpnpy.librmn.grids.
yyg_yangrot_py
(yinlat1, yinlon1, yinlat2, yinlon2)¶ Compute the rotation for the Yang grid using the rotation from Yin
- (yanlat1, yanlon1, yanlat2, yanlon2) =
- yyg_yangrot_py(yinlat1, yinlon1, yinlat2, yinlon2)
Parameters: yinlon1, yinlat2, yinlon2 (yinlat1,) – Returns: (yanlat1, yanlon1, yanlat2, yanlon2) Raises: TypeError on wrong input arg types Example:
>>> import rpnpy.librmn.all as rmn >>> (xlat1, xlon1, xlat2, xlon2) = (0., 180., 0., 270.) >>> (xlat1b, xlon1b,xlat2b, xlon2b) = rmn.yyg_yangrot_py(xlat1, xlon1, xlat2, xlon2)
See also
defGrid_YY decodeGrid encodeGrid
Module librmn.interp contains python wrapper to main librmn’s interp (ezscint) C functions
Notes
The functions described below are a very close ‘’port’’ from the original [[librmn]]’s [[Librmn/FSTDfunctions|FSTD]] package.<br> You may want to refer to the [[Librmn/FSTDfunctions|FSTD]] documentation for more details.
See also
rpnpy.librmn.base rpnpy.librmn.fstd98 rpnpy.librmn.grids rpnpy.librmn.const
-
exception
rpnpy.librmn.interp.
EzscintError
¶ General librmn.interp module error/exception
To make your code handle errors in an elegant manner, you may want to catch that error with a ‘try … except’ block.
Examples:
>>> import rpnpy.librmn.all as rmn >>> try: ... rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR) ... except rmn.EzscintError: ... pass #ignore the error ... finally: ... print("# Whatever happens, error or not, print this.") # Whatever happens, error or not, print this.
See also
rpnpy.librmn.RMNError
-
rpnpy.librmn.interp.
ezcalcarea
(lats, lons)¶ This function computes the area on the sphere of the solid polygon formed by 2 or 4 latlon points.
- Source of the formula :
- http://mathworld.wolfram.com/GreatCircle.html http://mathworld.wolfram.com/SphericalTrigonometry.html http://mathworld.wolfram.com/SphericalTriangle.html
area = ezcalcarea(lats, lons)
Parameters: - lats – latitudes of 2/4 points defining the rectangle/polygone [deg]
- lons – longitude of 2/4 points defining the rectangle/polygone [deg]
Returns: float, area on the sphere [m^2]
Raises: - TypeError on wrong input arg types
- ValueError on wrong number of inputs values
Examples: >>> import rpnpy.librmn.all as rmn >>> area = rmn.ezcalcarea((45,46),(270,271)) >>> print(“area = {}”.format(int(area))) area = 8666027008 >>> area = rmn.ezcalcarea((45,45,46,46),(270,271,270,271)) >>> print(“area = {}”.format(int(area))) area = 8666027008
See also
ezcalcdist
-
rpnpy.librmn.interp.
ezcalcdist
(lat1, lon1, lat2, lon2)¶ This function computes the distance between 2 latlon points on the sphere (double precision).
- Source of the formula :
- http://mathworld.wolfram.com/GreatCircle.html
dist = ezcalcdist(lat1, lon1, lat2, lon2)
Parameters: - lon1 (lat1,) – latitude, longitude of the first point [deg]
- lon2 (lat2,) – latitude, longitude of second point [deg]
Returns: float, distance on the sphere between the points [m]
Raises: TypeError on wrong input arg types
Examples: >>> import rpnpy.librmn.all as rmn >>> dist = rmn.ezcalcdist(45, 270, 45, 271) >>> print(“dist = {}”.format(int(dist))) dist = 78626
See also
ezcalcarea
-
rpnpy.librmn.interp.
ezdefset
(gdidout, gdidin)¶ Defines a set of grids for interpolation
gridsetid = ezdefset(gdidout, gdidin)
Parameters: - gdidout – output grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- gdidin – input grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
Returns: int, grid set id
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn
>>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Define a destination Grid >>> (lat0, lon0, dlat, dlon) = (35.,265.,0.25,0.25) >>> (ni, nj) = (200, 100) >>> outGrid = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> >>> # Define the grid-set and interpolate data linearly >>> gridsetid = rmn.ezdefset(outGrid, inGrid) >>> rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR) >>> me2 = rmn.ezsint(outGrid['id'], inGrid['id'], meRec['d'])
See also
ezsetopt ezsint ezuvint rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezgdef_fmem
(ni, nj=None, grtyp=None, grref=None, ig1=None, ig2=None, ig3=None, ig4=None, ax=None, ay=None)¶ Generic grid definition except for ‘U’ grids (with necessary positional parameters taken from the calling arguments)
gdid = ezgdef_fmem(ni, nj, grtyp, grref, ig1, ig2, ig3, ig4, ax, ay) gdid = ezgdef_fmem(gridParams)
Parameters: - nj (ni,) – grid dims (int)
- grref (grtyp,) – grid type and grid ref type (str)
- ig2, ig3, ig4 (ig1,) – grid parameters, encoded (int)
- ay (ax,) – grid axes (numpy.ndarray)
- gridParams – key=value pairs for each grid params (dict)
Returns: int, grid id
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import numpy as np >>> import rpnpy.librmn.all as rmn >>> (ni,nj) = (90, 45) >>> gp = { ... 'shape' : (ni,nj), ... 'ni' : ni, ... 'nj' : nj, ... 'grtyp' : 'Z', ... 'grref' : 'E', ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 0., ... 'xlon2' : 270., ... 'dlat' : 0.25, ... 'dlon' : 0.25, ... 'lat0' : 45., ... 'lon0' : 273. ... } >>> ig1234 = rmn.cxgaig(gp['grref'], gp['xlat1'], gp['xlon1'], ... gp['xlat2'], gp['xlon2']) >>> gp['ax'] = np.empty((ni,1), dtype=np.float32, order='F') >>> gp['ay'] = np.empty((1,nj), dtype=np.float32, order='F') >>> for i in range(ni): gp['ax'][i,0] = gp['lon0']+float(i)*gp['dlon'] >>> for j in range(nj): gp['ay'][0,j] = gp['lat0']+float(j)*gp['dlat'] >>> gid = rmn.ezgdef_fmem(ni, nj, gp['grtyp'], gp['grref'], ... ig1234[0], ig1234[1], ig1234[2], ig1234[3], ... gp['ax'], gp['ay'])
See also
ezqkdef rpnpy.librmn.base.cxgaig rpnpy.librmn.grids
-
rpnpy.librmn.interp.
ezgdef_supergrid
(ni, nj, grtyp, grref, vercode, subgridid)¶ U grid definition (which associates to a list of concatenated subgrids in one record)
gdid = ezgdef_supergrid(ni, nj, grtyp, grref, vercode, nsubgrids, subgridid) gdid = ezgdef_supergrid(gridParams)
Parameters: - nj (ni,) – grid dims (int)
- grref (grtyp,) – grid type and grid ref type (str)
- vercode –
- subgridid – list of subgrid id (list, tuple or numpy.ndarray)
- gridParams – key=value pairs for each grid params (dict)
Returns: int, super grid id
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> nj = 31 ; ni = (nj-1)*3 + 1 >>> gp = { ... 'ni' : ni, ... 'nj' : nj, ... 'grtyp' : 'Z', ... 'grref' : 'E', ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 0., ... 'xlon2' : 270., ... 'dlat' : 0.25, ... 'dlon' : 0.25, ... 'lat0' : 45., ... 'lon0' : 273. ... } >>> yin = rmn.encodeGrid(gp) >>> (gp['xlat1'], gp['xlon1'], gp['xlat2'], gp['xlon2']) = ( ... rmn.yyg_yangrot_py(gp['xlat1'],gp['xlon1'],gp['xlat2'],gp['xlon2'])) >>> yan = rmn.encodeGrid(gp) >>> yy_id = rmn.ezgdef_supergrid(ni, nj, 'U', 'F', 1, (yin['id'],yan['id']))
See also
ezget_nsubgrids ezget_subgridids rpnpy.librmn.grids.encodeGrid rpnpy.librmn.grids.yyg_yangrot_py rpnpy.librmn.grids.defGrid_YY
-
rpnpy.librmn.interp.
ezget_nsubgrids
(super_gdid)¶ Gets the number of subgrids from the ‘U’ (super) grid id
nsubgrids = ezget_nsubgrids(super_gdid)
Parameters: super_gdid – id of the super grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
Returns: int, number of sub grids associated with super_gdid
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> yy = rmn.defGrid_YY(31) >>> n = rmn.ezget_nsubgrids(yy['id']) >>> print("# There are {0} subgrids in the YY grid".format(n)) # There are 2 subgrids in the YY grid
See also
ezgdef_supergrid ezget_subgridids ezgprm ezgxprm ezgfstp gdgaxes rpnpy.librmn.grids.defGrid_YY rpnpy.librmn.grids.decodeGrid
-
rpnpy.librmn.interp.
ezget_subgridids
(super_gdid)¶ Gets the list of grid ids for the subgrids in the ‘U’ grid (super_gdid).
subgridids = ezget_subgridids(super_gdid)
Parameters: super_gdid – id of the super grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
Returns: int, list of grid ids for the subgrids
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> yy = rmn.defGrid_YY(31) >>> idlist = rmn.ezget_subgridids(yy['id']) >>> print("# Found {} subrids".format(len(idlist))) # Found 2 subrids
See also
ezgdef_supergrid ezget_nsubgrids ezgprm ezgxprm ezgfstp gdgaxes rpnpy.librmn.grids.defGrid_YY rpnpy.librmn.grids.decodeGrid
-
rpnpy.librmn.interp.
ezgetival
(option)¶ Gets an ezscint integer option value
value = ezgetival(option)
Parameters: option – option name (string)
Returns: integer, option value
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
See also
ezgetval ezgetopt ezsetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezgetopt
(option, vtype=<type 'int'>)¶ Gets an ezscint option value
value = ezgetopt(option) value = ezgetopt(option, vtype)
Parameters: - option – option name (string)
- vtype – type of requested option (type.int, type.float or type.string) default: int
Returns: option value of the requested type
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Notes
This function replaces the following C/Fortran functions: ezgetival, ezgetval, ezgetopt
Examples:
>>> import rpnpy.librmn.all as rmn >>> interp_degree = rmn.ezgetopt(rmn.EZ_OPT_INTERP_DEGREE, vtype=str) >>> print("# Field will be interpolated with type: {0}".format(interp_degree)) # Field will be interpolated with type: linear
See also
ezgetival ezgetval ezsetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezgetval
(option)¶ Gets an ezscint float option value
value = ezgetval(option)
Parameters: option – option name (string)
Returns: float, option value
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
See also
ezgetival ezgetopt ezsetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezgfstp
(gdid, doSubGrid=False)¶ Get the standard file attributes of the positional records
recParams = ezgfstp(gdid) recParams = ezgfstp(gdid, doSubGrid=True)
Parameters: - gdid – grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- doSubGrid – recurse on subgrids if True
Returns: - {
‘id’ : grid id, same as input arg ‘typvarx’: x-axe type of field (forecast, analysis, climatology) ‘nomvarx’: x-axe variable name ‘etikx’ : x-axe label ‘typvary’: y-axe type of field (forecast, analysis, climatology) ‘nomvary’: y-axe variable name ‘etiky’ : y-axe label ‘ip1’ : grid tag 1 ‘ip2’ : grid tag 2 ‘ip3’ : grid tag 3 ‘dateo’ : date time stamp ‘deet’ : length of a time step in seconds ‘npas’ : time step number ‘nbits’ : number of bits kept for the elements of the field
} if doSubGrid, add these {
’nsubgrids’ : Number of subgrids ‘subgridid’ : list of subgrids id ‘subgrid’ : list of subgrids details {‘id’, ‘typvarx’, …}
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES').strip() >>> myfile = os.path.join(ATM_MODEL_DFILES, 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> meGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Get standard file attributes of the positional records >>> params = rmn.ezgfstp(meGrid['id']) >>> print("# {0} grid axes are in {nomvarx} and {nomvary} records".format(meRec['nomvar'], **params)) # ME grid axes are in >> and ^^ records
See also
ezgprm ezgxprm gdgaxes ezget_nsubgrids ezget_subgridids rpnpy.librmn.grids.decodeGrid rpnpy.librmn.grids.readGrid rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall
-
rpnpy.librmn.interp.
ezgprm
(gdid, doSubGrid=False)¶ Get grid parameters
gridParams = ezgprm(gdid)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- doSubGrid – recurse on subgrids if True
Returns: - {
‘id’ : grid id, same as input arg ‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : first dimension of the grid ‘nj’ : second dimension of the grid ‘grtyp’ : type of geographical projection
(one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’)
’ig1’ : first grid descriptor ‘ig2’ : second grid descriptor ‘ig3’ : third grid descriptor ‘ig4’ : fourth grid descriptor
} if doSubGrid, add these {
’nsubgrids’ : Number of subgrids ‘subgridid’ : list of subgrids id ‘subgrid’ : list of subgrids details {‘id’, ‘shape’, …}
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> >>> # Define a LatLon grid >>> (grtyp, lat0, lon0, dlat, dlon) = ('L', 45., 273., 0.5, 0.5) >>> (ig1, ig2, ig3, ig4) = rmn.cxgaig(grtyp, lat0, lon0, dlat, dlon) >>> gid = rmn.ezqkdef(90, 45, grtyp, ig1, ig2, ig3, ig4) >>> >>> # Get grid info from any grid id >>> params = rmn.ezgprm(gid) >>> print("# Grid type={grtyp} of size={ni}, {nj}".format(**params)) # Grid type=L of size=90, 45
See also
ezgxprm ezgfstp gdgaxes ezget_nsubgrids ezget_subgridids ezqkdef rpnpy.librmn.base.cxgaig rpnpy.librmn.grids.decodeGrid
-
rpnpy.librmn.interp.
ezgxprm
(gdid, doSubGrid=False)¶ Get extended grid parameters
gridParams = ezgxprm(gdid)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- doSubGrid – recurse on subgrids if True
Returns: - {
‘id’ : grid id, same as input arg ‘shape’ : (ni, nj) # dimensions of the grid ‘ni’ : first dimension of the grid ‘nj’ : second dimension of the grid ‘grtyp’ : type of geographical projection
(one of ‘Z’, ‘#’, ‘Y’, ‘U’)
’ig1’ : first grid descriptor ‘ig2’ : second grid descriptor ‘ig3’ : third grid descriptor ‘ig4’ : fourth grid descriptor ‘grref’ : grid ref type (one of ‘A’, ‘B’, ‘E’, ‘G’, ‘L’, ‘N’, ‘S’) ‘ig1ref’ : first grid descriptor of grid ref ‘ig2ref’ : second grid descriptor of grid ref ‘ig3ref’ : third grid descriptor of grid ref ‘ig4ref’ : fourth grid descriptor of grid ref
} For grtyp not in (‘Z’, ‘#’, ‘Y’, ‘U’), grref=’ ‘, ig1..4ref=0 if doSubGrid, add these {
’nsubgrids’ : Number of subgrids ‘subgridid’ : list of subgrids id ‘subgrid’ : list of subgrids details {‘id’, ‘shape’, …}
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import numpy as np >>> import rpnpy.librmn.all as rmn >>> >>> # Define a Z/E grid >>> (ni,nj) = (90, 45) >>> gp = { ... 'shape' : (ni,nj), ... 'ni' : ni, ... 'nj' : nj, ... 'grtyp' : 'Z', ... 'grref' : 'E', ... 'xlat1' : 0., ... 'xlon1' : 180., ... 'xlat2' : 0., ... 'xlon2' : 270., ... 'dlat' : 0.25, ... 'dlon' : 0.25, ... 'lat0' : 45., ... 'lon0' : 273. ... } >>> ig1234 = rmn.cxgaig(gp['grref'], gp['xlat1'], gp['xlon1'], ... gp['xlat2'], gp['xlon2']) >>> gp['ax'] = np.empty((ni,1), dtype=np.float32, order='F') >>> gp['ay'] = np.empty((1,nj), dtype=np.float32, order='F') >>> for i in range(ni): gp['ax'][i,0] = gp['lon0']+float(i)*gp['dlon'] >>> for j in range(nj): gp['ay'][0,j] = gp['lat0']+float(j)*gp['dlat'] >>> gid = rmn.ezgdef_fmem(ni, nj, gp['grtyp'], gp['grref'], ... ig1234[0], ig1234[1], ig1234[2], ig1234[3], ... gp['ax'], gp['ay']) >>> >>> # Get grid info >>> params = rmn.ezgxprm(gid) >>> print("# Grid type={grtyp}/{grref} of size={ni}, {nj}".format(**params)) # Grid type=Z/E of size=90, 45
See also
ezgprm ezgfstp gdgaxes ezget_nsubgrids ezget_subgridids ezgdef_fmem rpnpy.librmn.base.cxgaig rpnpy.librmn.grids.decodeGrid rpnpy.librmn.grids.readGrid
-
rpnpy.librmn.interp.
ezqkdef
(ni, nj=None, grtyp=None, ig1=None, ig2=None, ig3=None, ig4=None, iunit=0)¶ Universal grid definition. Applicable to all cases.
gdid = ezqkdef(ni, nj, grtyp, ig1, ig2, ig3, ig4, iunit) gdid = ezqkdef(gridParams)
Parameters: - nj (ni,) – grid dims (int)
- grtyp – grid type (str)
- ig2, ig3, ig4 (ig1,) – grid parameters, encoded (int)
- iunit – File unit, optional (int)
- gridParams – key=value pairs for each grid params (dict)
Returns: int, grid id
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> # Define a LatLon grid >>> (grtyp, lat0, lon0, dlat, dlon) = ('L', 45., 273., 0.5, 0.5) >>> (ig1, ig2, ig3, ig4) = rmn.cxgaig(grtyp, lat0, lon0, dlat, dlon) >>> gid = rmn.ezqkdef(90, 45, grtyp, ig1, ig2, ig3, ig4)
See also
ezgdef_fmem rpnpy.librmn.base.cxgaig rpnpy.librmn.grids
-
rpnpy.librmn.interp.
ezsetival
(option, value)¶ Sets an integer numerical ezscint option
ezsetival(option, value)
Parameters: - option – option name (string)
- value – option value (float)
Returns: None
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
See also
ezsetval ezsetopt ezgetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezsetopt
(option, value)¶ Sets ezscint option: float, integer or string
ezsetopt(option, value)
Parameters: - option – option name (string)
- value – option value (int, float or string)
Returns: None
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Notes
This function replaces the following C/Fortran functions: ezsetival, ezsetval, ezsetopt
Examples:
>>> import rpnpy.librmn.all as rmn >>> rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR) >>> rmn.ezsetopt(rmn.EZ_OPT_USE_1SUBGRID, rmn.EZ_YES)
See also
ezsetval ezsetival ezgetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezsetval
(option, value)¶ Sets a floating point numerical ezscint option
ezsetval(option, value)
Parameters: - option – option name (string)
- value – option value (float)
Returns: None
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples: >>> import rpnpy.librmn.all as rmn >>> rmn.ezsetval(rmn.EZ_OPT_EXTRAP_VALUE, 999.)
See also
ezsetival ezsetopt ezgetopt rpnpy.librmn.const
-
rpnpy.librmn.interp.
ezsint
(gdidout, gdidin, zin, zout=None)¶ Scalar horizontal interpolation
zout = ezsint(gdidout, gdidin, zin) zout = ezsint(gdidout, gdidin, zin, zout)
Parameters: - gdidout – output grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- gdidid – grid id describing zin grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- zin – data to interpolate (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- zout – optional, interp.result array (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
Returns: numpy.ndarray, interpolation result
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Define a destination Grid >>> (ni, nj, lat0, lon0, dlat, dlon) = (200, 100, 35.,265.,0.25,0.25) >>> outGrid = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> >>> # Interpolate ME linearly >>> rmn.ezsetopt(rmn.EZ_OPT_INTERP_DEGREE, rmn.EZ_INTERP_LINEAR) >>> me = rmn.ezsint(outGrid['id'], inGrid['id'], meRec['d'])
See also
ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
ezuvint
(gdidout, gdidin, uuin, vvin, uuout=None, vvout=None)¶ Vectorial horizontal interpolation
(uuout, vvout) = ezuvint(gdidout, gdidin, uuin, vvin) (uuout, vvout) = ezuvint(gdidout, gdidin, uuin, vvin, uuout, vvout)
Parameters: - gdidout – output grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- gdidid – grid id describing uuin grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- uuin – data x-part to interpolate (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- vvin – data y-part to interpolate (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- uuout – interp.result array x-part (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- vvout – interp.result array y-part (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
Returns: interpolation result (numpy.ndarray, numpy.ndarray)
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', '2009042700_000') >>> funit = rmn.fstopenall(myfile) >>> uuRec = rmn.fstlir(funit, nomvar='UU', ip1=93423264) >>> vvRec = rmn.fstlir(funit, nomvar='VV', ip1=uuRec['ip1'], ip2=uuRec['ip2']) >>> inGrid = rmn.readGrid(funit, uuRec) >>> rmn.fstcloseall(funit) >>> >>> # Define a destination Grid >>> (ni, nj, lat0, lon0, dlat, dlon) = (200, 100, 35.,265.,0.25,0.25) >>> outGrid = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> >>> # Interpolate U/V vectorially >>> (uu, vv) = rmn.ezuvint(outGrid['id'], inGrid['id'], uuRec['d'], vvRec['d'])
See also
ezsint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdgaxes
(gdid, ax=None, ay=None)¶ Gets the deformation axes of the Z, Y, #, U grids
gridAxes = gdgaxes(gdid) gridAxes = gdgaxes(gdid, ax, ay) gridAxes = gdgaxes(gdid, gridAxes) gridAxes = gdgaxes(griddict)
Parameters: - gdid – id of the grid (int)
- ay (ax,) – (optional) 2 pre-allocated grid axes arrays (numpy.ndarray)
- gridAxes – (optional) gridAxes[‘ax’] and gridAxes[‘ay’] are 2 pre-allocated grid axes arrays (numpy.ndarray)
- griddict – dict with minimally key ‘id’ as id of the grid optionnaly keys ‘ax’ and ‘ay’ can be provided as 2 pre-allocated grid axes arrays (numpy.ndarray)
Returns: - {
‘id’ : grid id, same as input arg ‘ax’ : x grid axe data (numpy.ndarray)
same as gridAxes[‘subgrid’][0][‘ax’]
- ’ay’ : y grid axe data (numpy.ndarray)
same as gridAxes[‘subgrid’][0][‘ay’]
’nsubgrids’ : Number of subgrids ‘subgridid’ : list of subgrids id ‘subgrid’ : list of subgrids details {‘id’, ‘ax’, ‘ay’}
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Get grid for ME record in file >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> rec = rmn.fstlir(funit, nomvar='ME') >>> rec['iunit'] = funit >>> gridid = rmn.ezqkdef(rec) >>> rmn.fstcloseall(funit) >>> >>> # Get axes values for the grid >>> axes = rmn.gdgaxes(gridid) >>> print("# Got grid axes of shape: {0}, {1}" ... .format(str(axes['ax'].shape), str(axes['ay'].shape))) # Got grid axes of shape: (201, 1), (1, 100)
See also
ezgprm ezgxprm ezgfstp ezget_nsubgrids ezget_subgridids ezqkdef rpnpy.librmn.grids.decodeGrid rpnpy.librmn.grids.readGrid rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall
-
rpnpy.librmn.interp.
gdgetmask
(gdid, mask=None)¶ Returns the mask associated with grid ‘gdid’
Note that if no mask was previouly set on this grid, gdgetmask will raise an EzscintError
mask = gdgetmask(gdid) mask = gdgetmask(gdid, mask) mask = gdgetmask(griddict, mask) mask = gdgetmask(griddict)
Parameters: - gdid – id of the grid (int)
- mask – mask array (numpy.ndarray)
- griddict – dict with keys ‘id’ : id of the grid (int) ‘mask’ : (optional) mask array (numpy.ndarray)
Returns: mask array (numpy.ndarray)
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import numpy as np >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> mgRec = rmn.fstlir(funit, nomvar='MG') >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Set a mask >>> mask = np.rint(mgRec['d']).astype(np.intc) >>> rmn.gdsetmask(inGrid['id'], mask) >>> # ... >>> >>> # Get the mask back >>> mask2 = rmn.gdgetmask(inGrid['id'])
See also
gdsetmask rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdll
(gdid, lat=None, lon=None)¶ Gets the latitude/longitude position of grid ‘gdid’
gridLatLon = gdll(gdid) gridLatLon = gdll(gdid, lat, lon) gridLatLon = gdll(gdid, gridLatLon) gridLatLon = gdll(griddict)
Parameters: - gdid – id of the grid (int)
- lon (lat,) – (optional) 2 pre-allocated lat, lon arrays (numpy.ndarray)
- gridLatLon – (optional) gridLatLon[‘lat’], gridLatLon[‘lon’] are 2 pre-allocated lat, lon arrays (numpy.ndarray)
- griddict – dict with minimally key ‘id’ as id of the grid optionnaly keys ‘lat’ and ‘lon’ can be provided as 2 pre-allocated lat, lon arrays (numpy.ndarray)
Returns: - {
‘id’ : grid id, same as input arg ‘lat’ : latitude data (numpy.ndarray)
same as gridLatLon[‘subgrid’][0][‘lat’]
- ’lon’ : longitude data (numpy.ndarray)
same as gridLatLon[‘subgrid’][0][‘lon’]
’nsubgrids’ : Number of subgrids ‘subgridid’ : list of subgrids id ‘subgrid’ : list of subgrids {‘id’, ‘lat’, ‘lon’}
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> grid = rmn.defGrid_G(90, 45) >>> lalo = rmn.gdll(grid['id']) >>> (i, j) = (45, 20) >>> print("# Lat, Lon of point {0}, {1} is: {2:4.1f}, {3:5.1f}" ... .format(i, j, lalo['lat'][i,j], lalo['lon'][i,j])) # Lat, Lon of point 45, 20 is: -7.9, 180.0
See also
gdxyfll gdllfxy rpnpy.librmn.grids
-
rpnpy.librmn.interp.
gdllfxy
(gdid, xpts=None, ypts=None)¶ Returns the lat-lon coordinates of data located at positions x-y on grid GDID
Note that provided grid points coor. are considered to be Fortran indexing, from 1 to ni and from 1 to nj While numpy/C indexing starts from 0
pointLL = gdllfxy(gdid, xpts, ypts) pointLL = gdllfxy(gdid, xypts) pointLL = gdllfxy(griddict, xpts, ypts) pointLL = gdllfxy(griddict)
Parameters: - gdid – id of the grid (int)
- ypts (xpts,) – list of points x, y coor (list, tuple or numpy.ndarray)
- xypts – xypts[‘xpts’], xypts[‘ypts’] are 2 pre-allocated xpts, ypts arrays (numpy.ndarray)
- griddict – dict with keys ‘id’ : id of the grid (int) ‘xpts’ : (optional) list of points x coor (list, tuple or numpy.ndarray) ‘ypts’ : (optional) list of points y coor (list, tuple or numpy.ndarray)
Returns: - {
‘id’ : grid id, same as input arg ‘lat’ : list of points lat-coor (numpy.ndarray) ‘lon’ : list of points lon-coor (numpy.ndarray)
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> grid = rmn.defGrid_G(90, 45) >>> (i, j) = (69, 34) >>> lalo = rmn.gdllfxy(grid['id'], [i], [j]) >>> print("# Lat, Lon of point {0}, {1} is: {2:4.1f}, {3:5.1f}" ... .format(i, j, lalo['lat'][0], lalo['lon'][0])) # Lat, Lon of point 69, 34 is: 43.5, 272.0
See also
gdll gdxyfll rpnpy.librmn.grids
-
rpnpy.librmn.interp.
gdllsval
(gdid, lat, lon, zin, zout=None)¶ Scalar interpolation to points located at lat-lon coordinates
zout = gdllsval(gdid, lat, lon, zin) zout = gdllsval(gdid, lat, lon, zin, zout)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- lat – list of resquested points lat (list or numpy.ndarray)
- lon – list of resquested points lon (list or numpy.ndarray)
- zin – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- zout – optional, interp.result array, same shape a lat, lon (numpy.ndarray)
Returns: numpy.ndarray, interpolation result, same shape a lat, lon
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate ME to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> meValues = rmn.gdllsval(inGrid['id'], la,lo, meRec['d'])
See also
gdxysval gdllvval gdxyvval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdllvval
(gdid, lat, lon, uuin, vvin, uuout=None, vvout=None)¶ Vectorial interpolation to points located at lat-lon coordinates
(uuout, vvout) = gdllsval(gdid, lat, lon, uuin, vvin) (uuout, vvout) = gdllsval(gdid, lat, lon, uuin, vvin, uuout, vvout)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- lat – list of resquested points lat (list or numpy.ndarray)
- lon – list of resquested points lon (list or numpy.ndarray)
- vvin (uuin,) – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- vvout (uuout,) – optional, interp.result array, same shape a lat, lon (numpy.ndarray)
Returns: (uuout, vvout), tuple of 2 numpy.ndarray, interpolation result, same shape a lat, lon
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', '2009042700_000') >>> funit = rmn.fstopenall(myfile) >>> uuRec = rmn.fstlir(funit, nomvar='UU', ip1=93423264) >>> vvRec = rmn.fstlir(funit, nomvar='VV', ip1=uuRec['ip1'], ip2=uuRec['ip2']) >>> inGrid = rmn.readGrid(funit, uuRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate UV vectorially to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> (uu, vv) = rmn.gdllvval(inGrid['id'], la, lo, uuRec['d'], vvRec['d'])
See also
gdllsval gdxysval gdxyvval gdllwdval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdllwdval
(gdid, lat, lon, uuin, vvin, wsout=None, wdout=None)¶ Vectorial interpolation of points located at lat-lon coordinates, returned as speed and direction (WS and WD).
(ws, wd) = gdllwdval(gdid, lat, lon, uuin, vvin) (ws, wd) = gdllwdval(gdid, lat, lon, uuin, vvin, wsout, wdout)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- lat – list of resquested points lat (list or numpy.ndarray)
- lon – list of resquested points lon (list or numpy.ndarray)
- vvin (uuin,) – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- wdout (wsout,) – optional, interp.result array, same shape a lat, lon wind-speed and wind-direction (numpy.ndarray)
Returns: (wsout, wdout), tuple of 2 numpy.ndarray, interpolation result, same shape a lat, lon
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples: >>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv(‘ATM_MODEL_DFILES’) >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), ‘bcmk’, ‘2009042700_000’) >>> funit = rmn.fstopenall(myfile) >>> uuRec = rmn.fstlir(funit, nomvar=’UU’, ip1=93423264) >>> vvRec = rmn.fstlir(funit, nomvar=’VV’, ip1=uuRec[‘ip1’], ip2=uuRec[‘ip2’]) >>> inGrid = rmn.readGrid(funit, uuRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate UV vectorially to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> (ws, wd) = rmn.gdllwdval(inGrid[‘id’], la, lo, uuRec[‘d’], vvRec[‘d’]) >>> print(“# (ws,wd) pt1:({}, {}) pt2:({}, {})” … .format(int(round(ws[0])), int(round(wd[0])), … int(round(ws[1])), int(round(wd[1])))) # (ws,wd) pt1:(8, 119) pt2:(12, 125)
See also
gdllsval gdxysval gdllvval gdxyvval gdxywdval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdrls
(gdid)¶ Frees a previously allocated grid
gdrls(gdid)
Parameters: gdid – grid id to free/release (int, list or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
Returns: None
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import rpnpy.librmn.all as rmn >>> >>> # Define a Grid >>> (ni, nj, lat0, lon0, dlat, dlon) = (200, 100, 35.,265.,0.25,0.25) >>> grid = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> >>> # Release memory associated with grid info >>> rmn.gdrls(grid)
See also
ezqkdef ezgdef_fmem rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdsetmask
(gdid, mask)¶ Associates a permanent mask with grid ‘gdid’
gdsetmask(gdid, mask)
Parameters: - gdid – grid id (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- mask – field mask (numpy.ndarray)
Returns: None
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import numpy as np >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> mgRec = rmn.fstlir(funit, nomvar='MG') >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Define a destination Grid >>> (lat0, lon0, dlat, dlon) = (35.,265.,0.25,0.25) >>> (ni, nj) = (200, 100) >>> outGrid = rmn.defGrid_L(ni, nj, lat0, lon0, dlat, dlon) >>> >>> # Set a masks over land only for input and output grids >>> inMask = np.rint(mgRec['d']).astype(np.intc) >>> rmn.gdsetmask(inGrid['id'], inMask) >>> mg = rmn.ezsint(outGrid['id'], inGrid['id'], mgRec['d']) >>> outMask = np.rint(mg).astype(np.intc) >>> rmn.gdsetmask(outGrid['id'], outMask)
See also
gdgetmask ezsint rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdxyfll
(gdid, lat=None, lon=None)¶ Returns the x-y positions of lat lon points on grid ‘gdid’
Note that provided grid points coor. are considered to be Fortran indexing, from 1 to ni and from 1 to nj While numpy/C indexing starts from 0
pointXY = gdxyfll(gdid, lat, lon) pointXY = gdxyfll(griddict, lat, lon) pointXY = gdxyfll(gdid, gridLaLo) pointXY = gdxyfll(griddict)
Parameters: - gdid – id of the grid (int)
- lon (lat,) – list of points lat, lon (list, tuple or numpy.ndarray)
- gridLaLo – (optional) gridLaLo[‘lat’], gridLaLo[‘lon’] are 2 pre-allocated lat, lon arrays (numpy.ndarray)
- griddict – dict with keys ‘id’ : id of the grid (int) ‘lat’ : (optional) list of points lon (list, tuple or numpy.ndarray) ‘lon’ : (optional) list of points lon (list, tuple or numpy.ndarray)
Returns: - {
‘id’ : grid id, same as input arg ‘x’ : list of points x-coor (numpy.ndarray) ‘y’ : list of points y-coor (numpy.ndarray)
}
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Example:
>>> import rpnpy.librmn.all as rmn >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> grid = rmn.defGrid_G(90, 45) >>> (la, lo) = (45., 273.) >>> xy = rmn.gdxyfll(grid['id'], [la], [lo]) >>> print("# x, y pos at lat={0}, lon={1} is: {2:5.2f}, {3:5.2f}" ... .format(la, lo, xy['x'][0], xy['y'][0])) # x, y pos at lat=45.0, lon=273.0 is: 69.25, 34.38
See also
gdllfxy gdll rpnpy.librmn.grids
-
rpnpy.librmn.interp.
gdxysval
(gdid, xpts, ypts, zin, zout=None)¶ Scalar intepolation to points located at x-y coordinates
Note that provided grid points coor. are considered to be Fortran indexing, from 1 to ni and from 1 to nj While numpy/C indexing starts from 0
zout = gdxysval(gdid, xpts, ypts, zin) zout = gdxysval(gdid, xpts, ypts, zin, zout)
Parameters: - gdid – id of the grid (int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- xpts – list of resquested points x-coor (list or numpy.ndarray)
- ypts – list of resquested points y-coor (list or numpy.ndarray)
- zin – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- zout – optional, interp.result array, same shape a xpts, ypts (numpy.ndarray)
Returns: numpy.ndarray, interpolation result, same shape a xpts, ypts
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', 'geophy.fst') >>> funit = rmn.fstopenall(myfile) >>> meRec = rmn.fstlir(funit, nomvar='ME') >>> inGrid = rmn.readGrid(funit, meRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate ME to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> xy = rmn.gdxyfll(inGrid['id'], la, lo) >>> meValues = rmn.gdxysval(inGrid['id'], xy['x'], xy['y'], meRec['d'])
See also
gdllsval gdllvval gdxyvval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdxyvval
(gdid, xpts, ypts, uuin, vvin, uuout=None, vvout=None)¶ Vectorial intepolation to points located at x-y coordinates
Note that provided grid points coor. are considered to be Fortran indexing, from 1 to ni and from 1 to nj While numpy/C indexing starts from 0
(uuout, vvout) = gdxysval(gdid, xpts, ypts, uuin, vvin) (uuout, vvout) = gdxysval(gdid, xpts, ypts, uuin, vvin, uuout, vvout)
Parameters: - gdid – id of the grid(int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- xpts – list of resquested points x-coor (list or numpy.ndarray)
- ypts – list of resquested points y-coor (list or numpy.ndarray)
- vvin (uuin,) – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- vvout (uuout,) – optional, interp.result array, same shape a xpts, ypts (numpy.ndarray)
Returns: numpy.ndarray, interpolation result, same shape a xpts, ypts
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples:
>>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv('ATM_MODEL_DFILES') >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), 'bcmk', '2009042700_000') >>> funit = rmn.fstopenall(myfile) >>> uuRec = rmn.fstlir(funit, nomvar='UU', ip1=93423264) >>> vvRec = rmn.fstlir(funit, nomvar='VV', ip1=uuRec['ip1'], ip2=uuRec['ip2']) >>> inGrid = rmn.readGrid(funit, uuRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate UV vectorially to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> xy = rmn.gdxyfll(inGrid['id'], la, lo) >>> (uu, vv) = rmn.gdxyvval(inGrid['id'], xy['x'], xy['y'], uuRec['d'], vvRec['d'])
See also
gdllsval gdxysval gdllvval gdllwdval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid
-
rpnpy.librmn.interp.
gdxywdval
(gdid, xpts, ypts, uuin, vvin, wsout=None, wdout=None)¶ Vectorial intepolation to points located at x-y coordinates returned as speed and direction (WS and WD).
Note that provided grid points coor. are considered to be Fortran indexing, from 1 to ni and from 1 to nj While numpy/C indexing starts from 0
(wsout, wdout) = gdxywdval(gdid, xpts, ypts, uuin, vvin) (wsout, wdout) = gdxywdval(gdid, xpts, ypts, uuin, vvin, wsout, wdout)
Parameters: - gdid – id of the grid(int or dict) Dict with key ‘id’ is accepted from version 2.0.rc1
- xpts – list of resquested points x-coor (list or numpy.ndarray)
- ypts – list of resquested points y-coor (list or numpy.ndarray)
- vvin (uuin,) – data to interpolate, on grid gdid (numpy.ndarray or dict) Dict with key ‘d’ is accepted from version 2.0.rc1
- wdout (wsout,) – optional, interp.result array, same shape a xpts, ypts wind-speed and wind-direction (numpy.ndarray)
Returns: (wsout, wdout), tuple of 2 numpy.ndarray, interpolation result, same shape a lat, lon
Raises: - TypeError on wrong input arg types
- EzscintError on any other error
Examples: >>> import os, os.path >>> import rpnpy.librmn.all as rmn >>> >>> # Read source data and define its grid >>> rmn.fstopt(rmn.FSTOP_MSGLVL,rmn.FSTOPI_MSG_CATAST) >>> ATM_MODEL_DFILES = os.getenv(‘ATM_MODEL_DFILES’) >>> myfile = os.path.join(ATM_MODEL_DFILES.strip(), ‘bcmk’, ‘2009042700_000’) >>> funit = rmn.fstopenall(myfile) >>> uuRec = rmn.fstlir(funit, nomvar=’UU’, ip1=93423264) >>> vvRec = rmn.fstlir(funit, nomvar=’VV’, ip1=uuRec[‘ip1’], ip2=uuRec[‘ip2’]) >>> inGrid = rmn.readGrid(funit, uuRec) >>> rmn.fstcloseall(funit) >>> >>> # Interpolate UV vectorially to a specific set of points >>> destPoints = ((35.5, 10.), (36., 10.5)) >>> la = [x[0] for x in destPoints] >>> lo = [x[1] for x in destPoints] >>> xy = rmn.gdxyfll(inGrid[‘id’], la, lo) >>> (ws, wd) = rmn.gdxywdval(inGrid[‘id’], xy[‘x’], xy[‘y’], uuRec[‘d’], vvRec[‘d’]) >>> print(“# (ws,wd) pt1:({}, {}) pt2:({}, {})” … .format(int(round(ws[0])), int(round(wd[0])), … int(round(ws[1])), int(round(wd[1])))) # (ws,wd) pt1:(8, 119) pt2:(12, 125)
See also
gdllsval gdxysval gdllvval gdxyvval gdllwdval ezsint ezuvint ezsetopt rpnpy.librmn.const rpnpy.librmn.fstd98.fstopenall rpnpy.librmn.fstd98.fstlir rpnpy.librmn.fstd98.fstcloseall rpnpy.librmn.grids.readGrid rpnpy.librmn.grids.defGrid_L rpnpy.librmn.grids.encodeGrid