Esempio n. 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')
    h.add(_.Unsigned('matrixBitmapsPresent', 1))
    h.alias('secondaryBitmapPresent', 'matrixBitmapsPresent')
    h.add(_.Unsigned('numberOfCodedValues', 4))
    h.add(_.Unsigned('firstDimension', 2))
    h.alias('NR', 'firstDimension')
    h.add(_.Unsigned('secondDimension', 2))
    h.alias('NC', 'secondDimension')
    h.add(_.Unsigned('firstDimensionCoordinateValueDefinition', 1))
    h.add(_.Unsigned('NC1', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifyFirstDimensionCoordinateFunction',
        'NC1')
    h.add(_.Unsigned('secondDimensionCoordinateValueDefinition', 1))
    h.add(_.Unsigned('NC2', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifySecondDimensionCoordinateFunction',
        'NC2')
    h.add(_.Unsigned('firstDimensionPhysicalSignificance', 1))
    h.add(_.Unsigned('secondDimensionPhysicalSignificance', 1))
    h.add(_.Ieeefloat('coefsFirst', 4, _.Get('NC1')))
    h.add(_.Ieeefloat('coefsSecond', 4, _.Get('NC2')))
    h.alias('data.coefsFirst', 'coefsFirst')
    h.alias('data.coefsSecond', 'coefsSecond')

    if (h.get_l('matrixBitmapsPresent') == 1):
        h.add(_.Constant('datumSize', (_.Get('NC') * _.Get('NR'))))
        h.add(
            _.Constant('secondaryBitmapsCount', (_.Get('numberOfValues') + 0)))
        h.add(
            _.Constant('secondaryBitmapsSize',
                       (_.Get('secondaryBitmapsCount') / 8)))
        h.add(
            _.Transient('numberOfDataMatrices',
                        (_.Get('numberOfDataPoints') / _.Get('datumSize'))))
        h.add(_.Position('offsetBBitmap'))
        h.add(
            _.G2bitmap('secondaryBitmaps', _.Get('dummy'),
                       _.Get('missingValue'), _.Get('offsetBSection5'),
                       _.Get('section5Length'), _.Get('numberOfCodedValues'),
                       _.Get('dummy')))
        h.add(
            _.Data_g2secondary_bitmap('bitmap', _.Get('primaryBitmap'),
                                      _.Get('secondaryBitmaps'),
                                      _.Get('missingValue'),
                                      _.Get('datumSize'),
                                      _.Get('numberOfDataPoints')))
Esempio n. 2
0
def load(h):

    h.add(_.Constant('typeOfPreProcessing', 1))
    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(_.Ieeefloat('preProcessingParameter', 4))
Esempio n. 3
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.add(_.Unsigned('widthOfFirstOrderValues', 1))
    h.add(_.Unsigned('numberOfGroups', 4))
    h.add(_.Unsigned('numberOfSecondOrderPackedValues', 4))
    h.add(_.Unsigned('widthOfWidths', 1))
    h.add(_.Unsigned('widthOfLengths', 1))
    h.add(
        _.Codeflag('secondOrderFlags', 1,
                   "grib2/tables/[tablesVersion]/5.50002.table"))
    h.add(_.Unsigned('orderOfSPD', 1))
    h.add(_.Bit('boustrophedonicOrdering', _.Get('secondOrderFlags'), 7))
    h.alias('boustrophedonic', 'boustrophedonicOrdering')

    if h.get_l('orderOfSPD'):
        h.add(_.Unsigned('widthOfSPD', 1))
        h.add(_.Spd('SPD', _.Get('widthOfSPD'), _.Get('orderOfSPD')))
Esempio n. 4
0
def load(h):

    h.add(_.Constant('sphericalHarmonics', 1))
    h.add(_.Unsigned('J', 4))
    h.alias('pentagonalResolutionParameterJ', 'J')
    h.alias('geography.J', 'J')
    h.add(_.Unsigned('K', 4))
    h.alias('pentagonalResolutionParameterK', 'K')
    h.alias('geography.K', 'K')
    h.add(_.Unsigned('M', 4))
    h.alias('pentagonalResolutionParameterM', 'M')
    h.alias('geography.M', 'M')
    h.add(_.Codetable('spectralType', 1, "3.6.table", _.Get('masterDir'), _.Get('localDir')))
    h.alias('spectralDataRepresentationType', 'spectralType')
    h.add(_.Codetable('spectralMode', 1, "3.7.table", _.Get('masterDir'), _.Get('localDir')))
    h.alias('spectralDataRepresentationMode', 'spectralMode')
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection', 'longitudeOfSouthernPole')
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.G2lon('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ieeefloat('angleOfRotation', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotation')
    h.alias('angleOfRotationOfProjection', 'angleOfRotation')
    h.alias('isRotatedGrid', 'one')
Esempio n. 5
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(
        _.Codetable('typeOfOriginalFieldValues', 1, "5.1.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('groupSplittingMethodUsed', 1, "5.4.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('missingValueManagementUsed', 1, "5.5.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('primaryMissingValueSubstitute', 4))
    h.add(_.Unsigned('secondaryMissingValueSubstitute', 4))
    h.add(_.Unsigned('numberOfGroupsOfDataValues', 4))
    h.alias('NG', 'numberOfGroupsOfDataValues')
    h.add(_.Unsigned('referenceForGroupWidths', 1))
    h.add(_.Unsigned('numberOfBitsUsedForTheGroupWidths', 1))
    h.add(_.Unsigned('referenceForGroupLengths', 4))
    h.add(_.Unsigned('lengthIncrementForTheGroupLengths', 1))
    h.add(_.Unsigned('trueLengthOfLastGroup', 4))
    h.add(_.Unsigned('numberOfBitsForScaledGroupLengths', 1))
    h.alias('numberOfBitsUsedForTheScaledGroupLengths',
            'numberOfBitsForScaledGroupLengths')
Esempio n. 6
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(
        _.Codetable('typeOfOriginalFieldValues', 1, "5.1.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('ccsdsFlags', 1))
    h.alias('ccsdsCompressionOptionsMask', 'ccsdsFlags')
    h.add(_.Bit('AEC_DATA_SIGNED_OPTION_MASK', _.Get('ccsdsFlags'), 0))
    h.add(_.Bit('AEC_DATA_3BYTE_OPTION_MASK', _.Get('ccsdsFlags'), 1))
    h.add(_.Bit('AEC_DATA_MSB_OPTION_MASK', _.Get('ccsdsFlags'), 2))
    h.add(_.Bit('AEC_DATA_PREPROCESS_OPTION_MASK', _.Get('ccsdsFlags'), 3))
    h.add(_.Bit('AEC_RESTRICTED_OPTION_MASK', _.Get('ccsdsFlags'), 4))
    h.add(_.Bit('AEC_PAD_RSI_OPTION_MASK', _.Get('ccsdsFlags'), 5))
    h.add(_.Unsigned('ccsdsBlockSize', 1))
    h.add(_.Unsigned('ccsdsRsi', 2))
    h.alias('referenceSampleInterval', 'ccsdsRsi')
Esempio n. 7
0
def load(h):

    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection', 'longitudeOfSouthernPole')
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.G2lon('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ieeefloat('angleOfRotation', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotation')
    h.alias('angleOfRotationOfProjection', 'angleOfRotation')
    h.alias('isRotatedGrid', 'one')
Esempio n. 8
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(
        _.Codetable('typeOfOriginalFieldValues', 1, "5.1.table",
                    _.Get('masterDir'), _.Get('localDir')))
Esempio n. 9
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')
Esempio n. 10
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))

    if h.get_l('bitsPerValue'):
        h.add(_.Unsigned('widthOfFirstOrderValues', 1))
        h.add(_.Unsigned('numberOfGroups', 4))
        h.add(_.Unsigned('numberOfSecondOrderPackedValues', 4))
        h.add(_.Unsigned('widthOfWidths', 1))
        h.add(_.Unsigned('widthOfLengths', 1))
        h.add(_.Unsigned('orderOfSPD', 1))

        if h.get_l('orderOfSPD'):
            h.add(_.Unsigned('widthOfSPD', 1))
            h.add(_.Spd('SPD', _.Get('widthOfSPD'), _.Get('orderOfSPD')))
Esempio n. 11
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')
Esempio n. 12
0
def load(h):

    h.add(
        _.Codetable('shapeOfTheEarth', 1, "3.2.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(_.Unsigned('scaleFactorOfRadiusOfSphericalEarth', 1))
    h.add(_.Unsigned('scaledValueOfRadiusOfSphericalEarth', 4))
    h.add(_.Unsigned('scaleFactorOfEarthMajorAxis', 1))
    h.alias('scaleFactorOfMajorAxisOfOblateSpheroidEarth',
            'scaleFactorOfEarthMajorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMajorAxis', 4))
    h.alias('scaledValueOfMajorAxisOfOblateSpheroidEarth',
            'scaledValueOfEarthMajorAxis')
    h.add(_.Unsigned('scaleFactorOfEarthMinorAxis', 1))
    h.alias('scaleFactorOfMinorAxisOfOblateSpheroidEarth',
            'scaleFactorOfEarthMinorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMinorAxis', 4))
    h.alias('scaledValueOfMinorAxisOfOblateSpheroidEarth',
            'scaledValueOfEarthMinorAxis')
    h.alias('earthIsOblate', 'one')

    if (h.get_l('shapeOfTheEarth') == 0):
        h.add(_.Transient('radius', 6367470))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 1):
        h.add(
            _.From_scale_factor_scaled_value(
                'radius', _.Get('scaleFactorOfRadiusOfSphericalEarth'),
                _.Get('scaledValueOfRadiusOfSphericalEarth')))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 6):
        h.add(_.Transient('radius', 6371229))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 8):
        h.add(_.Transient('radius', 6371200))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 2):
        h.add(_.Transient('earthMajorAxis', 6.37816e+06))
        h.add(_.Transient('earthMinorAxis', 6.35678e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 3):
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'),
                _.Get('scaledValueOfEarthMajorAxis')))
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'),
                _.Get('scaledValueOfEarthMinorAxis')))
        h.add(
            _.Divdouble('earthMajorAxisInMetres', _.Get('earthMajorAxis'),
                        0.001))
        h.add(
            _.Divdouble('earthMinorAxisInMetres', _.Get('earthMinorAxis'),
                        0.001))

    if (h.get_l('shapeOfTheEarth') == 7):
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'),
                _.Get('scaledValueOfEarthMajorAxis')))
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'),
                _.Get('scaledValueOfEarthMinorAxis')))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if ((h.get_l('shapeOfTheEarth') == 4)
            or (h.get_l('shapeOfTheEarth') == 5)):
        h.add(_.Transient('earthMajorAxis', 6.37814e+06))
        h.add(_.Transient('earthMinorAxis', 6.35675e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 9):
        h.add(_.Transient('earthMajorAxis', 6.37756e+06))
        h.add(_.Transient('earthMinorAxis', 6.35626e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    h.add(_.Unsigned('Ni', 4))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.alias('geography.Ni', 'Ni')
    h.add(_.Unsigned('Nj', 4))
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.alias('Ny', 'Nj')
    h.alias('geography.Nj', 'Nj')
    h.add(_.Signed('latitudeOfReferencePoint', 4))
    h.alias('LaR', 'latitudeOfReferencePoint')
    h.add(
        _.Scale('latitudeOfReferencePointInDegrees',
                _.Get('latitudeOfReferencePoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfReferencePointInDegrees',
            'latitudeOfReferencePointInDegrees')
    h.add(_.Signed('longitudeOfReferencePoint', 4))
    h.alias('LoR', 'longitudeOfReferencePoint')
    h.add(
        _.Scale('longitudeOfReferencePointInDegrees',
                _.Get('longitudeOfReferencePoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfReferencePointInDegrees',
            'longitudeOfReferencePointInDegrees')
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(
        _.Bit('resolutionAndComponentFlags1',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags2',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              5))
    h.add(
        _.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 6))

    def ijDirectionIncrementGiven_inline_concept(h):
        def wrapped(h):

            iDirectionIncrementGiven = h.get_l('iDirectionIncrementGiven')
            jDirectionIncrementGiven = h.get_l('jDirectionIncrementGiven')

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 1:
                return 1

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 0:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 1:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 0:
                return 0

        return wrapped

    h.add(
        _.Concept('ijDirectionIncrementGiven',
                  None,
                  concepts=ijDirectionIncrementGiven_inline_concept(h)))

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(_.Ieeefloat('scaleFactorAtReferencePoint', 4))
    h.alias('m', 'scaleFactorAtReferencePoint')
    h.alias('geography.m', 'm')
    h.add(_.Signed('XR', 4))
    h.alias('falseEasting', 'XR')
    h.add(_.Scale('XRInMetres', _.Get('XR'), _.Get('one'), _.Get('hundred')))
    h.alias('geography.XRInMetres', 'XRInMetres')
    h.add(_.Signed('YR', 4))
    h.alias('falseNorthing', 'YR')
    h.add(_.Scale('YRInMetres', _.Get('YR'), _.Get('one'), _.Get('hundred')))
    h.alias('geography.YRInMetres', 'YRInMetres')
    h.add(
        _.Codeflag('scanningMode', 1,
                   "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

    if h.get_l('jPointsAreConsecutive'):
        h.alias('numberOfRows', 'Ni')
        h.alias('numberOfColumns', 'Nj')
    else:
        h.alias('numberOfRows', 'Nj')
        h.alias('numberOfColumns', 'Ni')

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Unsigned('Di', 4))
    h.alias('iDirectionIncrementGridLength', 'Di')
    h.add(
        _.Scale('DiInMetres', _.Get('Di'), _.Get('oneConstant'),
                _.Get('hundred'), _.Get('truncateDegrees')))
    h.alias('geography.DiInMetres', 'DiInMetres')
    h.add(_.Unsigned('Dj', 4))
    h.alias('jDirectionIncrementGridLength', 'Dj')
    h.add(
        _.Scale('DjInMetres', _.Get('Dj'), _.Get('oneConstant'),
                _.Get('hundred'), _.Get('truncateDegrees')))
    h.alias('geography.DjInMetres', 'DjInMetres')
    h.add(_.Signed('X1', 4))
    h.add(
        _.Scale('X1InGridLengths', _.Get('X1'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.X1InGridLengths', 'X1InGridLengths')
    h.add(_.Signed('Y1', 4))
    h.add(
        _.Scale('Y1InGridLengths', _.Get('Y1'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.Y1InGridLengths', 'Y1InGridLengths')
    h.add(_.Signed('X2', 4))
    h.add(
        _.Scale('X2InGridLengths', _.Get('X2'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.X2InGridLengths', 'X2InGridLengths')
    h.add(_.Signed('Y2', 4))
    h.add(
        _.Scale('Y2InGridLengths', _.Get('Y2'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.Y2InGridLengths', 'Y2InGridLengths')
Esempio n. 13
0
def load(h):

    h.add(_.Codetable('shapeOfTheEarth', 1, "3.2.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('scaleFactorOfRadiusOfSphericalEarth', 1))
    h.add(_.Unsigned('scaledValueOfRadiusOfSphericalEarth', 4))
    h.add(_.Unsigned('scaleFactorOfEarthMajorAxis', 1))
    h.alias('scaleFactorOfMajorAxisOfOblateSpheroidEarth', 'scaleFactorOfEarthMajorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMajorAxis', 4))
    h.alias('scaledValueOfMajorAxisOfOblateSpheroidEarth', 'scaledValueOfEarthMajorAxis')
    h.add(_.Unsigned('scaleFactorOfEarthMinorAxis', 1))
    h.alias('scaleFactorOfMinorAxisOfOblateSpheroidEarth', 'scaleFactorOfEarthMinorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMinorAxis', 4))
    h.alias('scaledValueOfMinorAxisOfOblateSpheroidEarth', 'scaledValueOfEarthMinorAxis')
    h.alias('earthIsOblate', 'one')

    if (h.get_l('shapeOfTheEarth') == 0):
        h.add(_.Transient('radius', 6367470))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 1):
        h.add(_.From_scale_factor_scaled_value('radius', _.Get('scaleFactorOfRadiusOfSphericalEarth'), _.Get('scaledValueOfRadiusOfSphericalEarth')))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 6):
        h.add(_.Transient('radius', 6371229))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 8):
        h.add(_.Transient('radius', 6371200))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 2):
        h.add(_.Transient('earthMajorAxis', 6.37816e+06))
        h.add(_.Transient('earthMinorAxis', 6.35678e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 3):
        h.add(_.From_scale_factor_scaled_value('earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'), _.Get('scaledValueOfEarthMajorAxis')))
        h.add(_.From_scale_factor_scaled_value('earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'), _.Get('scaledValueOfEarthMinorAxis')))
        h.add(_.Divdouble('earthMajorAxisInMetres', _.Get('earthMajorAxis'), 0.001))
        h.add(_.Divdouble('earthMinorAxisInMetres', _.Get('earthMinorAxis'), 0.001))

    if (h.get_l('shapeOfTheEarth') == 7):
        h.add(_.From_scale_factor_scaled_value('earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'), _.Get('scaledValueOfEarthMajorAxis')))
        h.add(_.From_scale_factor_scaled_value('earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'), _.Get('scaledValueOfEarthMinorAxis')))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if ((h.get_l('shapeOfTheEarth') == 4) or (h.get_l('shapeOfTheEarth') == 5)):
        h.add(_.Transient('earthMajorAxis', 6.37814e+06))
        h.add(_.Transient('earthMinorAxis', 6.35675e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 9):
        h.add(_.Transient('earthMajorAxis', 6.37756e+06))
        h.add(_.Transient('earthMinorAxis', 6.35626e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    h.add(_.Unsigned('Ni', 4))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.add(_.Unsigned('Nj', 4))
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.alias('Ny', 'Nj')
    h.alias('geography.Ni', 'Ni')
    h.alias('geography.Nj', 'Nj')
    h.add(_.Unsigned('basicAngleOfTheInitialProductionDomain', 4))
    h.add(_.Transient('mBasicAngle', (_.Get('basicAngleOfTheInitialProductionDomain') * _.Get('oneMillionConstant'))))
    h.add(_.Transient('angleMultiplier', 1))
    h.add(_.Transient('mAngleMultiplier', 1000000))
    pass  # when block
    h.add(_.Unsigned('subdivisionsOfBasicAngle', 4))
    h.add(_.Transient('angleDivisor', 1000000))
    pass  # when block
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Signed('longitudeOfFirstGridPoint', 4))
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(_.Bit('resolutionAndComponentFlags1', _.Get('resolutionAndComponentFlags'), 7))
    h.add(_.Bit('resolutionAndComponentFlags2', _.Get('resolutionAndComponentFlags'), 6))
    h.add(_.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 7))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 6))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 6))

    def ijDirectionIncrementGiven_inline_concept(h):
        def wrapped(h):

            iDirectionIncrementGiven = h.get_l('iDirectionIncrementGiven')
            jDirectionIncrementGiven = h.get_l('jDirectionIncrementGiven')

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 1:
                return 1

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 0:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 1:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 0:
                return 0

        return wrapped

    h.add(_.Concept('ijDirectionIncrementGiven', None, concepts=ijDirectionIncrementGiven_inline_concept(h)))

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(_.Signed('latitudeOfLastGridPoint', 4))
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 4))
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.add(_.Unsigned('iDirectionIncrement', 4))
    h.alias('Di', 'iDirectionIncrement')
    h.add(_.Unsigned('N', 4))
    h.alias('numberOfParallelsBetweenAPoleAndTheEquator', 'N')
    h.alias('geography.N', 'N')
    h.add(_.Codeflag('scanningMode', 1, "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

    if h.get_l('jPointsAreConsecutive'):
        h.alias('numberOfRows', 'Ni')
        h.alias('numberOfColumns', 'Nj')
    else:
        h.alias('numberOfRows', 'Nj')
        h.alias('numberOfColumns', 'Ni')

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(_.Change_scanning_direction('swapScanningX', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('xFirst'), _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(_.Change_scanning_direction('swapScanningY', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('yFirst'), _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.G2grid('g2grid', _.Get('latitudeOfFirstGridPoint'), _.Get('longitudeOfFirstGridPoint'), _.Get('latitudeOfLastGridPoint'), _.Get('longitudeOfLastGridPoint'), _.Get('iDirectionIncrement'), None, _.Get('basicAngleOfTheInitialProductionDomain'), _.Get('subdivisionsOfBasicAngle')))
    h.add(_.G2latlon('latitudeOfFirstGridPointInDegrees', _.Get('g2grid'), 0))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.add(_.G2latlon('longitudeOfFirstGridPointInDegrees', _.Get('g2grid'), 1))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.G2latlon('latitudeOfLastGridPointInDegrees', _.Get('g2grid'), 2))
    h.alias('geography.latitudeOfLastGridPointInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.add(_.G2latlon('longitudeOfLastGridPointInDegrees', _.Get('g2grid'), 3))
    h.alias('geography.longitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.add(_.G2latlon('iDirectionIncrementInDegrees', _.Get('g2grid'), 4, _.Get('iDirectionIncrementGiven')))
    h.alias('geography.iDirectionIncrementInDegrees', 'iDirectionIncrementInDegrees')
    h.add(_.Global_gaussian('global', _.Get('N'), _.Get('Ni'), _.Get('iDirectionIncrement'), _.Get('latitudeOfFirstGridPoint'), _.Get('longitudeOfFirstGridPoint'), _.Get('latitudeOfLastGridPoint'), _.Get('longitudeOfLastGridPoint'), _.Get('PLPresent'), _.Get('pl'), _.Get('basicAngleOfTheInitialProductionDomain'), _.Get('subdivisionsOfBasicAngle')))
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('DiInDegrees', 'iDirectionIncrementInDegrees')

    if (h._missing('Ni') and (h.get_l('PLPresent') == 1)):
        h.add(_.Iterator('ITERATOR', _.Get('gaussian_reduced'), _.Get('numberOfPoints'), _.Get('missingValue'), _.Get('values'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('N'), _.Get('pl'), _.Get('Nj')))
        h.add(_.Nearest('NEAREST', _.Get('reduced'), _.Get('values'), _.Get('radius'), _.Get('Nj'), _.Get('pl')))
    else:
        h.add(_.Iterator('ITERATOR', _.Get('gaussian'), _.Get('numberOfPoints'), _.Get('missingValue'), _.Get('values'), _.Get('longitudeFirstInDegrees'), _.Get('DiInDegrees'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('latitudeFirstInDegrees'), _.Get('latitudeLastInDegrees'), _.Get('N'), _.Get('jScansPositively')))
        h.add(_.Nearest('NEAREST', _.Get('regular'), _.Get('values'), _.Get('radius'), _.Get('Ni'), _.Get('Nj')))

    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))
    h.add(_.Octahedral_gaussian('isOctahedral', _.Get('N'), _.Get('Ni'), _.Get('PLPresent'), _.Get('pl')))
    h.add(_.Gaussian_grid_name('gaussianGridName', _.Get('N'), _.Get('Ni'), _.Get('isOctahedral')))
    h.alias('gridName', 'gaussianGridName')
    h.add(_.Number_of_points_gaussian('numberOfDataPointsExpected', _.Get('Ni'), _.Get('Nj'), _.Get('PLPresent'), _.Get('pl'), _.Get('N'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('zero')))
    h.add(_.Evaluate('legacyGaussSubarea', (_.Get('numberOfDataPoints') != _.Get('numberOfDataPointsExpected'))))
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection', 'longitudeOfSouthernPole')
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.G2lon('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ieeefloat('angleOfRotation', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotation')
    h.alias('angleOfRotationOfProjection', 'angleOfRotation')
    h.alias('isRotatedGrid', 'one')
Esempio n. 14
0
def load(h):

    h.add(
        _.Codetable('shapeOfTheEarth', 1, "3.2.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(_.Unsigned('scaleFactorOfRadiusOfSphericalEarth', 1))
    h.add(_.Unsigned('scaledValueOfRadiusOfSphericalEarth', 4))
    h.add(_.Unsigned('scaleFactorOfEarthMajorAxis', 1))
    h.alias('scaleFactorOfMajorAxisOfOblateSpheroidEarth',
            'scaleFactorOfEarthMajorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMajorAxis', 4))
    h.alias('scaledValueOfMajorAxisOfOblateSpheroidEarth',
            'scaledValueOfEarthMajorAxis')
    h.add(_.Unsigned('scaleFactorOfEarthMinorAxis', 1))
    h.alias('scaleFactorOfMinorAxisOfOblateSpheroidEarth',
            'scaleFactorOfEarthMinorAxis')
    h.add(_.Unsigned('scaledValueOfEarthMinorAxis', 4))
    h.alias('scaledValueOfMinorAxisOfOblateSpheroidEarth',
            'scaledValueOfEarthMinorAxis')
    h.alias('earthIsOblate', 'one')

    if (h.get_l('shapeOfTheEarth') == 0):
        h.add(_.Transient('radius', 6367470))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 1):
        h.add(
            _.From_scale_factor_scaled_value(
                'radius', _.Get('scaleFactorOfRadiusOfSphericalEarth'),
                _.Get('scaledValueOfRadiusOfSphericalEarth')))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 6):
        h.add(_.Transient('radius', 6371229))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 8):
        h.add(_.Transient('radius', 6371200))
        h.alias('radiusOfTheEarth', 'radius')
        h.alias('radiusInMetres', 'radius')
        h.alias('earthIsOblate', 'zero')

    if (h.get_l('shapeOfTheEarth') == 2):
        h.add(_.Transient('earthMajorAxis', 6.37816e+06))
        h.add(_.Transient('earthMinorAxis', 6.35678e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 3):
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'),
                _.Get('scaledValueOfEarthMajorAxis')))
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'),
                _.Get('scaledValueOfEarthMinorAxis')))
        h.add(
            _.Divdouble('earthMajorAxisInMetres', _.Get('earthMajorAxis'),
                        0.001))
        h.add(
            _.Divdouble('earthMinorAxisInMetres', _.Get('earthMinorAxis'),
                        0.001))

    if (h.get_l('shapeOfTheEarth') == 7):
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMajorAxis', _.Get('scaleFactorOfEarthMajorAxis'),
                _.Get('scaledValueOfEarthMajorAxis')))
        h.add(
            _.From_scale_factor_scaled_value(
                'earthMinorAxis', _.Get('scaleFactorOfEarthMinorAxis'),
                _.Get('scaledValueOfEarthMinorAxis')))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if ((h.get_l('shapeOfTheEarth') == 4)
            or (h.get_l('shapeOfTheEarth') == 5)):
        h.add(_.Transient('earthMajorAxis', 6.37814e+06))
        h.add(_.Transient('earthMinorAxis', 6.35675e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    if (h.get_l('shapeOfTheEarth') == 9):
        h.add(_.Transient('earthMajorAxis', 6.37756e+06))
        h.add(_.Transient('earthMinorAxis', 6.35626e+06))
        h.alias('earthMajorAxisInMetres', 'earthMajorAxis')
        h.alias('earthMinorAxisInMetres', 'earthMinorAxis')

    h.add(_.Unsigned('Ni', 4))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.add(_.Unsigned('Nj', 4))
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.alias('Ny', 'Nj')
    h.alias('geography.Ni', 'Ni')
    h.alias('geography.Nj', 'Nj')
    h.add(_.Unsigned('basicAngleOfTheInitialProductionDomain', 4))
    h.add(
        _.Transient('mBasicAngle',
                    (_.Get('basicAngleOfTheInitialProductionDomain') *
                     _.Get('oneMillionConstant'))))
    h.add(_.Transient('angleMultiplier', 1))
    h.add(_.Transient('mAngleMultiplier', 1000000))
    pass  # when block
    h.add(_.Unsigned('subdivisionsOfBasicAngle', 4))
    h.add(_.Transient('angleDivisor', 1000000))
    pass  # when block
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(
        _.Bit('resolutionAndComponentFlags1',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags2',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              5))
    h.add(
        _.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 6))

    def ijDirectionIncrementGiven_inline_concept(h):
        def wrapped(h):

            iDirectionIncrementGiven = h.get_l('iDirectionIncrementGiven')
            jDirectionIncrementGiven = h.get_l('jDirectionIncrementGiven')

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 1:
                return 1

            if iDirectionIncrementGiven == 1 and jDirectionIncrementGiven == 0:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 1:
                return 0

            if iDirectionIncrementGiven == 0 and jDirectionIncrementGiven == 0:
                return 0

        return wrapped

    h.add(
        _.Concept('ijDirectionIncrementGiven',
                  None,
                  concepts=ijDirectionIncrementGiven_inline_concept(h)))

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(
        _.Codeflag('scanningMode', 1,
                   "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

    if h.get_l('jPointsAreConsecutive'):
        h.alias('numberOfRows', 'Ni')
        h.alias('numberOfColumns', 'Nj')
    else:
        h.alias('numberOfRows', 'Nj')
        h.alias('numberOfColumns', 'Ni')

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')

    with h.list('longitudesList'):
        for i in range(0, h.get_l('Ni')):
            h.add(_.Unsigned('longitudes', 4))

    with h.list('latitudesList'):
        for i in range(0, h.get_l('Nj')):
            h.add(_.Signed('latitudes', 4))
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection',
            'longitudeOfSouthernPole')
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfSouthernPole'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(
        _.G2lon('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfSouthernPole')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ieeefloat('angleOfRotation', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotation')
    h.alias('angleOfRotationOfProjection', 'angleOfRotation')
    h.alias('isRotatedGrid', 'one')
Esempio n. 15
0
def load(h):

    h.add(_.Transient('timeRangeIndicator', 0))
    h.add(_.Position('offsetSection4'))
    h.add(_.Section_length('section4Length', 4))
    h.add(
        _.Section_pointer('section4Pointer', _.Get('offsetSection4'),
                          _.Get('section4Length'), 4))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(_.Unsigned('NV', 2))
    h.alias('numberOfVerticalCoordinateValues', 'NV')
    h.alias('numberOfCoordinatesValues', 'NV')
    h.alias('numberOfVerticalGridDescriptors', 'NV')
    h.add(_.Transient('neitherPresent', 0))

    if ((h.get_l('centre') == 7) or (h.get_l('centre') == 46)):
        h.alias('disableGrib1LocalSection', 'one')

    h.add(
        _.Codetable('productDefinitionTemplateNumber', 2, "4.0.table",
                    _.Get('masterDir'), _.Get('localDir')))

    if (h.get_l('section2Used') == 1):
        pass  # when block

    h.add(_.Transient('genVertHeightCoords', 0))
    _.Template(
        'grib2/template.4.[productDefinitionTemplateNumber:l].def').load(h)

    if (h._defined('marsStream') and h._defined('marsType')):
        _.Template('mars/grib.[marsStream:s].[marsType:s].def', True).load(h)

    _.Template('grib2/parameters.def').load(h)

    if h._defined('typeOfFirstFixedSurface'):

        if (h.get_l('typeOfFirstFixedSurface') == 150):
            h.add(_.Transient('genVertHeightCoords', 1))
            h.add(_.Transient('PVPresent', 0))

    if h.get_l('genVertHeightCoords'):
        h.add(_.Ieeefloat('nlev', 4))
        h.add(_.Ieeefloat('numberOfVGridUsed', 4))
        h.add(_.Bytes('uuidOfVGrid', 16))
        h.alias('numberOfVerticalCoordinateValues', 'nlev')
        h.alias('numberOfCoordinatesValues', 'nlev')
        h.alias('numberOfVerticalGridDescriptors', 'nlev')
    else:

        if (h.get_l('NV') == 0):
            h.add(_.Transient('PVPresent', 0))
        else:
            h.add(_.Transient('PVPresent', 1))

        if (h.get_l('PVPresent') or (h.get_l('NV') > 0)):
            h.add(_.Ieeefloat('pv', 4, _.Get('numberOfCoordinatesValues')))
            h.alias('vertical.pv', 'pv')

        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(
        _.Md5('md5Section4', _.Get('offsetSection4'), _.Get('section4Length')))