griberies — utilities around GRIB

Contains utilities around GRIB format.


class griberies.GribDef(actual_init=True, concepts=[])[source]

Bases: object

known_names(*args, **kwargs)[source]

Get sorted list of names for all concepts.

known_names_for_concept(*args, **kwargs)[source]

Get sorted list of names for concept.

known_values(concept=None, grib_edition='grib2')[source]

Get list of all values present throughout the GribDef for all keys.

known_values_for(*args, **kwargs)[source]

Get list of all values present throughout the GribDef for key.

read(filename, grib_edition=None)[source]

Read a grib def concept file, and update or register it.


functions

griberies.complete_grib_paths(rootdir, api_name, reset=False)[source]

Complete [GRIB|ECCODES]_SAMPLES_PATH and [GRIB|ECCODES]_DEFINITION_PATH according to rootdir installation path of GRIB API api_name.

Parameters:
  • rootdir – the directory in which is installed the API
  • api_name – the name of the GRIB API, among (‘eccodes’, ‘grib_api’)
  • reset – ignore predefined values of the variables

Reconstructed path are $rootdir$/share/$api_name$/samples and $rootdir$/share/$api_name$/definitions

griberies.complete_grib_samples_paths(rootdir, api_name, reset=False)[source]

Complete [GRIB|ECCODES]_SAMPLES_PATH according to rootdir installation path of GRIB API api_name.

Parameters:
  • rootdir – the directory in which is installed the API
  • api_name – the name of the GRIB API, among (‘eccodes’, ‘grib_api’)
  • reset – ignore predefined values of the variables

Reconstructed path is $rootdir$/share/$api_name$/samples

griberies.complete_grib_definition_paths(rootdir, api_name, reset=False)[source]

Complete [GRIB|ECCODES]_DEFINITION_PATH according to rootdir installation path of GRIB API api_name.

Parameters:
  • rootdir – the directory in which is installed the API
  • api_name – the name of the GRIB API, among (‘eccodes’, ‘grib_api’)
  • reset – ignore predefined values of the variables

Reconstructed path are $rootdir$/share/$api_name$/definitions

griberies.set_definition_path(path, api_name='eccodes', reset=False)[source]

Set path to GRIB|ECCODES_DEFINITION_PATH.

Parameters:
  • api_name – the name of the GRIB API, among (‘eccodes’, ‘grib_api’)
  • reset – ignore predefined values of the variables
griberies.get_samples_paths()[source]

Get the environment-variable-set path to samples

griberies.get_definition_paths()[source]

Get the environment-variable-set path to definitions

griberies.parse_GRIBstr_todict(strfid)[source]

Parse and return a dict GRIB fid from a string.

griberies.read_gribdef(filename)[source]

Read a grib definition file and return it as a dict.


tables

griberies.tables.productionStatusOfProcessedData_dict = {'dble': 1, 'oper': 0, 'research': 2, 'test': 2, 'unknown': 255}

Aliases to productionStatusOfProcessedData numbers

griberies.tables.typeOfGeneratingProcess_dict = {'Analysis': 0, 'Analysis error': 7, 'Bias corrected forecast': 3, 'Bias-corrected ensemble forecast': 11, 'Climatological': 9, 'Ensemble forecast': 4, 'Forecast': 2, 'Forecast error': 6, 'Hindcast': 15, 'Initialization': 1, 'Nowcast': 14, 'Observation': 8, 'Post-processed analysis': 12, 'Post-processed forecast': 13, 'Probability forecast': 5, 'Probability-weighted forecast': 10, 'unknown': 255}

Aliases to typeOfGeneratingProcess numbers

griberies.tables.pyproj_geoid_shapes = {0: {'a': 6367470.0, 'b': 6367470.0}, 2: {'a': 6378160.0, 'rf': 297.0}, 4: {'ellps': 'GRS80'}, 5: {'ellps': 'WGS84'}, 6: {'a': 6371229.0, 'b': 6371229.0}, 8: {'a': 6371200.0, 'b': 6371200.0}, 9: {'ellps': 'airy'}}

Geoid shapes for pyproj

griberies.tables.statistical_processes = {0: 'average', 1: 'accumulation', 2: 'maximum', 3: 'minimum', 4: 'difference', 5: 'rms', 6: 'stdev', 7: 'covariance', 8: '-difference', 9: 'ratio', 10: 'summation', 11: 'standardized anomaly'}

Type of statistical process over a duration

griberies.tables.typeoffixedsurface2sample = {1: 'sfc', 100: 'pl', 119: 'ml'}

Equivalence between typeOf[First|Second]FixedSurface and abbreviation in samples


defaults

griberies.defaults.GRIB2_keyvalue = {1: {'productionStatusOfProcessedData': 2, 'tablesVersion': 15, 'typeOfProcessedData': 2}, 2: {}, 3: {'iScansNegatively': 0, 'jPointsAreConsecutive': 0, 'jScansPositively': 0, 'shapeOfTheEarth': 6}, 4: {'NB': 1, 'generatingProcessIdentifier': 255, 'hoursAfterDataCutoff': None, 'indicatorOfUnitForTimeIncrement': 13, 'indicatorOfUnitForTimeRange': 13, 'indicatorOfUnitOfTimeRange': 13, 'instrumentType': 0, 'minutesAfterDataCutoff': None, 'satelliteNumber': 0, 'satelliteSeries': 0, 'scaleFactorOfCentralWaveNumber': 0, 'scaleFactorOfFirstFixedSurface': 0, 'scaleFactorOfSecondFixedSurface': 0, 'typeOfGeneratingProcess': 2, 'typeOfSecondFixedSurface': 255}, 5: {'bitsPerValue': 12, 'packingType': 'grid_second_order'}}

GRIB2 key/value defaults, ordered by section

griberies.defaults.GRIB2_metadata_to_embark = ['typeOfGeneratingProcess', 'productionStatusOfProcessedData', 'typeOfProcessedData', 'generatingProcessIdentifier', 'typeOfTimeIncrement', 'indicatorOfUnitOfTimeRange', 'indicatorOfUnitForTimeRange', 'indicatorOfUnitForTimeIncrement', 'hoursAfterDataCutoff', 'minutesAfterDataCutoff', 'timeIncrement', 'bitsPerValue', 'dataRepresentationTemplateNumber']

metadata to embark in field.misc_metadata

griberies.defaults.GRIB1_sample = 'GRIB1_grid_second_order'

GRIB1 sample (from epygram)

griberies.defaults.GRIB1_packing = {'bitsPerValue': 16, 'packingType': 'grid_second_order'}

packing

griberies.defaults.GRIB1_ordering = {'iScansNegatively': 0, 'jPointsAreConsecutive': 0, 'jScansPositively': 0}

ordering

griberies.defaults.GRIB1_keyvalue = {'generatingProcessIdentifier': 255}

GRIB1 key/value defaults, ordered by section