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

    h.add(_.Position('offsetSection6'))
    h.add(_.Position('offsetBSection6'))
    h.add(_.Section_length('section6Length', 4))
    h.add(_.Section_pointer('section6', _.Get('offsetSection6'), _.Get('section6Length'), 6))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(_.Codetable('bitMapIndicator', 1, "6.0.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.G2bitmap_present('bitmapPresent', _.Get('bitMapIndicator')))
    h.alias('geography.bitmapPresent', 'bitmapPresent')
    h.add(_.Transient('missingValuesPresent', _.Get('bitmapPresent')))

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

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

            if (h.get_l('matrixBitmapsPresent') == 1):
                h.add(_.G2bitmap('primaryBitmap', _.Get('tableReference'), _.Get('missingValue'), _.Get('offsetBSection6'), _.Get('section6Length'), _.Get('numberOfDataMatrices')))
            else:
                h.add(_.G2bitmap('bitmap', _.Get('tableReference'), _.Get('missingValue'), _.Get('offsetBSection6'), _.Get('section6Length'), _.Get('numberOfDataPoints')))
                h.alias('geography.bitmap', 'bitmap')

        else:
            h.add(_.G2bitmap('bitmap', _.Get('tableReference'), _.Get('missingValue'), _.Get('offsetBSection6'), _.Get('section6Length'), _.Get('numberOfDataPoints')))
            h.alias('geography.bitmap', 'bitmap')


    if (h.get_l('bitMapIndicator') == 255):

        if ((h.get_l('dataRepresentationTemplateNumber') == 2) or (h.get_l('dataRepresentationTemplateNumber') == 3)):
            h.add(_.Transient('missingValuesPresent', (_.Get('missingValueManagementUsed') != 0)))


    h.add(_.Md5('md5Section6', _.Get('offsetSection6'), _.Get('section6Length')))
コード例 #2
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')
コード例 #3
0
ファイル: boot_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Constant('tablesVersionLatest', 25))
    h.add(_.Constant('million', 1000000))
    h.add(_.Constant('grib2divider', 1000000))
    h.alias('extraDimensionPresent', 'zero')
    h.alias('is_tigge', 'zero')
    h.alias('is_s2s', 'zero')
    h.add(_.Transient('is_efas', 0))
    h.add(_.Transient('angleSubdivisions', _.Get('grib2divider')))
    h.add(_.Gts_header('gts_header'))
    h.add(_.Gts_header('gts_TTAAii', 20, 6))
    h.add(_.Gts_header('gts_CCCC', 27, 4))
    h.add(_.Gts_header('gts_ddhh00', 32, 6))
    h.add(_.Transient('missingValue', 9999))
    h.add(_.Constant('ieeeFloats', 1))
    h.add(_.Constant('isHindcast', 0))
    h.add(_.Position('offsetSection0'))
    h.add(_.Constant('section0Length', 16))
    h.add(_.Ascii('identifier', 4))
    h.add(_.Unsigned('reserved', 2))
    h.add(_.Codetable('discipline', 1, "0.0.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('editionNumber', 1))
    h.alias('ls.edition', 'editionNumber')
    h.add(_.Section_length('totalLength', 8))
    h.add(_.Position('startOfHeaders'))
    h.add(_.Section_pointer('section0Pointer', _.Get('offsetSection0'), _.Get('section0Length'), 0))
    _.Template('grib2/sections.def').load(h)
    _.Template('grib2/section.8.def').load(h)
コード例 #4
0
def load(h):

    h.add(_.Position('startOfHeaders'))
    h.add(_.Ascii('identifier', 4))
    h.alias('ls.identifier', 'identifier')
    h.add(_.Transient('missingValue', 9999))
    h.add(_.Constant('ieeeFloats', 0))
    h.add(_.Constant('zero', 0))
    _.Template('diag/section.1.def').load(h)
    _.Template('diag/section.4.def').load(h)
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
コード例 #5
0
def load(h):

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

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

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

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

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

        _.Template('grib1/section.4.def').load(h)
        _.Template('grib1/section.5.def').load(h)
コード例 #6
0
def load(h):

    h.add(_.Position('startOfHeaders'))
    h.add(_.Ascii('identifier', 4))
    h.alias('ls.identifier', 'identifier')
    h.add(_.Uint64('totalLength', 8))
    h.add(_.Uint8('version', 1))
    h.add(_.Uint8('spare', 1))
    _.Template('wrap/metadata.[version].def').load(h)
    h.add(_.Position('endOfHeadersMarker'))
    h.add(_.Constant('dataLength', ((_.Get('totalLength') - _.Get('endOfHeadersMarker')) - 4)))
    h.add(_.Blob('data', _.Get('dataLength')))
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
コード例 #7
0
ファイル: section_3_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetSection3'))
    h.add(_.Section_length('section3Length', 3))
    h.add(_.Section_pointer('section3Pointer', _.Get('offsetSection3'), _.Get('section3Length'), 3))
    h.add(_.Unsigned('numberOfUnusedBitsAtEndOfSection3', 1))
    h.alias('unusedBitsInBitmap', 'numberOfUnusedBitsAtEndOfSection3')
    h.add(_.Unsigned('tableReference', 2))
    h.add(_.Position('offsetBeforeBitmap'))
    h.add(_.G1bitmap('bitmap', _.Get('tableReference'), _.Get('missingValue'), _.Get('offsetSection3'), _.Get('section3Length'), _.Get('numberOfUnusedBitsAtEndOfSection3')))
    h.alias('geography.bitmap', 'bitmap')
    h.add(_.Position('offsetAfterBitmap'))
    h.add(_.Padtoeven('padding_sec3_1', _.Get('offsetSection3'), _.Get('section3Length')))
    h.add(_.Section_padding('section3Padding'))
    h.add(_.Md5('md5Section3', _.Get('offsetSection3'), _.Get('section3Length')))
コード例 #8
0
ファイル: section_0_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetSection0'))
    h.add(_.Constant('section0Length', 16))
    h.add(_.Ascii('identifier', 4))
    h.add(_.Unsigned('reserved', 2))
    h.add(
        _.Codetable('discipline', 1, "0.0.table", _.Get('masterDir'),
                    _.Get('localDir')))
    h.add(_.Unsigned('editionNumber', 1))
    h.alias('ls.edition', 'editionNumber')
    h.add(_.Section_length('totalLength', 8))
    h.add(_.Position('startOfHeaders'))
    h.add(
        _.Section_pointer('section0Pointer', _.Get('offsetSection0'),
                          _.Get('section0Length'), 0))
コード例 #9
0
def load(h):

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

    if ((h.get_l('extraLocalSectionPresent')
         or h.get_l('addExtraLocalSection'))
            and not (h.get_l('deleteExtraLocalSection'))):
        h.add(
            _.Codetable(
                'extraLocalSectionNumber', 2,
                "grib2/grib2LocalSectionNumber.[centreForLocal:l].table"))
        _.Template('grib2/local.98.[extraLocalSectionNumber:l].def').load(h)
コード例 #10
0
ファイル: template_7_3_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetBeforeData'))
    h.add(
        _.Data_g22order_packing('codedValues', _.Get('section7Length'),
                                _.Get('offsetBeforeData'),
                                _.Get('offsetSection7'),
                                _.Get('numberOfValues'), _.Get('bitsPerValue'),
                                _.Get('referenceValue'),
                                _.Get('binaryScaleFactor'),
                                _.Get('decimalScaleFactor'),
                                _.Get('typeOfOriginalFieldValues'),
                                _.Get('groupSplittingMethodUsed'),
                                _.Get('missingValueManagementUsed'),
                                _.Get('primaryMissingValueSubstitute'),
                                _.Get('secondaryMissingValueSubstitute'),
                                _.Get('numberOfGroupsOfDataValues'),
                                _.Get('referenceForGroupWidths'),
                                _.Get('numberOfBitsUsedForTheGroupWidths'),
                                _.Get('referenceForGroupLengths'),
                                _.Get('lengthIncrementForTheGroupLengths'),
                                _.Get('trueLengthOfLastGroup'),
                                _.Get('numberOfBitsForScaledGroupLengths'),
                                _.Get('orderOfSpatialDifferencing'),
                                _.Get('numberOfOctetsExtraDescriptors')))
    h.add(
        _.Data_apply_bitmap('values', _.Get('codedValues'), _.Get('bitmap'),
                            _.Get('missingValue'), _.Get('binaryScaleFactor'),
                            _.Get('numberOfDataPoints'),
                            _.Get('numberOfValues')))
    h.alias('data.packedValues', 'codedValues')
    _.Template('common/statistics_grid.def').load(h)
コード例 #11
0
def load(h):

    h.add(_.Constant('section8Length', 4))
    h.add(_.Position('offsetSection8'))
    h.add(_.Ascii('7777', 4))
    h.add(
        _.Section_pointer('section8Pointer', _.Get('offsetSection8'),
                          _.Get('section8Length'), 8))
コード例 #12
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    h.add(_.Ieeefloat('referenceValue', 4))
    h.add(
        _.Reference_value_error('referenceValueError', _.Get('referenceValue'),
                                _.Get('ieee')))
    h.add(_.Signed('binaryScaleFactor', 2))
    h.add(_.Signed('decimalScaleFactor', 2))
    h.add(_.Transient('optimizeScaleFactor', 0))
    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBits', 'bitsPerValue')
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
    h.add(_.Unsigned('matrixBitmapsPresent', 1))
    h.alias('secondaryBitmapPresent', 'matrixBitmapsPresent')
    h.add(_.Unsigned('numberOfCodedValues', 4))
    h.add(_.Unsigned('firstDimension', 2))
    h.alias('NR', 'firstDimension')
    h.add(_.Unsigned('secondDimension', 2))
    h.alias('NC', 'secondDimension')
    h.add(_.Unsigned('firstDimensionCoordinateValueDefinition', 1))
    h.add(_.Unsigned('NC1', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifyFirstDimensionCoordinateFunction',
        'NC1')
    h.add(_.Unsigned('secondDimensionCoordinateValueDefinition', 1))
    h.add(_.Unsigned('NC2', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifySecondDimensionCoordinateFunction',
        'NC2')
    h.add(_.Unsigned('firstDimensionPhysicalSignificance', 1))
    h.add(_.Unsigned('secondDimensionPhysicalSignificance', 1))
    h.add(_.Ieeefloat('coefsFirst', 4, _.Get('NC1')))
    h.add(_.Ieeefloat('coefsSecond', 4, _.Get('NC2')))
    h.alias('data.coefsFirst', 'coefsFirst')
    h.alias('data.coefsSecond', 'coefsSecond')

    if (h.get_l('matrixBitmapsPresent') == 1):
        h.add(_.Constant('datumSize', (_.Get('NC') * _.Get('NR'))))
        h.add(
            _.Constant('secondaryBitmapsCount', (_.Get('numberOfValues') + 0)))
        h.add(
            _.Constant('secondaryBitmapsSize',
                       (_.Get('secondaryBitmapsCount') / 8)))
        h.add(
            _.Transient('numberOfDataMatrices',
                        (_.Get('numberOfDataPoints') / _.Get('datumSize'))))
        h.add(_.Position('offsetBBitmap'))
        h.add(
            _.G2bitmap('secondaryBitmaps', _.Get('dummy'),
                       _.Get('missingValue'), _.Get('offsetBSection5'),
                       _.Get('section5Length'), _.Get('numberOfCodedValues'),
                       _.Get('dummy')))
        h.add(
            _.Data_g2secondary_bitmap('bitmap', _.Get('primaryBitmap'),
                                      _.Get('secondaryBitmaps'),
                                      _.Get('missingValue'),
                                      _.Get('datumSize'),
                                      _.Get('numberOfDataPoints')))
コード例 #14
0
ファイル: section_2_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetSection2'))
    h.add(_.Section_length('section2Length', 4))
    h.add(
        _.Section_pointer('section2Pointer', _.Get('offsetSection2'),
                          _.Get('section2Length'), 2))
    h.add(_.Unsigned('numberOfSection', 1))
    h.alias('tiggeSuiteID', 'zero')
    h.add(_.Transient('addEmptySection2', 0))

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

        if ((h.get_l('grib2LocalSectionPresent') == 1)
                or ((h.get_l('section2Length') > 5) or h._new())):
            h.alias('section2Used', 'one')

            if ((h.get_l('productionStatusOfProcessedData') == 4)
                    or (h.get_l('productionStatusOfProcessedData') == 5)):
                h.add(
                    _.Codetable('tiggeLocalVersion', 2,
                                "grib2/tiggeLocalVersion.table"))
                _.Template('grib2/local.tigge.[tiggeLocalVersion:l].def').load(
                    h)

            if ((h.get_l('productionStatusOfProcessedData') == 10)
                    or (h.get_l('productionStatusOfProcessedData') == 11)):
                h.add(
                    _.Codetable('crraLocalVersion', 2,
                                "grib2/crraLocalVersion.table"))
                _.Template('grib2/local.crra.[crraLocalVersion:l].def').load(h)

            h.add(
                _.Codetable(
                    'grib2LocalSectionNumber', 2,
                    "grib2/grib2LocalSectionNumber.[centreForLocal:l].table"))

            if (h.get_l('grib2LocalSectionNumber') != 0):
                _.Template('grib2/local.[centreForLocal:l].def', True).load(h)
            else:
                h.add(_.Constant('deleteLocalDefinition', 1))

            h.add(_.Position('offsetAfterCentreLocalSection'))

    h.add(_.Section_padding('section2Padding'))
コード例 #15
0
def load(h):

    h.alias('localDefinitionNumber', 'grib2LocalSectionNumber')
    _.Template('grib2/local.[centreForLocal:l].[grib2LocalSectionNumber:l].def'
               ).load(h)
    _.Template('grib2/mars_labeling.82.def').load(h)
    _.Template('mars/eswi/grib2.[stream:s].[type:s].def', True).load(h)
    _.Template('grib2/ls_labeling.82.def').load(h)
    h.add(_.Position('offsetAfterLocalSection'))
コード例 #16
0
def load(h):

    h.add(_.Position('startOfHeaders'))
    h.add(_.Ascii('identifier', 4))
    h.alias('ls.identifier', 'identifier')
    h.add(_.Transient('missingValue', 9999))
    h.add(_.Constant('ieeeFloats', 0))
    _.Template('tide/section.1.def').load(h)
    _.Template('tide/mars_labeling.def').load(h)
    h.add(_.Position('endOfHeadersMarker'))
    h.add(
        _.Evaluate('lengthOfHeaders',
                   (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(
        _.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))
    _.Template('tide/section.4.def').load(h)
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
コード例 #17
0
ファイル: boot_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

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

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

    h.alias('ls.BBB', 'BBB')
    h.alias('ls.count', 'count')
    h.alias('ls.TT', 'TT')
    h.alias('ls.AA', 'AA')
    h.alias('ls.II', 'II')
    h.alias('ls.CCCC', 'CCCC')
    h.alias('ls.YY', 'YY')
    h.alias('ls.GG', 'GG')
    h.alias('ls.gg', 'gg')
    h.add(_.Position('endOfHeadersMarker'))
    h.add(_.Message('theMessage', 4))
    h.add(
        _.Evaluate('lengthOfHeaders',
                   (_.Get('endOfHeadersMarker') - _.Get('startOfHeaders'))))
    h.add(
        _.Md5('md5Headers', _.Get('startOfHeaders'), _.Get('lengthOfHeaders')))
    h.add(_.Ascii('endMark', 4))
    h.add(_.Position('totalLength'))
    h.alias('ls.totalLength', 'totalLength')
コード例 #18
0
def load(h):

    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Pad('padding_loc191_1', 2))
    h.add(_.Unsigned('formatVersionMajorNumber', 1))
    h.add(_.Unsigned('formatVersionMinorNumber', 1))
    h.add(_.Unsigned('originalSubCentreIdentifier', 1))
    h.alias('mars.levelist', 'level')
    h.add(_.Pad('padding_loc191_2', 4))
    h.add(_.Unsigned('numberOfBytesOfFreeFormatData', 2))
    h.add(_.Position('offsetFreeFormData'))
    h.add(_.Unsigned('freeFormData', 1,
                     _.Get('numberOfBytesOfFreeFormatData')))
    h.add(_.Padtomultiple('padding_loc191_3', _.Get('offsetFreeFormData'), 80))
    h.add(_.Position('offsetAfterPadding'))
    h.add(
        _.Constant(
            'GRIBEXSection1Problem',
            ((_.Get('offsetAfterPadding') - _.Get('offsetFreeFormData')) %
             80)))
コード例 #19
0
ファイル: local_98_17_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Unsigned('perturbationNumber', 1))
    h.alias('number', 'perturbationNumber')
    h.add(_.Unsigned('numberOfForecastsInEnsemble', 1))
    h.add(_.Unsigned('dateOfSSTFieldUsed', 3))
    h.add(_.Unsigned('typeOfSSTFieldUsed', 1))
    h.add(_.Unsigned('countOfICEFieldsUsed', 1))
    h.add(_.Position('offsetICEFieldsUsed'))

    with h.list('ICEFieldsUsed'):
        for i in range(0, h.get_l('countOfICEFieldsUsed')):
            h.add(_.Unsigned('dateOfIceFieldUsed', 3))
            h.add(_.Unsigned('satelliteNumber', 1))
    h.add(_.Padtomultiple('padding_loc17_2', _.Get('offsetICEFieldsUsed'), 40))
    h.add(_.Position('offsetAfterPadding'))
    h.add(
        _.Constant(
            'GRIBEXSection1Problem',
            ((_.Get('offsetAfterPadding') - _.Get('offsetICEFieldsUsed')) %
             40)))
コード例 #20
0
def load(h):

    _.Template('grib1/mars_labeling.def').load(h)
    h.add(_.Unsigned('perturbationNumber', 1))
    h.alias('number', 'perturbationNumber')
    h.add(_.Unsigned('numberOfForecastsInEnsemble', 1))
    h.add(_.Ascii('Model_Identifier', 8))
    h.add(_.Ascii('LBC_Initial_Conditions', 8))
    h.add(_.Ascii('Model_LBC_Member_Identifier', 4))
    h.add(_.Ascii('Model_Additional_Information', 8))
    h.add(_.Pad('padding_loc245_1', 20))
    h.add(_.Unsigned('Extra_Data_FreeFormat_0_none', 2))
    h.add(_.Position('offsetFreeFormData'))
    h.add(_.Unsigned('freeFormData', 1, _.Get('Extra_Data_FreeFormat_0_none')))
    h.add(_.Padtomultiple('padding_loc245_2', _.Get('offsetSection1'), 80))
コード例 #21
0
def load(h):

    h.add(_.Position('offsetSection3'))
    h.add(_.Transient('section3Length', 1))
    h.add(
        _.Section_pointer('section3Pointer', _.Get('offsetSection3'),
                          _.Get('section3Length'), 3))
    h.add(_.Transient('numberOfUnusedBitsAtEndOfSection3', 0))
    h.add(_.Transient('tableReference', 0))
    h.add(
        _.Gds_not_present_bitmap('bitmap', _.Get('missingValue'),
                                 _.Get('numberOfValues'),
                                 _.Get('numberOfPoints'),
                                 _.Get('latitudeOfFirstGridPoint'),
                                 _.Get('Ni'),
                                 _.Get('numberOfUnusedBitsAtEndOfSection3')))
コード例 #22
0
def load(h):

    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
    h.add(_.Ibmfloat('realPart', 4))
    h.add(_.Position('offsetBeforeData'))
    h.add(_.Transient('P', 0))

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

    h.add(
        _.Data_g1simple_packing('codedValues', _.Get('section4Length'),
                                _.Get('offsetBeforeData'),
                                _.Get('offsetSection4'), _.Get('unitsFactor'),
                                _.Get('unitsBias'), _.Get('changingPrecision'),
                                _.Get('numberOfCodedValues'),
                                _.Get('bitsPerValue'), _.Get('referenceValue'),
                                _.Get('binaryScaleFactor'),
                                _.Get('decimalScaleFactor'),
                                _.Get('optimizeScaleFactor'),
                                _.Get('halfByte')))
    h.add(
        _.Data_g1shsimple_packing('values', _.Get('codedValues'),
                                  _.Get('realPart')))
    h.alias('data.packedValues', 'values')
    h.add(
        _.G1number_of_coded_values_sh_simple('numberOfCodedValues',
                                             _.Get('bitsPerValue'),
                                             _.Get('offsetBeforeData'),
                                             _.Get('offsetAfterData'),
                                             _.Get('halfByte'),
                                             _.Get('numberOfValues')))
    _.Template('common/statistics_spectral.def').load(h)
コード例 #23
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')))
コード例 #24
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')
コード例 #25
0
def load(h):

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

    if h.get_l('localUsePresent'):

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

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

    h.add(_.Constant('constantFieldHalfByte', 0))
    h.add(_.Unsigned('bitsPerValue', 1))
    h.alias('numberOfBitsContainingEachPackedValue', 'bitsPerValue')
    h.add(_.Unsigned('octetAtWichPackedDataBegins', 2))
    h.add(_.Codeflag('extendedFlag', 1, "grib1/11-2.table"))
    h.add(_.Bit('matrixOfValues', _.Get('extendedFlag'), 3))
    h.add(_.Bit('secondaryBitmapPresent', _.Get('extendedFlag'), 2))
    h.add(_.Bit('secondOrderOfDifferentWidth', _.Get('extendedFlag'), 1))
    h.alias('secondOrderValuesDifferentWidths', 'secondOrderOfDifferentWidth')
    h.alias('secondaryBitMap', 'secondaryBitmapPresent')
    h.add(_.Unsigned('NR', 2))
    h.alias('firstDimension', 'NR')
    h.add(_.Unsigned('NC', 2))
    h.alias('secondDimension', 'NC')
    h.add(_.Codeflag('coordinateFlag1', 1, "grib1/12.table"))
    h.alias('firstDimensionCoordinateValueDefinition', 'coordinateFlag1')
    h.add(_.Unsigned('NC1', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifyFirstDimensionCoordinateFunction',
        'NC1')
    h.add(_.Codeflag('coordinateFlag2', 1, "grib1/12.table"))
    h.alias('secondDimensionCoordinateValueDefinition', 'coordinateFlag2')
    h.add(_.Unsigned('NC2', 1))
    h.alias(
        'numberOfCoefficientsOrValuesUsedToSpecifySecondDimensionCoordinateFunction',
        'NC2')
    h.add(_.Codeflag('physicalFlag1', 1, "grib1/13.table"))
    h.alias('firstDimensionPhysicalSignificance', 'physicalFlag1')
    h.add(_.Codeflag('physicalFlag2', 1, "grib1/13.table"))
    h.alias('secondDimensionPhysicalSignificance', 'physicalFlag2')
    h.add(_.Ibmfloat('coefsFirst', 4, _.Get('NC1')))
    h.add(_.Ibmfloat('coefsSecond', 4, _.Get('NC2')))
    h.alias('data.coefsFirst', 'coefsFirst')
    h.alias('data.coefsSecond', 'coefsSecond')
    h.add(_.Position('offsetBeforeData'))

    if (h.get_l('matrixOfValues') == 0):
        h.add(_.Constant('matrixBitmapsPresent', 0))
        h.add(_.Position('offsetBeforeData'))

        if h.get_l('bitmapPresent'):
            h.add(_.Constant('bitMapIndicator', 0))
            h.add(
                _.Data_g1simple_packing('codedValues', _.Get('section4Length'),
                                        _.Get('offsetBeforeData'),
                                        _.Get('offsetSection4'),
                                        _.Get('unitsFactor'),
                                        _.Get('unitsBias'),
                                        _.Get('changingPrecision'),
                                        _.Get('numberOfCodedValues'),
                                        _.Get('bitsPerValue'),
                                        _.Get('referenceValue'),
                                        _.Get('binaryScaleFactor'),
                                        _.Get('decimalScaleFactor'),
                                        _.Get('optimizeScaleFactor'),
                                        _.Get('halfByte'),
                                        _.Get('packingType'),
                                        _.Get('grid_ieee')))
            h.alias('data.packedValues', 'codedValues')
            h.add(
                _.Data_apply_bitmap('values', _.Get('codedValues'),
                                    _.Get('bitmap'), _.Get('missingValue'),
                                    _.Get('binaryScaleFactor')))
        else:
            h.add(_.Constant('bitMapIndicator', 255))
            h.add(
                _.Data_g1simple_packing('values', _.Get('section4Length'),
                                        _.Get('offsetBeforeData'),
                                        _.Get('offsetSection4'),
                                        _.Get('unitsFactor'),
                                        _.Get('unitsBias'),
                                        _.Get('changingPrecision'),
                                        _.Get('numberOfCodedValues'),
                                        _.Get('bitsPerValue'),
                                        _.Get('referenceValue'),
                                        _.Get('binaryScaleFactor'),
                                        _.Get('decimalScaleFactor'),
                                        _.Get('optimizeScaleFactor'),
                                        _.Get('halfByte')))
            h.alias('data.packedValues', 'values')

    else:
        h.add(_.Constant('matrixBitmapsPresent', 1))
        h.add(_.Constant('bitMapIndicator', 0))
        h.add(_.Constant('datumSize', (_.Get('NC') * _.Get('NR'))))
        h.add(
            _.Transient(
                'secondaryBitmapsCount',
                (_.Get('octetAtWichPackedDataBegins') * _.Get('datumSize'))))
        h.add(
            _.Transient('secondaryBitmapsSize',
                        (_.Get('secondaryBitmapsCount') / 8)))
        h.add(_.Position('offsetBBitmap'))
        h.add(
            _.G1bitmap('secondaryBitmaps', _.Get('dummy'),
                       _.Get('missingValue'), _.Get('offsetBBitmap'),
                       _.Get('secondaryBitmapsSize'), _.Get('dummy')))
        h.add(_.Position('offsetBeforeData'))
        h.add(
            _.Data_g1simple_packing('codedValues', _.Get('section4Length'),
                                    _.Get('offsetBeforeData'),
                                    _.Get('offsetSection4'),
                                    _.Get('unitsFactor'), _.Get('unitsBias'),
                                    _.Get('changingPrecision'),
                                    _.Get('numberOfCodedValues'),
                                    _.Get('bitsPerValue'),
                                    _.Get('referenceValue'),
                                    _.Get('binaryScaleFactor'),
                                    _.Get('decimalScaleFactor'),
                                    _.Get('optimizeScaleFactor'),
                                    _.Get('halfByte')))
        h.alias('data.packedValues', 'codedValues')
        h.add(_.Constant('expandBy', (_.Get('NC') * _.Get('NR'))))
        h.add(
            _.Data_g1secondary_bitmap('secondaryBitmap', _.Get('bitmap'),
                                      _.Get('secondaryBitmaps'),
                                      _.Get('missingValue'), _.Get('expandBy'),
                                      _.Get('octetAtWichPackedDataBegins')))
        h.add(
            _.Data_apply_bitmap('values', _.Get('codedValues'),
                                _.Get('secondaryBitmap'),
                                _.Get('missingValue'),
                                _.Get('binaryScaleFactor')))

    h.add(
        _.Simple_packing_error('packingError', _.Get('bitsPerValue'),
                               _.Get('binaryScaleFactor'),
                               _.Get('decimalScaleFactor'),
                               _.Get('referenceValue'), _.Get('ibm')))
    h.add(
        _.Number_of_coded_values('numberOfCodedValues', _.Get('bitsPerValue'),
                                 _.Get('offsetBeforeData'),
                                 _.Get('offsetAfterData'), _.Get('halfByte'),
                                 _.Get('numberOfValues')))
    _.Template('common/statistics_grid.def').load(h)
コード例 #27
0
ファイル: section_1_def.py プロジェクト: ecmwf/pyeccodes
def load(h):

    h.add(_.Position('offsetSection1'))
    h.add(_.Section_length('section1Length', 4))
    h.add(_.Section_pointer('section1Pointer', _.Get('offsetSection1'), _.Get('section1Length'), 1))
    h.add(_.Unsigned('numberOfSection', 1))
    h.add(_.StringCodetable('centre', 2, "common/c-11.table"))
    h.alias('identificationOfOriginatingGeneratingCentre', 'centre')
    h.add(_.Codetable_title('centreDescription', _.Get('centre')))
    h.alias('parameter.centre', 'centre')
    h.alias('ls.centre', 'centre')
    h.alias('originatingCentre', 'centre')
    h.add(_.Unsigned('subCentre', 2))

    if (h.get_l('subCentre') == 98):
        h.alias('centreForLocal', 'subCentre')
    else:
        h.alias('centreForLocal', 'centre')

    h.add(_.Codetable('tablesVersion', 1, "grib2/tables/1.0.table"))
    h.alias('gribMasterTablesVersionNumber', 'tablesVersion')
    h.add(_.Transient('masterDir', "grib2/tables/[tablesVersion]"))

    if (h.get_l('tablesVersion') > h.get_l('tablesVersionLatest')):
        h.add(_.Transient('masterDir', "grib2/tables/[tablesVersionLatest]"))

    pass  # when block
    h.add(_.Codetable('localTablesVersion', 1, "grib2/tables/local/[centreForLocal]/1.1.table"))
    h.alias('versionNumberOfGribLocalTables', 'localTablesVersion')
    h.add(_.Transient('localDir', ""))

    if ((h.get_l('localTablesVersion') != 0) and (h.get_l('localTablesVersion') != 255)):
        h.add(_.Transient('localDir', "grib2/tables/local/[centre]/[localTablesVersion]"))

    h.add(_.Codetable('significanceOfReferenceTime', 1, "1.2.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.Unsigned('year', 2))
    h.add(_.Unsigned('month', 1))
    h.add(_.Unsigned('day', 1))
    h.add(_.Unsigned('hour', 1))
    h.add(_.Unsigned('minute', 1))
    h.add(_.Unsigned('second', 1))
    h.add(_.G2date('dataDate', _.Get('year'), _.Get('month'), _.Get('day')))
    h.alias('mars.date', 'dataDate')
    h.alias('ls.date', 'dataDate')
    h.add(_.Julian_day('julianDay', _.Get('dataDate'), _.Get('hour'), _.Get('minute'), _.Get('second')))
    h.add(_.Time('dataTime', _.Get('hour'), _.Get('minute'), _.Get('second')))
    h.alias('mars.time', 'dataTime')
    h.add(_.Codetable('productionStatusOfProcessedData', 1, "1.3.table", _.Get('masterDir'), _.Get('localDir')))
    h.add(_.StringCodetable('typeOfProcessedData', 1, "1.4.table", _.Get('masterDir'), _.Get('localDir')))
    h.alias('ls.dataType', 'typeOfProcessedData')
    h.add(_.Md5('md5Section1', _.Get('offsetSection1'), _.Get('section1Length')))
    h.add(_.Select_step_template('selectStepTemplateInterval', _.Get('productDefinitionTemplateNumber'), 0))
    h.add(_.Select_step_template('selectStepTemplateInstant', _.Get('productDefinitionTemplateNumber'), 1))
    h.add(_.Transient('stepTypeInternal', "instant"))

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

            selectStepTemplateInstant = h.get_l('selectStepTemplateInstant')
            stepTypeInternal = h.get_s('stepTypeInternal')

            if selectStepTemplateInstant == 1 and stepTypeInternal == "instant":
                return 'instant'

            selectStepTemplateInterval = h.get_l('selectStepTemplateInterval')

            if selectStepTemplateInterval == 1 and stepTypeInternal == "avg":
                return 'avg'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "avgd":
                return 'avgd'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "accum":
                return 'accum'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "max":
                return 'max'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "min":
                return 'min'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "diff":
                return 'diff'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "sdiff":
                return 'sdiff'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "rms":
                return 'rms'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "sd":
                return 'sd'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "cov":
                return 'cov'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "ratio":
                return 'ratio'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "stdanom":
                return 'stdanom'

            if selectStepTemplateInterval == 1 and stepTypeInternal == "sum":
                return 'sum'

        return wrapped

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

    h.add(_.G2_chemical('is_chemical', _.Get('productDefinitionTemplateNumber'), _.Get('stepType'), 0))
    h.add(_.G2_chemical('is_chemical_distfn', _.Get('productDefinitionTemplateNumber'), _.Get('stepType'), 1))
    h.add(_.G2_aerosol('is_aerosol', _.Get('productDefinitionTemplateNumber'), _.Get('stepType'), 0))
    h.add(_.G2_aerosol('is_aerosol_optical', _.Get('productDefinitionTemplateNumber'), _.Get('stepType'), 1))
    h.add(_.Transient('setCalendarId', 0))
    h.add(_.Transient('deleteCalendarId', 0))
    h.alias('calendarIdPresent', 'zero')

    if (((h.get_l('section1Length') > 21) or (h.get_l('setCalendarId') > 0)) and (h.get_l('deleteCalendarId') == 0)):
        h.alias('calendarIdPresent', 'present')
        h.add(_.StringCodetable('calendarIdentificationTemplateNumber', 2, "1.5.table", _.Get('masterDir'), _.Get('localDir')))
        _.Template('grib2/template.1.[calendarIdentificationTemplateNumber:l].def').load(h)

    def is_uerra_inline_concept(h):
        def wrapped(h):

            productionStatusOfProcessedData = h.get_l('productionStatusOfProcessedData')

            if productionStatusOfProcessedData == 10:
                return 1

            if productionStatusOfProcessedData == 11:
                return 1

            if productionStatusOfProcessedData == 9:
                return 1

            if productionStatusOfProcessedData == 8:
                return 1

            dummy = h.get_l('dummy')

            if dummy == 1:
                return 0

        return wrapped

    h.add(_.Concept('is_uerra', 'zero', concepts=is_uerra_inline_concept(h)))
コード例 #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(_.Unsigned('N2', 2))
    h.add(_.Unsigned('codedNumberOfFirstOrderPackedValues', 2))
    h.add(_.Unsigned('numberOfSecondOrderPackedValues', 2))
    h.add(_.Unsigned('extraValues', 1))
    h.add(
        _.Evaluate('numberOfGroups',
                   (_.Get('codedNumberOfFirstOrderPackedValues') +
                    (65536 * _.Get('extraValues')))))
    h.add(_.Unsigned('groupWidths', 1, _.Get('numberOfGroups')))
    h.add(
        _.Second_order_bits_per_value('bitsPerValue', _.Get('values'),
                                      _.Get('binaryScaleFactor'),
                                      _.Get('decimalScaleFactor')))
    h.add(_.Position('offsetBeforeData'))

    if h.get_l('bitmapPresent'):
        h.add(
            _.Data_g1second_order_row_by_row_packing(
                'codedValues', _.Get('section4Length'),
                _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                _.Get('unitsFactor'), _.Get('unitsBias'),
                _.Get('changingPrecision'), _.Get('numberOfCodedValues'),
                _.Get('bitsPerValue'), _.Get('referenceValue'),
                _.Get('binaryScaleFactor'), _.Get('decimalScaleFactor'),
                _.Get('optimizeScaleFactor'), _.Get('halfByte'),
                _.Get('packingType'), _.Get('grid_ieee'), _.Get('precision'),
                _.Get('widthOfFirstOrderValues'), _.Get('N1'), _.Get('N2'),
                _.Get('numberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('Ni'), _.Get('Nj'), _.Get('pl'),
                _.Get('jPointsAreConsecutive'), _.Get('groupWidths'),
                _.Get('bitmap')))
        h.alias('data.packedValues', 'codedValues')
        h.add(
            _.Data_apply_bitmap('values', _.Get('codedValues'),
                                _.Get('bitmap'), _.Get('missingValue'),
                                _.Get('binaryScaleFactor')))
    else:
        h.add(
            _.Data_g1second_order_row_by_row_packing(
                'values', _.Get('section4Length'), _.Get('offsetBeforeData'),
                _.Get('offsetSection4'), _.Get('unitsFactor'),
                _.Get('unitsBias'), _.Get('changingPrecision'),
                _.Get('numberOfCodedValues'), _.Get('bitsPerValue'),
                _.Get('referenceValue'), _.Get('binaryScaleFactor'),
                _.Get('decimalScaleFactor'), _.Get('optimizeScaleFactor'),
                _.Get('halfByte'), _.Get('packingType'), _.Get('grid_ieee'),
                _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                _.Get('N1'), _.Get('N2'), _.Get('numberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('Ni'), _.Get('Nj'), _.Get('pl'),
                _.Get('jPointsAreConsecutive'), _.Get('groupWidths')))
        h.alias('data.packedValues', 'values')

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

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

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

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

    if h.get_l('bitmapPresent'):
        h.add(
            _.Data_g1second_order_general_extended_packing(
                'codedValues', _.Get('section4Length'),
                _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                _.Get('unitsFactor'), _.Get('unitsBias'),
                _.Get('changingPrecision'), _.Get('numberOfCodedValues'),
                _.Get('bitsPerValue'), _.Get('referenceValue'),
                _.Get('binaryScaleFactor'), _.Get('decimalScaleFactor'),
                _.Get('optimizeScaleFactor'), _.Get('halfByte'),
                _.Get('packingType'), _.Get('grid_ieee'), _.Get('precision'),
                _.Get('widthOfFirstOrderValues'), _.Get('firstOrderValues'),
                _.Get('N1'), _.Get('N2'), _.Get('numberOfGroups'),
                _.Get('codedNumberOfGroups'),
                _.Get('numberOfSecondOrderPackedValues'), _.Get('extraValues'),
                _.Get('groupWidths'), _.Get('widthOfWidths'),
                _.Get('groupLengths'), _.Get('widthOfLengths'), _.Get('NL'),
                _.Get('SPD'), _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                _.Get('numberOfPoints')))
        h.alias('data.packedValues', 'codedValues')

        if h.get_l('boustrophedonicOrdering'):

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

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

    else:

        if h.get_l('boustrophedonicOrdering'):
            h.add(
                _.Data_g1second_order_general_extended_packing(
                    'codedValues', _.Get('section4Length'),
                    _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                    _.Get('unitsFactor'), _.Get('unitsBias'),
                    _.Get('changingPrecision'), _.Get('numberOfCodedValues'),
                    _.Get('bitsPerValue'), _.Get('referenceValue'),
                    _.Get('binaryScaleFactor'), _.Get('decimalScaleFactor'),
                    _.Get('optimizeScaleFactor'), _.Get('halfByte'),
                    _.Get('packingType'), _.Get('grid_ieee'),
                    _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                    _.Get('firstOrderValues'), _.Get('N1'), _.Get('N2'),
                    _.Get('numberOfGroups'), _.Get('codedNumberOfGroups'),
                    _.Get('numberOfSecondOrderPackedValues'),
                    _.Get('extraValues'), _.Get('groupWidths'),
                    _.Get('widthOfWidths'), _.Get('groupLengths'),
                    _.Get('widthOfLengths'), _.Get('NL'), _.Get('SPD'),
                    _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                    _.Get('numberOfPoints')))
            h.add(
                _.Data_apply_boustrophedonic('values', _.Get('codedValues'),
                                             _.Get('numberOfRows'),
                                             _.Get('numberOfColumns'),
                                             _.Get('numberOfPoints'),
                                             _.Get('pl')))
        else:
            h.add(
                _.Data_g1second_order_general_extended_packing(
                    'values', _.Get('section4Length'),
                    _.Get('offsetBeforeData'), _.Get('offsetSection4'),
                    _.Get('unitsFactor'), _.Get('unitsBias'),
                    _.Get('changingPrecision'), _.Get('numberOfCodedValues'),
                    _.Get('bitsPerValue'), _.Get('referenceValue'),
                    _.Get('binaryScaleFactor'), _.Get('decimalScaleFactor'),
                    _.Get('optimizeScaleFactor'), _.Get('halfByte'),
                    _.Get('packingType'), _.Get('grid_ieee'),
                    _.Get('precision'), _.Get('widthOfFirstOrderValues'),
                    _.Get('firstOrderValues'), _.Get('N1'), _.Get('N2'),
                    _.Get('numberOfGroups'), _.Get('codedNumberOfGroups'),
                    _.Get('numberOfSecondOrderPackedValues'),
                    _.Get('extraValues'), _.Get('groupWidths'),
                    _.Get('widthOfWidths'), _.Get('groupLengths'),
                    _.Get('widthOfLengths'), _.Get('NL'), _.Get('SPD'),
                    _.Get('widthOfSPD'), _.Get('orderOfSPD'),
                    _.Get('numberOfPoints')))
            h.alias('codedValues', 'values')

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

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