示例#1
0
def load(h):

    h.add(_.Section_length('section4Length', 3))
    h.add(_.Unsigned('reserved1', 1))
    h.add(_.Codeflag('missingDataFlag', 1, "grib1/1.table"))
    h.add(_.Unsigned('numberOfBytesPerInteger', 1))
    h.add(_.Unsigned('reserved', 2))
    h.add(_.Unsigned('numberOfCharacters', 3))
    h.alias('numberOfChars', 'numberOfCharacters')
    h.add(_.Unsigned('numberOfFloats', 3))
    h.add(_.Unsigned('numberOfIntegers', 3))
    h.alias('numberOfInts', 'numberOfIntegers')
    h.add(_.Unsigned('numberOfLogicals', 3))
    h.add(_.Unsigned('numberOfReservedBytes', 3))
    h.add(_.Unsigned('reserved', 4))
    h.add(_.Unsigned('reserved', 4))
    h.add(_.Unsigned('reserved', 1))
    h.add(_.Ibmfloat('floatValues', 4, _.Get('numberOfFloats')))
    h.alias('floatVal', 'floatValues')

    if h.get_l('numberOfIntegers'):
        h.add(_.Signed('integerValues', 4, _.Get('numberOfIntegers')))

    if h.get_l('numberOfCharacters'):
        h.add(_.StringUnsigned('charValues', 1, _.Get('numberOfCharacters')))

    h.add(_.Section_padding('padding'))
示例#2
0
def load(h):

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

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

    h.add(_.Constant('gridDefinitionTemplateNumber', 3))
    _.Template('grib1/grid_definition_latlon.def').load(h)
    h.add(_.Ascii('zeros', 4))
    h.add(_.Signed('latitudeOfSouthernPole', 3))
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfSouthernPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(_.Signed('longitudeOfSouthernPole', 3))
    h.add(
        _.Scale('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ibmfloat('angleOfRotationInDegrees', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotationInDegrees')
    h.alias('angleOfRotation', 'angleOfRotationInDegrees')
    h.alias('isRotatedGrid', 'one')
    h.add(_.Signed('latitudeOfStretchingPole', 3))
    h.add(_.Signed('longitudeOfStretchingPole', 3))
    h.add(
        _.Scale('latitudeOfStretchingPoleInDegrees',
                _.Get('latitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfStretchingPoleInDegrees',
            'latitudeOfStretchingPoleInDegrees')
    h.add(
        _.Scale('longitudeOfStretchingPoleInDegrees',
                _.Get('longitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfStretchingPoleInDegrees',
            'longitudeOfStretchingPoleInDegrees')
    h.add(_.Ibmfloat('stretchingFactor', 4))
    h.alias('geography.stretchingFactor', 'stretchingFactor')
示例#5
0
def load(h):

    h.add(_.Signed('latitudeOfStretchingPole', 3))
    h.add(_.Signed('longitudeOfStretchingPole', 3))
    h.add(
        _.Scale('latitudeOfStretchingPoleInDegrees',
                _.Get('latitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfStretchingPoleInDegrees',
            'latitudeOfStretchingPoleInDegrees')
    h.add(
        _.Scale('longitudeOfStretchingPoleInDegrees',
                _.Get('longitudeOfStretchingPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfStretchingPoleInDegrees',
            'longitudeOfStretchingPoleInDegrees')
    h.add(_.Ibmfloat('stretchingFactor', 4))
    h.alias('geography.stretchingFactor', 'stretchingFactor')
示例#6
0
def load(h):

    h.add(_.Constant('gridDefinitionTemplateNumber', 51))
    _.Template('grib1/grid_definition_spherical_harmonics.def').load(h)
    h.add(_.Signed('latitudeOfSouthernPole', 3))
    h.add(
        _.Scale('latitudeOfSouthernPoleInDegrees',
                _.Get('latitudeOfSouthernPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees',
            'latitudeOfSouthernPoleInDegrees')
    h.add(_.Signed('longitudeOfSouthernPole', 3))
    h.add(
        _.Scale('longitudeOfSouthernPoleInDegrees',
                _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees',
            'longitudeOfSouthernPoleInDegrees')
    h.add(_.Ibmfloat('angleOfRotationInDegrees', 4))
    h.alias('geography.angleOfRotationInDegrees', 'angleOfRotationInDegrees')
    h.alias('angleOfRotation', 'angleOfRotationInDegrees')
    h.alias('isRotatedGrid', 'one')
示例#7
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)
示例#8
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')
示例#9
0
def load(h):

    h.add(_.Section_length('section4Length', 3))
    h.add(_.Unsigned('reserved1', 1))

    if (h.get_l('reserved1') == 0):
        h.add(_.Codeflag('missingDataFlag', 1, "grib1/1.table"))
        h.add(_.Unsigned('numberOfBytesPerInteger', 1))
        h.add(_.Unsigned('reserved', 2))
        h.add(_.Unsigned('numberOfChars', 3))
        h.add(_.Unsigned('numberOfFloats', 3))
        h.add(_.Unsigned('numberOfIntegers', 3))
        h.alias('numberOfInts', 'numberOfIntegers')
        h.add(_.Unsigned('numberOfLogicals', 3))
        h.add(_.Unsigned('numberOfReservedBytes', 3))
        h.add(_.Unsigned('reserved', 4))
        h.add(_.Unsigned('reserved', 4))
        h.add(_.Unsigned('reserved', 1))
        h.add(_.Ibmfloat('floatValues', 4, _.Get('numberOfFloats')))
        h.alias('floatVal', 'floatValues')

        if (h.get_l('numberOfBytesPerInteger') == 1):
            h.add(_.Signed('integerValues', 1, _.Get('numberOfIntegers')))

        if (h.get_l('numberOfBytesPerInteger') == 2):
            h.add(_.Signed('integerValues', 2, _.Get('numberOfIntegers')))

        if (h.get_l('numberOfBytesPerInteger') == 3):
            h.add(_.Signed('integerValues', 3, _.Get('numberOfIntegers')))

        if (h.get_l('numberOfBytesPerInteger') == 4):
            h.add(_.Signed('integerValues', 4, _.Get('numberOfIntegers')))

        if (h.get_l('numberOfChars') >= 12):
            h.add(_.Ascii('marsClass', 2))
            h.add(_.Ascii('dummy1', 2))
            h.add(_.Ascii('marsType', 2))
            h.add(_.Ascii('dummy2', 2))
            h.add(_.Ascii('experimentVersionNumber', 4))
            h.alias('expver', 'experimentVersionNumber')
            h.alias('marsExpver', 'experimentVersionNumber')
            h.add(
                _.Constant('numberOfRemaininChars',
                           (_.Get('numberOfChars') - 12)))

            with h.list('charValues'):
                for i in range(0, h.get_l('numberOfRemaininChars')):
                    h.add(_.Ascii('char', 1))
            h.add(_.Constant('zero', 0))

            def isEps_inline_concept(h):
                def wrapped(h):

                    marsType = h.get_s('marsType')

                    if marsType == "pf":
                        return 1

                return wrapped

            h.add(_.Concept('isEps', 'zero', concepts=isEps_inline_concept(h)))

            def isSens_inline_concept(h):
                def wrapped(h):

                    marsType = h.get_s('marsType')

                    if marsType == "sf":
                        return 1

                return wrapped

            h.add(
                _.Concept('isSens', 'zero', concepts=isSens_inline_concept(h)))

            h.add(_.Constant('oper', "oper"))

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

                    marsType = h.get_s('marsType')

                    if marsType == "pf":
                        return 'enfo'

                    if marsType == "cf":
                        return 'enfo'

                    if marsType == "sf":
                        return 'sens'

                return wrapped

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

            if h.get_l('isEps'):
                h.add(_.Constant('perturbationNumber', 0))
                h.alias('mars.number', 'perturbationNumber')

            if h.get_l('isSens'):
                h.add(_.Constant('iterationNumber', 0))
                h.add(_.Constant('diagnosticNumber', 0))
                h.alias('mars.iteration', 'iterationNumber')
                h.alias('mars.diagnostic', 'diagnosticNumber')

            h.alias('mars.stream', 'marsStream')
            h.alias('mars.class', 'marsClass')
            h.alias('mars.type', 'marsType')
            h.alias('mars.expver', 'marsExpver')
        else:

            with h.list('charValues'):
                for i in range(0, h.get_l('numberOfChars')):
                    h.add(_.Ascii('char', 1))

    else:
        h.add(_.Section_padding('padding'))
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)
示例#11
0
def load(h):

    h.add(_.Position('offsetSection2'))
    h.add(_.Section_length('section2Length', 3))
    h.add(_.Section_pointer('section2Pointer', _.Get('offsetSection2'), _.Get('section2Length'), 2))
    h.add(_.Transient('radius', 6367470))
    h.alias('radiusOfTheEarth', 'radius')
    h.alias('radiusInMetres', 'radius')
    h.add(_.Transient('shapeOfTheEarth', 6))
    h.add(_.Unsigned('numberOfVerticalCoordinateValues', 1))
    h.add(_.Constant('neitherPresent', 255))
    h.alias('NV', 'numberOfVerticalCoordinateValues')
    h.alias('numberOfCoordinatesValues', 'numberOfVerticalCoordinateValues')
    h.add(_.Unsigned('pvlLocation', 1))
    h.add(_.Codetable('dataRepresentationType', 1, "grib1/6.table"))
    h.add(_.Codetable_title('gridDefinitionDescription', _.Get('dataRepresentationType')))
    h.alias('isRotatedGrid', 'zero')

    if (h.get_l('dataRepresentationType') < 192):
        _.Template('grib1/grid_definition_[dataRepresentationType:l].def').load(h)
    else:
        _.Template('grib1/grid_definition_[dataRepresentationType:l].[centre:l].def').load(h)

    h.add(_.Position('endGridDefinition'))
    h.add(_.Position('offsetBeforePV'))
    h.add(_.Transient('PVPresent', (_.Get('NV') > 0)))

    if (h.get_l('pvlLocation') != h.get_l('neitherPresent')):
        h.add(_.Padto('padding_sec2_2', ((_.Get('offsetSection2') + _.Get('pvlLocation')) - 1)))
    else:
        h.add(_.Padto('padding_sec2_2', (_.Get('offsetSection2') + 32)))

    if h.get_l('PVPresent'):
        h.add(_.Ibmfloat('pv', 4, _.Get('NV')))
        h.alias('vertical.pv', 'pv')

    h.add(_.Position('offsetBeforePL'))
    h.add(_.Transient('PLPresent', _.And((_.Get('section2Length') > (_.Get('offsetBeforePL') - _.Get('offsetSection2'))), (_.Get('section2Length') >= (((_.Get('Nj') * 2) + _.Get('offsetBeforePL')) - _.Get('offsetSection2'))))))

    if h.get_l('PLPresent'):
        h.add(_.Constant('numberOfOctectsForNumberOfPoints', 2))
        h.add(_.Constant('interpretationOfNumberOfPoints', 1))
        h.add(_.Unsigned('pl', 2, _.Get('Nj')))
        h.alias('geography.pl', 'pl')

    if ((h.get_l('PVPresent') == 0) and (h.get_l('PLPresent') == 0)):
        h.add(_.Padto('padding_sec2_1', (_.Get('offsetSection2') + 32)))

    pass  # when block
    pass  # when block
    h.alias('reducedGrid', 'PLPresent')

    def deletePV_inline_concept(h):
        def wrapped(h):

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

            if PVPresent == 0 and NV == 0:
                return 1

        return wrapped

    h.add(_.Concept('deletePV', 'unknown', concepts=deletePV_inline_concept(h)))

    h.add(_.Padtoeven('padding_sec2_3', _.Get('offsetSection2'), _.Get('section2Length')))
    h.add(_.Md5('md5Section2', _.Get('offsetSection2'), _.Get('section2Length')))
    h.alias('md5GridSection', 'md5Section2')