HWRF
trunk@4391
|
Describes regribbing operations using an algebraic structure. More...
Describes regribbing operations using an algebraic structure.
This module provides an object-oriented interface to the low-level GRIB manipulation routines in produtil.gribop. It also sits on top of the produtil.datastore module, providing a means to grab GRIB files from Task and Product objects, processing them upon availability.
Classes | |
class | FixedLocation |
Represents a specific location on the earth as a latitude, longitude pair. More... | |
class | GRIB1Fetcher |
The GRIB1Fetcher is a GRIB1Op subclass that fetches a GRIB1 file from a RegribMany. More... | |
class | GRIB1File |
This subclass of GRIB1Op represents a GRIB1 file on disk that is ALREADY PRESENT. More... | |
class | GRIB1Op |
This subclass of GRIBOp produces GRIB1 files. More... | |
class | GRIB1Product |
This class represents a GRIB1 file produced by this workflow. More... | |
class | GRIB1Selector |
This object produces a GRIB1Op from a call to a Task object's Task.product. More... | |
class | GRIB2File |
This subclass of GRIB2Op represents a GRIB2 file on disk that is ALREADY PRESENT. More... | |
class | GRIB2Op |
This subclass of GRIBOp produces GRIB2 files, and can be converted to GRIB1 via obj*GRIB1 or obj.to_grib1(). More... | |
class | GRIB2Product |
This class represents a GRIB2 file that is produced by this workflow. More... | |
class | GRIBBase |
Base class for the regridding object tree. More... | |
class | GRIBGrid |
This class represents a GRIB1 or GRIB2 grid specification. More... | |
class | GRIBGridBase |
This abstract base class represents something that is able to produce a GRIBGrid object when make() is called. More... | |
class | GRIBGridCompute |
This class represents a GRIBGrid that must be computed from some other input, usually a GRIB file. More... | |
class | GRIBGridFetcher |
This class represents a GRIBGrid that is stored in a RegribMany object. More... | |
class | GRIBOp |
This is the abstract base class for all GRIB1 and GRIB2 files and operators. More... | |
class | GRIBSubsetter |
A GRIBBase that subsets GRIB files, keeping only certain parameters. More... | |
class | GRIBSubsetterFetcher |
This class grabs a GRIBSubsetter from a RegribMany object. More... | |
class | Regrib |
This is a helper class intended to be used internally by RegribMany. More... | |
class | RegribBase |
This is the abstract base class of Regrib and RegribMany and should not be instantiated directly. More... | |
class | RegribMany |
Runs regrib operations on many input times, sending output to an hwrf.gribtask.GRIBTask. More... | |
class | UpstreamGRIB1 |
This subclass of GRIB1Op and UpstreamFile represents a GRIB1 file that is produced by an upstream workflow. More... | |
Functions | |
def | checkgrib (regrib, filename) |
Internal function for validating GRIB files. More... | |
def | action_grib1to2 (op, regrib, infile, args, kwargs) |
Converts GRIB1 file to GRIB2. More... | |
def | action_grib2to1 (op, regrib, infile, args, kwargs) |
Converts GRIB2 files to GRIB1. More... | |
def | action_grib1regridmerge (op, regrib, grid, in1, in2, kwargs) |
Performs regridding and merges two files in a single operation. More... | |
def | action_grbindex (op, regrib, ingrib, task=None, kwargs) |
Runs the grbindex program on a GRIB1 file. More... | |
def | action_grib1merge (op, regrib, in1, in2, kwargs) |
Merges two GRIB1 files that must already have the same grid. More... | |
def | action_grib1regrid (op, regrib, infile, ingrid, args, kwargs) |
Regrids a GRIB1 file. More... | |
def | action_grib1subset (op, regrib, infile, subsetter, args, kwargs) |
Subsets a GRIB1 file. More... | |
def | action_clatlon (op, regrib, name, center, nsres, ewres, nssize, ewsize, nscount, ewcount, scan, kwargs) |
Generates a latitude-longitude grid centered on a GRIB file or specified point. More... | |
def | clatlon |
Create a GRIBGridCompute that makes a lat-lon grid. More... | |
def | igrb1 (task, kwargs) |
This is a convenient alias for the GRIB1Selector constructor. More... | |
Variables | |
list | __all__ |
List of symbols to export by "from hwrf.regrib import *". More... | |
int | GRIB1 = 1 |
Constant used to represent a request to convert GRIB files to GRIB version 1. More... | |
int | GRIB2 = 2 |
Constant used to represent a request to convert GRIB files to GRIB version 2. More... | |
int | GRIB_FILE_MIN_SIZE = 8 |
Eight bytes: the minimum required size of a non-empty GRIB1 or GRIB2 file. More... | |
tuple | quarterDegree = GRIBGrid('Quarter_Degree_Grid_193','193',None) |
A special GRIBGrid representing grid 193, which is a quarter degree regular lat-lon grid the NCEP GFS model uses as output. More... | |
def hwrf.regrib.action_clatlon | ( | op, | |
regrib, | |||
name, | |||
center, | |||
nsres, | |||
ewres, | |||
nssize, | |||
ewsize, | |||
nscount, | |||
ewcount, | |||
scan, | |||
kwargs | |||
) |
Generates a latitude-longitude grid centered on a GRIB file or specified point.
This is an internal implementation function that should not be called directly. It queries the center object's nscenter and ewcenter properties to get the objects location. It then adds a border around that, creating a GRIB1 grid 255 grid specification centered on the center
object.
op | The GRIBBase operation running this funciton. |
center | The GRIBBase operation on which to center the grid |
regrib | a Regrib for data information |
name | the name of the resulting grid, for storage in a RegribMany |
nsres,ewres | GRIB1 grid 255 resolution information |
nssize,ewsize | GRIB1 grid 255 size information, but in degrees. It will be converted to millidegrees for passing to underlying GRIB manipulation programs. |
nscount,ewcount | Number of gridpoints in each direction, for the GRIB1 grid 255 information. |
scan | GRIB1 grid 255 scanning mode byte |
kwargs | Ignored |
Definition at line 1059 of file regrib.py.
Referenced by hwrf.regrib.action_grib1subset().
def hwrf.regrib.action_grbindex | ( | op, | |
regrib, | |||
ingrib, | |||
task = None , |
|||
kwargs | |||
) |
Runs the grbindex program on a GRIB1 file.
This is a low-level implementation function. It should not be called directly. This function adds a grbindex output to the specified input file's product, unless one is already available. Unlike most action_* functions, this one does not create a new GRIBFile or GRIBProduct, instead it modifies the existing one to add the location of the grbindex output.
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
ingrib | The input GRIBBase that represents the input file. |
task | An hwrf.hwrftask.HWRFTask to provide the path to grbindex |
kwargs | Ignored |
def hwrf.regrib.action_grib1merge | ( | op, | |
regrib, | |||
in1, | |||
in2, | |||
kwargs | |||
) |
Merges two GRIB1 files that must already have the same grid.
This is a low-level implementation function. It should not be called directly. This function is sent as a parameter to GRIB1Op to do a copygb merge (-xM) of two GRIB1 files to produce a single GRIB1 file. It requires that at least one of the files have a known grid, and if both have a known grid then their grids must mach.
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
in1,in2 | The input GRIBGrid objects that provide filenames |
kwargs | Ignored |
def hwrf.regrib.action_grib1regrid | ( | op, | |
regrib, | |||
infile, | |||
ingrid, | |||
args, | |||
kwargs | |||
) |
Regrids a GRIB1 file.
This is a low-level implementation function. It should not be called directly. This is sent as a parameter to GRIB1Op to convert a GRIB1 file from one grid to another. The output has a known grid, so it can be sent into an action_grib1merge.
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
infile | The input filename. |
ingrid | Input GRIB1Grid that specifies the target grid. |
args,kwargs | Ignored |
def hwrf.regrib.action_grib1regridmerge | ( | op, | |
regrib, | |||
grid, | |||
in1, | |||
in2, | |||
kwargs | |||
) |
Performs regridding and merges two files in a single operation.
This is a low-level implementation function. It should not be called directly. This function is sent as a parameter to GRIB1Op to do a copygb regrid AND merge in a single operation (one call to the copygb program). The grid argument is the target grid, and the in1 and in2 arguments are the input GRIB1 files.
def hwrf.regrib.action_grib1subset | ( | op, | |
regrib, | |||
infile, | |||
subsetter, | |||
args, | |||
kwargs | |||
) |
Subsets a GRIB1 file.
This is a low-level implementation function. It should not be called directly. It subsets a GRIB1 file infile using the given subsetter. The subsetter should have a list of strings accessible via subsetter.grib1sub. It should also have a name accessible through subsetter.subsetname. The wgrib -s output of infile is scanned. Any line in wgrib -s's output that contains the entirety of any line in the subsetter.grib1sub is retained. The subsetting is done via wgrib -i -grib (infile) -o (outfile).
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
infile | The input filename. |
subsetter | A GRIBSubsetter that chooses the fields to keep. |
args,kwargs | Ignored |
def hwrf.regrib.action_grib1to2 | ( | op, | |
regrib, | |||
infile, | |||
args, | |||
kwargs | |||
) |
Converts GRIB1 file to GRIB2.
This is a low-level implementation function. It should not be called directly. This function is sent as a parameter to GRIB1Op to produce a GRIB2 version of a GRIB1 file. It uses regrib.cnvgrib_g12 to perform the conversion.
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
infile | The input filename. |
args,kwargs | Ignored |
def hwrf.regrib.action_grib2to1 | ( | op, | |
regrib, | |||
infile, | |||
args, | |||
kwargs | |||
) |
Converts GRIB2 files to GRIB1.
This is a low-level implementation function. It should not be called directly. This function is sent as a parameter to GRIB2Op to produce a GRIB1 version of a GRIB2 file. It uses regrib.cnvgrib_g21 to do the conversion.
op | The GRIBBase operation running this funciton. |
regrib | a Regrib for data information |
infile | The input filename. |
args,kwargs | Ignored |
def hwrf.regrib.checkgrib | ( | regrib, | |
filename | |||
) |
Internal function for validating GRIB files.
This is a low-level implementation function. It should not be called directly. This checks a file to make sure it exists, is a regular file (or symlink to a regular file) and is large enough to plausibly contain some GRIB1 or GRIB2 data. Returns True for such plausible files and False otherwise. Does not open the file, and performs only a single stat. Uses errno ENOENT (no such file or directory) and ELOOP (too many symbolic links) to detect non-existence. Other exceptions will be passed to the caller.
regrib | a regrib for logging information |
filename | the name of the file of interest |
Definition at line 731 of file regrib.py.
Referenced by hwrf.regrib.action_grib1merge(), hwrf.regrib.action_grib1regrid(), and hwrf.regrib.action_grib1regridmerge().
def hwrf.regrib.clatlon | ( | center, | |
res, | |||
size, | |||
n, | |||
scan = 136 , |
|||
name = None |
|||
) |
Create a GRIBGridCompute that makes a lat-lon grid.
Returns a GRIBGridCompute that will produce a lat-lon grid centered on the given object. The provided object must have nscenter and ewcenter properties that produce real lats and lons that are positive North and positive East. The res parameter is a two element array containing the resolution in degrees.
name | the new grid's name |
center | An object on which to center. Must have nscenter and ewcenter properties. |
res | The GRIB1 grid 255 resolution information in a two-element array. |
size | The size parameter is a two-element array containing the extent in degrees. |
n | The n parameter contains the number of gridpoints. |
scan | The "scan" parameter is the scanning mode parameter: 128 means E-W are reversed, 64 means N-S are reversed, and 32 means the data is transposed. |
def hwrf.regrib.igrb1 | ( | task, | |
kwargs | |||
) |
This is a convenient alias for the GRIB1Selector constructor.
task,kwargs | Passed to GRIB1Selector.__init__() |
hwrf.regrib.__all__ |
hwrf.regrib.GRIB1 = 1 |
hwrf.regrib.GRIB2 = 2 |
hwrf.regrib.GRIB_FILE_MIN_SIZE = 8 |