Ejemplo n.º 1
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 52))
    _.Template('grib1/grid_definition_spherical_harmonics.def').load(h)
    h.add(_.Signed('latitudeOfStretchingPole', 3))
    h.add(_.Signed('longitudeOfStretchingPole', 3))
    h.add(_.Scale('latitudeOfStretchingPoleInDegrees', _.Get('latitudeOfStretchingPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfStretchingPoleInDegrees', 'latitudeOfStretchingPoleInDegrees')
    h.add(_.Scale('longitudeOfStretchingPoleInDegrees', _.Get('longitudeOfStretchingPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfStretchingPoleInDegrees', 'longitudeOfStretchingPoleInDegrees')
    h.add(_.Ibmfloat('stretchingFactor', 4))
    h.alias('geography.stretchingFactor', 'stretchingFactor')
Ejemplo n.º 2
0
def load(h):

    h.add(_.Signed('latitudeOfSouthernPole', 3))
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.Signed('longitudeOfSouthernPole', 3))
    h.add(_.Scale('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ibmfloat('angleOfRotationInDegrees', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotationInDegrees')
    h.alias('angleOfRotation', 'angleOfRotationInDegrees')
    h.alias('isRotatedGrid', 'one')
Ejemplo n.º 3
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 41))
    _.Template('grib1/grid_definition_gaussian.def').load(h)
    h.add(_.Signed('latitudeOfSouthernPole', 3))
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.Signed('longitudeOfSouthernPole', 3))
    h.add(_.Scale('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ibmfloat('angleOfRotationInDegrees', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotationInDegrees')
    h.alias('angleOfRotation', 'angleOfRotationInDegrees')
    h.alias('isRotatedGrid', 'one')
Ejemplo 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')
Ejemplo n.º 5
0
def load(h):

    h.add(_.Signed('latitudeOfFirstGridPoint', 3))
    h.add(_.Scale('latitudeOfFirstGridPointInDegrees', _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Signed('longitudeOfFirstGridPoint', 3))
    h.add(_.Scale('longitudeOfFirstGridPointInDegrees', _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib1/7.table"))
    h.add(_.Bit('ijDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 7))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Bit('earthIsOblate', _.Get('resolutionAndComponentFlags'), 6))

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

    h.add(_.Bit('resolutionAndComponentFlags3', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('resolutionAndComponentFlags4', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 2))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 1))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('latitudeOfLastGridPoint', 3))
    h.add(_.Scale('latitudeOfLastGridPointInDegrees', _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 3))
    h.add(_.Scale('longitudeOfLastGridPointInDegrees', _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
Ejemplo n.º 6
0
def load(h):

    h.add(_.Signed('latitudeOfStretchingPole', 3))
    h.add(_.Signed('longitudeOfStretchingPole', 3))
    h.add(
        _.Scale('latitudeOfStretchingPoleInDegrees',
                _.Get('latitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfStretchingPoleInDegrees',
            'latitudeOfStretchingPoleInDegrees')
    h.add(
        _.Scale('longitudeOfStretchingPoleInDegrees',
                _.Get('longitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfStretchingPoleInDegrees',
            'longitudeOfStretchingPoleInDegrees')
    h.add(_.Ibmfloat('stretchingFactor', 4))
    h.alias('geography.stretchingFactor', 'stretchingFactor')
Ejemplo 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')
Ejemplo 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')

    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')
Ejemplo 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')
    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')
Ejemplo n.º 10
0
def load(h):

    h.add(_.Unsigned('n2', 1))
    h.add(_.Unsigned('n3', 1))
    h.add(_.Unsigned('Ni', 2))
    h.add(_.Unsigned('nd', 1))
    h.alias('numberOfDiamonds', 'nd')
    h.add(_.Signed('latitudeOfThePolePoint', 4))
    h.add(
        _.Scale('latitudeOfThePolePointInDegrees',
                _.Get('latitudeOfThePolePoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfThePolePointInDegrees',
            'latitudeOfThePolePointInDegrees')
    h.add(_.Unsigned('longitudeOfThePolePoint', 4))
    h.add(
        _.G2lon('longitudeOfThePolePointInDegrees',
                _.Get('longitudeOfThePolePoint')))
    h.alias('geography.longitudeOfThePolePointInDegrees',
            'longitudeOfThePolePointInDegrees')
    h.add(_.Unsigned('longitudeOfFirstDiamondCentreLine', 4))
    h.add(
        _.G2lon('longitudeOfFirstDiamondCentreLineInDegrees',
                _.Get('longitudeOfFirstDiamondCentreLine')))
    h.alias('geography.longitudeOfFirstDiamondCentreLineInDegrees',
            'longitudeOfFirstDiamondCentreLineInDegrees')
    h.add(
        _.Codetable('gridPointPosition', 1, "3.8.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(
        _.Codeflag('numberingOrderOfDiamonds', 1,
                   "grib2/tables/[tablesVersion]/3.9.table"))
    h.add(
        _.Codeflag('scanningModeForOneDiamond', 1,
                   "grib2/tables/[tablesVersion]/3.10.table"))
    h.add(_.Unsigned('totalNumberOfGridPoints', 4))
    h.alias('nt', 'totalNumberOfGridPoints')
Ejemplo n.º 11
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')
Ejemplo 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('Nx', 4))
    h.alias('numberOfPointsAlongTheXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('numberOfPointsAlongTheYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Unsigned('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('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(_.Unsigned('LoV', 4))
    h.add(_.Unsigned('xDirectionGridLength', 4))
    h.alias('Dx', 'xDirectionGridLength')
    h.add(_.Unsigned('yDirectionGridLength', 4))
    h.alias('Dy', 'yDirectionGridLength')
    h.add(
        _.Codeflag('projectionCentreFlag', 1,
                   "grib2/tables/[tablesVersion]/3.5.table"))
    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(_.Signed('Latin1', 4))
    h.add(
        _.Scale('Latin1InDegrees', _.Get('Latin1'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin1InDegrees', 'Latin1InDegrees')
    h.add(_.Unsigned('Latin2', 4))
    h.add(
        _.Scale('Latin2InDegrees', _.Get('Latin2'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin2InDegrees', 'Latin2InDegrees')
    h.add(_.Signed('latitudeOfTheSouthernPoleOfProjection', 4))
    h.alias('latitudeOfSouthernPole', 'latitudeOfTheSouthernPoleOfProjection')
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfTheSouthernPoleOfProjection'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(_.Unsigned('longitudeOfTheSouthernPoleOfProjection', 4))
    h.alias('longitudeOfSouthernPole',
            'longitudeOfTheSouthernPoleOfProjection')
    h.add(
        _.Scale('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfTheSouthernPoleOfProjection'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 20))
    h.add(_.Signed('Ni', 2))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.alias('geography.Ni', 'Ni')
    h.add(_.Signed('Nj', 2))
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.alias('Nx', 'Nj')
    h.alias('geography.Nj', 'Nj')
    h.add(_.Signed('latitudeOfFirstGridPoint', 3))
    h.add(_.Scale('latitudeOfFirstGridPointInDegrees', _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Signed('longitudeOfFirstGridPoint', 3))
    h.add(_.Scale('longitudeOfFirstGridPointInDegrees', _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib1/7.table"))
    h.add(_.Bit('ijDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 7))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Bit('earthIsOblate', _.Get('resolutionAndComponentFlags'), 6))

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

    h.add(_.Bit('resolutionAndComponentFlags3', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('resolutionAndComponentFlags4', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 2))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 1))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('latitudeOfLastGridPoint', 3))
    h.add(_.Scale('latitudeOfLastGridPointInDegrees', _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 3))
    h.add(_.Scale('longitudeOfLastGridPointInDegrees', _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Signed('Latin', 3))
    h.add(_.Scale('LaDInDegrees', _.Get('Latin'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.add(_.Pad('padding_grid1_1', 1))
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    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')

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

    h.add(_.Signed('DiInMetres', 3))
    h.alias('longitudinalDirectionGridLength', 'DiInMetres')
    h.alias('Di', 'DiInMetres')
    h.alias('geography.DiInMetres', 'DiInMetres')
    h.add(_.Signed('DjInMetres', 3))
    h.alias('latitudinalDirectionGridLength', 'DjInMetres')
    h.alias('Dj', 'DjInMetres')
    h.alias('geography.DjInMetres', 'DjInMetres')
    h.add(_.Constant('orientationOfTheGridInDegrees', 0))
    h.add(_.Pad('padding_grid1_2', 8))
    h.add(_.Number_of_points('numberOfDataPoints', _.Get('Ni'), _.Get('Nj')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Number_of_values('numberOfValues', _.Get('values'), _.Get('bitsPerValue'), _.Get('numberOfDataPoints'), _.Get('bitmapPresent'), _.Get('bitmap'), _.Get('numberOfCodedValues')))
Ejemplo n.º 15
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 90))
    h.add(_.Unsigned('Nx', 2))
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('Ni', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 2))
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('Nj', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfSubSatellitePoint', 3))
    h.add(_.Scale('latitudeOfSubSatellitePointInDegrees', _.Get('latitudeOfSubSatellitePoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSubSatellitePointInDegrees', 'latitudeOfSubSatellitePointInDegrees')
    h.alias('Lap', 'latitudeOfSubSatellitePoint')
    h.add(_.Signed('longitudeOfSubSatellitePoint', 3))
    h.add(_.Scale('longitudeOfSubSatellitePointInDegrees', _.Get('longitudeOfSubSatellitePoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSubSatellitePointInDegrees', 'longitudeOfSubSatellitePointInDegrees')
    h.alias('Lap', 'longitudeOfSubSatellitePoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib1/7.table"))
    h.add(_.Bit('ijDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 7))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Bit('earthIsOblate', _.Get('resolutionAndComponentFlags'), 6))

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

    h.add(_.Bit('resolutionAndComponentFlags3', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('resolutionAndComponentFlags4', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 2))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 1))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Unsigned('dx', 3))
    h.alias('geography.dx', 'dx')
    h.add(_.Unsigned('dy', 3))
    h.alias('geography.dy', 'dy')
    h.add(_.Unsigned('XpInGridLengths', 2))
    h.alias('geography.XpInGridLengths', 'XpInGridLengths')
    h.add(_.Unsigned('YpInGridLengths', 2))
    h.alias('geography.YpInGridLengths', 'YpInGridLengths')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    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')

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

    h.add(_.Unsigned('orientationOfTheGrid', 3))
    h.add(_.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees', 'orientationOfTheGridInDegrees')
    h.add(_.Unsigned('NrInRadiusOfEarth', 3))
    h.alias('altitudeOfTheCameraFromTheEarthsCentreMeasuredInUnitsOfTheEarthsRadius', 'NrInRadiusOfEarth')
    h.add(_.Unsigned('Xo', 2))
    h.alias('xCoordinateOfOriginOfSectorImage', 'Xo')
    h.alias('geography.Xo', 'Xo')
    h.add(_.Unsigned('Yo', 2))
    h.alias('yCoordinateOfOriginOfSectorImage', 'Yo')
    h.alias('geography.Yo', 'Yo')

    if (h.get_l('centre') != 98):
        h.add(_.Pad('padding_grid90_1', 6))

    h.add(_.Number_of_points('numberOfDataPoints', _.Get('Ni'), _.Get('Nj'), _.Get('PLPresent'), _.Get('pl')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Number_of_values('numberOfValues', _.Get('values'), _.Get('bitsPerValue'), _.Get('numberOfDataPoints'), _.Get('bitmapPresent'), _.Get('bitmap'), _.Get('numberOfCodedValues')))
Ejemplo n.º 16
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')
Ejemplo n.º 17
0
def load(h):

    h.add(_.Transient('biFourierMakeTemplate', 0))
    h.add(_.Label('BiFourier coefficients'))
    h.add(_.Constant('biFourierCoefficients', 1))
    h.add(
        _.Codetable('spectralType', 1, "3.6.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.alias('spectralDataRepresentationType', 'spectralType')
    h.add(_.Unsigned('biFourierResolutionParameterN', 4))
    h.add(_.Unsigned('biFourierResolutionParameterM', 4))
    h.add(
        _.Codetable('biFourierTruncationType', 1, "3.25.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('Lx', 8))
    h.alias('geography.LxInMetres', 'Lx')
    h.add(_.Unsigned('Lux', 8))
    h.alias('geography.LuxInMetres', 'Lux')
    h.add(_.Unsigned('Lcx', 8))
    h.alias('geography.LcxInMetres', 'Lcx')
    h.add(_.Unsigned('Ly', 8))
    h.alias('geography.LyInMetres', 'Ly')
    h.add(_.Unsigned('Luy', 8))
    h.alias('geography.LuyInMetres', 'Luy')
    h.add(_.Unsigned('Lcy', 8))
    h.alias('geography.LcyInMetres', 'Lcy')
    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(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1InDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.add(_.Unsigned('longitudeOfFirstGridPoint', 4))
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(
        _.Scale('longitudeOfFirstGridPointInDegrees',
                _.Get('longitudeOfFirstGridPoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees',
            'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1InDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.Signed('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(
        _.Scale('LaDInDegrees', _.Get('LaD'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.add(_.Unsigned('LoV', 4))
    h.add(
        _.Scale('LoVInDegrees', _.Get('LoV'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LoVInDegrees', 'LoVInDegrees')
    h.add(
        _.Codeflag('projectionCentreFlag', 1,
                   "grib2/tables/[tablesVersion]/3.5.table"))
    h.add(_.Signed('Latin1', 4))
    h.alias('FirstLatitude', 'Latin1')
    h.add(
        _.Scale('Latin1InDegrees', _.Get('Latin1'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin1InDegrees', 'Latin1InDegrees')
    h.add(_.Signed('Latin2', 4))
    h.alias('SecondLatitude', 'Latin2')
    h.add(
        _.Scale('Latin2InDegrees', _.Get('Latin2'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin2InDegrees', 'Latin2InDegrees')
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfSouthernPole'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection',
            'longitudeOfSouthernPole')
    h.add(
        _.Scale('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
Ejemplo n.º 18
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('Nx', 4))
    h.alias('Ni', 'Nx')
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('Nj', 'Ny')
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfSubSatellitePoint', 4))
    h.add(_.Signed('longitudeOfSubSatellitePoint', 4))
    h.add(
        _.Scale('latitudeOfSubSatellitePointInDegrees',
                _.Get('latitudeOfSubSatellitePoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSubSatellitePointInDegrees',
            'latitudeOfSubSatellitePointInDegrees')
    h.add(
        _.Scale('longitudeOfSubSatellitePointInDegrees',
                _.Get('longitudeOfSubSatellitePoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSubSatellitePointInDegrees',
            'longitudeOfSubSatellitePointInDegrees')
    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(_.Unsigned('dx', 4))
    h.alias('geography.dx', 'dx')
    h.add(_.Unsigned('dy', 4))
    h.alias('geography.dy', 'dy')
    h.add(_.Unsigned('Xp', 4))
    h.add(
        _.Scale('XpInGridLengths', _.Get('Xp'), _.Get('one'),
                _.Get('thousand')))
    h.alias('geography.XpInGridLengths', 'XpInGridLengths')
    h.alias('xCoordinateOfSubSatellitePoint', 'XpInGridLengths')
    h.add(_.Unsigned('Yp', 4))
    h.add(
        _.Scale('YpInGridLengths', _.Get('Yp'), _.Get('one'),
                _.Get('thousand')))
    h.alias('geography.YpInGridLengths', 'YpInGridLengths')
    h.alias('yCoordinateOfSubSatellitePoint', 'YpInGridLengths')
    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(_.Signed('orientationOfTheGrid', 4))
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.add(_.Unsigned('Nr', 4))
    h.alias(
        'altitudeOfTheCameraFromTheEarthsCentreMeasuredInUnitsOfTheEarthsRadius',
        'Nr')
    h.add(
        _.Scale('NrInRadiusOfEarth', _.Get('Nr'), _.Get('oneConstant'),
                _.Get('oneMillionConstant'), _.Get('truncateDegrees')))
    h.alias('geography.NrInRadiusOfEarth', 'NrInRadiusOfEarth')
    h.add(_.Unsigned('Xo', 4))
    h.alias('xCoordinateOfOriginOfSectorImage', 'Xo')
    h.alias('geography.Xo', 'Xo')
    h.add(_.Unsigned('Yo', 4))
    h.alias('yCoordinateOfOriginOfSectorImage', 'Yo')
    h.alias('geography.Yo', 'Yo')
    h.add(
        _.Iterator('ITERATOR', _.Get('space_view'), _.Get('numberOfPoints'),
                   _.Get('missingValue'), _.Get('values'), _.Get('radius'),
                   _.Get('earthIsOblate'), _.Get('earthMajorAxis'),
                   _.Get('earthMinorAxis'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfSubSatellitePointInDegrees'),
                   _.Get('longitudeOfSubSatellitePointInDegrees'), _.Get('dx'),
                   _.Get('dy'), _.Get('XpInGridLengths'),
                   _.Get('YpInGridLengths'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('NrInRadiusOfEarth'), _.Get('Xo'), _.Get('Yo'),
                   _.Get('iScansNegatively'), _.Get('jScansPositively'),
                   _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))
Ejemplo n.º 19
0
def load(h):

    h.add(_.Constant('ECMWF', 98))
    h.add(_.Constant('ECMWF_s', "ecmf"))
    h.add(_.Constant('WMO', 0))
    h.add(_.Constant('conceptsMasterDir', "grib1"))
    h.add(_.Constant('conceptsLocalDirECMF', "grib1/localConcepts/ecmf"))
    h.add(_.Constant('conceptsLocalDirAll', "grib1/localConcepts/[centre:s]"))
    h.add(_.Constant('tablesMasterDir', "grib1"))
    h.add(_.Constant('tablesLocalDir', "grib1/local/[centre:s]"))
    h.add(_.Transient('productionStatusOfProcessedData', 0))
    h.add(_.Position('offsetSection1'))
    h.add(_.Section_length('section1Length', 3))
    h.add(_.Section_pointer('section1Pointer', _.Get('offsetSection1'), _.Get('section1Length'), 1))
    h.add(_.Constant('wrongPadding', 0))
    h.add(_.Unsigned('table2Version', 1))
    h.alias('gribTablesVersionNo', 'table2Version')
    h.add(_.StringCodetable('centre', 1, "common/c-1.table"))
    h.alias('identificationOfOriginatingGeneratingCentre', 'centre')
    h.add(_.Codetable_title('centreDescription', _.Get('centre')))
    h.alias('parameter.centre', 'centre')
    h.alias('originatingCentre', 'centre')
    h.alias('ls.centre', 'centre')
    h.add(_.Unsigned('generatingProcessIdentifier', 1))
    h.alias('generatingProcessIdentificationNumber', 'generatingProcessIdentifier')
    h.alias('process', 'generatingProcessIdentifier')
    h.add(_.Unsigned('gridDefinition', 1))
    h.add(_.Codeflag('section1Flags', 1, "grib1/1.table"))
    h.alias('centreForTable2', 'centre')
    h.add(_.Codetable('indicatorOfParameter', 1, "grib1/2.[centreForTable2:l].[table2Version:l].table"))
    h.add(_.Codetable_title('parameterName', _.Get('indicatorOfParameter')))
    h.add(_.Codetable_units('parameterUnits', _.Get('indicatorOfParameter')))
    h.add(_.StringCodetable('indicatorOfTypeOfLevel', 1, "3.table", _.Get('tablesLocalDir'), _.Get('tablesMasterDir')))
    h.alias('levelType', 'indicatorOfTypeOfLevel')
    h.add(_.Transient('pressureUnits', "hPa"))
    h.add(_.Concept('typeOfLevelECMF', 'unknown', 'typeOfLevel.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', True))
    h.add(_.Concept('typeOfLevel', 'typeOfLevelECMF', 'typeOfLevel.def', 'conceptsMasterDir', 'conceptsLocalDirAll', True))
    h.alias('vertical.typeOfLevel', 'typeOfLevel')
    pass  # when block
    h.alias('ls.typeOfLevel', 'typeOfLevel')

    if ((((((((((((h.get_l('indicatorOfTypeOfLevel') == 101) or (h.get_l('indicatorOfTypeOfLevel') == 104)) or (h.get_l('indicatorOfTypeOfLevel') == 106)) or (h.get_l('indicatorOfTypeOfLevel') == 108)) or (h.get_l('indicatorOfTypeOfLevel') == 110)) or (h.get_l('indicatorOfTypeOfLevel') == 112)) or (h.get_l('indicatorOfTypeOfLevel') == 114)) or (h.get_l('indicatorOfTypeOfLevel') == 116)) or (h.get_l('indicatorOfTypeOfLevel') == 120)) or (h.get_l('indicatorOfTypeOfLevel') == 121)) or (h.get_l('indicatorOfTypeOfLevel') == 128)) or (h.get_l('indicatorOfTypeOfLevel') == 141)):
        h.add(_.Unsigned('topLevel', 1))
        h.add(_.Unsigned('bottomLevel', 1))
        h.add(_.Sprintf('levels', "%d-%d", _.Get('topLevel'), _.Get('bottomLevel')))
        h.alias('ls.levels', 'levels')
        h.alias('vertical.level', 'topLevel')
        h.alias('vertical.topLevel', 'topLevel')
        h.alias('vertical.bottomLevel', 'bottomLevel')
    else:
        h.add(_.Unsigned('level', 2))

        if (h.get_l('indicatorOfTypeOfLevel') == 210):
            h.add(_.Scale('marsLevel', _.Get('level'), _.Get('oneConstant'), _.Get('hundred')))
            h.alias('mars.levelist', 'marsLevel')

        h.alias('vertical.level', 'level')
        h.alias('vertical.topLevel', 'level')
        h.alias('vertical.bottomLevel', 'level')
        h.alias('ls.level', 'level')
        h.alias('lev', 'level')

    if (((((h.get_l('indicatorOfTypeOfLevel') == 109) or (h.get_l('indicatorOfTypeOfLevel') == 100)) or (h.get_l('indicatorOfTypeOfLevel') == 110)) or (h.get_l('indicatorOfTypeOfLevel') == 113)) or (h.get_l('indicatorOfTypeOfLevel') == 117)):
        h.alias('mars.levelist', 'level')

    h.add(_.Unsigned('yearOfCentury', 1))
    h.add(_.Unsigned('month', 1))
    h.add(_.Unsigned('day', 1))
    h.add(_.Unsigned('hour', 1))
    h.add(_.Unsigned('minute', 1))
    h.add(_.Transient('second', 0))
    h.add(_.Codetable('unitOfTimeRange', 1, "grib1/4.table"))
    h.alias('unitOfTime', 'unitOfTimeRange')
    h.alias('indicatorOfUnitOfTimeRange', 'unitOfTimeRange')
    h.add(_.Unsigned('P1', 1))
    h.add(_.Unsigned('P2', 1))
    h.add(_.Codetable('timeRangeIndicator', 1, "5.table", _.Get('tablesLocalDir'), _.Get('tablesMasterDir')))
    h.add(_.Unsigned('numberIncludedInAverage', 2))
    h.add(_.Bits('mybits', _.Get('numberIncludedInAverage'), 0, 12))
    h.add(_.Unsigned('numberMissingFromAveragesOrAccumulations', 1))
    h.add(_.Unsigned('centuryOfReferenceTimeOfData', 1))
    h.add(_.Codetable('subCentre', 1, "grib1/0.[centre].table"))

    if (h.get_l('table2Version') >= 128):

        if ((h.get_l('centre') != 98) and (h.get_l('subCentre') == 98)):
            h.alias('centreForTable2', 'subCentre')
        else:
            h.alias('centreForTable2', 'centre')

    else:
        h.alias('centreForTable2', 'WMO')

    h.add(_.Concept('paramIdECMF', 'defaultParameter', 'paramId.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('paramId', 'paramIdECMF', 'paramId.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(_.Concept('cfNameECMF', 'defaultName', 'cfName.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('cfName', 'cfNameECMF', 'cfName.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(_.Concept('cfVarNameECMF', 'defaultName', 'cfVarName.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('cfVarName', 'cfVarNameECMF', 'cfVarName.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(_.Concept('unitsECMF', 'defaultName', 'units.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('units', 'unitsECMF', 'units.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(_.Concept('nameECMF', 'defaultName', 'name.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('name', 'nameECMF', 'name.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(_.Signed('decimalScaleFactor', 2))
    h.add(_.Transient('setLocalDefinition', 0))
    h.add(_.Transient('optimizeScaleFactor', 0))
    h.add(_.G1date('dataDate', _.Get('centuryOfReferenceTimeOfData'), _.Get('yearOfCentury'), _.Get('month'), _.Get('day')))
    h.add(_.Evaluate('year', (_.Get('dataDate') / 10000)))
    h.add(_.Time('dataTime', _.Get('hour'), _.Get('minute'), _.Get('second')))
    h.add(_.Julian_day('julianDay', _.Get('dataDate'), _.Get('hour'), _.Get('minute'), _.Get('second')))
    h.add(_.TransientCodetable('stepUnits', 1, "stepUnits.table"))
    h.add(_.Concept('stepType', 'timeRangeIndicator', 'stepType.def', 'conceptsMasterDir', 'conceptsLocalDirAll', True))

    if (h.get_s('stepType') == "instant"):
        h.alias('productDefinitionTemplateNumber', 'zero')
    else:
        h.alias('productDefinitionTemplateNumber', 'eight')

    h.add(_.G1step_range('stepRange', _.Get('P1'), _.Get('P2'), _.Get('timeRangeIndicator'), _.Get('unitOfTimeRange'), _.Get('stepUnits'), _.Get('stepType')))
    h.add(_.Long_vector('startStep', _.Get('stepRange'), 0))
    h.add(_.Long_vector('endStep', _.Get('stepRange'), 1))
    h.alias('stepInHours', 'endStep')
    h.alias('ls.stepRange', 'stepRange')
    h.alias('ls.dataDate', 'dataDate')
    h.alias('mars.step', 'endStep')
    h.alias('mars.date', 'dataDate')
    h.alias('mars.levtype', 'indicatorOfTypeOfLevel')
    h.alias('mars.time', 'dataTime')
    h.add(_.Mars_param('marsParam', _.Get('paramId'), _.Get('gribTablesVersionNo'), _.Get('indicatorOfParameter')))
    h.alias('mars.param', 'marsParam')

    if ((h.get_l('centre') == 34) and (h.get_l('subCentre') == 241)):
        h.alias('mars.param', 'paramId')

        if (h.get_l('indicatorOfTypeOfLevel') == 101):
            h.add(_.Constant('sfc_levtype', "sfc"))
            h.alias('mars.levtype', 'sfc_levtype')


    h.add(_.Validity_date('validityDate', _.Get('dataDate'), _.Get('dataTime'), _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityDate', 'validityDate')
    h.add(_.Validity_time('validityTime', _.Get('dataDate'), _.Get('dataTime'), _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityTime', 'validityTime')
    h.add(_.Transient('deleteLocalDefinition', 0))

    if ((((h.get_l('section1Length') > 40) or h._new()) or (h.get_l('setLocalDefinition') > 0)) and (h.get_l('deleteLocalDefinition') == 0)):
        h.add(_.Constant('localUsePresent', 1))
        h.alias('grib2LocalSectionPresent', 'present')

        if ((h.get_l('centre') == h.get_l('ECMWF')) or ((h.get_l('centre') != h.get_l('ECMWF')) and (h.get_l('subCentre') == h.get_l('ECMWF')))):
            h.add(_.Pad('reservedNeedNotBePresent', 12))
            h.add(_.Codetable('localDefinitionNumber', 1, "grib1/localDefinitionNumber.98.table"))
            _.Template('grib1/local.98.[localDefinitionNumber:l].def', True).load(h)

            if h._changed('localDefinitionNumber'):

                if (not (h._new()) and (h.get_l('localDefinitionNumber') != 4)):
                    h.add(_.Section_padding('localExtensionPadding'))


            _.Template('mars/grib.[stream:s].[type:s].def', True).load(h)
        else:

            if (not (h._new()) or h.get_l('setLocalDefinition')):
                h.add(_.Pad('reservedNeedNotBePresent', 12))
                _.Template('grib1/local.[centre:l].def', True).load(h)
                h.add(_.Section_padding('localExtensionPadding'))

    else:
        h.add(_.Constant('localUsePresent', 0))

    h.add(_.Section_padding('section1Padding'))
    h.add(_.Concept('shortNameECMF', 'defaultShortName', 'shortName.def', 'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(_.Concept('shortName', 'shortNameECMF', 'shortName.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.alias('ls.shortName', 'shortName')
    h.add(_.Ifs_param('ifsParam', _.Get('paramId'), _.Get('type')))
    h.alias('parameter.paramId', 'paramId')
    h.alias('parameter.shortName', 'shortName')
    h.alias('parameter.units', 'units')
    h.alias('parameter.name', 'name')
    h.alias('parameter', 'paramId')
    h.alias('short_name', 'shortName')
    h.alias('time.stepRange', 'stepRange')
    h.alias('time.stepUnits', 'stepUnits')
    h.alias('time.dataDate', 'dataDate')
    h.alias('time.dataTime', 'dataTime')
    h.alias('time.startStep', 'startStep')
    h.alias('time.endStep', 'endStep')
    h.alias('time.stepType', 'stepType')
    h.add(_.Concept('stepTypeForConversion', 'unknown', 'stepTypeForConversion.def', 'conceptsMasterDir', 'conceptsLocalDirAll', True))

    if (h.get_s('stepTypeForConversion') == "accum"):
        h.alias('productDefinitionTemplateNumber', 'eight')

    h.add(_.Md5('md5Section1', _.Get('offsetSection1'), _.Get('section1Length')))
    h.add(_.Md5('md5Product', _.Get('offsetSection1'), _.Get('section1Length'), _.Get('gridDefinition'), _.Get('section1Flags'), _.Get('decimalScaleFactor')))
Ejemplo n.º 20
0
def load(h):

    h.add(_.Unsigned('Ni', 2))
    h.alias('numberOfPointsAlongFirstAxis', 'Ni')
    h.alias('Nx', 'Ni')
    h.add(_.Unsigned('Nj', 2))
    h.alias('numberOfPointsAlongSecondAxis', 'Nj')
    h.alias('Nx', 'Nj')
    h.add(_.Signed('latitudeOfFirstGridPoint', 3))
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    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')

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

    h.add(
        _.Number_of_points('numberOfDataPoints', _.Get('Ni'), _.Get('Nj'),
                           _.Get('PLPresent'), _.Get('pl')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(
        _.Number_of_values('numberOfValues', _.Get('values'),
                           _.Get('bitsPerValue'), _.Get('numberOfDataPoints'),
                           _.Get('bitmapPresent'), _.Get('bitmap'),
                           _.Get('numberOfCodedValues')))
Ejemplo n.º 21
0
def load(h):

    h.add(_.Unsigned('Ni', 2))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.add(_.Signed('Nj', 2))
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.alias('Ny', 'Nj')
    h.add(_.Signed('latitudeOfFirstGridPoint', 3))
    h.add(_.Scale('latitudeOfFirstGridPointInDegrees', _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Signed('longitudeOfFirstGridPoint', 3))
    h.add(_.Scale('longitudeOfFirstGridPointInDegrees', _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib1/7.table"))
    h.add(_.Bit('ijDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'), 7))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Bit('earthIsOblate', _.Get('resolutionAndComponentFlags'), 6))

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

    h.add(_.Bit('resolutionAndComponentFlags3', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('resolutionAndComponentFlags4', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 2))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 1))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('latitudeOfLastGridPoint', 3))
    h.add(_.Scale('latitudeOfLastGridPointInDegrees', _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 3))
    h.add(_.Scale('longitudeOfLastGridPointInDegrees', _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Unsigned('iDirectionIncrement', 2))
    h.add(_.Scale('iDirectionIncrementInDegrees', _.Get('iDirectionIncrement'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.iDirectionIncrementInDegrees', 'iDirectionIncrementInDegrees')
    h.alias('Di', 'iDirectionIncrement')
    h.add(_.Unsigned('N', 2))
    h.alias('numberOfParallelsBetweenAPoleAndTheEquator', 'N')
    h.alias('geography.N', 'N')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    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')

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

    h.add(_.Pad('padding_grid4_1', 4))
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('DiInDegrees', 'iDirectionIncrementInDegrees')
    h.add(_.Global_gaussian('global', _.Get('N'), _.Get('Ni'), _.Get('iDirectionIncrement'), _.Get('latitudeOfFirstGridPoint'), _.Get('longitudeOfFirstGridPoint'), _.Get('latitudeOfLastGridPoint'), _.Get('longitudeOfLastGridPoint'), _.Get('PLPresent'), _.Get('pl')))
    h.add(_.Number_of_points_gaussian('numberOfDataPoints', _.Get('Ni'), _.Get('Nj'), _.Get('PLPresent'), _.Get('pl'), _.Get('N'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('one')))
    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.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Number_of_values('numberOfValues', _.Get('values'), _.Get('bitsPerValue'), _.Get('numberOfDataPoints'), _.Get('bitmapPresent'), _.Get('bitmap'), _.Get('numberOfCodedValues')))

    if h._missing('Ni'):
        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')))
        h.add(_.Box('BOX', _.Get('reduced_gaussian'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('N'), _.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')
Ejemplo n.º 22
0
def load(h):

    h.add(
        _.Codetable('parameterCategory', 1, "4.1.[discipline:l].table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('parameterNumber', 1,
                    "4.2.[discipline:l].[parameterCategory:l].table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('parameterUnits', _.Get('parameterNumber')))
    h.add(_.Codetable_title('parameterName', _.Get('parameterNumber')))
    h.add(
        _.Codetable('aerosolType', 2, "4.233.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(
        _.Codetable('sourceSinkChemicalPhysicalProcess', 1, "4.238.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('typeOfSizeInterval', 1, "4.91.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.alias('typeOfIntervalForFirstAndSecondSize', 'typeOfSizeInterval')
    h.add(_.Signed('scaleFactorOfFirstSize', 1))
    h.add(_.Signed('scaledValueOfFirstSize', 4))
    h.add(_.Signed('scaleFactorOfSecondSize', 1))
    h.add(_.Signed('scaledValueOfSecondSize', 4))
    h.add(
        _.Codetable('typeOfWavelengthInterval', 1, "4.91.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.alias('typeOfIntervalForFirstAndSecondWavelength',
            'typeOfWavelengthInterval')
    h.add(_.Signed('scaleFactorOfFirstWavelength', 1))
    h.add(_.Signed('scaledValueOfFirstWavelength', 4))
    h.add(_.Signed('scaleFactorOfSecondWavelength', 1))
    h.add(_.Signed('scaledValueOfSecondWavelength', 4))
    h.add(
        _.Codetable('typeOfGeneratingProcess', 1, "4.3.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('backgroundProcess', 1))
    h.alias('backgroundGeneratingProcessIdentifier', 'backgroundProcess')
    h.add(_.Unsigned('generatingProcessIdentifier', 1))
    h.add(_.Unsigned('hoursAfterDataCutoff', 2))
    h.alias('hoursAfterReferenceTimeOfDataCutoff', 'hoursAfterDataCutoff')
    h.add(_.Unsigned('minutesAfterDataCutoff', 1))
    h.alias('minutesAfterReferenceTimeOfDataCutoff', 'minutesAfterDataCutoff')
    h.add(
        _.Codetable('indicatorOfUnitOfTimeRange', 1, "4.4.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.alias('defaultStepUnits', 'one')
    _.Template('grib2/localConcepts/[centre:s]/default_step_units.def',
               True).load(h)
    h.add(_.TransientCodetable('stepUnits', 1, "stepUnits.table"))
    h.add(_.Signed('forecastTime', 4))
    h.add(
        _.Step_in_units('startStep', _.Get('forecastTime'),
                        _.Get('indicatorOfUnitOfTimeRange'),
                        _.Get('stepUnits')))
    h.add(_.G2end_step('endStep', _.Get('startStep'), _.Get('stepUnits')))
    h.alias('step', 'startStep')
    h.alias('marsStep', 'startStep')
    h.alias('mars.step', 'startStep')
    h.alias('marsStartStep', 'startStep')
    h.alias('marsEndStep', 'endStep')
    h.add(_.G2step_range('stepRange', _.Get('startStep')))
    h.alias('ls.stepRange', 'stepRange')

    def stepTypeInternal_inline_concept(h):
        def wrapped(h):

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 'instant'

        return wrapped

    h.add(
        _.Concept('stepTypeInternal',
                  None,
                  concepts=stepTypeInternal_inline_concept(h)))

    h.alias('time.stepType', 'stepType')
    h.alias('time.stepRange', 'stepRange')
    h.alias('time.stepUnits', 'stepUnits')
    h.alias('time.dataDate', 'dataDate')
    h.alias('time.dataTime', 'dataTime')
    h.alias('time.startStep', 'startStep')
    h.alias('time.endStep', 'endStep')
    h.add(
        _.Validity_date('validityDate', _.Get('dataDate'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityDate', 'validityDate')
    h.add(
        _.Validity_time('validityTime', _.Get('dataDate'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityTime', 'validityTime')
    h.add(
        _.StringCodetable('typeOfFirstFixedSurface', 1, "4.5.table",
                          _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable_units('unitsOfFirstFixedSurface',
                          _.Get('typeOfFirstFixedSurface')))
    h.add(
        _.Codetable_title('nameOfFirstFixedSurface',
                          _.Get('typeOfFirstFixedSurface')))
    h.add(_.Signed('scaleFactorOfFirstFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfFirstFixedSurface', 4))
    h.add(
        _.Codetable('typeOfSecondFixedSurface', 1, "4.5.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable_units('unitsOfSecondFixedSurface',
                          _.Get('typeOfSecondFixedSurface')))
    h.add(
        _.Codetable_title('nameOfSecondFixedSurface',
                          _.Get('typeOfSecondFixedSurface')))
    h.add(_.Signed('scaleFactorOfSecondFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfSecondFixedSurface', 4))
    h.add(_.Transient('pressureUnits', "hPa"))

    def typeOfLevel_inline_concept(h):
        def wrapped(h):

            typeOfFirstFixedSurface = h.get_l('typeOfFirstFixedSurface')
            typeOfSecondFixedSurface = h.get_l('typeOfSecondFixedSurface')

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 255:
                return 'surface'

            if typeOfFirstFixedSurface == 2 and typeOfSecondFixedSurface == 255:
                return 'cloudBase'

            if typeOfFirstFixedSurface == 3 and typeOfSecondFixedSurface == 255:
                return 'cloudTop'

            if typeOfFirstFixedSurface == 4 and typeOfSecondFixedSurface == 255:
                return 'isothermZero'

            if typeOfFirstFixedSurface == 5 and typeOfSecondFixedSurface == 255:
                return 'adiabaticCondensation'

            if typeOfFirstFixedSurface == 6 and typeOfSecondFixedSurface == 255:
                return 'maxWind'

            if typeOfFirstFixedSurface == 7 and typeOfSecondFixedSurface == 255:
                return 'tropopause'

            if typeOfFirstFixedSurface == 8 and typeOfSecondFixedSurface == 255:
                return 'nominalTop'

            if typeOfFirstFixedSurface == 9 and typeOfSecondFixedSurface == 255:
                return 'seaBottom'

            if typeOfFirstFixedSurface == 10 and typeOfSecondFixedSurface == 255:
                return 'atmosphere'

            if typeOfFirstFixedSurface == 20 and typeOfSecondFixedSurface == 255:
                return 'isothermal'

            pressureUnits = h.get_s('pressureUnits')

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 255 and pressureUnits == "Pa":
                return 'isobaricInPa'

            if typeOfFirstFixedSurface == 100 and pressureUnits == "hPa" and typeOfSecondFixedSurface == 255:
                return 'isobaricInhPa'

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 100:
                return 'isobaricLayer'

            if typeOfFirstFixedSurface == 101 and typeOfSecondFixedSurface == 255:
                return 'meanSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 255:
                return 'heightAboveSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 102:
                return 'heightAboveSeaLayer'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 255:
                return 'heightAboveGround'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 103:
                return 'heightAboveGroundLayer'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 255:
                return 'sigma'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 104:
                return 'sigmaLayer'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 255:
                return 'hybrid'

            if typeOfFirstFixedSurface == 118 and typeOfSecondFixedSurface == 255:
                return 'hybridHeight'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 105:
                return 'hybridLayer'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 255:
                return 'depthBelowLand'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 106:
                return 'depthBelowLandLayer'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 255:
                return 'theta'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 107:
                return 'thetaLayer'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 255:
                return 'pressureFromGround'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 108:
                return 'pressureFromGroundLayer'

            if typeOfFirstFixedSurface == 109 and typeOfSecondFixedSurface == 255:
                return 'potentialVorticity'

            if typeOfFirstFixedSurface == 111 and typeOfSecondFixedSurface == 255:
                return 'eta'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 255:
                return 'soil'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 151:
                return 'soilLayer'

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

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and NV == 6:
                return 'generalVertical'

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and typeOfSecondFixedSurface == 150 and NV == 6:
                return 'generalVerticalLayer'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 255:
                return 'depthBelowSea'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 8:
                return 'entireAtmosphere'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 9:
                return 'entireOcean'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 255:
                return 'snow'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 114:
                return 'snowLayer'

            scaleFactorOfFirstFixedSurface = h.get_l(
                'scaleFactorOfFirstFixedSurface')
            scaledValueOfFirstFixedSurface = h.get_l(
                'scaledValueOfFirstFixedSurface')

            if typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 255:
                return 'oceanSurface'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 160:
                return 'oceanLayer'

            if typeOfFirstFixedSurface == 169 and typeOfSecondFixedSurface == 255:
                return 'mixedLayerDepth'

        return wrapped

    h.add(
        _.Concept('typeOfLevel',
                  'unknown',
                  concepts=typeOfLevel_inline_concept(h)))

    h.alias('vertical.typeOfLevel', 'typeOfLevel')
    h.alias('levelType', 'typeOfFirstFixedSurface')

    if (h.get_l('typeOfSecondFixedSurface') == 255):
        h.add(
            _.G2level('level', _.Get('typeOfFirstFixedSurface'),
                      _.Get('scaleFactorOfFirstFixedSurface'),
                      _.Get('scaledValueOfFirstFixedSurface'),
                      _.Get('pressureUnits')))
        h.add(_.Transient('bottomLevel', _.Get('level')))
        h.add(_.Transient('topLevel', _.Get('level')))
    else:
        h.add(
            _.G2level('topLevel', _.Get('typeOfFirstFixedSurface'),
                      _.Get('scaleFactorOfFirstFixedSurface'),
                      _.Get('scaledValueOfFirstFixedSurface'),
                      _.Get('pressureUnits')))
        h.add(
            _.G2level('bottomLevel', _.Get('typeOfSecondFixedSurface'),
                      _.Get('scaleFactorOfSecondFixedSurface'),
                      _.Get('scaledValueOfSecondFixedSurface'),
                      _.Get('pressureUnits')))
        h.alias('level', 'topLevel')

    h.alias('ls.level', 'level')
    h.alias('vertical.level', 'level')
    h.alias('vertical.bottomLevel', 'bottomLevel')
    h.alias('vertical.topLevel', 'topLevel')
    h.alias('extraDim', 'zero')

    if h._defined('extraDimensionPresent'):

        if h.get_l('extraDimensionPresent'):
            h.alias('extraDim', 'one')

    if h.get_l('extraDim'):
        h.alias('mars.levelist', 'dimension')
        h.alias('mars.levtype', 'dimensionType')
    else:
        h.add(_.Transient('tempPressureUnits', _.Get('pressureUnits')))

        if not ((h.get_s('typeOfLevel') == "surface")):

            if (h.get_s('tempPressureUnits') == "Pa"):
                h.add(
                    _.Scale('marsLevel', _.Get('level'), _.Get('one'),
                            _.Get('hundred')))
                h.alias('mars.levelist', 'marsLevel')
            else:
                h.alias('mars.levelist', 'level')

        h.alias('mars.levtype', 'typeOfFirstFixedSurface')

        if (h.get_s('levtype') == "sfc"):
            h.unalias('mars.levelist')

    if ((h.get_l('typeOfFirstFixedSurface') == 151)
            and (h.get_l('typeOfSecondFixedSurface') == 151)):
        h.alias('mars.levelist', 'bottomLevel')

    h.alias('ls.typeOfLevel', 'typeOfLevel')
    h.add(
        _.Codetable('typeOfEnsembleForecast', 1, "4.6.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('perturbationNumber', 1))
    h.alias('number', 'perturbationNumber')
    h.add(_.Unsigned('numberOfForecastsInEnsemble', 1))
    h.alias('totalNumber', 'numberOfForecastsInEnsemble')

    if ((((((((h.get_l('productionStatusOfProcessedData') == 4) or
              (h.get_l('productionStatusOfProcessedData') == 5)) or
             (h.get_l('productionStatusOfProcessedData') == 6)) or
            (h.get_l('productionStatusOfProcessedData') == 7)) or
           (h.get_l('productionStatusOfProcessedData') == 8)) or
          (h.get_l('productionStatusOfProcessedData') == 9)) or
         (h.get_l('productionStatusOfProcessedData') == 10))
            or (h.get_l('productionStatusOfProcessedData') == 11)):
        h.alias('mars.number', 'perturbationNumber')
Ejemplo n.º 23
0
def load(h):

    h.add(
        _.Codetable('parameterCategory', 1, "4.1.[discipline:l].table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable('parameterNumber', 1,
                    "4.2.[discipline:l].[parameterCategory:l].table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('parameterUnits', _.Get('parameterNumber')))
    h.add(_.Codetable_title('parameterName', _.Get('parameterNumber')))
    h.add(
        _.Codetable('typeOfGeneratingProcess', 1, "4.3.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('backgroundProcess', 1))
    h.alias('backgroundGeneratingProcessIdentifier', 'backgroundProcess')
    h.add(_.Unsigned('generatingProcessIdentifier', 1))
    h.add(_.Unsigned('hoursAfterDataCutoff', 2))
    h.alias('hoursAfterReferenceTimeOfDataCutoff', 'hoursAfterDataCutoff')
    h.add(_.Unsigned('minutesAfterDataCutoff', 1))
    h.alias('minutesAfterReferenceTimeOfDataCutoff', 'minutesAfterDataCutoff')
    h.add(
        _.Codetable('indicatorOfUnitOfTimeRange', 1, "4.4.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.alias('defaultStepUnits', 'one')
    _.Template('grib2/localConcepts/[centre:s]/default_step_units.def',
               True).load(h)
    h.add(_.TransientCodetable('stepUnits', 1, "stepUnits.table"))
    h.add(_.Signed('forecastTime', 4))
    h.add(
        _.StringCodetable('typeOfFirstFixedSurface', 1, "4.5.table",
                          _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable_units('unitsOfFirstFixedSurface',
                          _.Get('typeOfFirstFixedSurface')))
    h.add(
        _.Codetable_title('nameOfFirstFixedSurface',
                          _.Get('typeOfFirstFixedSurface')))
    h.add(_.Signed('scaleFactorOfFirstFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfFirstFixedSurface', 4))
    h.add(
        _.Codetable('typeOfSecondFixedSurface', 1, "4.5.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable_units('unitsOfSecondFixedSurface',
                          _.Get('typeOfSecondFixedSurface')))
    h.add(
        _.Codetable_title('nameOfSecondFixedSurface',
                          _.Get('typeOfSecondFixedSurface')))
    h.add(_.Signed('scaleFactorOfSecondFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfSecondFixedSurface', 4))
    h.add(_.Transient('pressureUnits', "hPa"))

    def typeOfLevel_inline_concept(h):
        def wrapped(h):

            typeOfFirstFixedSurface = h.get_l('typeOfFirstFixedSurface')
            typeOfSecondFixedSurface = h.get_l('typeOfSecondFixedSurface')

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 255:
                return 'surface'

            if typeOfFirstFixedSurface == 2 and typeOfSecondFixedSurface == 255:
                return 'cloudBase'

            if typeOfFirstFixedSurface == 3 and typeOfSecondFixedSurface == 255:
                return 'cloudTop'

            if typeOfFirstFixedSurface == 4 and typeOfSecondFixedSurface == 255:
                return 'isothermZero'

            if typeOfFirstFixedSurface == 5 and typeOfSecondFixedSurface == 255:
                return 'adiabaticCondensation'

            if typeOfFirstFixedSurface == 6 and typeOfSecondFixedSurface == 255:
                return 'maxWind'

            if typeOfFirstFixedSurface == 7 and typeOfSecondFixedSurface == 255:
                return 'tropopause'

            if typeOfFirstFixedSurface == 8 and typeOfSecondFixedSurface == 255:
                return 'nominalTop'

            if typeOfFirstFixedSurface == 9 and typeOfSecondFixedSurface == 255:
                return 'seaBottom'

            if typeOfFirstFixedSurface == 10 and typeOfSecondFixedSurface == 255:
                return 'atmosphere'

            if typeOfFirstFixedSurface == 20 and typeOfSecondFixedSurface == 255:
                return 'isothermal'

            pressureUnits = h.get_s('pressureUnits')

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 255 and pressureUnits == "Pa":
                return 'isobaricInPa'

            if typeOfFirstFixedSurface == 100 and pressureUnits == "hPa" and typeOfSecondFixedSurface == 255:
                return 'isobaricInhPa'

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 100:
                return 'isobaricLayer'

            if typeOfFirstFixedSurface == 101 and typeOfSecondFixedSurface == 255:
                return 'meanSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 255:
                return 'heightAboveSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 102:
                return 'heightAboveSeaLayer'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 255:
                return 'heightAboveGround'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 103:
                return 'heightAboveGroundLayer'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 255:
                return 'sigma'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 104:
                return 'sigmaLayer'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 255:
                return 'hybrid'

            if typeOfFirstFixedSurface == 118 and typeOfSecondFixedSurface == 255:
                return 'hybridHeight'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 105:
                return 'hybridLayer'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 255:
                return 'depthBelowLand'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 106:
                return 'depthBelowLandLayer'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 255:
                return 'theta'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 107:
                return 'thetaLayer'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 255:
                return 'pressureFromGround'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 108:
                return 'pressureFromGroundLayer'

            if typeOfFirstFixedSurface == 109 and typeOfSecondFixedSurface == 255:
                return 'potentialVorticity'

            if typeOfFirstFixedSurface == 111 and typeOfSecondFixedSurface == 255:
                return 'eta'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 255:
                return 'soil'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 151:
                return 'soilLayer'

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

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and NV == 6:
                return 'generalVertical'

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and typeOfSecondFixedSurface == 150 and NV == 6:
                return 'generalVerticalLayer'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 255:
                return 'depthBelowSea'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 8:
                return 'entireAtmosphere'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 9:
                return 'entireOcean'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 255:
                return 'snow'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 114:
                return 'snowLayer'

            scaleFactorOfFirstFixedSurface = h.get_l(
                'scaleFactorOfFirstFixedSurface')
            scaledValueOfFirstFixedSurface = h.get_l(
                'scaledValueOfFirstFixedSurface')

            if typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 255:
                return 'oceanSurface'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 160:
                return 'oceanLayer'

            if typeOfFirstFixedSurface == 169 and typeOfSecondFixedSurface == 255:
                return 'mixedLayerDepth'

        return wrapped

    h.add(
        _.Concept('typeOfLevel',
                  'unknown',
                  concepts=typeOfLevel_inline_concept(h)))

    h.alias('vertical.typeOfLevel', 'typeOfLevel')
    h.alias('levelType', 'typeOfFirstFixedSurface')

    if (h.get_l('typeOfSecondFixedSurface') == 255):
        h.add(
            _.G2level('level', _.Get('typeOfFirstFixedSurface'),
                      _.Get('scaleFactorOfFirstFixedSurface'),
                      _.Get('scaledValueOfFirstFixedSurface'),
                      _.Get('pressureUnits')))
        h.add(_.Transient('bottomLevel', _.Get('level')))
        h.add(_.Transient('topLevel', _.Get('level')))
    else:
        h.add(
            _.G2level('topLevel', _.Get('typeOfFirstFixedSurface'),
                      _.Get('scaleFactorOfFirstFixedSurface'),
                      _.Get('scaledValueOfFirstFixedSurface'),
                      _.Get('pressureUnits')))
        h.add(
            _.G2level('bottomLevel', _.Get('typeOfSecondFixedSurface'),
                      _.Get('scaleFactorOfSecondFixedSurface'),
                      _.Get('scaledValueOfSecondFixedSurface'),
                      _.Get('pressureUnits')))
        h.alias('level', 'topLevel')

    h.alias('ls.level', 'level')
    h.alias('vertical.level', 'level')
    h.alias('vertical.bottomLevel', 'bottomLevel')
    h.alias('vertical.topLevel', 'topLevel')
    h.alias('extraDim', 'zero')

    if h._defined('extraDimensionPresent'):

        if h.get_l('extraDimensionPresent'):
            h.alias('extraDim', 'one')

    if h.get_l('extraDim'):
        h.alias('mars.levelist', 'dimension')
        h.alias('mars.levtype', 'dimensionType')
    else:
        h.add(_.Transient('tempPressureUnits', _.Get('pressureUnits')))

        if not ((h.get_s('typeOfLevel') == "surface")):

            if (h.get_s('tempPressureUnits') == "Pa"):
                h.add(
                    _.Scale('marsLevel', _.Get('level'), _.Get('one'),
                            _.Get('hundred')))
                h.alias('mars.levelist', 'marsLevel')
            else:
                h.alias('mars.levelist', 'level')

        h.alias('mars.levtype', 'typeOfFirstFixedSurface')

        if (h.get_s('levtype') == "sfc"):
            h.unalias('mars.levelist')

    if ((h.get_l('typeOfFirstFixedSurface') == 151)
            and (h.get_l('typeOfSecondFixedSurface') == 151)):
        h.alias('mars.levelist', 'bottomLevel')

    h.alias('ls.typeOfLevel', 'typeOfLevel')
    h.add(
        _.Codetable('derivedForecast', 1, "4.7.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(_.Unsigned('numberOfForecastsInEnsemble', 1))
    h.alias('totalNumber', 'numberOfForecastsInEnsemble')
    h.add(_.Unsigned('clusterIdentifier', 1))
    h.alias('number', 'clusterIdentifier')
    h.add(_.Unsigned('numberOfClusterHighResolution', 1))
    h.add(_.Unsigned('numberOfClusterLowResolution', 1))
    h.add(_.Unsigned('totalNumberOfClusters', 1))
    h.alias('totalNumber', 'totalNumberOfClusters')
    h.add(
        _.Codetable('clusteringMethod', 1, "4.8.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(_.Unsigned('latitudeOfCentralPointInClusterDomain', 4))
    h.add(_.Unsigned('longitudeOfCentralPointInClusterDomain', 4))
    h.add(_.Unsigned('radiusOfClusterDomain', 4))
    h.add(_.Unsigned('numberOfForecastsInTheCluster', 1))
    h.alias('NC', 'numberOfForecastsInTheCluster')
    h.add(_.Unsigned('scaleFactorOfStandardDeviation', 1))
    h.alias('scaleFactorOfStandardDeviationInTheCluster',
            'scaleFactorOfStandardDeviation')
    h.add(_.Unsigned('scaledValueOfStandardDeviation', 4))
    h.alias('scaledValueOfStandardDeviationInTheCluster',
            'scaledValueOfStandardDeviation')
    h.add(_.Unsigned('scaleFactorOfDistanceFromEnsembleMean', 1))
    h.add(_.Unsigned('scaleFactorOfDistanceFromEnsembleMean', 4))
    h.add(_.Unsigned('yearOfEndOfOverallTimeInterval', 2))
    h.add(_.Unsigned('monthOfEndOfOverallTimeInterval', 1))
    h.add(_.Unsigned('dayOfEndOfOverallTimeInterval', 1))
    h.add(_.Unsigned('hourOfEndOfOverallTimeInterval', 1))
    h.add(_.Unsigned('minuteOfEndOfOverallTimeInterval', 1))
    h.add(_.Unsigned('secondOfEndOfOverallTimeInterval', 1))
    h.add(_.Unsigned('numberOfTimeRange', 1))
    h.alias('n', 'numberOfTimeRange')
    h.add(_.Unsigned('numberOfMissingInStatisticalProcess', 4))
    h.alias('totalNumberOfDataValuesMissingInStatisticalProcess',
            'numberOfMissingInStatisticalProcess')

    with h.list('statisticalProcessesList'):
        for i in range(0, h.get_l('numberOfTimeRange')):
            h.add(
                _.Codetable('typeOfStatisticalProcessing', 1, "4.10.table",
                            _.Get('masterDir'), _.Get('localDir')))
            h.add(
                _.Codetable('typeOfTimeIncrement', 1, "4.11.table",
                            _.Get('masterDir'), _.Get('localDir')))
            h.alias(
                'typeOfTimeIncrementBetweenSuccessiveFieldsUsedInTheStatisticalProcessing',
                'typeOfTimeIncrement')
            h.add(
                _.Codetable('indicatorOfUnitForTimeRange', 1, "4.4.table",
                            _.Get('masterDir'), _.Get('localDir')))
            h.add(_.Unsigned('lengthOfTimeRange', 4))
            h.add(
                _.Codetable('indicatorOfUnitForTimeIncrement', 1, "4.4.table",
                            _.Get('masterDir'), _.Get('localDir')))
            h.add(_.Unsigned('timeIncrement', 4))
            h.alias('timeIncrementBetweenSuccessiveFields', 'timeIncrement')

    if ((h.get_l('numberOfTimeRange') == 1)
            or (h.get_l('numberOfTimeRange') == 2)):

        def stepTypeInternal_inline_concept(h):
            def wrapped(h):

                typeOfStatisticalProcessing = h.get_l(
                    'typeOfStatisticalProcessing')

                if typeOfStatisticalProcessing == 255:
                    return 'instant'

                typeOfTimeIncrement = h.get_l('typeOfTimeIncrement')

                if typeOfStatisticalProcessing == 0 and typeOfTimeIncrement == 2:
                    return 'avg'

                if typeOfStatisticalProcessing == 0 and typeOfTimeIncrement == 3:
                    return 'avg'

                if typeOfStatisticalProcessing == 0 and typeOfTimeIncrement == 1:
                    return 'avgd'

                if typeOfStatisticalProcessing == 1 and typeOfTimeIncrement == 2:
                    return 'accum'

                if typeOfStatisticalProcessing == 2:
                    return 'max'

                if typeOfStatisticalProcessing == 3:
                    return 'min'

                if typeOfStatisticalProcessing == 4:
                    return 'diff'

                if typeOfStatisticalProcessing == 5:
                    return 'rms'

                if typeOfStatisticalProcessing == 6:
                    return 'sd'

                if typeOfStatisticalProcessing == 7:
                    return 'cov'

                if typeOfStatisticalProcessing == 8:
                    return 'sdiff'

                if typeOfStatisticalProcessing == 9:
                    return 'ratio'

                if typeOfStatisticalProcessing == 10:
                    return 'stdanom'

                if typeOfStatisticalProcessing == 11:
                    return 'sum'

            return wrapped

        h.add(
            _.Concept('stepTypeInternal',
                      None,
                      concepts=stepTypeInternal_inline_concept(h)))

        h.add(
            _.Step_in_units('startStep', _.Get('forecastTime'),
                            _.Get('indicatorOfUnitOfTimeRange'),
                            _.Get('stepUnits'),
                            _.Get('indicatorOfUnitForTimeRange'),
                            _.Get('lengthOfTimeRange')))
        h.add(
            _.G2end_step('endStep', _.Get('startStep'), _.Get('stepUnits'),
                         _.Get('year'), _.Get('month'), _.Get('day'),
                         _.Get('hour'), _.Get('minute'), _.Get('second'),
                         _.Get('yearOfEndOfOverallTimeInterval'),
                         _.Get('monthOfEndOfOverallTimeInterval'),
                         _.Get('dayOfEndOfOverallTimeInterval'),
                         _.Get('hourOfEndOfOverallTimeInterval'),
                         _.Get('minuteOfEndOfOverallTimeInterval'),
                         _.Get('secondOfEndOfOverallTimeInterval'),
                         _.Get('indicatorOfUnitForTimeRange'),
                         _.Get('lengthOfTimeRange'),
                         _.Get('typeOfTimeIncrement'),
                         _.Get('numberOfTimeRange')))
        h.add(_.G2step_range('stepRange', _.Get('startStep'),
                             _.Get('endStep')))
    else:
        h.add(_.Constant('stepType', "multiple steps"))
        h.add(_.Constant('stepTypeInternal', "multiple steps"))
        h.add(_.Constant('endStep', "unavailable"))
        h.add(_.Constant('startStep', "unavailable"))
        h.add(_.Constant('stepRange', "unavailable"))

    h.alias('ls.stepRange', 'stepRange')
    h.alias('mars.step', 'endStep')
    h.alias('time.stepType', 'stepType')
    h.alias('time.stepRange', 'stepRange')
    h.alias('time.stepUnits', 'stepUnits')
    h.alias('time.dataDate', 'dataDate')
    h.alias('time.dataTime', 'dataTime')
    h.alias('time.startStep', 'startStep')
    h.alias('time.endStep', 'endStep')
    h.add(
        _.Validity_date('validityDate', _.Get('date'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits'),
                        _.Get('yearOfEndOfOverallTimeInterval'),
                        _.Get('monthOfEndOfOverallTimeInterval'),
                        _.Get('dayOfEndOfOverallTimeInterval')))
    h.alias('time.validityDate', 'validityDate')
    h.add(
        _.Validity_time('validityTime', _.Get('date'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits'),
                        _.Get('hourOfEndOfOverallTimeInterval'),
                        _.Get('minuteOfEndOfOverallTimeInterval')))
    h.alias('time.validityTime', 'validityTime')

    with h.list('ensembleForecastNumbersList'):
        for i in range(0, h.get_l('numberOfForecastsInTheCluster')):
            h.add(_.Unsigned('ensembleForecastNumbers', 1))
Ejemplo n.º 24
0
def load(h):

    h.add(_.Codetable('parameterCategory', 1, "4.1.[discipline:l].table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable('parameterNumber', 1, "4.2.[discipline:l].[parameterCategory:l].table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('parameterUnits', _.Get('parameterNumber')))
    h.add(_.Codetable_title('parameterName', _.Get('parameterNumber')))
    h.add(_.Codetable('tileClassification', 1, "4.242.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('totalNumberOfTileAttributePairs', 1))
    h.add(_.Unsigned('numberOfUsedSpatialTiles', 1))
    h.add(_.Unsigned('tileIndex', 1))
    h.add(_.Unsigned('numberOfUsedTileAttributes', 1))
    h.add(_.Codetable('attributeOfTile', 1, "4.241.table", _.Get('masterDir'), _.Get('localDir')))
    h.alias('NT', 'totalNumberOfTileAttributePairs')
    h.alias('NUT', 'numberOfUsedSpatialTiles')
    h.alias('ITN', 'tileIndex')
    h.alias('NAT', 'numberOfUsedTileAttributes')
    h.add(_.Codetable('typeOfGeneratingProcess', 1, "4.3.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('backgroundProcess', 1))
    h.alias('backgroundGeneratingProcessIdentifier', 'backgroundProcess')
    h.add(_.Unsigned('generatingProcessIdentifier', 1))
    h.add(_.Unsigned('hoursAfterDataCutoff', 2))
    h.alias('hoursAfterReferenceTimeOfDataCutoff', 'hoursAfterDataCutoff')
    h.add(_.Unsigned('minutesAfterDataCutoff', 1))
    h.alias('minutesAfterReferenceTimeOfDataCutoff', 'minutesAfterDataCutoff')
    h.add(_.Codetable('indicatorOfUnitOfTimeRange', 1, "4.4.table", _.Get('masterDir'), _.Get('localDir')))
    h.alias('defaultStepUnits', 'one')
    _.Template('grib2/localConcepts/[centre:s]/default_step_units.def', True).load(h)
    h.add(_.TransientCodetable('stepUnits', 1, "stepUnits.table"))
    h.add(_.Signed('forecastTime', 4))
    h.add(_.StringCodetable('typeOfFirstFixedSurface', 1, "4.5.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('unitsOfFirstFixedSurface', _.Get('typeOfFirstFixedSurface')))
    h.add(_.Codetable_title('nameOfFirstFixedSurface', _.Get('typeOfFirstFixedSurface')))
    h.add(_.Signed('scaleFactorOfFirstFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfFirstFixedSurface', 4))
    h.add(_.Codetable('typeOfSecondFixedSurface', 1, "4.5.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('unitsOfSecondFixedSurface', _.Get('typeOfSecondFixedSurface')))
    h.add(_.Codetable_title('nameOfSecondFixedSurface', _.Get('typeOfSecondFixedSurface')))
    h.add(_.Signed('scaleFactorOfSecondFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfSecondFixedSurface', 4))
    h.add(_.Transient('pressureUnits', "hPa"))

    def typeOfLevel_inline_concept(h):
        def wrapped(h):

            typeOfFirstFixedSurface = h.get_l('typeOfFirstFixedSurface')
            typeOfSecondFixedSurface = h.get_l('typeOfSecondFixedSurface')

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 255:
                return 'surface'

            if typeOfFirstFixedSurface == 2 and typeOfSecondFixedSurface == 255:
                return 'cloudBase'

            if typeOfFirstFixedSurface == 3 and typeOfSecondFixedSurface == 255:
                return 'cloudTop'

            if typeOfFirstFixedSurface == 4 and typeOfSecondFixedSurface == 255:
                return 'isothermZero'

            if typeOfFirstFixedSurface == 5 and typeOfSecondFixedSurface == 255:
                return 'adiabaticCondensation'

            if typeOfFirstFixedSurface == 6 and typeOfSecondFixedSurface == 255:
                return 'maxWind'

            if typeOfFirstFixedSurface == 7 and typeOfSecondFixedSurface == 255:
                return 'tropopause'

            if typeOfFirstFixedSurface == 8 and typeOfSecondFixedSurface == 255:
                return 'nominalTop'

            if typeOfFirstFixedSurface == 9 and typeOfSecondFixedSurface == 255:
                return 'seaBottom'

            if typeOfFirstFixedSurface == 10 and typeOfSecondFixedSurface == 255:
                return 'atmosphere'

            if typeOfFirstFixedSurface == 20 and typeOfSecondFixedSurface == 255:
                return 'isothermal'

            pressureUnits = h.get_s('pressureUnits')

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 255 and pressureUnits == "Pa":
                return 'isobaricInPa'

            if typeOfFirstFixedSurface == 100 and pressureUnits == "hPa" and typeOfSecondFixedSurface == 255:
                return 'isobaricInhPa'

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 100:
                return 'isobaricLayer'

            if typeOfFirstFixedSurface == 101 and typeOfSecondFixedSurface == 255:
                return 'meanSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 255:
                return 'heightAboveSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 102:
                return 'heightAboveSeaLayer'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 255:
                return 'heightAboveGround'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 103:
                return 'heightAboveGroundLayer'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 255:
                return 'sigma'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 104:
                return 'sigmaLayer'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 255:
                return 'hybrid'

            if typeOfFirstFixedSurface == 118 and typeOfSecondFixedSurface == 255:
                return 'hybridHeight'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 105:
                return 'hybridLayer'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 255:
                return 'depthBelowLand'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 106:
                return 'depthBelowLandLayer'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 255:
                return 'theta'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 107:
                return 'thetaLayer'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 255:
                return 'pressureFromGround'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 108:
                return 'pressureFromGroundLayer'

            if typeOfFirstFixedSurface == 109 and typeOfSecondFixedSurface == 255:
                return 'potentialVorticity'

            if typeOfFirstFixedSurface == 111 and typeOfSecondFixedSurface == 255:
                return 'eta'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 255:
                return 'soil'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 151:
                return 'soilLayer'

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

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and NV == 6:
                return 'generalVertical'

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and typeOfSecondFixedSurface == 150 and NV == 6:
                return 'generalVerticalLayer'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 255:
                return 'depthBelowSea'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 8:
                return 'entireAtmosphere'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 9:
                return 'entireOcean'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 255:
                return 'snow'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 114:
                return 'snowLayer'

            scaleFactorOfFirstFixedSurface = h.get_l('scaleFactorOfFirstFixedSurface')
            scaledValueOfFirstFixedSurface = h.get_l('scaledValueOfFirstFixedSurface')

            if typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 255:
                return 'oceanSurface'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 160:
                return 'oceanLayer'

            if typeOfFirstFixedSurface == 169 and typeOfSecondFixedSurface == 255:
                return 'mixedLayerDepth'

        return wrapped

    h.add(_.Concept('typeOfLevel', 'unknown', concepts=typeOfLevel_inline_concept(h)))

    h.alias('vertical.typeOfLevel', 'typeOfLevel')
    h.alias('levelType', 'typeOfFirstFixedSurface')

    if (h.get_l('typeOfSecondFixedSurface') == 255):
        h.add(_.G2level('level', _.Get('typeOfFirstFixedSurface'), _.Get('scaleFactorOfFirstFixedSurface'), _.Get('scaledValueOfFirstFixedSurface'), _.Get('pressureUnits')))
        h.add(_.Transient('bottomLevel', _.Get('level')))
        h.add(_.Transient('topLevel', _.Get('level')))
    else:
        h.add(_.G2level('topLevel', _.Get('typeOfFirstFixedSurface'), _.Get('scaleFactorOfFirstFixedSurface'), _.Get('scaledValueOfFirstFixedSurface'), _.Get('pressureUnits')))
        h.add(_.G2level('bottomLevel', _.Get('typeOfSecondFixedSurface'), _.Get('scaleFactorOfSecondFixedSurface'), _.Get('scaledValueOfSecondFixedSurface'), _.Get('pressureUnits')))
        h.alias('level', 'topLevel')

    h.alias('ls.level', 'level')
    h.alias('vertical.level', 'level')
    h.alias('vertical.bottomLevel', 'bottomLevel')
    h.alias('vertical.topLevel', 'topLevel')
    h.alias('extraDim', 'zero')

    if h._defined('extraDimensionPresent'):

        if h.get_l('extraDimensionPresent'):
            h.alias('extraDim', 'one')


    if h.get_l('extraDim'):
        h.alias('mars.levelist', 'dimension')
        h.alias('mars.levtype', 'dimensionType')
    else:
        h.add(_.Transient('tempPressureUnits', _.Get('pressureUnits')))

        if not ((h.get_s('typeOfLevel') == "surface")):

            if (h.get_s('tempPressureUnits') == "Pa"):
                h.add(_.Scale('marsLevel', _.Get('level'), _.Get('one'), _.Get('hundred')))
                h.alias('mars.levelist', 'marsLevel')
            else:
                h.alias('mars.levelist', 'level')


        h.alias('mars.levtype', 'typeOfFirstFixedSurface')

        if (h.get_s('levtype') == "sfc"):
            h.unalias('mars.levelist')

    if ((h.get_l('typeOfFirstFixedSurface') == 151) and (h.get_l('typeOfSecondFixedSurface') == 151)):
        h.alias('mars.levelist', 'bottomLevel')

    h.alias('ls.typeOfLevel', 'typeOfLevel')
    h.add(_.Unsigned('perturbationNumber', 1))
    h.alias('number', 'perturbationNumber')
    h.add(_.Unsigned('numberOfForecastsInEnsemble', 1))
    h.alias('totalNumber', 'numberOfForecastsInEnsemble')
Ejemplo n.º 25
0
def load(h):

    _.Template('grib1/grid_[gridDefinition].def').load(h)
    h.add(_.Constant('numberOfVerticalCoordinateValues', 0))
    h.add(_.Constant('neitherPresent', 255))
    h.alias('NV', 'numberOfVerticalCoordinateValues')
    h.alias('numberOfCoordinatesValues', 'numberOfVerticalCoordinateValues')
    h.add(_.Constant('pvlLocation', 255))
    h.add(_.Constant('dataRepresentationType', 0))
    h.add(_.Constant('gridDefinitionTemplateNumber', 0))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('numberOfPointsAlongAMeridian', 'Nj')
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(
        _.Scale('longitudeOfFirstGridPointInDegrees',
                _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees',
            'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Constant('resolutionAndComponentFlags', 128))
    h.add(_.Constant('ijDirectionIncrementGiven', 1))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Constant('earthIsOblate', 0))
    h.add(_.Constant('resolutionAndComponentFlags3', 0))
    h.add(_.Constant('resolutionAndComponentFlags4', 0))
    h.add(_.Constant('uvRelativeToGrid', 0))
    h.add(_.Constant('resolutionAndComponentFlags6', 0))
    h.add(_.Constant('resolutionAndComponentFlags7', 0))
    h.add(_.Constant('resolutionAndComponentFlags8', 0))
    h.add(
        _.Scale('latitudeOfLastGridPointInDegrees',
                _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees',
            'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(
        _.Scale('longitudeOfLastGridPointInDegrees',
                _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees',
            'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('Dj', 'jDirectionIncrement')
    h.alias('Di', 'iDirectionIncrement')
    h.add(_.Constant('scanningMode', 64))
    h.add(_.Constant('iScansNegatively', 0))
    h.add(_.Constant('jScansPositively', 1))
    h.add(_.Constant('jPointsAreConsecutive', 0))
    h.add(_.Constant('iScansPositively', 1))
    h.add(_.Constant('scanningMode4', 0))
    h.add(_.Constant('scanningMode5', 0))
    h.add(_.Constant('scanningMode6', 0))
    h.add(_.Constant('scanningMode7', 0))
    h.add(_.Constant('scanningMode8', 0))
    h.add(
        _.Latlon_increment('jDirectionIncrementInDegrees',
                           _.Get('ijDirectionIncrementGiven'),
                           _.Get('jDirectionIncrement'),
                           _.Get('jScansPositively'),
                           _.Get('latitudeOfFirstGridPointInDegrees'),
                           _.Get('latitudeOfLastGridPointInDegrees'),
                           _.Get('numberOfPointsAlongAMeridian'),
                           _.Get('oneConstant'), _.Get('grib1divider'), 0))
    h.alias('geography.jDirectionIncrementInDegrees',
            'jDirectionIncrementInDegrees')
    h.add(
        _.Latlon_increment('iDirectionIncrementInDegrees',
                           _.Get('ijDirectionIncrementGiven'),
                           _.Get('iDirectionIncrement'),
                           _.Get('iScansPositively'),
                           _.Get('longitudeOfFirstGridPointInDegrees'),
                           _.Get('longitudeOfLastGridPointInDegrees'),
                           _.Get('Ni'), _.Get('oneConstant'),
                           _.Get('grib1divider'), 1))
    h.alias('geography.iDirectionIncrementInDegrees',
            'iDirectionIncrementInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('DiInDegrees', 'iDirectionIncrementInDegrees')
    h.alias('DjInDegrees', 'jDirectionIncrementInDegrees')
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Constant('PVPresent', 0))
    h.add(_.Constant('PLPresent', 0))
    h.add(_.Constant('reducedGrid', 0))
    h.add(_.Constant('numberOfUnusedBitsAtEndOfSection3', 0))
    h.add(_.Constant('tableReference', 0))
    h.add(
        _.Gds_not_present_bitmap('bitmap', _.Get('missingValue'),
                                 _.Get('numberOfValues'),
                                 _.Get('numberOfPoints'),
                                 _.Get('latitudeOfFirstGridPoint'),
                                 _.Get('Ni'),
                                 _.Get('numberOfUnusedBitsAtEndOfSection3')))
Ejemplo n.º 26
0
def load(h):

    h.add(_.StringCodetable('typeOfFirstFixedSurface', 1, "4.5.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('unitsOfFirstFixedSurface', _.Get('typeOfFirstFixedSurface')))
    h.add(_.Codetable_title('nameOfFirstFixedSurface', _.Get('typeOfFirstFixedSurface')))
    h.add(_.Signed('scaleFactorOfFirstFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfFirstFixedSurface', 4))
    h.add(_.Codetable('typeOfSecondFixedSurface', 1, "4.5.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Codetable_units('unitsOfSecondFixedSurface', _.Get('typeOfSecondFixedSurface')))
    h.add(_.Codetable_title('nameOfSecondFixedSurface', _.Get('typeOfSecondFixedSurface')))
    h.add(_.Signed('scaleFactorOfSecondFixedSurface', 1))
    h.add(_.Unsigned('scaledValueOfSecondFixedSurface', 4))
    h.add(_.Transient('pressureUnits', "hPa"))

    def typeOfLevel_inline_concept(h):
        def wrapped(h):

            typeOfFirstFixedSurface = h.get_l('typeOfFirstFixedSurface')
            typeOfSecondFixedSurface = h.get_l('typeOfSecondFixedSurface')

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 255:
                return 'surface'

            if typeOfFirstFixedSurface == 2 and typeOfSecondFixedSurface == 255:
                return 'cloudBase'

            if typeOfFirstFixedSurface == 3 and typeOfSecondFixedSurface == 255:
                return 'cloudTop'

            if typeOfFirstFixedSurface == 4 and typeOfSecondFixedSurface == 255:
                return 'isothermZero'

            if typeOfFirstFixedSurface == 5 and typeOfSecondFixedSurface == 255:
                return 'adiabaticCondensation'

            if typeOfFirstFixedSurface == 6 and typeOfSecondFixedSurface == 255:
                return 'maxWind'

            if typeOfFirstFixedSurface == 7 and typeOfSecondFixedSurface == 255:
                return 'tropopause'

            if typeOfFirstFixedSurface == 8 and typeOfSecondFixedSurface == 255:
                return 'nominalTop'

            if typeOfFirstFixedSurface == 9 and typeOfSecondFixedSurface == 255:
                return 'seaBottom'

            if typeOfFirstFixedSurface == 10 and typeOfSecondFixedSurface == 255:
                return 'atmosphere'

            if typeOfFirstFixedSurface == 20 and typeOfSecondFixedSurface == 255:
                return 'isothermal'

            pressureUnits = h.get_s('pressureUnits')

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 255 and pressureUnits == "Pa":
                return 'isobaricInPa'

            if typeOfFirstFixedSurface == 100 and pressureUnits == "hPa" and typeOfSecondFixedSurface == 255:
                return 'isobaricInhPa'

            if typeOfFirstFixedSurface == 100 and typeOfSecondFixedSurface == 100:
                return 'isobaricLayer'

            if typeOfFirstFixedSurface == 101 and typeOfSecondFixedSurface == 255:
                return 'meanSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 255:
                return 'heightAboveSea'

            if typeOfFirstFixedSurface == 102 and typeOfSecondFixedSurface == 102:
                return 'heightAboveSeaLayer'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 255:
                return 'heightAboveGround'

            if typeOfFirstFixedSurface == 103 and typeOfSecondFixedSurface == 103:
                return 'heightAboveGroundLayer'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 255:
                return 'sigma'

            if typeOfFirstFixedSurface == 104 and typeOfSecondFixedSurface == 104:
                return 'sigmaLayer'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 255:
                return 'hybrid'

            if typeOfFirstFixedSurface == 118 and typeOfSecondFixedSurface == 255:
                return 'hybridHeight'

            if typeOfFirstFixedSurface == 105 and typeOfSecondFixedSurface == 105:
                return 'hybridLayer'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 255:
                return 'depthBelowLand'

            if typeOfFirstFixedSurface == 106 and typeOfSecondFixedSurface == 106:
                return 'depthBelowLandLayer'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 255:
                return 'theta'

            if typeOfFirstFixedSurface == 107 and typeOfSecondFixedSurface == 107:
                return 'thetaLayer'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 255:
                return 'pressureFromGround'

            if typeOfFirstFixedSurface == 108 and typeOfSecondFixedSurface == 108:
                return 'pressureFromGroundLayer'

            if typeOfFirstFixedSurface == 109 and typeOfSecondFixedSurface == 255:
                return 'potentialVorticity'

            if typeOfFirstFixedSurface == 111 and typeOfSecondFixedSurface == 255:
                return 'eta'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 255:
                return 'soil'

            if typeOfFirstFixedSurface == 151 and typeOfSecondFixedSurface == 151:
                return 'soilLayer'

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

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and NV == 6:
                return 'generalVertical'

            if genVertHeightCoords == 1 and typeOfFirstFixedSurface == 150 and typeOfSecondFixedSurface == 150 and NV == 6:
                return 'generalVerticalLayer'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 255:
                return 'depthBelowSea'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 8:
                return 'entireAtmosphere'

            if typeOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 9:
                return 'entireOcean'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 255:
                return 'snow'

            if typeOfFirstFixedSurface == 114 and typeOfSecondFixedSurface == 114:
                return 'snowLayer'

            scaleFactorOfFirstFixedSurface = h.get_l('scaleFactorOfFirstFixedSurface')
            scaledValueOfFirstFixedSurface = h.get_l('scaledValueOfFirstFixedSurface')

            if typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 255:
                return 'oceanSurface'

            if typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 160:
                return 'oceanLayer'

            if typeOfFirstFixedSurface == 169 and typeOfSecondFixedSurface == 255:
                return 'mixedLayerDepth'

        return wrapped

    h.add(_.Concept('typeOfLevel', 'unknown', concepts=typeOfLevel_inline_concept(h)))

    h.alias('vertical.typeOfLevel', 'typeOfLevel')
    h.alias('levelType', 'typeOfFirstFixedSurface')

    if (h.get_l('typeOfSecondFixedSurface') == 255):
        h.add(_.G2level('level', _.Get('typeOfFirstFixedSurface'), _.Get('scaleFactorOfFirstFixedSurface'), _.Get('scaledValueOfFirstFixedSurface'), _.Get('pressureUnits')))
        h.add(_.Transient('bottomLevel', _.Get('level')))
        h.add(_.Transient('topLevel', _.Get('level')))
    else:
        h.add(_.G2level('topLevel', _.Get('typeOfFirstFixedSurface'), _.Get('scaleFactorOfFirstFixedSurface'), _.Get('scaledValueOfFirstFixedSurface'), _.Get('pressureUnits')))
        h.add(_.G2level('bottomLevel', _.Get('typeOfSecondFixedSurface'), _.Get('scaleFactorOfSecondFixedSurface'), _.Get('scaledValueOfSecondFixedSurface'), _.Get('pressureUnits')))
        h.alias('level', 'topLevel')

    h.alias('ls.level', 'level')
    h.alias('vertical.level', 'level')
    h.alias('vertical.bottomLevel', 'bottomLevel')
    h.alias('vertical.topLevel', 'topLevel')
    h.alias('extraDim', 'zero')

    if h._defined('extraDimensionPresent'):

        if h.get_l('extraDimensionPresent'):
            h.alias('extraDim', 'one')


    if h.get_l('extraDim'):
        h.alias('mars.levelist', 'dimension')
        h.alias('mars.levtype', 'dimensionType')
    else:
        h.add(_.Transient('tempPressureUnits', _.Get('pressureUnits')))

        if not ((h.get_s('typeOfLevel') == "surface")):

            if (h.get_s('tempPressureUnits') == "Pa"):
                h.add(_.Scale('marsLevel', _.Get('level'), _.Get('one'), _.Get('hundred')))
                h.alias('mars.levelist', 'marsLevel')
            else:
                h.alias('mars.levelist', 'level')


        h.alias('mars.levtype', 'typeOfFirstFixedSurface')

        if (h.get_s('levtype') == "sfc"):
            h.unalias('mars.levelist')

    if ((h.get_l('typeOfFirstFixedSurface') == 151) and (h.get_l('typeOfSecondFixedSurface') == 151)):
        h.alias('mars.levelist', 'bottomLevel')

    h.alias('ls.typeOfLevel', 'typeOfLevel')
Ejemplo n.º 27
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')
Ejemplo n.º 28
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('numberOfPointsAlongXAxis', 4))
    h.alias('Nx', 'numberOfPointsAlongXAxis')
    h.alias('Ni', 'Nx')
    h.add(_.Unsigned('numberOfPointsAlongYAxis', 4))
    h.alias('Ny', 'numberOfPointsAlongYAxis')
    h.alias('Nj', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Scale('latitudeOfFirstGridPointInDegrees', _.Get('latitudeOfFirstGridPoint'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.add(_.Signed('longitudeOfFirstGridPoint', 4))
    h.alias('La1', 'longitudeOfFirstGridPoint')
    h.add(_.Scale('longitudeOfFirstGridPointInDegrees', _.Get('longitudeOfFirstGridPoint'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.Signed('standardParallelInMicrodegrees', 4))
    h.alias('standardParallel', 'standardParallelInMicrodegrees')
    h.add(_.Scale('standardParallelInDegrees', _.Get('standardParallelInMicrodegrees'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.standardParallelInDegrees', 'standardParallelInDegrees')
    h.add(_.Signed('centralLongitudeInMicrodegrees', 4))
    h.alias('centralLongitude', 'centralLongitudeInMicrodegrees')
    h.add(_.Scale('centralLongitudeInDegrees', _.Get('centralLongitudeInMicrodegrees'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.centralLongitudeInDegrees', 'centralLongitudeInDegrees')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(_.Unsigned('xDirectionGridLengthInMillimetres', 4))
    h.alias('Dx', 'xDirectionGridLengthInMillimetres')
    h.add(_.Scale('xDirectionGridLengthInMetres', _.Get('xDirectionGridLengthInMillimetres'), _.Get('one'), _.Get('thousand'), _.Get('truncateDegrees')))
    h.alias('geography.xDirectionGridLengthInMetres', 'xDirectionGridLengthInMetres')
    h.add(_.Unsigned('yDirectionGridLengthInMillimetres', 4))
    h.alias('Dy', 'yDirectionGridLengthInMillimetres')
    h.add(_.Scale('yDirectionGridLengthInMetres', _.Get('yDirectionGridLengthInMillimetres'), _.Get('one'), _.Get('thousand'), _.Get('truncateDegrees')))
    h.alias('geography.yDirectionGridLengthInMetres', 'yDirectionGridLengthInMetres')
    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(_.Iterator('ITERATOR', _.Get('lambert_azimuthal_equal_area'), _.Get('numberOfPoints'), _.Get('missingValue'), _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('standardParallel'), _.Get('centralLongitude'), _.Get('Dx'), _.Get('Dy'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('jPointsAreConsecutive'), _.Get('alternativeRowScanning')))
    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))
Ejemplo n.º 29
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 20))
    h.add(_.Unsigned('Nx', 2))
    h.alias('Ni', 'Nx')
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 2))
    h.alias('Nj', 'Ny')
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 3))
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Signed('longitudeOfFirstGridPoint', 3))
    h.add(
        _.Scale('longitudeOfFirstGridPointInDegrees',
                _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees',
            'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib1/7.table"))
    h.add(
        _.Bit('ijDirectionIncrementGiven',
              _.Get('resolutionAndComponentFlags'), 7))
    h.alias('iDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('jDirectionIncrementGiven', 'ijDirectionIncrementGiven')
    h.alias('DiGiven', 'ijDirectionIncrementGiven')
    h.alias('DjGiven', 'ijDirectionIncrementGiven')
    h.add(_.Bit('earthIsOblate', _.Get('resolutionAndComponentFlags'), 6))

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

    h.add(
        _.Bit('resolutionAndComponentFlags3',
              _.Get('resolutionAndComponentFlags'), 5))
    h.add(
        _.Bit('resolutionAndComponentFlags4',
              _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 2))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 1))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('orientationOfTheGrid', 3))
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.alias('LoV', 'orientationOfTheGrid')
    h.add(_.Unsigned('DxInMetres', 3))
    h.alias('xDirectionGridLengthInMetres', 'DxInMetres')
    h.alias('Dx', 'DxInMetres')
    h.alias('geography.DxInMetres', 'DxInMetres')
    h.alias('Di', 'DxInMetres')
    h.add(_.Unsigned('DyInMetres', 3))
    h.alias('yDirectionGridLengthInMetres', 'DyInMetres')
    h.alias('Dy', 'DyInMetres')
    h.alias('Dj', 'DyInMetres')
    h.alias('geography.DyInMetres', 'DyInMetres')
    h.add(_.Constant('latitudeWhereDxAndDyAreSpecifiedInDegrees', 60))
    h.add(_.Constant('LaDInDegrees', 60))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.add(_.Unsigned('projectionCentreFlag', 1))
    h.alias('projectionCenterFlag', 'projectionCentreFlag')
    h.add(_.Bit('southPoleOnProjectionPlane', _.Get('projectionCentreFlag'),
                7))
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    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')

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

    h.add(_.Pad('padding_grid5_1', 4))
    h.add(
        _.Number_of_points('numberOfDataPoints', _.Get('Nx'), _.Get('Ny'),
                           _.Get('PLPresent'), _.Get('pl')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(
        _.Number_of_values('numberOfValues', _.Get('values'),
                           _.Get('bitsPerValue'), _.Get('numberOfDataPoints'),
                           _.Get('bitmapPresent'), _.Get('bitmap'),
                           _.Get('numberOfCodedValues')))
    h.add(
        _.Iterator('ITERATOR', _.Get('polar_stereographic'),
                   _.Get('numberOfPoints'), _.Get('missingValue'),
                   _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfFirstGridPointInDegrees'),
                   _.Get('longitudeOfFirstGridPointInDegrees'),
                   _.Get('southPoleOnProjectionPlane'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('LaDInDegrees'), _.Get('Dx'), _.Get('Dy'),
                   _.Get('iScansNegatively'), _.Get('jScansPositively'),
                   _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))
    h.add(
        _.Nearest('NEAREST', _.Get('polar_stereographic'), _.Get('values'),
                  _.Get('radius'), _.Get('Nx'), _.Get('Ny')))
    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))
Ejemplo n.º 30
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(_.Transient('oneThousand', 1000))
    h.add(_.Unsigned('Nx', 4))
    h.alias('Ni', 'Nx')
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('Nj', 'Ny')
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Unsigned('longitudeOfFirstGridPoint', 4))
    h.add(
        _.Scale('longitudeOfFirstGridPointInDegrees',
                _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees',
            'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(_.Signed('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(
        _.Scale('LaDInDegrees', _.Get('LaD'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.alias('latitudeWhereDxAndDyAreSpecifiedInDegrees', 'LaDInDegrees')
    h.add(_.Signed('orientationOfTheGrid', 4))
    h.alias('LoV', 'orientationOfTheGrid')
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.add(_.Unsigned('Dx', 4))
    h.add(
        _.Scale('DxInMetres', _.Get('Dx'), _.Get('one'), _.Get('thousand'),
                _.Get('truncateDegrees')))
    h.alias('geography.DxInMetres', 'DxInMetres')
    h.alias('xDirectionGridLength', 'Dx')
    h.add(_.Unsigned('Dy', 4))
    h.add(
        _.Scale('DyInMetres', _.Get('Dy'), _.Get('one'), _.Get('thousand'),
                _.Get('truncateDegrees')))
    h.alias('geography.DyInMetres', 'DyInMetres')
    h.alias('yDirectionGridLength', 'Dy')
    h.add(
        _.Codeflag('projectionCentreFlag', 1,
                   "grib2/tables/[tablesVersion]/3.5.table"))
    h.add(_.Bit('southPoleOnProjectionPlane', _.Get('projectionCentreFlag'),
                7))
    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(
        _.Iterator('ITERATOR', _.Get('polar_stereographic'),
                   _.Get('numberOfPoints'), _.Get('missingValue'),
                   _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfFirstGridPointInDegrees'),
                   _.Get('longitudeOfFirstGridPointInDegrees'),
                   _.Get('southPoleOnProjectionPlane'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('LaDInDegrees'), _.Get('DxInMetres'),
                   _.Get('DyInMetres'), _.Get('iScansNegatively'),
                   _.Get('jScansPositively'), _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))
    h.add(
        _.Nearest('NEAREST', _.Get('polar_stereographic'), _.Get('values'),
                  _.Get('radius'), _.Get('Nx'), _.Get('Ny')))
    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(_.Unsigned('Nux', 4))
    h.alias('numberOfUsefulPointsAlongXAxis', 'Nux')
    h.add(_.Unsigned('Ncx', 4))
    h.alias('numberOfPointsAlongXAxisInCouplingArea', 'Ncx')
    h.add(_.Unsigned('Nuy', 4))
    h.alias('numberOfUsefulPointsAlongYAxis', 'Nuy')
    h.add(_.Unsigned('Ncy', 4))
    h.alias('numberOfPointsAlongYAxisInCouplingArea', 'Ncy')