Beispiel #1
0
def load(h):

    h.add(
        _.G1verificationdate('verificationDate', _.Get('dataDate'),
                             _.Get('dataTime'), _.Get('endStep')))
    h.add(_.G1monthlydate('monthlyVerificationDate',
                          _.Get('verificationDate')))
    h.alias('mars.date', 'monthlyVerificationDate')
    h.alias('mars.step', 'endStep')
    h.add(_.Evaluate('verificationYear', (_.Get('verificationDate') / 10000)))
    h.add(
        _.Evaluate('monthlyVerificationYear',
                   (_.Get('monthlyVerificationDate') / 10000)))
    h.add(
        _.Evaluate('verificationMonth',
                   ((_.Get('verificationDate') / 100) % 100)))
    h.add(
        _.Evaluate('monthlyVerificationMonth',
                   ((_.Get('monthlyVerificationDate') / 100) % 100)))
    h.alias('monthlyVerificationTime', 'zero')

    if (h.get_l('class') != 3):
        h.unalias('mars.time')
        h.unalias('mars.step')

    h.alias('mars.number', 'perturbationNumber')
Beispiel #2
0
def load(h):

    h.add(
        _.G1verificationdate('verificationDate', _.Get('dataDate'),
                             _.Get('dataTime'), _.Get('endStep')))
    h.add(_.G1monthlydate('monthlyVerificationDate',
                          _.Get('verificationDate')))
    h.alias('mars.date', 'monthlyVerificationDate')
    h.add(_.Evaluate('verificationYear', (_.Get('verificationDate') / 10000)))
    h.add(
        _.Evaluate('monthlyVerificationYear',
                   (_.Get('monthlyVerificationDate') / 10000)))
    h.add(
        _.Evaluate('verificationMonth',
                   ((_.Get('verificationDate') / 100) % 100)))
    h.add(
        _.Evaluate('monthlyVerificationMonth',
                   ((_.Get('monthlyVerificationDate') / 100) % 100)))
    h.alias('monthlyVerificationTime', 'validityTime')

    if ((((((((h.get_s('class') == "em") or (h.get_s('class') == "e2")) or
             (h.get_s('class') == "ea")) or (h.get_s('class') == "ep")) or
           (h.get_s('class') == "rd")) or (h.get_s('class') == "mc")) or
         (h.get_s('class') == "et")) or (h.get_s('class') == "l5")):
        h.alias('mars.step', 'endStep')
    else:
        h.alias('mars.step', 'startStep')

    h.alias('mars.number', 'perturbationNumber')
Beispiel #3
0
def load(h):

    h.add(_.G1verificationdate('verificationDate', _.Get('dataDate'), _.Get('dataTime'), _.Get('endStep')))
    h.add(_.G1monthlydate('monthlyVerificationDate', _.Get('verificationDate')))
    h.alias('mars.date', 'monthlyVerificationDate')
    h.add(_.Evaluate('verificationYear', (_.Get('verificationDate') / 10000)))
    h.add(_.Evaluate('monthlyVerificationYear', (_.Get('monthlyVerificationDate') / 10000)))
    h.add(_.Evaluate('verificationMonth', ((_.Get('verificationDate') / 100) % 100)))
    h.add(_.Evaluate('monthlyVerificationMonth', ((_.Get('monthlyVerificationDate') / 100) % 100)))
Beispiel #4
0
def load(h):

    h.alias('mars.number', 'perturbationNumber')
    h.unalias('mars.step')
    h.add(_.Evaluate('forecastPeriodFrom', (_.Get('verifyingMonth') / 1000)))
    h.add(_.Evaluate('forecastPeriodTo', (_.Get('verifyingMonth') % 1000)))
    h.add(_.Sprintf('forecastPeriod', "%d-%d", _.Get('forecastPeriodFrom'), _.Get('forecastPeriodTo')))
    h.alias('mars.fcperiod', 'forecastPeriod')
    h.alias('mars.method', 'methodNumber')

    if (h.get_s('class') == "od"):
        h.alias('mars.system', 'systemNumber')
Beispiel #5
0
def load(h):

    _.Template('grib2/mars_labeling.def').load(h)
    h.add(_.Transient('productDefinitionTemplateNumberInternal', -1))
    h.add(
        _.Local_definition('localDefinitionNumber',
                           _.Get('grib2LocalSectionNumber'),
                           _.Get('productDefinitionTemplateNumber'),
                           _.Get('productDefinitionTemplateNumberInternal'),
                           _.Get('type'), _.Get('stream'), _.Get('class'),
                           _.Get('eps'), _.Get('stepType'),
                           _.Get('derivedForecast')))
    h.add(
        _.G2_eps('eps', _.Get('productDefinitionTemplateNumber'),
                 _.Get('type'), _.Get('stream'), _.Get('stepType'),
                 _.Get('derivedForecast')))
    _.Template('grib2/local.98.[grib2LocalSectionNumber:l].def', True).load(h)
    h.add(_.Position('offsetAfterLocalSection'))
    h.add(_.Transient('addExtraLocalSection', 0))
    h.add(_.Transient('deleteExtraLocalSection', 0))
    h.add(
        _.Evaluate(
            'extraLocalSectionPresent',
            (((_.Get('section2Length') - _.Get('offsetAfterLocalSection')) +
              _.Get('offsetSection2')) > 0)))

    if ((h.get_l('extraLocalSectionPresent')
         or h.get_l('addExtraLocalSection'))
            and not (h.get_l('deleteExtraLocalSection'))):
        h.add(
            _.Codetable(
                'extraLocalSectionNumber', 2,
                "grib2/grib2LocalSectionNumber.[centreForLocal:l].table"))
        _.Template('grib2/local.98.[extraLocalSectionNumber:l].def').load(h)
Beispiel #6
0
def load(h):

    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 1) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.1.def').load(h)

    h.add(_.Lookup('sectionNumber', 1, 4))
    h.add(_.Transient('grib2LocalSectionPresent', 0))
    h.alias('section2Used', 'zero')
    h.alias('setLocalDefinition', 'grib2LocalSectionPresent')
    h.add(_.Transient('deleteLocalDefinition', 0))

    if (((h.get_l('sectionNumber') == 2) or
         (h.get_l('grib2LocalSectionPresent') > 0))
            and (h.get_l('deleteLocalDefinition') == 0)):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.2.def').load(h)

    h.alias('localUsePresent', 'section2Used')
    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 3) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.3.def').load(h)

    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 4) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.4.def').load(h)

    h.add(_.Position('endOfHeadersMarker'))
    h.add(
        _.Evaluate('lengthOfHeaders',
                   (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(
        _.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))
    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 5) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.5.def').load(h)

    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 6) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.6.def').load(h)

    h.add(_.Lookup('sectionNumber', 1, 4))

    if ((h.get_l('sectionNumber') == 7) or h._new()):
        h.add(_.Position('sectionPosition'))
        _.Template('grib2/section.7.def').load(h)
Beispiel #7
0
def load(h):

    h.add(
        _.G1verificationdate('verificationDate', _.Get('dataDate'),
                             _.Get('dataTime'), _.Get('endStep')))
    h.add(_.G1monthlydate('monthlyVerificationDate',
                          _.Get('verificationDate')))
    h.alias('mars.date', 'monthlyVerificationDate')
    h.add(_.Evaluate('verificationYear', (_.Get('verificationDate') / 10000)))
    h.add(
        _.Evaluate('monthlyVerificationYear',
                   (_.Get('monthlyVerificationDate') / 10000)))
    h.add(
        _.Evaluate('verificationMonth',
                   ((_.Get('verificationDate') / 100) % 100)))
    h.add(
        _.Evaluate('monthlyVerificationMonth',
                   ((_.Get('monthlyVerificationDate') / 100) % 100)))
    h.alias('mars.step', 'startStep')
    h.alias('mars.instrument', 'instrumentType')
    h.alias('mars.ident', 'satelliteNumber')
Beispiel #8
0
def load(h):

    h.add(_.Constant('ieeeFloats', 0))
    h.add(_.Transient('eps', 0))
    h.add(_.Constant('two', 1))
    h.add(_.Constant('three', 1))
    h.add(_.Constant('eight', 8))
    h.add(_.Constant('eleven', 11))
    h.add(_.Constant('epsPoint', 1))
    h.add(_.Constant('epsContinous', 11))
    h.add(_.Constant('epsStatisticsPoint', 2))
    h.add(_.Constant('epsStatisticsContinous', 12))
    h.add(_.Headers_only('headersOnly'))
    h.add(_.Gts_header('gts_header'))
    h.add(_.Gts_header('gts_TTAAii', 20, 6))
    h.add(_.Gts_header('gts_CCCC', 27, 4))
    h.add(_.Gts_header('gts_ddhh00', 32, 6))
    h.add(_.Ascii('identifier', 4))
    h.add(_.Constant('offsetSection0', 0))
    h.add(_.Constant('section0Length', 8))
    h.add(_.Section_pointer('section0Pointer', _.Get('offsetSection0'), _.Get('section0Length'), 0))
    h.add(_.G1_message_length('totalLength', 3, _.Get('section4Length')))
    h.add(_.Position('startOfHeaders'))
    h.add(_.Unsigned('editionNumber', 1))
    _.Template('grib1/section.1.def').load(h)
    h.alias('ls.edition', 'editionNumber')
    h.add(_.Bit('gridDescriptionSectionPresent', _.Get('section1Flags'), 7))
    h.add(_.Gds_is_present('GDSPresent', _.Get('gridDescriptionSectionPresent'), _.Get('gridDefinition'), _.Get('bitmapPresent'), _.Get('values')))
    h.add(_.Bit('bitmapPresent', _.Get('section1Flags'), 6))
    h.alias('bitmapSectionPresent', 'bitmapPresent')
    h.alias('geography.bitmapPresent', 'bitmapPresent')
    h.alias('missingValuesPresent', 'bitmapPresent')
    h.add(_.Transient('angleSubdivisions', 1000))

    if h.get_l('gridDescriptionSectionPresent'):
        _.Template('grib1/section.2.def').load(h)
    else:
        _.Template('grib1/predefined_grid.def').load(h)

    h.add(_.Position('endOfHeadersMarker'))
    h.add(_.Evaluate('lengthOfHeaders', (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(_.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))

    if not (h.get_l('headersOnly')):
        h.add(_.Transient('missingValue', 9999))

        if h.get_l('bitmapPresent'):
            _.Template('grib1/section.3.def').load(h)
        else:
            h.add(_.Constant('tableReference', 0))

        _.Template('grib1/section.4.def').load(h)
        _.Template('grib1/section.5.def').load(h)
Beispiel #9
0
def load(h):

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

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

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

    h.add(_.Position('startOfHeaders'))
    h.add(_.Ascii('identifier', 4))
    h.alias('ls.identifier', 'identifier')
    h.add(_.Transient('missingValue', 9999))
    h.add(_.Constant('ieeeFloats', 0))
    _.Template('tide/section.1.def').load(h)
    _.Template('tide/mars_labeling.def').load(h)
    h.add(_.Position('endOfHeadersMarker'))
    h.add(
        _.Evaluate('lengthOfHeaders',
                   (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(
        _.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))
    _.Template('tide/section.4.def').load(h)
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
Beispiel #11
0
def load(h):

    h.add(_.Position('startOfHeaders'))
    h.add(_.Ascii('SOH', 4))
    h.add(_.Ascii('nnn', 3))
    h.add(_.Ascii('crcrlf', 3))
    h.add(_.Ascii('TT', 2))
    h.add(_.Ascii('AA', 2))
    h.add(_.Ascii('II', 2))
    h.add(_.Ascii('sp1', 1))
    h.add(_.Ascii('CCCC', 4))
    h.add(_.Ascii('sp2', 1))
    h.add(_.Ascii('YY', 2))
    h.add(_.Ascii('GG', 2))
    h.add(_.Ascii('gg', 2))
    h.add(_.Lookup('lBB', 2, 29, _.Get('BB')))

    if (((h.get_s('lBB') == "RR") or (h.get_s('lBB') == "CC"))
            or (h.get_s('lBB') == "AA")):
        h.add(_.Ascii('sp3', 1))
        h.add(_.Ascii('BBB', 3))
    else:
        h.add(_.Constant('BBB', "NNN"))

    h.alias('ls.BBB', 'BBB')
    h.alias('ls.count', 'count')
    h.alias('ls.TT', 'TT')
    h.alias('ls.AA', 'AA')
    h.alias('ls.II', 'II')
    h.alias('ls.CCCC', 'CCCC')
    h.alias('ls.YY', 'YY')
    h.alias('ls.GG', 'GG')
    h.alias('ls.gg', 'gg')
    h.add(_.Position('endOfHeadersMarker'))
    h.add(_.Message('theMessage', 4))
    h.add(
        _.Evaluate('lengthOfHeaders',
                   (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(
        _.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
    h.alias('ls.totalLength', 'totalLength')
Beispiel #12
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')
Beispiel #13
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

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

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

    if h.get_l('localUsePresent'):

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

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

    h.add(_.Constant('GRIBEXSection1Problem', 0))
    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Transient('localFlag', 1))
    h.add(_.Constant('oceanStream', 1090))

    if (h.get_l('marsStream') == h.get_l('oceanStream')):
        h.add(_.Unsigned('perturbationNumber', 2))

    if (h.get_l('marsStream') != h.get_l('oceanStream')):
        h.add(_.Unsigned('perturbationNumber', 1))
        h.add(_.Pad('padding_loc4_2', 1))

    h.add(_.Unsigned('flagShowingPostAuxiliaryArrayInUse', 1))
    h.add(_.Unsigned('systemNumber', 1))
    h.alias('system', 'systemNumber')
    h.add(_.Unsigned('methodNumber', 1))
    h.add(_.Unsigned('spaceUnitFlag', 1))
    h.add(_.Unsigned('verticalCoordinateDefinition', 1))
    h.add(_.Unsigned('horizontalCoordinateDefinition', 1))
    h.add(_.Unsigned('timeUnitFlag', 1))
    h.add(_.Unsigned('timeCoordinateDefinition', 1))
    h.add(_.Unsigned('mixedCoordinateFieldFlag', 1))
    h.add(_.Unsigned('coordinate1Flag', 1))
    h.add(_.Unsigned('averaging1Flag', 1))
    h.add(_.Signed('coordinate1Start', 4))
    h.add(_.Signed('coordinate1End', 4))
    h.add(_.Unsigned('coordinate2Flag', 1))
    h.add(_.Unsigned('averaging2Flag', 1))
    h.add(_.Signed('coordinate2Start', 4))
    h.add(_.Signed('coordinate2End', 4))
    h.add(_.Unsigned('coordinate3Flag', 1))
    h.add(_.Unsigned('coordinate4Flag', 1))
    h.add(_.Signed('coordinate4OfFirstGridPoint', 4))
    h.add(_.Signed('coordinate3OfFirstGridPoint', 4))
    h.add(_.Signed('coordinate4OfLastGridPoint', 4))
    h.add(_.Signed('coordinate3OfLastGridPoint', 4))
    h.add(_.Signed('iIncrement', 4))
    h.add(_.Signed('jIncrement', 4))
    h.add(
        _.Codeflag('flagForIrregularGridCoordinateList', 1,
                   "grib1/ocean.1.table"))
    h.add(_.Codeflag('flagForNormalOrStaggeredGrid', 1, "grib1/ocean.1.table"))
    h.add(_.Codeflag('flagForAnyFurtherInformation', 1, "grib1/ocean.1.table"))
    h.add(_.Unsigned('numberInHorizontalCoordinates', 1))
    h.add(_.Unsigned('numberInMixedCoordinateDefinition', 2))
    h.add(_.Unsigned('numberInTheGridCoordinateList', 2))
    h.add(_.Unsigned('numberInTheAuxiliaryArray', 2))
    h.add(
        _.Unsigned('horizontalCoordinateSupplement', 4,
                   _.Get('numberInHorizontalCoordinates')))
    h.add(
        _.Unsigned('mixedCoordinateDefinition', 4,
                   _.Get('numberInMixedCoordinateDefinition')))

    if (h.get_l('numberInTheGridCoordinateList') > 0):
        h.add(
            _.Signed('gridCoordinate', 4,
                     _.Get('numberInTheGridCoordinateList')))

    h.add(_.Unsigned('auxiliary', 4, _.Get('numberInTheAuxiliaryArray')))
    h.add(_.Constant('postAuxiliaryArrayPresent', 1))

    if (h.get_l('flagShowingPostAuxiliaryArrayInUse') == h.get_l(
            'postAuxiliaryArrayPresent')):
        h.add(_.Unsigned('sizeOfPostAuxiliaryArrayPlusOne', 4))
        h.add(
            _.Evaluate('sizeOfPostAuxiliaryArray',
                       (_.Get('sizeOfPostAuxiliaryArrayPlusOne') - 1)))

        if (h.get_l('sizeOfPostAuxiliaryArray') > 0):
            h.add(
                _.Unsigned('postAuxiliary', 4,
                           _.Get('sizeOfPostAuxiliaryArray')))

            if (h.get_l('sizeOfPostAuxiliaryArray') > 3):
                h.add(_.Element('referenceDate', _.Get('postAuxiliary'), 3))

        else:
            h.add(_.Transient('referenceDate', 0))

    h.alias('hdate', 'dataDate')
    _.Template('grib1/mars_labeling.4.def').load(h)
Beispiel #16
0
def load(h):

    h.add(_.Position('offsetSection4'))
    h.add(_.G1_section4_length('section4Length', 3, _.Get('totalLength')))
    h.add(
        _.Section_pointer('section4Pointer', _.Get('offsetSection4'),
                          _.Get('section4Length'), 4))
    h.add(_.G1_half_byte_codeflag('halfByte'))
    h.add(_.Codeflag('dataFlag', 1, "grib1/11.table"))
    h.add(_.Signed('binaryScaleFactor', 2))
    h.add(_.Ibmfloat('referenceValue', 4))
    h.add(
        _.Reference_value_error('referenceValueError', _.Get('referenceValue'),
                                _.Get('ibm')))
    h.add(_.Bit('sphericalHarmonics', _.Get('dataFlag'), 7))
    h.add(_.Bit('complexPacking', _.Get('dataFlag'), 6))
    h.add(_.Bit('integerPointValues', _.Get('dataFlag'), 5))
    h.add(_.Bit('additionalFlagPresent', _.Get('dataFlag'), 4))

    if (h.get_l('complexPacking') and (h.get_l('sphericalHarmonics') == 0)):
        h.add(_.Unsigned('widthOfFirstOrderValues', 1))
        h.add(_.Unsigned('N1', 2))
        h.add(_.Codeflag('extendedFlag', 1, "grib1/11-2.table"))
        h.add(_.Bit('matrixOfValues', _.Get('extendedFlag'), 6))
        h.add(_.Bit('secondaryBitmapPresent', _.Get('extendedFlag'), 5))
        h.add(_.Bit('secondOrderOfDifferentWidth', _.Get('extendedFlag'), 4))
        h.add(_.Bit('generalExtended2ordr', _.Get('extendedFlag'), 3))
        h.add(_.Bit('boustrophedonicOrdering', _.Get('extendedFlag'), 2))
        h.add(_.Bit('twoOrdersOfSPD', _.Get('extendedFlag'), 1))
        h.add(_.Bit('plusOneinOrdersOfSPD', _.Get('extendedFlag'), 0))
        h.add(
            _.Evaluate('orderOfSPD', (_.Get('plusOneinOrdersOfSPD') +
                                      (2 * _.Get('twoOrdersOfSPD')))))
        h.alias('secondaryBitmap', 'secondaryBitmapPresent')
        h.alias('boustrophedonic', 'boustrophedonicOrdering')
    else:
        h.add(_.Transient('orderOfSPD', 2))
        h.add(_.Transient('boustrophedonic', 0))

    h.add(_.Transient('hideThis', 0))

    def packingType_inline_concept(h):
        def wrapped(h):

            sphericalHarmonics = h.get_l('sphericalHarmonics')
            complexPacking = h.get_l('complexPacking')
            additionalFlagPresent = h.get_l('additionalFlagPresent')

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 0:
                return 'grid_simple'

            integerPointValues = h.get_l('integerPointValues')

            if sphericalHarmonics == 0 and complexPacking == 0 and integerPointValues == 1 and additionalFlagPresent == 1:
                return 'grid_ieee'

            if sphericalHarmonics == 1 and complexPacking == 1 and additionalFlagPresent == 0:
                return 'spectral_complex'

            representationMode = h.get_l('representationMode')

            if sphericalHarmonics == 1 and complexPacking == 0 and additionalFlagPresent == 0 and representationMode == 1:
                return 'spectral_simple'

            hideThis = h.get_l('hideThis')

            if sphericalHarmonics == 1 and complexPacking == 1 and additionalFlagPresent == 0 and hideThis == 1:
                return 'spectral_ieee'

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 1:
                return 'grid_simple_matrix'

            secondOrderOfDifferentWidth = h.get_l(
                'secondOrderOfDifferentWidth')
            matrixOfValues = h.get_l('matrixOfValues')
            secondaryBitmapPresent = h.get_l('secondaryBitmapPresent')
            generalExtended2ordr = h.get_l('generalExtended2ordr')

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 0:
                return 'grid_second_order_row_by_row'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 0 and matrixOfValues == 0 and secondaryBitmapPresent == 1 and generalExtended2ordr == 0:
                return 'grid_second_order_constant_width'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 1 and generalExtended2ordr == 0:
                return 'grid_second_order_general_grib1'

            plusOneinOrdersOfSPD = h.get_l('plusOneinOrdersOfSPD')
            twoOrdersOfSPD = h.get_l('twoOrdersOfSPD')

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 0:
                return 'grid_second_order_no_SPD'

            boustrophedonic = h.get_l('boustrophedonic')

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 1 and boustrophedonic == 1:
                return 'grid_second_order'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 1 and boustrophedonic == 0:
                return 'grid_second_order'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 1 and boustrophedonic == 0:
                return 'grid_second_order_no_boustrophedonic'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 1 and boustrophedonic == 1:
                return 'grid_second_order_boustrophedonic'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 1 and twoOrdersOfSPD == 0:
                return 'grid_second_order_SPD1'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 0 and twoOrdersOfSPD == 1:
                return 'grid_second_order_SPD2'

            if sphericalHarmonics == 0 and complexPacking == 1 and secondOrderOfDifferentWidth == 1 and matrixOfValues == 0 and secondaryBitmapPresent == 0 and generalExtended2ordr == 1 and plusOneinOrdersOfSPD == 1 and twoOrdersOfSPD == 1:
                return 'grid_second_order_SPD3'

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 0:
                return 'grid_jpeg'

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 0:
                return 'grid_png'

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 0:
                return 'grid_ccsds'

            if sphericalHarmonics == 0 and complexPacking == 0 and additionalFlagPresent == 0:
                return 'grid_simple_log_preprocessing'

        return wrapped

    h.add(
        _.Concept('packingType', None, concepts=packingType_inline_concept(h)))

    h.alias('ls.packingType', 'packingType')
    h.alias('typeOfPacking', 'packingType')

    if (h.get_l('binaryScaleFactor') == -32767):
        h.add(_.Unsigned('bitsPerValue', 1))
        h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
        h.add(_.Constant('dataRepresentationTemplateNumber', 0))
        h.add(_.Constant('bitMapIndicator', 0))
        h.add(_.Position('offsetBeforeData'))
        h.add(_.Transient('numberOfCodedValues', _.Get('numberOfPoints')))
        h.add(
            _.Data_dummy_field('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('halfByte'),
                               _.Get('packingType'), _.Get('grid_ieee'),
                               _.Get('precision'), _.Get('missingValue'),
                               _.Get('numberOfPoints'), _.Get('bitmap')))
    else:
        _.Template('grib1/data.[packingType:s].def').load(h)

    h.add(_.Position('offsetAfterData'))
    h.add(
        _.Transient(
            'dataLength',
            ((_.Get('offsetAfterData') - _.Get('offsetBeforeData')) / 8)))

    if (h.get_l('bitmapPresent') == 1):
        h.alias('numberOfEffectiveValues', 'numberOfDataPoints')
    else:
        h.alias('numberOfEffectiveValues', 'numberOfCodedValues')

    if h.get_l('sphericalHarmonics'):
        h.alias('numberOfEffectiveValues', 'numberOfValues')

    h.add(
        _.Decimal_precision('changeDecimalPrecision', _.Get('bitsPerValue'),
                            _.Get('decimalScaleFactor'),
                            _.Get('changingPrecision'), _.Get('values')))
    h.add(
        _.Decimal_precision('decimalPrecision', _.Get('bitsPerValue'),
                            _.Get('decimalScaleFactor'),
                            _.Get('changingPrecision')))
    h.alias('setDecimalPrecision', 'changeDecimalPrecision')
    h.add(
        _.Bits_per_value('bitsPerValueAndRepack', _.Get('values'),
                         _.Get('bitsPerValue')))
    h.alias('setBitsPerValue', 'bitsPerValueAndRepack')
    h.add(
        _.Scale_values('scaleValuesBy', _.Get('values'),
                       _.Get('missingValue')))
    h.add(
        _.Offset_values('offsetValuesBy', _.Get('values'),
                        _.Get('missingValue')))

    def gridType_inline_concept(h):
        def wrapped(h):

            dataRepresentationType = h.get_l('dataRepresentationType')
            sphericalHarmonics = h.get_l('sphericalHarmonics')
            PLPresent = h.get_l('PLPresent')

            if dataRepresentationType == 0 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'regular_ll'

            Ni = h.get_l('Ni')

            if dataRepresentationType == 0 and sphericalHarmonics == 0 and PLPresent == 1 and Ni == h._missing(
            ):
                return 'reduced_ll'

            if dataRepresentationType == 1 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'mercator'

            if dataRepresentationType == 3 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'lambert'

            if dataRepresentationType == 5 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'polar_stereographic'

            if dataRepresentationType == 6 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'UTM'

            if dataRepresentationType == 7 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'simple_polyconic'

            if dataRepresentationType == 8 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'albers'

            if dataRepresentationType == 8 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'miller'

            if dataRepresentationType == 10 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'rotated_ll'

            if dataRepresentationType == 20 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'stretched_ll'

            if dataRepresentationType == 30 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'stretched_rotated_ll'

            if dataRepresentationType == 4 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'regular_gg'

            if dataRepresentationType == 14 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'rotated_gg'

            if dataRepresentationType == 24 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'stretched_gg'

            if dataRepresentationType == 34 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'stretched_rotated_gg'

            numberOfPointsAlongAParallel = h.get_l(
                'numberOfPointsAlongAParallel')
            iDirectionIncrement = h.get_l('iDirectionIncrement')
            ijDirectionIncrementGiven = h.get_l('ijDirectionIncrementGiven')

            if dataRepresentationType == 4 and sphericalHarmonics == 0 and PLPresent == 1 and numberOfPointsAlongAParallel == h._missing(
            ) and iDirectionIncrement == h._missing(
            ) and ijDirectionIncrementGiven == 0:
                return 'reduced_gg'

            if dataRepresentationType == 14 and sphericalHarmonics == 0 and PLPresent == 1 and numberOfPointsAlongAParallel == h._missing(
            ) and iDirectionIncrement == h._missing(
            ) and ijDirectionIncrementGiven == 0:
                return 'reduced_rotated_gg'

            if dataRepresentationType == 24 and sphericalHarmonics == 0 and PLPresent == 1 and numberOfPointsAlongAParallel == h._missing(
            ) and iDirectionIncrement == h._missing(
            ) and ijDirectionIncrementGiven == 0:
                return 'reduced_stretched_gg'

            if dataRepresentationType == 34 and sphericalHarmonics == 0 and PLPresent == 1 and numberOfPointsAlongAParallel == h._missing(
            ) and iDirectionIncrement == h._missing(
            ) and ijDirectionIncrementGiven == 0:
                return 'reduced_stretched_rotated_gg'

            if dataRepresentationType == 14 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'regular_rotated_gg'

            if dataRepresentationType == 24 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'regular_stretched_gg'

            if dataRepresentationType == 34 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'regular_stretched_rotated_gg'

            if dataRepresentationType == 50 and sphericalHarmonics == 1 and PLPresent == 0:
                return 'sh'

            if dataRepresentationType == 60 and sphericalHarmonics == 1 and PLPresent == 0:
                return 'rotated_sh'

            if dataRepresentationType == 70 and sphericalHarmonics == 1 and PLPresent == 0:
                return 'stretched_sh'

            if dataRepresentationType == 80 and sphericalHarmonics == 1 and PLPresent == 0:
                return 'stretched_rotated_sh'

            if dataRepresentationType == 90 and sphericalHarmonics == 0 and PLPresent == 0:
                return 'space_view'

            if PLPresent == 0:
                return 'unknown'

            if PLPresent == 1:
                return 'unknown_PLPresent'

        return wrapped

    h.add(_.Concept('gridType', None, concepts=gridType_inline_concept(h)))

    h.alias('ls.gridType', 'gridType')
    h.alias('geography.gridType', 'gridType')
    h.alias('typeOfGrid', 'gridType')
    h.add(_.Size('getNumberOfValues', _.Get('values')))

    if ((h.get_l('complexPacking') == 0)
            or (h.get_l('sphericalHarmonics') == 1)):
        h.add(
            _.Padtoeven('padding_sec4_1', _.Get('offsetSection4'),
                        _.Get('section4Length')))

    h.add(
        _.Md5('md5Section4', _.Get('offsetSection4'), _.Get('section4Length')))
    h.alias('md5DataSection', 'md5Section4')
Beispiel #17
0
def load(h):

    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'))))
Beispiel #18
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')))
Beispiel #19
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')
Beispiel #20
0
def load(h):

    h.add(_.Unsigned('N2', 2))
    h.add(_.Unsigned('codedNumberOfGroups', 2))
    h.add(_.Unsigned('numberOfSecondOrderPackedValues', 2))
    h.add(_.Unsigned('extraValues', 1))
    h.add(
        _.Evaluate('numberOfGroups', (_.Get('codedNumberOfGroups') +
                                      (65536 * _.Get('extraValues')))))
    h.add(_.Unsigned('widthOfWidths', 1))
    h.add(_.Unsigned('widthOfLengths', 1))
    h.add(_.Unsigned('NL', 2))

    if h.get_l('orderOfSPD'):
        h.add(_.Unsigned('widthOfSPD', 1))
        h.add(_.Spd('SPD', _.Get('widthOfSPD'), _.Get('orderOfSPD')))

    h.add(
        _.Unsigned_bits('groupWidths', _.Get('widthOfWidths'),
                        _.Get('numberOfGroups')))
    h.add(
        _.Unsigned_bits('groupLengths', _.Get('widthOfLengths'),
                        _.Get('numberOfGroups')))
    h.add(
        _.Unsigned_bits('firstOrderValues', _.Get('widthOfFirstOrderValues'),
                        _.Get('numberOfGroups')))
    h.add(_.Sum('countOfGroupLengths', _.Get('groupLengths')))
    h.add(
        _.Transient('numberOfCodedValues',
                    (_.Get('countOfGroupLengths') + _.Get('orderOfSPD'))))
    h.add(
        _.Second_order_bits_per_value('bitsPerValue', _.Get('codedValues'),
                                      _.Get('binaryScaleFactor'),
                                      _.Get('decimalScaleFactor')))
    h.add(_.Position('offsetBeforeData'))

    if h.get_l('bitmapPresent'):
        h.add(
            _.Data_g1second_order_general_extended_packing(
                'codedValues', _.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('halfByte'),
                _.Get('packingType'), _.Get('grid_ieee'), _.Get('precision'),
                _.Get('widthOfFirstOrderValues'), _.Get('firstOrderValues'),
                _.Get('N1'), _.Get('N2'), _.Get('numberOfGroups'),
                _.Get('codedNumberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('groupWidths'), _.Get('widthOfWidths'),
                _.Get('groupLengths'), _.Get('widthOfLengths'), _.Get('NL'),
                _.Get('SPD'), _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                _.Get('numberOfPoints')))
        h.alias('data.packedValues', 'codedValues')

        if h.get_l('boustrophedonicOrdering'):

            if h.get_l('GRIBEX_boustrophedonic'):
                h.add(
                    _.Data_apply_boustrophedonic_bitmap(
                        'preBitmapValues', _.Get('codedValues'),
                        _.Get('bitmap'), _.Get('missingValue'),
                        _.Get('binaryScaleFactor'), _.Get('numberOfRows'),
                        _.Get('numberOfColumns'), _.Get('numberOfPoints')))
            else:
                h.add(
                    _.Data_apply_bitmap('preBitmapValues',
                                        _.Get('codedValues'), _.Get('bitmap'),
                                        _.Get('missingValue'),
                                        _.Get('binaryScaleFactor')))

            h.add(
                _.Data_apply_boustrophedonic('values',
                                             _.Get('preBitmapValues'),
                                             _.Get('numberOfRows'),
                                             _.Get('numberOfColumns'),
                                             _.Get('numberOfPoints'),
                                             _.Get('pl')))
        else:
            h.add(
                _.Data_apply_bitmap('values', _.Get('codedValues'),
                                    _.Get('bitmap'), _.Get('missingValue'),
                                    _.Get('binaryScaleFactor')))

    else:

        if h.get_l('boustrophedonicOrdering'):
            h.add(
                _.Data_g1second_order_general_extended_packing(
                    'codedValues', _.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('halfByte'),
                    _.Get('packingType'), _.Get('grid_ieee'),
                    _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                    _.Get('firstOrderValues'), _.Get('N1'), _.Get('N2'),
                    _.Get('numberOfGroups'), _.Get('codedNumberOfGroups'),
                    _.Get('numberOfSecondOrderPackedValues'),
                    _.Get('extraValues'), _.Get('groupWidths'),
                    _.Get('widthOfWidths'), _.Get('groupLengths'),
                    _.Get('widthOfLengths'), _.Get('NL'), _.Get('SPD'),
                    _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                    _.Get('numberOfPoints')))
            h.add(
                _.Data_apply_boustrophedonic('values', _.Get('codedValues'),
                                             _.Get('numberOfRows'),
                                             _.Get('numberOfColumns'),
                                             _.Get('numberOfPoints'),
                                             _.Get('pl')))
        else:
            h.add(
                _.Data_g1second_order_general_extended_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('halfByte'),
                    _.Get('packingType'), _.Get('grid_ieee'),
                    _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                    _.Get('firstOrderValues'), _.Get('N1'), _.Get('N2'),
                    _.Get('numberOfGroups'), _.Get('codedNumberOfGroups'),
                    _.Get('numberOfSecondOrderPackedValues'),
                    _.Get('extraValues'), _.Get('groupWidths'),
                    _.Get('widthOfWidths'), _.Get('groupLengths'),
                    _.Get('widthOfLengths'), _.Get('NL'), _.Get('SPD'),
                    _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                    _.Get('numberOfPoints')))
            h.alias('codedValues', 'values')

        h.alias('data.packedValues', 'values')

    h.add(
        _.Simple_packing_error('packingError', _.Get('bitsPerValue'),
                               _.Get('binaryScaleFactor'),
                               _.Get('decimalScaleFactor'),
                               _.Get('referenceValue'), _.Get('ibm')))
    _.Template('common/statistics_grid.def').load(h)
Beispiel #21
0
def load(h):

    h.add(_.Unsigned('N2', 2))
    h.add(_.Unsigned('codedNumberOfFirstOrderPackedValues', 2))
    h.add(_.Unsigned('numberOfSecondOrderPackedValues', 2))
    h.add(_.Unsigned('extraValues', 1))
    h.add(
        _.Evaluate('numberOfGroups',
                   (_.Get('codedNumberOfFirstOrderPackedValues') +
                    (65536 * _.Get('extraValues')))))
    h.add(_.Unsigned('groupWidths', 1, _.Get('numberOfGroups')))
    h.add(
        _.Second_order_bits_per_value('bitsPerValue', _.Get('values'),
                                      _.Get('binaryScaleFactor'),
                                      _.Get('decimalScaleFactor')))
    h.add(_.Position('offsetBeforeData'))

    if h.get_l('bitmapPresent'):
        h.add(
            _.Data_g1second_order_row_by_row_packing(
                'codedValues', _.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('halfByte'),
                _.Get('packingType'), _.Get('grid_ieee'), _.Get('precision'),
                _.Get('widthOfFirstOrderValues'), _.Get('N1'), _.Get('N2'),
                _.Get('numberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('Ni'), _.Get('Nj'), _.Get('pl'),
                _.Get('jPointsAreConsecutive'), _.Get('groupWidths'),
                _.Get('bitmap')))
        h.alias('data.packedValues', 'codedValues')
        h.add(
            _.Data_apply_bitmap('values', _.Get('codedValues'),
                                _.Get('bitmap'), _.Get('missingValue'),
                                _.Get('binaryScaleFactor')))
    else:
        h.add(
            _.Data_g1second_order_row_by_row_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('halfByte'), _.Get('packingType'), _.Get('grid_ieee'),
                _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                _.Get('N1'), _.Get('N2'), _.Get('numberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('Ni'), _.Get('Nj'), _.Get('pl'),
                _.Get('jPointsAreConsecutive'), _.Get('groupWidths')))
        h.alias('data.packedValues', 'values')

    h.add(
        _.Transient('numberOfCodedValues',
                    _.Get('numberOfSecondOrderPackedValues')))
    h.add(
        _.Simple_packing_error('packingError', _.Get('bitsPerValue'),
                               _.Get('binaryScaleFactor'),
                               _.Get('decimalScaleFactor'),
                               _.Get('referenceValue'), _.Get('ibm')))
    _.Template('common/statistics_grid.def').load(h)
Beispiel #22
0
def load(h):

    h.add(_.Constant('P_INST', 0))
    h.add(_.Constant('P_TAVG', 1))
    h.add(_.Constant('P_TACC', 3))
    h.add(_.Constant('TYPE_AN', 2))
    h.add(_.Constant('TYPE_FC', 9))
    h.add(_.Constant('TYPE_CF', 10))
    h.add(_.Constant('TYPE_PF', 11))
    h.add(_.Constant('TYPE_FF', 25))
    h.add(_.Constant('TYPE_OF', 26))
    h.add(_.Constant('TYPE_OR', 70))
    h.add(_.Constant('TYPE_FX', 71))
    h.add(_.Constant('coordAveraging0', "inst"))
    h.add(_.Constant('coordAveraging1', "tavg"))
    h.add(_.Constant('coordAveraging2', 2))
    h.add(_.Constant('coordAveraging3', "tacc"))
    h.add(_.Constant('coordAveragingTims', "tims"))
    h.add(_.Constant('isectionNumber2', "h"))
    h.add(_.Constant('isectionNumber3', "m"))
    h.add(_.Constant('isectionNumber4', "z"))
    h.add(_.Constant('tsectionNumber3', "v"))
    h.add(_.Constant('tsectionNumber4', "z"))
    h.add(_.Constant('tsectionNumber5', "m"))
    h.add(_.Constant('GRIB_DEPTH', 2))
    h.add(_.Constant('GRIB_LONGITUDE', 3))
    h.add(_.Constant('GRIB_LATITUDE', 4))
    h.add(_.G1verificationdate('verificationDate', _.Get('dataDate'), _.Get('dataTime'), _.Get('endStep')))

    if (h.get_l('horizontalCoordinateDefinition') == 0):

        if (h.get_l('coordinate1Flag') == 1):

            if (h.get_l('averaging1Flag') == h.get_l('P_TAVG')):

                if ((((h.get_l('marsType') == h.get_l('TYPE_OR')) or (h.get_l('marsType') == h.get_l('TYPE_FC'))) or (h.get_l('marsType') == h.get_l('TYPE_FF'))) or (h.get_l('marsType') == h.get_l('TYPE_FX'))):
                    h.add(_.Evaluate('marsRange', ((_.Get('coordinate1End') - _.Get('coordinate1Start')) / 3600)))
                    h.alias('mars.range', 'marsRange')


            if (h.get_l('coordinate2Flag') == 2):
                h.alias('mars.section', 'isectionNumber2')

            if (h.get_l('coordinate2Flag') == 3):
                h.alias('mars.section', 'isectionNumber3')

            if (h.get_l('coordinate2Flag') == 4):
                h.alias('mars.section', 'isectionNumber4')

            if (h.get_l('coordinate2Flag') == h.get_l('GRIB_DEPTH')):
                h.add(_.Divdouble('marsLevelist', _.Get('coordinate2Start'), 1000))
                h.add(_.Round('roundedMarsLevelist', _.Get('marsLevelist'), 1000))
                h.alias('mars.levelist', 'roundedMarsLevelist')

            if (h.get_l('coordinate2Flag') == h.get_l('GRIB_LONGITUDE')):
                h.add(_.Divdouble('marsLongitude', _.Get('coordinate2Start'), 1000000))
                h.add(_.Round('roundedMarsLongitude', _.Get('marsLongitude'), 1000))
                h.alias('mars.longitude', 'roundedMarsLongitude')

            if (h.get_l('coordinate2Flag') == h.get_l('GRIB_LATITUDE')):
                h.add(_.Divdouble('marsLatitude', _.Get('coordinate2Start'), 1000000))
                h.add(_.Round('roundedMarsLatitude', _.Get('marsLatitude'), 1000))
                h.alias('mars.latitude', 'roundedMarsLatitude')

            if (h.get_l('averaging1Flag') == 0):
                h.alias('mars.product', 'coordAveraging0')

            if (h.get_l('averaging1Flag') == 1):
                h.alias('mars.product', 'coordAveraging1')

            if (h.get_l('averaging1Flag') == 2):
                h.alias('mars.product', 'coordAveraging2')

            if (h.get_l('averaging1Flag') == 3):
                h.alias('mars.product', 'coordAveraging3')

            if ((((h.get_l('marsType') == h.get_l('TYPE_OR')) and (h.get_l('averaging1Flag') == h.get_l('P_TAVG'))) or ((h.get_l('marsType') == h.get_l('TYPE_OR')) and (h.get_l('averaging1Flag') == h.get_l('P_TACC')))) or ((h.get_l('marsType') == h.get_l('TYPE_FX')) and (h.get_l('averaging1Flag') == h.get_l('P_TAVG')))):
                h.alias('mars.date', 'verificationDate')
                h.add(_.Constant('stepZero', 0))
                h.alias('mars.step', 'stepZero')

        else:
            h.add(_.Evaluate('coordinateIndexNumber', (_.Get('coordinate4Flag') + _.Get('coordinate3Flag'))))

            if (h.get_l('coordinateIndexNumber') == 3):
                h.add(_.Divdouble('marsLatitude', _.Get('coordinate1Start'), 1000000))
                h.add(_.Divdouble('marsLongitude', _.Get('coordinate2Start'), 1000000))
                h.add(_.Round('roundedMarsLatitude', _.Get('marsLatitude'), 1000))
                h.add(_.Round('roundedMarsLongitude', _.Get('marsLongitude'), 1000))
                h.alias('mars.latitude', 'roundedMarsLatitude')
                h.alias('mars.longitude', 'roundedMarsLongitude')

            if (h.get_l('coordinateIndexNumber') == 4):
                h.add(_.Divdouble('marsLevelist', _.Get('coordinate1Start'), 1000))
                h.add(_.Divdouble('marsLatitude', _.Get('coordinate2Start'), 1000000))
                h.add(_.Round('roundedMarsLevelist', _.Get('marsLevelist'), 1000))
                h.add(_.Round('roundedMarsLatitude', _.Get('marsLatitude'), 1000))
                h.alias('mars.levelist', 'roundedMarsLevelist')
                h.alias('mars.latitude', 'roundedMarsLatitude')

            if (h.get_l('coordinateIndexNumber') == 5):
                h.add(_.Divdouble('marsLevelist', _.Get('coordinate1Start'), 1000))
                h.add(_.Divdouble('marsLongitude', _.Get('coordinate2Start'), 1000000))
                h.add(_.Round('roundedMarsLevelist', _.Get('marsLevelist'), 1000))
                h.add(_.Round('roundedMarsLongitude', _.Get('marsLongitude'), 1000))
                h.alias('mars.levelist', 'roundedMarsLevelist')
                h.alias('mars.longitude', 'roundedMarsLongitude')

            if (h.get_l('coordinateIndexNumber') == 3):
                h.alias('mars.section', 'tsectionNumber3')

            if (h.get_l('coordinateIndexNumber') == 4):
                h.alias('mars.section', 'tsectionNumber4')

            if (h.get_l('coordinateIndexNumber') == 5):
                h.alias('mars.section', 'tsectionNumber5')

            if (h.get_l('averaging1Flag') == h.get_l('P_INST')):

                if ((((((h.get_l('marsType') == h.get_l('TYPE_OR')) or (h.get_l('marsType') == h.get_l('TYPE_FC'))) or (h.get_l('marsType') == h.get_l('TYPE_CF'))) or (h.get_l('marsType') == h.get_l('TYPE_PF'))) or (h.get_l('marsType') == h.get_l('TYPE_FF'))) or (h.get_l('marsType') == h.get_l('TYPE_OF'))):

                    if (h.get_l('coordinate4Flag') == 1):
                        h.add(_.Evaluate('marsRange', ((_.Get('coordinate4OfLastGridPoint') - _.Get('coordinate4OfFirstGridPoint')) / 3600)))
                    else:
                        h.add(_.Evaluate('marsRange', ((_.Get('coordinate3OfLastGridPoint') - _.Get('coordinate3OfFirstGridPoint')) / 3600)))

                    h.alias('mars.range', 'marsRange')


            h.alias('mars.product', 'coordAveragingTims')

            if ((h.get_l('marsType') == h.get_l('TYPE_OR')) and (h.get_l('averaging1Flag') == h.get_l('P_INST'))):
                h.alias('mars.date', 'verificationDate')
                h.add(_.Constant('stepZero', 0))
                h.alias('mars.step', 'stepZero')