コード例 #1
0
ファイル: local_85_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Transient('defaultFaFieldName', ""))
    h.add(_.Transient('defaultFaLevelName', ""))
    h.add(_.Transient('defaultFaModelName', ""))
    h.add(
        _.Concept('faFieldName', 'defaultFaFieldName', 'faFieldName.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.alias('ls.faFieldName', 'faFieldName')
    h.add(
        _.Concept('faLevelName', 'defaultFaLevelName', 'faLevelName.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.alias('ls.faLevelName', 'faLevelName')
    h.add(
        _.Concept('faModelName', 'defaultFaModelName', 'faModelName.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.alias('ls.faModelName', 'faModelName')
    h.add(_.Transient('LSTCUM', 0))
    h.add(_.Transient('ZLMULT', 1))
    h.add(_.Transient('ZLBASE', 0))
    h.add(_.Transient('CLNOMA', ""))
    h.add(_.Transient('INGRIB', 0))
    h.add(_.Transient('LLCOSP', 0))
    h.add(_.Transient('INBITS', 0))
    h.add(_.Transient('FMULTM', 1))
    h.add(_.Transient('FMULTE', 0))
コード例 #2
0
ファイル: ls_labeling_82_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Constant('g1conceptsMasterDir', "grib1"))
    h.add(_.Constant('g1conceptsLocalDirAll', "grib1/localConcepts/[centre:s]"))
    h.alias('ls.dataType', 'marsType')

    if (h.get_l('localDefinitionNumber') == 83):
        h.add(_.Concept('timerepres', 'unknown', 'timeRepresConcept.def', 'g1conceptsLocalDirAll', 'g1conceptsMasterDir', True))
        h.alias('ls.timerepres', 'timerepres')
        h.add(_.Concept('sort', 'unknown', 'sortConcept.def', 'g1conceptsLocalDirAll', 'g1conceptsMasterDir', True))
        h.alias('ls.sort', 'sort')
        h.add(_.Concept('landtype', 'unknown', 'landTypeConcept.def', 'g1conceptsLocalDirAll', 'g1conceptsMasterDir', True))
        h.alias('ls.landtype', 'landtype')
        h.add(_.Concept('aerosolbinnumber', 'unknown', 'aerosolConcept.def', 'g1conceptsLocalDirAll', 'g1conceptsMasterDir', True))
        h.alias('ls.aerosolbinnumber', 'aerosolbinnumber')
コード例 #3
0
def load(h):

    h.add(_.Constant('GRIBEXSection1Problem', (334 - _.Get('section1Length'))))
    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Unsigned('tubeNumber', 1))
    h.add(_.Unsigned('totalNumberOfTubes', 1))
    h.add(_.Unsigned('centralClusterDefinition', 1))
    h.add(_.Unsigned('parameterIndicator', 1))
    h.add(_.Unsigned('levelIndicator', 1))
    h.add(_.Signed('northLatitudeOfDomainOfTubing', 3))
    h.add(_.Signed('westLongitudeOfDomainOfTubing', 3))
    h.add(_.Signed('southLatitudeOfDomainOfTubing', 3))
    h.add(_.Signed('eastLongitudeOfDomainOfTubing', 3))
    h.add(_.Unsigned('numberOfOperationalForecastTube', 1))
    h.add(_.Unsigned('numberOfControlForecastTube', 1))
    h.add(_.Unsigned('heightOrPressureOfLevel', 2))
    h.add(_.Unsigned('referenceStep', 2))
    h.add(_.Unsigned('radiusOfCentralCluster', 2))
    h.add(_.Unsigned('ensembleStandardDeviation', 2))
    h.add(_.Unsigned('distanceFromTubeToEnsembleMean', 2))
    h.add(_.Unsigned('numberOfForecastsInTube', 1))
    h.add(_.Unsigned('ensembleForecastNumbers', 1, _.Get('numberOfForecastsInTube')))
    h.add(_.Padto('padding_loc10_1', (_.Get('offsetSection1') + 334)))
    h.add(_.Concept('tubeDomain', 'unknown', 'tube_domain.def', 'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.alias('number', 'tubeNumber')
    h.alias('totalNumber', 'totalNumberOfTubes')
    h.alias('reference', 'referenceStep')
    h.alias('domain', 'tubeDomain')
コード例 #4
0
ファイル: section_7_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetSection7'))
    h.add(_.Section_length('section7Length', 4))
    h.add(_.Section_pointer('section7', _.Get('offsetSection7'), _.Get('section7Length'), 7))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(_.Position('offsetBeforeData'))
    _.Template('grib2/template.7.[dataRepresentationTemplateNumber:l].def').load(h)
    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('setBitsPerValue', _.Get('values'), _.Get('bitsPerValue')))
    h.add(_.Size('getNumberOfValues', _.Get('values')))
    h.add(_.Scale_values('scaleValuesBy', _.Get('values'), _.Get('missingValue')))
    h.add(_.Offset_values('offsetValuesBy', _.Get('values'), _.Get('missingValue')))

    def productType_inline_concept(h):
        def wrapped(h):

            grib2LocalSectionPresent = h.get_l('grib2LocalSectionPresent')
            centre = h.get_l('centre')
            grib2LocalSectionNumber = h.get_l('grib2LocalSectionNumber')
            productDefinitionTemplateNumber = h.get_l('productDefinitionTemplateNumber')

            if grib2LocalSectionPresent == 1 and centre == 98 and grib2LocalSectionNumber == 500 and productDefinitionTemplateNumber == 2000:
                return 'obstat'

        return wrapped

    h.add(_.Concept('productType', 'unknown', concepts=productType_inline_concept(h)))

    h.add(_.Position('offsetAfterData'))
    h.add(_.Md5('md5Section7', _.Get('offsetSection7'), _.Get('section7Length')))
    h.alias('md5DataSection', 'md5Section7')
コード例 #5
0
def load(h):

    h.add(_.Constant('GRIBEXSection1Problem', (328 - _.Get('section1Length'))))
    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Unsigned('clusterNumber', 1))
    h.alias('number', 'clusterNumber')
    h.add(_.Unsigned('totalNumberOfClusters', 1))
    h.alias('totalNumber', 'totalNumberOfClusters')
    h.add(_.Pad('padding_loc2_1', 1))
    h.add(_.Unsigned('clusteringMethod', 1))
    h.add(_.Unsigned('startTimeStep', 2))
    h.add(_.Unsigned('endTimeStep', 2))
    h.add(_.Signed('northernLatitudeOfDomain', 3))
    h.add(_.Signed('westernLongitudeOfDomain', 3))
    h.add(_.Signed('southernLatitudeOfDomain', 3))
    h.add(_.Signed('easternLongitudeOfDomain', 3))
    h.add(_.Unsigned('operationalForecastCluster', 1))
    h.add(_.Unsigned('controlForecastCluster', 1))
    h.add(_.Unsigned('numberOfForecastsInCluster', 1))

    if (h.get_l('numberOfForecastsInCluster') > 0):
        h.add(
            _.Unsigned('ensembleForecastNumbers', 1,
                       _.Get('numberOfForecastsInCluster')))

    h.add(_.Padto('padding_loc2_2', (_.Get('offsetSection1') + 328)))
    h.add(_.Constant('unknown', "-"))
    h.add(
        _.Concept('clusteringDomain', 'unknown', 'cluster_domain.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', True))
    h.alias('number', 'clusterNumber')
    h.alias('domain', 'clusteringDomain')
コード例 #6
0
def load(h):

    h.add(_.Transient('conceptDir', "mars"))
    h.add(_.Concept('waveDomain', 'unknown', 'wave_domain.def', 'conceptDir', 'conceptDir', False))
    h.alias('mars.domain', 'waveDomain')

    if (h.get_s('class') == "lw"):
        h.unalias('mars.domain')
コード例 #7
0
def load(h):

    h.add(_.Transient('conceptDir', "mars"))
    h.add(
        _.Concept('waveDomain', 'unknown', 'wave_domain.def', 'conceptDir',
                  'conceptDir', False))
    h.alias('mars.domain', 'waveDomain')
    h.alias('mars.anoffset', 'offsetToEndOf4DvarWindow')
コード例 #8
0
def load(h):

    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')
コード例 #9
0
def load(h):

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

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

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 'instant'

        return wrapped

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

    h.alias('time.stepType', 'stepType')
    h.alias('time.stepRange', 'stepRange')
    h.alias('time.stepUnits', 'stepUnits')
    h.alias('time.dataDate', 'dataDate')
    h.alias('time.dataTime', 'dataTime')
    h.alias('time.startStep', 'startStep')
    h.alias('time.endStep', 'endStep')
    h.add(_.Validity_date('validityDate', _.Get('dataDate'), _.Get('dataTime'), _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityDate', 'validityDate')
    h.add(_.Validity_time('validityTime', _.Get('dataDate'), _.Get('dataTime'), _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityTime', 'validityTime')
コード例 #10
0
def load(h):

    h.add(
        _.Step_in_units('startStep', _.Get('forecastTime'),
                        _.Get('indicatorOfUnitOfTimeRange'),
                        _.Get('stepUnits')))
    h.add(_.G2end_step('endStep', _.Get('startStep'), _.Get('stepUnits')))
    h.alias('step', 'startStep')
    h.alias('marsStep', 'startStep')
    h.alias('mars.step', 'startStep')
    h.alias('marsStartStep', 'startStep')
    h.alias('marsEndStep', 'endStep')
    h.add(_.G2step_range('stepRange', _.Get('startStep')))
    h.alias('ls.stepRange', 'stepRange')

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

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 'instant'

        return wrapped

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

    h.alias('time.stepType', 'stepType')
    h.alias('time.stepRange', 'stepRange')
    h.alias('time.stepUnits', 'stepUnits')
    h.alias('time.dataDate', 'dataDate')
    h.alias('time.dataTime', 'dataTime')
    h.alias('time.startStep', 'startStep')
    h.alias('time.endStep', 'endStep')
    h.add(
        _.Validity_date('validityDate', _.Get('dataDate'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityDate', 'validityDate')
    h.add(
        _.Validity_time('validityTime', _.Get('dataDate'), _.Get('dataTime'),
                        _.Get('step'), _.Get('stepUnits')))
    h.alias('time.validityTime', 'validityTime')
コード例 #11
0
def load(h):

    h.add(_.Constant('conceptsMasterMarsDir', "mars"))
    h.add(_.Constant('conceptsLocalMarsDirAll', "mars/[centre:s]"))
    h.alias('mars.class', 'marsClass')
    h.alias('mars.type', 'marsType')
    h.alias('mars.stream', 'marsStream')
    h.alias('mars.model', 'marsModel')
    h.alias('mars.expver', 'experimentVersionNumber')
    h.alias('mars.domain', 'globalDomain')

    if (h.get_l('localDefinitionNumber') == 83):
        h.alias('mars.sort', 'matchSort')
        h.alias('mars.timerepres', 'matchTimeRepres')
        h.alias('mars.landtype', 'matchLandType')
        h.alias('mars.aerosolbinnumber', 'matchAerosolBinNumber')
        h.add(
            _.Concept('matchAerosolPacking', 'unknown',
                      'aerosolPackingConcept.def', 'conceptsLocalMarsDirAll',
                      'conceptsMasterMarsDir', True))
        h.alias('mars.aerosolpacking', 'matchAerosolPacking')
コード例 #12
0
def load(h):

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

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

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

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

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

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

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

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

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

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

    h.add(_.Unsigned('Ni', 4))
    h.alias('numberOfPointsAlongAParallel', 'Ni')
    h.alias('Nx', 'Ni')
    h.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')
コード例 #13
0
def load(h):

    h.add(_.Section_length('section1Length', 3))
    h.add(_.Unsigned('gribTablesVersionNo', 1))
    h.add(_.StringCodetable('centre', 1, "common/c-1.table"))
    h.alias('ls.centre', 'centre')
    h.alias('identificationOfOriginatingGeneratingCentre', 'centre')
    h.add(_.Unsigned('generatingProcessIdentifier', 1))
    h.add(_.Unsigned('gridDefinition', 1))
    h.add(_.Codeflag('flag', 1, "grib1/1.table"))
    h.add(
        _.Codetable('indicatorOfParameter', 1,
                    "grib1/2.[centre:l].[gribTablesVersionNo:l].table"))
    h.add(_.Codetable('indicatorOfTypeOfLevel', 1, "grib1/3.table"))
    h.add(_.Codetable('heightPressureEtcOfLevels', 2, "grib1/3.table"))
    h.alias('ls.levelType', 'indicatorOfTypeOfLevel')
    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(
        _.Budgdate('dataDate', _.Get('yearOfCentury'), _.Get('month'),
                   _.Get('day')))
    h.alias('ls.date', 'dataDate')
    h.add(_.Time('dataTime', _.Get('hour'), _.Get('minute'), _.Get('second')))
    h.alias('ls.time', 'dataTime')
    h.add(
        _.Julian_day('julianDay', _.Get('dataDate'), _.Get('hour'),
                     _.Get('minute'), _.Get('second')))
    h.add(_.Codetable('indicatorOfUnitOfTimeRange', 1, "grib1/4.table"))
    h.add(_.Unsigned('periodOfTime', 1))
    h.alias('P1', 'periodOfTime')
    h.add(_.Unsigned('periodOfTimeIntervals', 1))
    h.alias('P2', 'periodOfTimeIntervals')
    h.add(_.Codetable('timeRangeIndicator', 1, "grib1/5.table"))
    h.add(_.TransientCodetable('stepUnits', 1, "grib2/tables/1/4.4.table"))

    def stepType_inline_concept(h):
        def wrapped(h):

            timeRangeIndicator = h.get_l('timeRangeIndicator')

            if timeRangeIndicator == 1:
                return 'instant'

            if timeRangeIndicator == 10:
                return 'instant'

            if timeRangeIndicator == 0:
                return 'instant'

            if timeRangeIndicator == 3:
                return 'avg'

            if timeRangeIndicator == 4:
                return 'accum'

            if timeRangeIndicator == 2:
                return 'max'

            if timeRangeIndicator == 2:
                return 'min'

            if timeRangeIndicator == 5:
                return 'diff'

            if timeRangeIndicator == 2:
                return 'rms'

            if timeRangeIndicator == 2:
                return 'sd'

            if timeRangeIndicator == 2:
                return 'cov'

            if timeRangeIndicator == 2:
                return 'ratio'

        return wrapped

    h.add(_.Concept('stepType', None, concepts=stepType_inline_concept(h)))

    h.add(
        _.G1step_range('stepRange', _.Get('P1'), _.Get('P2'),
                       _.Get('timeRangeIndicator'),
                       _.Get('indicatorOfUnitOfTimeRange'), _.Get('stepUnits'),
                       _.Get('stepType')))
    h.alias('ls.stepRange', 'stepRange')
    h.add(_.Long_vector('startStep', _.Get('stepRange'), 0))
    h.add(_.Long_vector('endStep', _.Get('stepRange'), 1))
    h.add(
        _.G1step_range('stepRangeInHours', _.Get('P1'), _.Get('P2'),
                       _.Get('timeRangeIndicator'),
                       _.Get('indicatorOfUnitOfTimeRange'), _.Get('one'),
                       _.Get('stepType')))
    h.add(_.Long_vector('startStepInHours', _.Get('stepRangeInHours'), 0))
    h.add(_.Long_vector('endStepInHours', _.Get('stepRangeInHours'), 1))
    h.add(_.Constant('paramId', 0))
    h.alias('parameter', 'paramId')
    h.alias('ls.parameter', 'parameter')
    h.add(_.Section_padding('section1Padding'))
コード例 #14
0
ファイル: template_3_31_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

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

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

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

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

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

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

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

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

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

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

    h.add(_.Unsigned('Nx', 4))
    h.alias('numberOfPointsAlongTheXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('numberOfPointsAlongTheYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Unsigned('longitudeOfFirstGridPoint', 4))
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(
        _.Bit('resolutionAndComponentFlags1',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags2',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              5))
    h.add(
        _.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 6))

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

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

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

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

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

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

        return wrapped

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

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(_.Signed('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(_.Unsigned('LoV', 4))
    h.add(_.Unsigned('xDirectionGridLength', 4))
    h.alias('Dx', 'xDirectionGridLength')
    h.add(_.Unsigned('yDirectionGridLength', 4))
    h.alias('Dy', 'yDirectionGridLength')
    h.add(
        _.Codeflag('projectionCentreFlag', 1,
                   "grib2/tables/[tablesVersion]/3.5.table"))
    h.add(
        _.Codeflag('scanningMode', 1,
                   "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Signed('Latin1', 4))
    h.add(
        _.Scale('Latin1InDegrees', _.Get('Latin1'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin1InDegrees', 'Latin1InDegrees')
    h.add(_.Unsigned('Latin2', 4))
    h.add(
        _.Scale('Latin2InDegrees', _.Get('Latin2'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin2InDegrees', 'Latin2InDegrees')
    h.add(_.Signed('latitudeOfTheSouthernPoleOfProjection', 4))
    h.alias('latitudeOfSouthernPole', 'latitudeOfTheSouthernPoleOfProjection')
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfTheSouthernPoleOfProjection'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(_.Unsigned('longitudeOfTheSouthernPoleOfProjection', 4))
    h.alias('longitudeOfSouthernPole',
            'longitudeOfTheSouthernPoleOfProjection')
    h.add(
        _.Scale('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfTheSouthernPoleOfProjection'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
コード例 #15
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'))))
コード例 #16
0
ファイル: template_3_5_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

    with h.list('latitudesList'):
        for i in range(0, h.get_l('Nj')):
            h.add(_.Signed('latitudes', 4))
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection',
            'longitudeOfSouthernPole')
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfSouthernPole'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(
        _.G2lon('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfSouthernPole')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ieeefloat('angleOfRotation', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotation')
    h.alias('angleOfRotationOfProjection', 'angleOfRotation')
    h.alias('isRotatedGrid', 'one')
コード例 #17
0
ファイル: products_11_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Constant('marsExpver', "test"))
    h.add(_.Constant('marsClass', "rr"))
    h.alias('tigge_short_name', 'shortName')
    h.alias('short_name', 'shortName')
    h.alias('parameter', 'paramId')
    h.alias('tigge_name', 'name')
    h.alias('parameter.paramId', 'paramId')
    h.alias('parameter.shortName', 'shortName')
    h.alias('parameter.units', 'units')
    h.alias('parameter.name', 'name')

    if (h.get_l('typeOfFirstFixedSurface') == 103):

        if (h.get_l('level') > 10):
            h.add(_.Constant('heightLevelName', "hl"))
            h.alias('mars.levtype', 'heightLevelName')
            h.alias('mars.levelist', 'level')

    if (h.get_l('typeOfFirstFixedSurface') == 118):
        h.add(_.Constant('levTypeName', "ml"))
        h.alias('mars.levtype', 'levTypeName')

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

    h.alias('mars.expver', 'marsExpver')
    h.alias('mars.class', 'marsClass')
    h.alias('mars.param', 'paramId')
    h.alias('mars.origin', 'centre')

    if (h.get_l('section2Used') == 1):
        h.alias('mars.origin', 'crraSuiteID')
        h.unalias('mars.domain')
        h.unalias('mars.model')

    def marsType_inline_concept(h):
        def wrapped(h):

            typeOfProcessedData = h.get_l('typeOfProcessedData')

            if typeOfProcessedData == 1:
                return 'fc'

            if typeOfProcessedData == 1:
                return 9

            if typeOfProcessedData == 0:
                return 'an'

            if typeOfProcessedData == 0:
                return 2

            centre = h.get_l('centre')
            typeOfGeneratingProcess = h.get_l('typeOfGeneratingProcess')
            generatingProcessIdentifier = h.get_l(
                'generatingProcessIdentifier')

            if centre == 82 and typeOfGeneratingProcess == 0 and generatingProcessIdentifier == 50:
                return 'oi'

            if centre == 82 and typeOfGeneratingProcess == 0 and generatingProcessIdentifier == 50:
                return 4

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsType', None, concepts=marsType_inline_concept(h)))

    def marsStream_inline_concept(h):
        def wrapped(h):

            productDefinitionTemplateNumber = h.get_l(
                'productDefinitionTemplateNumber')

            if productDefinitionTemplateNumber == 8:
                return 'oper'

            if productDefinitionTemplateNumber == 0:
                return 'oper'

            if productDefinitionTemplateNumber == 11:
                return 'enda'

            if productDefinitionTemplateNumber == 1:
                return 'enda'

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsStream', None, concepts=marsStream_inline_concept(h)))

    h.alias('mars.stream', 'marsStream')
    h.alias('mars.type', 'marsType')
コード例 #18
0
def load(h):

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

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

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 'instant'

        return wrapped

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            pressureUnits = h.get_s('pressureUnits')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

    if h._defined('extraDimensionPresent'):

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

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

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

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

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

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

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

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

    if ((((((((h.get_l('productionStatusOfProcessedData') == 4) or
              (h.get_l('productionStatusOfProcessedData') == 5)) or
             (h.get_l('productionStatusOfProcessedData') == 6)) or
            (h.get_l('productionStatusOfProcessedData') == 7)) or
           (h.get_l('productionStatusOfProcessedData') == 8)) or
          (h.get_l('productionStatusOfProcessedData') == 9)) or
         (h.get_l('productionStatusOfProcessedData') == 10))
            or (h.get_l('productionStatusOfProcessedData') == 11)):
        h.alias('mars.number', 'perturbationNumber')
コード例 #19
0
def load(h):

    h.add(_.Position('offsetBSection5'))
    h.add(_.Position('offsetSection5'))
    h.add(_.Section_length('section5Length', 4))
    h.add(
        _.Section_pointer('section5', _.Get('offsetSection5'),
                          _.Get('section5Length'), 5))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(_.Unsigned('numberOfValues', 4))
    h.alias('numberOfCodedValues', 'numberOfValues')
    h.alias('numberOfEffectiveValues', 'numberOfValues')
    h.add(
        _.Codetable('dataRepresentationTemplateNumber', 2, "5.0.table",
                    _.Get('masterDir'), _.Get('localDir')))

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

            dataRepresentationTemplateNumber = h.get_l(
                'dataRepresentationTemplateNumber')

            if dataRepresentationTemplateNumber == 0:
                return 'grid_simple'

            spectralType = h.get_l('spectralType')
            spectralMode = h.get_l('spectralMode')

            if dataRepresentationTemplateNumber == 51 and spectralType == 1 and spectralMode == 1:
                return 'spectral_complex'

            if dataRepresentationTemplateNumber == 50 and spectralType == 1 and spectralMode == 1:
                return 'spectral_simple'

            if dataRepresentationTemplateNumber == 1:
                return 'grid_simple_matrix'

            if dataRepresentationTemplateNumber == 2:
                return 'grid_complex'

            if dataRepresentationTemplateNumber == 3:
                return 'grid_complex_spatial_differencing'

            if dataRepresentationTemplateNumber == 40000:
                return 'grid_jpeg'

            if dataRepresentationTemplateNumber == 40:
                return 'grid_jpeg'

            if dataRepresentationTemplateNumber == 40010:
                return 'grid_png'

            if dataRepresentationTemplateNumber == 41:
                return 'grid_png'

            if dataRepresentationTemplateNumber == 42:
                return 'grid_ccsds'

            if dataRepresentationTemplateNumber == 4:
                return 'grid_ieee'

            if dataRepresentationTemplateNumber == 50001:
                return 'grid_second_order'

            if dataRepresentationTemplateNumber == 50002:
                return 'grid_second_order'

            if dataRepresentationTemplateNumber == 50002:
                return 'grid_second_order_boustrophedonic'

            if dataRepresentationTemplateNumber == 50001:
                return 'grid_second_order_no_boustrophedonic'

            if dataRepresentationTemplateNumber == 50001:
                return 'grid_second_order_row_by_row'

            if dataRepresentationTemplateNumber == 50001:
                return 'grid_second_order_constant_width'

            if dataRepresentationTemplateNumber == 50001:
                return 'grid_second_order_general_grib1'

            orderOfSPD = h.get_l('orderOfSPD')

            if dataRepresentationTemplateNumber == 50001 and orderOfSPD == 0:
                return 'grid_second_order_no_SPD'

            if dataRepresentationTemplateNumber == 50001 and orderOfSPD == 1:
                return 'grid_second_order_SPD1'

            if dataRepresentationTemplateNumber == 50001 and orderOfSPD == 2:
                return 'grid_second_order_SPD2'

            if dataRepresentationTemplateNumber == 50001 and orderOfSPD == 3:
                return 'grid_second_order_SPD3'

            if dataRepresentationTemplateNumber == 50000:
                return 'spectral_ieee'

            if dataRepresentationTemplateNumber == 61:
                return 'grid_simple_log_preprocessing'

            if dataRepresentationTemplateNumber == 53 and spectralType == 2:
                return 'bifourier_complex'

        return wrapped

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

    _.Template(
        'grib2/template.5.[dataRepresentationTemplateNumber:l].def').load(h)
    h.alias('ls.packingType', 'packingType')
    h.alias('dataRepresentation', 'packingType')
    h.alias('typeOfPacking', 'packingType')
    h.add(_.Transient('representationMode', 0))
    h.add(
        _.Md5('md5Section5', _.Get('offsetSection5'), _.Get('section5Length')))
コード例 #20
0
def load(h):

    h.add(_.Constant('gridDescriptionSectionPresent', 1))
    h.add(_.Position('offsetSection3'))
    h.add(_.Section_length('section3Length', 4))
    h.add(
        _.Section_pointer('section3Pointer', _.Get('offsetSection3'),
                          _.Get('section3Length'), 3))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(
        _.Codetable('sourceOfGridDefinition', 1, "3.0.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('numberOfDataPoints', 4))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Unsigned('numberOfOctectsForNumberOfPoints', 1))
    h.add(
        _.Codetable('interpretationOfNumberOfPoints', 1, "3.11.table",
                    _.Get('masterDir'), _.Get('localDir')))

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

    h.add(
        _.Codetable('gridDefinitionTemplateNumber', 2, "3.1.table",
                    _.Get('masterDir'), _.Get('localDir')))
    h.add(
        _.Codetable_title('gridDefinitionDescription',
                          _.Get('gridDefinitionTemplateNumber')))
    h.alias('isRotatedGrid', 'zero')
    _.Template('grib2/template.3.[gridDefinitionTemplateNumber:l].def').load(h)

    if h.get_l('PLPresent'):

        if (h.get_l('numberOfOctectsForNumberOfPoints') == 1):
            h.add(_.Unsigned('pl', 1, _.Get('Nj')))

        if (h.get_l('numberOfOctectsForNumberOfPoints') == 2):
            h.add(_.Unsigned('pl', 2, _.Get('Nj')))

        if (h.get_l('numberOfOctectsForNumberOfPoints') == 3):
            h.add(_.Unsigned('pl', 3, _.Get('Nj')))

        h.alias('geography.pl', 'pl')

    pass  # when block
    h.add(_.Section_padding('section3Padding'))

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

            gridDefinitionTemplateNumber = h.get_l(
                'gridDefinitionTemplateNumber')
            PLPresent = h.get_l('PLPresent')

            if gridDefinitionTemplateNumber == 0 and PLPresent == 0:
                return 'regular_ll'

            if gridDefinitionTemplateNumber == 0 and PLPresent == 1:
                return 'reduced_ll'

            if gridDefinitionTemplateNumber == 1 and PLPresent == 0:
                return 'rotated_ll'

            if gridDefinitionTemplateNumber == 2 and PLPresent == 0:
                return 'stretched_ll'

            if gridDefinitionTemplateNumber == 3 and PLPresent == 0:
                return 'stretched_rotated_ll'

            if gridDefinitionTemplateNumber == 10 and PLPresent == 0:
                return 'mercator'

            if gridDefinitionTemplateNumber == 12 and PLPresent == 0:
                return 'transverse_mercator'

            if gridDefinitionTemplateNumber == 20 and PLPresent == 0:
                return 'polar_stereographic'

            if gridDefinitionTemplateNumber == 30 and PLPresent == 0:
                return 'lambert'

            if gridDefinitionTemplateNumber == 31 and PLPresent == 0:
                return 'albers'

            if gridDefinitionTemplateNumber == 40 and PLPresent == 0:
                return 'regular_gg'

            numberOfOctectsForNumberOfPoints = h.get_l(
                'numberOfOctectsForNumberOfPoints')
            iDirectionIncrementGiven = h.get_l('iDirectionIncrementGiven')
            numberOfPointsAlongAParallel = h.get_l(
                'numberOfPointsAlongAParallel')

            if gridDefinitionTemplateNumber == 40 and PLPresent == 1 and numberOfOctectsForNumberOfPoints == 2 and iDirectionIncrementGiven == 0 and numberOfPointsAlongAParallel == h._missing(
            ):
                return 'reduced_gg'

            if gridDefinitionTemplateNumber == 41 and PLPresent == 0:
                return 'rotated_gg'

            if gridDefinitionTemplateNumber == 41 and PLPresent == 1 and numberOfOctectsForNumberOfPoints == 2 and iDirectionIncrementGiven == 0 and numberOfPointsAlongAParallel == h._missing(
            ):
                return 'reduced_rotated_gg'

            if gridDefinitionTemplateNumber == 42 and PLPresent == 0:
                return 'stretched_gg'

            if gridDefinitionTemplateNumber == 42 and PLPresent == 1 and numberOfOctectsForNumberOfPoints == 2 and iDirectionIncrementGiven == 0 and numberOfPointsAlongAParallel == h._missing(
            ):
                return 'reduced_stretched_gg'

            if gridDefinitionTemplateNumber == 43 and PLPresent == 0:
                return 'stretched_rotated_gg'

            if gridDefinitionTemplateNumber == 43 and PLPresent == 1 and numberOfOctectsForNumberOfPoints == 2 and iDirectionIncrementGiven == 0 and numberOfPointsAlongAParallel == h._missing(
            ):
                return 'reduced_stretched_rotated_gg'

            if gridDefinitionTemplateNumber == 41 and PLPresent == 0:
                return 'regular_rotated_gg'

            if gridDefinitionTemplateNumber == 42 and PLPresent == 0:
                return 'regular_stretched_gg'

            if gridDefinitionTemplateNumber == 43 and PLPresent == 0:
                return 'regular_stretched_rotated_gg'

            if gridDefinitionTemplateNumber == 50 and PLPresent == 0:
                return 'sh'

            if gridDefinitionTemplateNumber == 51 and PLPresent == 0:
                return 'rotated_sh'

            if gridDefinitionTemplateNumber == 52 and PLPresent == 0:
                return 'stretched_sh'

            if gridDefinitionTemplateNumber == 53 and PLPresent == 0:
                return 'stretched_rotated_sh'

            if gridDefinitionTemplateNumber == 90 and PLPresent == 0:
                return 'space_view'

            if gridDefinitionTemplateNumber == 100 and PLPresent == 0:
                return 'triangular_grid'

            if gridDefinitionTemplateNumber == 101 and PLPresent == 0:
                return 'unstructured_grid'

            if gridDefinitionTemplateNumber == 110 and PLPresent == 0:
                return 'equatorial_azimuthal_equidistant'

            if gridDefinitionTemplateNumber == 120 and PLPresent == 0:
                return 'azimuth_range'

            if gridDefinitionTemplateNumber == 130 and PLPresent == 0:
                return 'irregular_latlon'

            if gridDefinitionTemplateNumber == 140 and PLPresent == 0:
                return 'lambert_azimuthal_equal_area'

            if gridDefinitionTemplateNumber == 1000 and PLPresent == 0:
                return 'cross_section'

            if gridDefinitionTemplateNumber == 1100 and PLPresent == 0:
                return 'Hovmoller'

            if gridDefinitionTemplateNumber == 1200 and PLPresent == 0:
                return 'time_section'

            if gridDefinitionTemplateNumber == 33 and PLPresent == 0:
                return 'lambert_lam'

            if gridDefinitionTemplateNumber == 13 and PLPresent == 0:
                return 'mercator_lam'

            if gridDefinitionTemplateNumber == 23 and PLPresent == 0:
                return 'polar_stereographic_lam'

            if gridDefinitionTemplateNumber == 63 and PLPresent == 0:
                return 'lambert_bf'

            if gridDefinitionTemplateNumber == 61 and PLPresent == 0:
                return 'mercator_bf'

            if gridDefinitionTemplateNumber == 62 and PLPresent == 0:
                return 'polar_stereographic_bf'

            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(
        _.Md5('md5Section3', _.Get('offsetSection3'), _.Get('section3Length')))
    h.alias('md5GridSection', 'md5Section3')
コード例 #21
0
ファイル: param_limits_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.DoubleConstant('default_min_val', -1e+09))
    h.add(_.DoubleConstant('default_max_val', 1e+09))

    def param_value_min_inline_concept(h):
        def wrapped(h):

            paramId = h.get_l('paramId')

            if paramId == 165:
                return '-150'

            if paramId == 166:
                return '-100'

            if paramId == 260260:
                return 0

            if paramId == 228028:
                return 0

            if paramId == 49:
                return 0

            if paramId == 207:
                return 0

            if paramId == 168:
                return 25

            if paramId == 260242:
                return 0

            if paramId == 167:
                return 160

            if paramId == 260509:
                return 0

            if paramId == 151175:
                return 5

            if paramId == 260257:
                return 0

            if paramId == 59:
                return 0

            if paramId == 228001:
                return '-60000'

            if paramId == 151163:
                return 0

            if paramId == 151131:
                return '-3.5'

            if paramId == 260259:
                return '-10'

            if paramId == 129:
                return '-13000'

            if paramId == 156:
                return '-1300'

            if paramId == 3075:
                return 0

            if paramId == 172:
                return 0

            if paramId == 3062:
                return '-0.05'

            if paramId == 260210:
                return 0

            if paramId == 3073:
                return 0

            one = h.get_l('one')

            if one == (_.Get('step') > 0) and paramId == 121:
                return 160

            if one == (_.Get('step') > 0) and paramId == 122:
                return 150

            if paramId == 151:
                return 85000

            if paramId == 151126:
                return 270

            if paramId == 140230:
                return '-1'

            if paramId == 140221:
                return 0

            if paramId == 3074:
                return 0

            if paramId == 140214:
                return 0

            if paramId == 151132:
                return '-3.5'

            if paramId == 151225:
                return 0

            if paramId == 228002:
                return '-1300'

            if paramId == 140231:
                return 0

            if paramId == 260430:
                return 0

            if paramId == 3:
                return 170

            if paramId == 60:
                return '-1'

            if paramId == 54:
                return 100

            if paramId == 157:
                return 0

            if paramId == 151145:
                return '-4'

            if paramId == 151219:
                return 0

            if paramId == 34:
                return 160

            if paramId == 31:
                return 0

            if paramId == 174098:
                return 0

            if paramId == 140229:
                return 0

            if paramId == 235:
                return 120

            if paramId == 228032:
                return 20

            if paramId == 33:
                return 10

            if paramId == 3066:
                return 0

            if paramId == 228141:
                return '-1e-10'

            if paramId == 260367:
                return '0.005'

            if paramId == 260364:
                return '-1000'

            if paramId == 228039:
                return 0

            if paramId == 228087:
                return 0

            if paramId == 228086:
                return '-20'

            if paramId == 260360:
                return 170

            if paramId == 228139:
                return 170

            if paramId == 228096:
                return 170

            if paramId == 228095:
                return 170

            if paramId == 43:
                return 0

            if paramId == 247:
                return '-0.001'

            if paramId == 246:
                return '-0.001'

            if paramId == 133:
                return '-0.1'

            if paramId == 134:
                return 43000

            if paramId == 173:
                return 0

            if paramId == 130:
                return 140

            if paramId == 260057:
                return '-3'

            if paramId == 136:
                return '-50'

            if paramId == 131:
                return '-250'

            if paramId == 132:
                return '-250'

            if paramId == 135:
                return '-30'

            if paramId == 260199:
                return 0

            if paramId == 3031:
                return 0

            if paramId == 10:
                return 0

        return wrapped

    h.add(_.Concept('param_value_min', 'default_min_val', concepts=param_value_min_inline_concept(h)))

    def param_value_max_inline_concept(h):
        def wrapped(h):

            paramId = h.get_l('paramId')

            if paramId == 165:
                return 150

            if paramId == 166:
                return 100

            if paramId == 260260:
                return '360.1'

            if paramId == 228028:
                return 140

            if paramId == 49:
                return 100

            if paramId == 207:
                return 300

            if paramId == 168:
                return 350

            if paramId == 260242:
                return 160

            if paramId == 167:
                return 370

            if paramId == 260509:
                return 100

            if paramId == 151175:
                return 50

            if paramId == 260257:
                return 100

            if paramId == 59:
                return 40000

            if paramId == 228001:
                return 1000

            if paramId == 151163:
                return 1500

            if paramId == 151131:
                return '3.5'

            if paramId == 260259:
                return 5

            if paramId == 129:
                return 350000

            if paramId == 156:
                return 35000

            if paramId == 3075:
                return 100

            if paramId == 172:
                return 1

            if paramId == 3062:
                return 130

            if paramId == 260210:
                return 1

            if paramId == 3073:
                return 100

            if paramId == 121:
                return 380

            if paramId == 151:
                return 125000

            if paramId == 151126:
                return 308

            if paramId == 140230:
                return '360.5'

            if paramId == 140221:
                return 50

            if paramId == 3074:
                return 100

            if paramId == 122:
                return 330

            if paramId == 140214:
                return 150

            if paramId == 151132:
                return '3.5'

            if paramId == 151225:
                return 4000

            if paramId == 228002:
                return 8888

            if paramId == 140231:
                return 50

            if paramId == 260430:
                return 30

            if paramId == 3:
                return 1200

            if paramId == 60:
                return 1

            if paramId == 54:
                return 108000

            if paramId == 157:
                return 180

            if paramId == 151145:
                return 4

            if paramId == 151219:
                return 50

            if paramId == 34:
                return 320

            if paramId == 31:
                return '1.001'

            if paramId == 174098:
                return 15

            if paramId == 140229:
                return 100

            if paramId == 235:
                return 380

            if paramId == 228032:
                return 100

            if paramId == 33:
                return 1000

            if paramId == 3066:
                return 5

            if paramId == 228141:
                return 15000

            if paramId == 260367:
                return 100

            if paramId == 260364:
                return 1000

            if paramId == 228039:
                return 2000

            if paramId == 228087:
                return 2000

            if paramId == 228086:
                return 2000

            if paramId == 260360:
                return 350

            if paramId == 228139:
                return 350

            if paramId == 228096:
                return 350

            if paramId == 228095:
                return 350

            if paramId == 43:
                return 10

            if paramId == 247:
                return '0.01'

            if paramId == 246:
                return '1e+06'

            if paramId == 133:
                return '0.1'

            if paramId == 134:
                return 115000

            if paramId == 173:
                return 10

            if paramId == 130:
                return 400

            if paramId == 260057:
                return 150

            if paramId == 136:
                return 220

            if paramId == 131:
                return 250

            if paramId == 132:
                return 250

            if paramId == 135:
                return 30

            if paramId == 260199:
                return 1

            if paramId == 3031:
                return '360.1'

            if paramId == 10:
                return 300

        return wrapped

    h.add(_.Concept('param_value_max', 'default_max_val', concepts=param_value_max_inline_concept(h)))
コード例 #22
0
def load(h):

    h.add(_.Constant('marsExpver', "prod"))
    h.add(_.Constant('marsClass', "ti"))
    h.add(_.Constant('marsModel', "glob"))
    h.alias('is_tigge', 'one')
    h.alias('tigge_short_name', 'shortName')
    h.alias('short_name', 'shortName')
    h.alias('parameter', 'paramId')
    h.alias('tigge_name', 'name')
    h.alias('parameter.paramId', 'paramId')
    h.alias('parameter.shortName', 'shortName')
    h.alias('parameter.units', 'units')
    h.alias('parameter.name', 'name')

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

    h.alias('mars.expver', 'marsExpver')
    h.alias('mars.class', 'marsClass')
    h.alias('mars.param', 'paramId')
    h.alias('mars.model', 'marsModel')
    h.alias('mars.origin', 'centre')

    if (h.get_l('section2Used') == 1):
        h.add(_.Constant('marsLamModel', "lam"))
        h.alias('mars.model', 'marsLamModel')
        h.alias('mars.origin', 'tiggeSuiteID')
        h.unalias('mars.domain')

    def marsType_inline_concept(h):
        def wrapped(h):

            typeOfProcessedData = h.get_l('typeOfProcessedData')

            if typeOfProcessedData == 2:
                return 'fc'

            if typeOfProcessedData == 2:
                return 9

            if typeOfProcessedData == 3:
                return 'cf'

            if typeOfProcessedData == 3:
                return 10

            if typeOfProcessedData == 4:
                return 'pf'

            if typeOfProcessedData == 4:
                return 11

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsType', None, concepts=marsType_inline_concept(h)))

    def marsStream_inline_concept(h):
        def wrapped(h):

            typeOfProcessedData = h.get_l('typeOfProcessedData')

            if typeOfProcessedData == 0:
                return 'oper'

            if typeOfProcessedData == 2:
                return 'oper'

            if typeOfProcessedData == 3:
                return 'enfo'

            if typeOfProcessedData == 4:
                return 'enfo'

            if typeOfProcessedData == 8:
                return 'enfo'

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsStream', None, concepts=marsStream_inline_concept(h)))

    h.alias('mars.stream', 'marsStream')
    h.alias('mars.type', 'marsType')
コード例 #23
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            pressureUnits = h.get_s('pressureUnits')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

    if h._defined('extraDimensionPresent'):

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

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

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

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

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

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

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

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

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

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

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

                typeOfStatisticalProcessing = h.get_l(
                    'typeOfStatisticalProcessing')

                if typeOfStatisticalProcessing == 255:
                    return 'instant'

                typeOfTimeIncrement = h.get_l('typeOfTimeIncrement')

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

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

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

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

                if typeOfStatisticalProcessing == 2:
                    return 'max'

                if typeOfStatisticalProcessing == 3:
                    return 'min'

                if typeOfStatisticalProcessing == 4:
                    return 'diff'

                if typeOfStatisticalProcessing == 5:
                    return 'rms'

                if typeOfStatisticalProcessing == 6:
                    return 'sd'

                if typeOfStatisticalProcessing == 7:
                    return 'cov'

                if typeOfStatisticalProcessing == 8:
                    return 'sdiff'

                if typeOfStatisticalProcessing == 9:
                    return 'ratio'

                if typeOfStatisticalProcessing == 10:
                    return 'stdanom'

                if typeOfStatisticalProcessing == 11:
                    return 'sum'

            return wrapped

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

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

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

    with h.list('ensembleForecastNumbersList'):
        for i in range(0, h.get_l('numberOfForecastsInTheCluster')):
            h.add(_.Unsigned('ensembleForecastNumbers', 1))
コード例 #24
0
def load(h):

    h.add(_.Constant('marsExpver', "test"))
    h.add(_.Constant('marsClass', "s2"))
    h.add(_.Constant('marsModel', "glob"))
    h.alias('is_s2s', 'one')
    h.alias('parameter.paramId', 'paramId')
    h.alias('parameter.shortName', 'shortName')
    h.alias('parameter.units', 'units')
    h.alias('parameter.name', 'name')
    h.alias('mars.expver', 'marsExpver')
    h.alias('mars.class', 'marsClass')
    h.alias('mars.param', 'paramId')
    h.alias('mars.model', 'marsModel')

    if ((h.get_s('centre') == "cnmc") and (h.get_l('subCentre') == 102)):
        h.add(_.Constant('cnmc_isac', "isac"))
        h.alias('mars.origin', 'cnmc_isac')
    else:
        h.alias('mars.origin', 'centre')

    h.unalias('mars.domain')

    def marsType_inline_concept(h):
        def wrapped(h):

            typeOfProcessedData = h.get_l('typeOfProcessedData')

            if typeOfProcessedData == 2:
                return 'fc'

            if typeOfProcessedData == 2:
                return 9

            if typeOfProcessedData == 3:
                return 'cf'

            if typeOfProcessedData == 3:
                return 10

            if typeOfProcessedData == 4:
                return 'pf'

            if typeOfProcessedData == 4:
                return 11

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsType', None, concepts=marsType_inline_concept(h)))

    def marsStream_inline_concept(h):
        def wrapped(h):

            typeOfProcessedData = h.get_l('typeOfProcessedData')

            if typeOfProcessedData == 0:
                return 'oper'

            if typeOfProcessedData == 2:
                return 'oper'

            if typeOfProcessedData == 3:
                return 'enfo'

            if typeOfProcessedData == 4:
                return 'enfo'

            if typeOfProcessedData == 8:
                return 'enfo'

            dummyc = h.get_l('dummyc')

            if dummyc == 0:
                return 'default'

        return wrapped

    h.add(_.Concept('marsStream', None, concepts=marsStream_inline_concept(h)))

    h.alias('mars.stream', 'marsStream')
    h.alias('mars.type', 'marsType')

    if (h.get_s('stepType') == "avg"):
        h.alias('mars.step', 'stepRange')

    if (h.get_l('isHindcast') == 1):
        h.add(_.Constant('theHindcastMarsStream', "enfh"))
        h.alias('mars.stream', 'theHindcastMarsStream')
        h.alias('mars.hdate', 'dataDate')
        h.alias('mars.date', 'modelVersionDate')
        h.alias('mars.time', 'modelVersionTime')

    def is_ocean2d_param_inline_concept(h):
        def wrapped(h):

            discipline = h.get_l('discipline')
            typeOfFirstFixedSurface = h.get_l('typeOfFirstFixedSurface')
            scaleFactorOfFirstFixedSurface = h.get_l(
                'scaleFactorOfFirstFixedSurface')
            scaledValueOfFirstFixedSurface = h.get_l(
                'scaledValueOfFirstFixedSurface')
            typeOfSecondFixedSurface = h.get_l('typeOfSecondFixedSurface')

            if discipline == 10 and typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 255:
                return 1

            if discipline == 10 and typeOfFirstFixedSurface == 20 and scaleFactorOfFirstFixedSurface == 2 and scaledValueOfFirstFixedSurface == 29315 and typeOfSecondFixedSurface == 255:
                return 1

            if discipline == 10 and typeOfFirstFixedSurface == 169 and scaleFactorOfFirstFixedSurface == 2 and scaledValueOfFirstFixedSurface == 1 and typeOfSecondFixedSurface == 255:
                return 1

            scaleFactorOfSecondFixedSurface = h.get_l(
                'scaleFactorOfSecondFixedSurface')
            scaledValueOfSecondFixedSurface = h.get_l(
                'scaledValueOfSecondFixedSurface')

            if discipline == 10 and typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 160 and scaleFactorOfSecondFixedSurface == 0 and scaledValueOfSecondFixedSurface == 300:
                return 1

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 0

        return wrapped

    h.add(
        _.Concept('is_ocean2d_param',
                  'zero',
                  concepts=is_ocean2d_param_inline_concept(h)))

    def is_ocean3d_param_inline_concept(h):
        def wrapped(h):

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

            if discipline == 10 and typeOfFirstFixedSurface == 160 and typeOfSecondFixedSurface == 160:
                return 1

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

            if discipline == 10 and typeOfFirstFixedSurface == 160 and scaleFactorOfFirstFixedSurface == 0 and scaledValueOfFirstFixedSurface == 0 and typeOfSecondFixedSurface == 160 and scaleFactorOfSecondFixedSurface == 0 and scaledValueOfSecondFixedSurface == 300:
                return 0

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 0

        return wrapped

    h.add(
        _.Concept('is_ocean3d_param',
                  'zero',
                  concepts=is_ocean3d_param_inline_concept(h)))

    if h.get_l('is_ocean2d_param'):
        h.add(_.Constant('oceanLevName', "o2d"))
        h.alias('mars.levtype', 'oceanLevName')
        h.unalias('mars.levelist')

    if h.get_l('is_ocean3d_param'):
        h.add(_.Constant('oceanLevName', "o3d"))
        h.alias('mars.levtype', 'oceanLevName')
        h.unalias('mars.levelist')
コード例 #25
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(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(
        _.Bit('resolutionAndComponentFlags1',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags2',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              5))
    h.add(
        _.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 6))

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

    with h.list('latitudesList'):
        for i in range(0, h.get_l('Nj')):
            h.add(_.Signed('latitudes', 4))
コード例 #26
0
def load(h):

    h.add(_.Transient('dummyc', 0))
    h.add(_.Constant('conceptsMasterDir', "grib2"))
    h.add(_.Constant('conceptsLocalDirAll', "grib2/localConcepts/[centre:s]"))
    h.add(_.Constant('conceptsLocalDirECMF', "grib2/localConcepts/ecmf"))
    h.add(
        _.Concept('paramIdECMF', 'defaultParameter', 'paramId.def',
                  'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(
        _.Concept('paramId', 'paramIdECMF', 'paramId.def', 'conceptsMasterDir',
                  'conceptsLocalDirAll', False))
    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(
        _.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(
        _.Concept('cfNameECMF', 'defaultShortName', 'cfName.def',
                  'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(
        _.Concept('cfName', 'cfNameECMF', 'cfName.def', 'conceptsMasterDir',
                  'conceptsLocalDirAll', False))
    h.add(
        _.Concept('cfVarNameECMF', 'defaultShortName', 'cfVarName.def',
                  'conceptsMasterDir', 'conceptsLocalDirECMF', False))
    h.add(
        _.Concept('cfVarName', 'cfVarNameECMF', 'cfVarName.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', False))
    h.add(
        _.Concept('modelName', 'defaultName', 'modelName.def',
                  'conceptsMasterDir', 'conceptsLocalDirAll', False))
    _.Template('grib2/products_[productionStatusOfProcessedData].def',
               True).load(h)
    h.add(_.Ifs_param('ifsParam', _.Get('paramId'), _.Get('type')))
コード例 #27
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Unsigned('Di', 4))
    h.alias('iDirectionIncrementGridLength', 'Di')
    h.add(
        _.Scale('DiInMetres', _.Get('Di'), _.Get('oneConstant'),
                _.Get('hundred'), _.Get('truncateDegrees')))
    h.alias('geography.DiInMetres', 'DiInMetres')
    h.add(_.Unsigned('Dj', 4))
    h.alias('jDirectionIncrementGridLength', 'Dj')
    h.add(
        _.Scale('DjInMetres', _.Get('Dj'), _.Get('oneConstant'),
                _.Get('hundred'), _.Get('truncateDegrees')))
    h.alias('geography.DjInMetres', 'DjInMetres')
    h.add(_.Signed('X1', 4))
    h.add(
        _.Scale('X1InGridLengths', _.Get('X1'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.X1InGridLengths', 'X1InGridLengths')
    h.add(_.Signed('Y1', 4))
    h.add(
        _.Scale('Y1InGridLengths', _.Get('Y1'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.Y1InGridLengths', 'Y1InGridLengths')
    h.add(_.Signed('X2', 4))
    h.add(
        _.Scale('X2InGridLengths', _.Get('X2'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.X2InGridLengths', 'X2InGridLengths')
    h.add(_.Signed('Y2', 4))
    h.add(
        _.Scale('Y2InGridLengths', _.Get('Y2'), _.Get('one'),
                _.Get('hundred')))
    h.alias('geography.Y2InGridLengths', 'Y2InGridLengths')
コード例 #28
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')
コード例 #29
0
def load(h):

    h.add(
        _.Codetable('tiggeModel', 2,
                    "grib2/local/[localSubSectionCentre:l]/models.table"))
    h.add(
        _.Codetable('tiggeCentre', 2,
                    "grib2/local/[localSubSectionCentre:l]/centres.table"))

    def tiggeLAMName_inline_concept(h):
        def wrapped(h):

            tiggeCentre = h.get_l('tiggeCentre')
            tiggeModel = h.get_l('tiggeModel')

            if tiggeCentre == 0 and tiggeModel == 0:
                return 'MOGREPS-MO- EUA'

            if tiggeCentre == 1 and tiggeModel == 1:
                return 'AEMet-SREPS-MM-EUAT'

            if tiggeCentre == 1 and tiggeModel == 2:
                return 'SRNWP-PEPS'

            if tiggeCentre == 2 and tiggeModel == 3:
                return 'COSMOLEPS-ARPASIMC-EU'

            if tiggeCentre == 3 and tiggeModel == 4:
                return 'NORLAMEPS'

            if tiggeCentre == 4 and tiggeModel == 5:
                return 'ALADIN-LAEF'

            if tiggeCentre == 5 and tiggeModel == 6:
                return 'COSMO-DE EPS'

            if tiggeCentre == 2 and tiggeModel == 7:
                return 'COSMO-SREPS-BO-EU'

            if tiggeCentre == 6 and tiggeModel == 8:
                return 'GLAMEPS'

            if tiggeCentre == 7 and tiggeModel == 9:
                return 'PEARCE'

            if tiggeCentre == 8 and tiggeModel == 10:
                return 'DMI- HIRLAM'

            if tiggeCentre == 9 and tiggeModel == 11:
                return 'OMSZ- ALADIN-EPS'

            if tiggeCentre == 10 and tiggeModel == 11:
                return 'OMSZ- ALADIN-EPS'

            if tiggeCentre == 11 and tiggeModel == 11:
                return 'OMSZ- ALADIN-EPS'

        return wrapped

    h.add(
        _.Concept('tiggeLAMName',
                  None,
                  concepts=tiggeLAMName_inline_concept(h)))
コード例 #30
0
ファイル: template_3_90_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

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

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

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

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

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

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

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

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

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

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

    h.add(_.Unsigned('Nx', 4))
    h.alias('Ni', 'Nx')
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('Nj', 'Ny')
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfSubSatellitePoint', 4))
    h.add(_.Signed('longitudeOfSubSatellitePoint', 4))
    h.add(
        _.Scale('latitudeOfSubSatellitePointInDegrees',
                _.Get('latitudeOfSubSatellitePoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSubSatellitePointInDegrees',
            'latitudeOfSubSatellitePointInDegrees')
    h.add(
        _.Scale('longitudeOfSubSatellitePointInDegrees',
                _.Get('longitudeOfSubSatellitePoint'), _.Get('one'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSubSatellitePointInDegrees',
            'longitudeOfSubSatellitePointInDegrees')
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(
        _.Bit('resolutionAndComponentFlags1',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags2',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('iDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              5))
    h.add(
        _.Bit('jDirectionIncrementGiven', _.Get('resolutionAndComponentFlags'),
              4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 7))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 6))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 6))

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

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

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

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

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

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

        return wrapped

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

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(_.Unsigned('dx', 4))
    h.alias('geography.dx', 'dx')
    h.add(_.Unsigned('dy', 4))
    h.alias('geography.dy', 'dy')
    h.add(_.Unsigned('Xp', 4))
    h.add(
        _.Scale('XpInGridLengths', _.Get('Xp'), _.Get('one'),
                _.Get('thousand')))
    h.alias('geography.XpInGridLengths', 'XpInGridLengths')
    h.alias('xCoordinateOfSubSatellitePoint', 'XpInGridLengths')
    h.add(_.Unsigned('Yp', 4))
    h.add(
        _.Scale('YpInGridLengths', _.Get('Yp'), _.Get('one'),
                _.Get('thousand')))
    h.alias('geography.YpInGridLengths', 'YpInGridLengths')
    h.alias('yCoordinateOfSubSatellitePoint', 'YpInGridLengths')
    h.add(
        _.Codeflag('scanningMode', 1,
                   "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Signed('orientationOfTheGrid', 4))
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.add(_.Unsigned('Nr', 4))
    h.alias(
        'altitudeOfTheCameraFromTheEarthsCentreMeasuredInUnitsOfTheEarthsRadius',
        'Nr')
    h.add(
        _.Scale('NrInRadiusOfEarth', _.Get('Nr'), _.Get('oneConstant'),
                _.Get('oneMillionConstant'), _.Get('truncateDegrees')))
    h.alias('geography.NrInRadiusOfEarth', 'NrInRadiusOfEarth')
    h.add(_.Unsigned('Xo', 4))
    h.alias('xCoordinateOfOriginOfSectorImage', 'Xo')
    h.alias('geography.Xo', 'Xo')
    h.add(_.Unsigned('Yo', 4))
    h.alias('yCoordinateOfOriginOfSectorImage', 'Yo')
    h.alias('geography.Yo', 'Yo')
    h.add(
        _.Iterator('ITERATOR', _.Get('space_view'), _.Get('numberOfPoints'),
                   _.Get('missingValue'), _.Get('values'), _.Get('radius'),
                   _.Get('earthIsOblate'), _.Get('earthMajorAxis'),
                   _.Get('earthMinorAxis'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfSubSatellitePointInDegrees'),
                   _.Get('longitudeOfSubSatellitePointInDegrees'), _.Get('dx'),
                   _.Get('dy'), _.Get('XpInGridLengths'),
                   _.Get('YpInGridLengths'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('NrInRadiusOfEarth'), _.Get('Xo'), _.Get('Yo'),
                   _.Get('iScansNegatively'), _.Get('jScansPositively'),
                   _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))