Beispiel #1
0
def load(h):

    h.add(_.Ieeefloat('referenceValue', 4))
    h.add(
        _.Reference_value_error('referenceValueError', _.Get('referenceValue'),
                                _.Get('ieee')))
    h.add(_.Signed('binaryScaleFactor', 2))
    h.add(_.Signed('decimalScaleFactor', 2))
    h.add(_.Transient('optimizeScaleFactor', 0))
    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBits', 'bitsPerValue')
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')

    if h._gribex_mode_on():
        h.add(_.Transient('computeLaplacianOperator', 0))
    else:
        h.add(_.Transient('computeLaplacianOperator', 1))

    h.add(
        _.Spectral_truncation('_numberOfValues', _.Get('J'), _.Get('K'),
                              _.Get('M'), _.Get('numberOfValues')))
    h.add(_.Constant('laplacianScalingFactorUnset', -2147483647))
    h.add(_.Signed('laplacianScalingFactor', 4))
    h.add(
        _.Scale('laplacianOperator', _.Get('laplacianScalingFactor'),
                _.Get('one'), _.Get('million'), _.Get('truncateLaplacian')))
    h.alias('data.laplacianOperator', 'laplacianOperator')
    h.add(
        _.Evaluate(
            'laplacianOperatorIsSet',
            _.And((_.Get('laplacianScalingFactor') !=
                   _.Get('laplacianScalingFactorUnset')),
                  _.Not(_.Get('computeLaplacianOperator')))))
    h.add(_.Transient('JS', 20))
    h.add(_.Transient('KS', 20))
    h.add(_.Transient('MS', 20))
    h.add(_.Transient('subSetJ', 0))
    h.add(_.Transient('subSetK', 0))
    h.add(_.Transient('subSetM', 0))
    h.add(_.Unsigned('TS', 4))
    h.add(
        _.Spectral_truncation('_TS', _.Get('J'), _.Get('K'), _.Get('M'),
                              _.Get('TS')))
    h.add(
        _.Codetable('unpackedSubsetPrecision', 1, "5.7.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.alias('precisionOfTheUnpackedSubset', 'unpackedSubsetPrecision')
Beispiel #2
0
def load(h):

    h.add(_.Ieeefloat('referenceValue', 4))
    h.add(
        _.Reference_value_error('referenceValueError', _.Get('referenceValue'),
                                _.Get('ieee')))
    h.add(_.Signed('binaryScaleFactor', 2))
    h.add(_.Signed('decimalScaleFactor', 2))
    h.add(_.Transient('optimizeScaleFactor', 0))
    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBits', 'bitsPerValue')
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
    h.add(_.Transient('computeLaplacianOperator', 1))
    h.add(
        _.Codetable('biFourierSubTruncationType', 1, "5.25.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('biFourierPackingModeForAxes', 1, "5.26.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Constant('laplacianScalingFactorUnset', -2147483647))
    h.add(_.Signed('laplacianScalingFactor', 4))
    h.add(
        _.Scale('laplacianOperator', _.Get('laplacianScalingFactor'),
                _.Get('one'), _.Get('million'), _.Get('truncateLaplacian')))
    h.alias('data.laplacianOperator', 'laplacianOperator')
    h.add(
        _.Evaluate(
            'laplacianOperatorIsSet',
            _.And((_.Get('laplacianScalingFactor') !=
                   _.Get('laplacianScalingFactorUnset')),
                  _.Not(_.Get('computeLaplacianOperator')))))
    h.add(_.Unsigned('biFourierResolutionSubSetParameterN', 2))
    h.add(_.Unsigned('biFourierResolutionSubSetParameterM', 2))
    h.add(_.Unsigned('totalNumberOfValuesInUnpackedSubset', 4))
    h.add(
        _.Codetable('unpackedSubsetPrecision', 1, "5.7.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.alias('precisionOfTheUnpackedSubset', 'unpackedSubsetPrecision')
def load(h):

    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
    h.add(_.Constant('PUnset', -32767))
    h.add(_.Unsigned('N', 2))
    h.add(_.Signed('P', 2))
    h.add(_.Unsigned('JS', 1))
    h.add(_.Unsigned('KS', 1))
    h.add(_.Unsigned('MS', 1))
    h.alias('subSetJ', 'JS')
    h.alias('subSetK', 'KS')
    h.alias('subSetM', 'MS')
    h.add(_.Constant('GRIBEXShBugPresent', 1))
    h.add(_.Transient('computeLaplacianOperator', 0))
    h.add(
        _.Scale('laplacianOperator', _.Get('P'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateLaplacian')))
    h.alias('data.laplacianOperator', 'laplacianOperator')
    h.add(
        _.Evaluate(
            'laplacianOperatorIsSet',
            _.And((_.Get('P') != _.Get('PUnset')),
                  _.Not(_.Get('computeLaplacianOperator')))))

    if h.get_l('localUsePresent'):

        if h._changed('localDefinitionNumber'):
            h.add(_.Transient('TS', 0))
            h.add(
                _.Spectral_truncation('TScalc', _.Get('JS'), _.Get('KS'),
                                      _.Get('MS'), _.Get('TS')))
            h.add(
                _.Octect_number('Nassigned', _.Get('N'),
                                (4 * _.Get('TScalc'))))

    h.add(_.Position('offsetBeforeData'))
    h.add(
        _.Data_g1complex_packing('values', _.Get('section4Length'),
                                 _.Get('offsetBeforeData'),
                                 _.Get('offsetSection4'), _.Get('unitsFactor'),
                                 _.Get('unitsBias'),
                                 _.Get('changingPrecision'),
                                 _.Get('numberOfCodedValues'),
                                 _.Get('bitsPerValue'),
                                 _.Get('referenceValue'),
                                 _.Get('binaryScaleFactor'),
                                 _.Get('decimalScaleFactor'),
                                 _.Get('optimizeScaleFactor'),
                                 _.Get('GRIBEXShBugPresent'),
                                 _.Get('ieeeFloats'),
                                 _.Get('laplacianOperatorIsSet'),
                                 _.Get('laplacianOperator'), _.Get('subSetJ'),
                                 _.Get('subSetK'), _.Get('subSetM'),
                                 _.Get('pentagonalResolutionParameterJ'),
                                 _.Get('pentagonalResolutionParameterK'),
                                 _.Get('pentagonalResolutionParameterM'),
                                 _.Get('halfByte'), _.Get('N'),
                                 _.Get('packingType'), _.Get('spectral_ieee'),
                                 _.Get('precision')))
    h.add(
        _.Data_sh_packed('packedValues', _.Get('section4Length'),
                         _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                         _.Get('unitsFactor'), _.Get('unitsBias'),
                         _.Get('changingPrecision'),
                         _.Get('numberOfCodedValues'), _.Get('bitsPerValue'),
                         _.Get('referenceValue'), _.Get('binaryScaleFactor'),
                         _.Get('decimalScaleFactor'),
                         _.Get('optimizeScaleFactor'),
                         _.Get('GRIBEXShBugPresent'), _.Get('ieeeFloats'),
                         _.Get('laplacianOperatorIsSet'),
                         _.Get('laplacianOperator'), _.Get('subSetJ'),
                         _.Get('subSetK'), _.Get('subSetM'),
                         _.Get('pentagonalResolutionParameterJ'),
                         _.Get('pentagonalResolutionParameterK'),
                         _.Get('pentagonalResolutionParameterM')))
    h.alias('data.packedValues', 'packedValues')
    h.add(
        _.Data_sh_unpacked('unpackedValues', _.Get('section4Length'),
                           _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                           _.Get('unitsFactor'), _.Get('unitsBias'),
                           _.Get('changingPrecision'),
                           _.Get('numberOfCodedValues'), _.Get('bitsPerValue'),
                           _.Get('referenceValue'), _.Get('binaryScaleFactor'),
                           _.Get('decimalScaleFactor'),
                           _.Get('optimizeScaleFactor'),
                           _.Get('GRIBEXShBugPresent'), _.Get('ieeeFloats'),
                           _.Get('laplacianOperatorIsSet'),
                           _.Get('laplacianOperator'), _.Get('subSetJ'),
                           _.Get('subSetK'), _.Get('subSetM'),
                           _.Get('pentagonalResolutionParameterJ'),
                           _.Get('pentagonalResolutionParameterK'),
                           _.Get('pentagonalResolutionParameterM')))
    h.alias('data.unpackedValues', 'unpackedValues')
    h.add(
        _.Simple_packing_error('packingError', _.Get('bitsPerValue'),
                               _.Get('binaryScaleFactor'),
                               _.Get('decimalScaleFactor'),
                               _.Get('referenceValue'), _.Get('ibm')))
    h.add(
        _.Simple_packing_error('unpackedError', _.Get('zero'),
                               _.Get('binaryScaleFactor'),
                               _.Get('decimalScaleFactor'),
                               _.Get('referenceValue'), _.Get('ibm')))
    h.add(
        _.G1number_of_coded_values_sh_complex('numberOfCodedValues',
                                              _.Get('bitsPerValue'),
                                              _.Get('offsetBeforeData'),
                                              _.Get('offsetAfterData'),
                                              _.Get('halfByte'),
                                              _.Get('numberOfValues'),
                                              _.Get('subSetJ'),
                                              _.Get('subSetK'),
                                              _.Get('subSetM')))
    _.Template('common/statistics_spectral.def').load(h)
Beispiel #4
0
def load(h):

    h.add(_.Position('offsetSection2'))
    h.add(_.Section_length('section2Length', 3))
    h.add(_.Section_pointer('section2Pointer', _.Get('offsetSection2'), _.Get('section2Length'), 2))
    h.add(_.Transient('radius', 6367470))
    h.alias('radiusOfTheEarth', 'radius')
    h.alias('radiusInMetres', 'radius')
    h.add(_.Transient('shapeOfTheEarth', 6))
    h.add(_.Unsigned('numberOfVerticalCoordinateValues', 1))
    h.add(_.Constant('neitherPresent', 255))
    h.alias('NV', 'numberOfVerticalCoordinateValues')
    h.alias('numberOfCoordinatesValues', 'numberOfVerticalCoordinateValues')
    h.add(_.Unsigned('pvlLocation', 1))
    h.add(_.Codetable('dataRepresentationType', 1, "grib1/6.table"))
    h.add(_.Codetable_title('gridDefinitionDescription', _.Get('dataRepresentationType')))
    h.alias('isRotatedGrid', 'zero')

    if (h.get_l('dataRepresentationType') < 192):
        _.Template('grib1/grid_definition_[dataRepresentationType:l].def').load(h)
    else:
        _.Template('grib1/grid_definition_[dataRepresentationType:l].[centre:l].def').load(h)

    h.add(_.Position('endGridDefinition'))
    h.add(_.Position('offsetBeforePV'))
    h.add(_.Transient('PVPresent', (_.Get('NV') > 0)))

    if (h.get_l('pvlLocation') != h.get_l('neitherPresent')):
        h.add(_.Padto('padding_sec2_2', ((_.Get('offsetSection2') + _.Get('pvlLocation')) - 1)))
    else:
        h.add(_.Padto('padding_sec2_2', (_.Get('offsetSection2') + 32)))

    if h.get_l('PVPresent'):
        h.add(_.Ibmfloat('pv', 4, _.Get('NV')))
        h.alias('vertical.pv', 'pv')

    h.add(_.Position('offsetBeforePL'))
    h.add(_.Transient('PLPresent', _.And((_.Get('section2Length') > (_.Get('offsetBeforePL') - _.Get('offsetSection2'))), (_.Get('section2Length') >= (((_.Get('Nj') * 2) + _.Get('offsetBeforePL')) - _.Get('offsetSection2'))))))

    if h.get_l('PLPresent'):
        h.add(_.Constant('numberOfOctectsForNumberOfPoints', 2))
        h.add(_.Constant('interpretationOfNumberOfPoints', 1))
        h.add(_.Unsigned('pl', 2, _.Get('Nj')))
        h.alias('geography.pl', 'pl')

    if ((h.get_l('PVPresent') == 0) and (h.get_l('PLPresent') == 0)):
        h.add(_.Padto('padding_sec2_1', (_.Get('offsetSection2') + 32)))

    pass  # when block
    pass  # when block
    h.alias('reducedGrid', 'PLPresent')

    def deletePV_inline_concept(h):
        def wrapped(h):

            PVPresent = h.get_l('PVPresent')
            NV = h.get_l('NV')

            if PVPresent == 0 and NV == 0:
                return 1

        return wrapped

    h.add(_.Concept('deletePV', 'unknown', concepts=deletePV_inline_concept(h)))

    h.add(_.Padtoeven('padding_sec2_3', _.Get('offsetSection2'), _.Get('section2Length')))
    h.add(_.Md5('md5Section2', _.Get('offsetSection2'), _.Get('section2Length')))
    h.alias('md5GridSection', 'md5Section2')