예제 #1
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

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

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

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

    h.add(
        _.Bit('resolutionAndComponentFlags3',
              _.Get('resolutionAndComponentFlags'), 5))
    h.add(
        _.Bit('resolutionAndComponentFlags4',
              _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 2))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 1))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('orientationOfTheGrid', 3))
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.alias('LoV', 'orientationOfTheGrid')
    h.add(_.Unsigned('DxInMetres', 3))
    h.alias('xDirectionGridLengthInMetres', 'DxInMetres')
    h.alias('Dx', 'DxInMetres')
    h.alias('geography.DxInMetres', 'DxInMetres')
    h.alias('Di', 'DxInMetres')
    h.add(_.Unsigned('DyInMetres', 3))
    h.alias('yDirectionGridLengthInMetres', 'DyInMetres')
    h.alias('Dy', 'DyInMetres')
    h.alias('Dj', 'DyInMetres')
    h.alias('geography.DyInMetres', 'DyInMetres')
    h.add(_.Constant('latitudeWhereDxAndDyAreSpecifiedInDegrees', 60))
    h.add(_.Constant('LaDInDegrees', 60))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.add(_.Unsigned('projectionCentreFlag', 1))
    h.alias('projectionCenterFlag', 'projectionCentreFlag')
    h.add(_.Bit('southPoleOnProjectionPlane', _.Get('projectionCentreFlag'),
                7))
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')

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

    h.add(_.Pad('padding_grid5_1', 4))
    h.add(
        _.Number_of_points('numberOfDataPoints', _.Get('Nx'), _.Get('Ny'),
                           _.Get('PLPresent'), _.Get('pl')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(
        _.Number_of_values('numberOfValues', _.Get('values'),
                           _.Get('bitsPerValue'), _.Get('numberOfDataPoints'),
                           _.Get('bitmapPresent'), _.Get('bitmap'),
                           _.Get('numberOfCodedValues')))
    h.add(
        _.Iterator('ITERATOR', _.Get('polar_stereographic'),
                   _.Get('numberOfPoints'), _.Get('missingValue'),
                   _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfFirstGridPointInDegrees'),
                   _.Get('longitudeOfFirstGridPointInDegrees'),
                   _.Get('southPoleOnProjectionPlane'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('LaDInDegrees'), _.Get('Dx'), _.Get('Dy'),
                   _.Get('iScansNegatively'), _.Get('jScansPositively'),
                   _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))
    h.add(
        _.Nearest('NEAREST', _.Get('polar_stereographic'), _.Get('values'),
                  _.Get('radius'), _.Get('Nx'), _.Get('Ny')))
    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))
예제 #3
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

    h.alias('DiGiven', 'iDirectionIncrementGiven')
    h.alias('DjGiven', 'jDirectionIncrementGiven')
    h.add(_.Signed('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(_.Scale('LaDInDegrees', _.Get('LaD'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.add(_.Unsigned('LoV', 4))
    h.add(_.Scale('LoVInDegrees', _.Get('LoV'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LoVInDegrees', 'LoVInDegrees')
    h.add(_.Unsigned('Dx', 4))
    h.alias('xDirectionGridLength', 'Dx')
    h.alias('Di', 'Dx')
    h.add(_.Scale('DxInMetres', _.Get('Dx'), _.Get('one'), _.Get('thousand')))
    h.alias('geography.DxInMetres', 'DxInMetres')
    h.add(_.Unsigned('Dy', 4))
    h.alias('yDirectionGridLength', 'Dy')
    h.alias('Dj', 'Dy')
    h.add(_.Scale('DyInMetres', _.Get('Dy'), _.Get('one'), _.Get('thousand')))
    h.alias('geography.DyInMetres', 'DyInMetres')
    h.add(_.Codeflag('projectionCentreFlag', 1, "grib2/tables/[tablesVersion]/3.5.table"))
    h.add(_.Codeflag('scanningMode', 1, "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(_.Change_scanning_direction('swapScanningX', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('xFirst'), _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(_.Change_scanning_direction('swapScanningY', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('yFirst'), _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Signed('Latin1', 4))
    h.alias('FirstLatitude', 'Latin1')
    h.add(_.Scale('Latin1InDegrees', _.Get('Latin1'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin1InDegrees', 'Latin1InDegrees')
    h.add(_.Signed('Latin2', 4))
    h.alias('SecondLatitude', 'Latin2')
    h.add(_.Scale('Latin2InDegrees', _.Get('Latin2'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.Latin2InDegrees', 'Latin2InDegrees')
    h.add(_.Signed('latitudeOfSouthernPole', 4))
    h.alias('latitudeOfTheSouthernPoleOfProjection', 'latitudeOfSouthernPole')
    h.add(_.Scale('latitudeOfSouthernPoleInDegrees', _.Get('latitudeOfSouthernPole'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfSouthernPoleInDegrees', 'latitudeOfSouthernPoleInDegrees')
    h.add(_.Unsigned('longitudeOfSouthernPole', 4))
    h.alias('longitudeOfTheSouthernPoleOfProjection', 'longitudeOfSouthernPole')
    h.add(_.Scale('longitudeOfSouthernPoleInDegrees', _.Get('longitudeOfSouthernPole'), _.Get('oneConstant'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfSouthernPoleInDegrees', 'longitudeOfSouthernPoleInDegrees')
    h.add(_.Iterator('ITERATOR', _.Get('lambert_conformal'), _.Get('numberOfPoints'), _.Get('missingValue'), _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'), _.Get('LoVInDegrees'), _.Get('LaDInDegrees'), _.Get('Latin1InDegrees'), _.Get('Latin2InDegrees'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('DxInMetres'), _.Get('DyInMetres'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('jPointsAreConsecutive'), _.Get('alternativeRowScanning')))
    h.add(_.Nearest('NEAREST', _.Get('lambert_conformal'), _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny')))
    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
예제 #4
0
def load(h):

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))
    h.add(
        _.Octahedral_gaussian('isOctahedral', _.Get('N'), _.Get('Ni'),
                              _.Get('PLPresent'), _.Get('pl')))
    h.add(
        _.Gaussian_grid_name('gaussianGridName', _.Get('N'), _.Get('Ni'),
                             _.Get('isOctahedral')))
    h.alias('gridName', 'gaussianGridName')
    h.add(
        _.Number_of_points_gaussian(
            'numberOfDataPointsExpected', _.Get('Ni'), _.Get('Nj'),
            _.Get('PLPresent'), _.Get('pl'), _.Get('N'),
            _.Get('latitudeOfFirstGridPointInDegrees'),
            _.Get('longitudeOfFirstGridPointInDegrees'),
            _.Get('latitudeOfLastGridPointInDegrees'),
            _.Get('longitudeOfLastGridPointInDegrees'), _.Get('zero')))
    h.add(
        _.Evaluate('legacyGaussSubarea',
                   (_.Get('numberOfDataPoints') !=
                    _.Get('numberOfDataPointsExpected'))))
예제 #5
0
def load(h):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return wrapped

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    h.add(_.Transient('oneThousand', 1000))
    h.add(_.Unsigned('Nx', 4))
    h.alias('Ni', 'Nx')
    h.alias('numberOfPointsAlongXAxis', 'Nx')
    h.alias('geography.Nx', 'Nx')
    h.add(_.Unsigned('Ny', 4))
    h.alias('Nj', 'Ny')
    h.alias('numberOfPointsAlongYAxis', 'Ny')
    h.alias('geography.Ny', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.add(
        _.Scale('latitudeOfFirstGridPointInDegrees',
                _.Get('latitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees',
            'latitudeOfFirstGridPointInDegrees')
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Unsigned('longitudeOfFirstGridPoint', 4))
    h.add(
        _.Scale('longitudeOfFirstGridPointInDegrees',
                _.Get('longitudeOfFirstGridPoint'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees',
            'longitudeOfFirstGridPointInDegrees')
    h.alias('Lo1', 'longitudeOfFirstGridPoint')
    h.add(
        _.Codeflag('resolutionAndComponentFlags', 1,
                   "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(_.Signed('LaD', 4))
    h.alias('latitudeWhereDxAndDyAreSpecified', 'LaD')
    h.add(
        _.Scale('LaDInDegrees', _.Get('LaD'), _.Get('oneConstant'),
                _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.LaDInDegrees', 'LaDInDegrees')
    h.alias('latitudeWhereDxAndDyAreSpecifiedInDegrees', 'LaDInDegrees')
    h.add(_.Signed('orientationOfTheGrid', 4))
    h.alias('LoV', 'orientationOfTheGrid')
    h.add(
        _.Scale('orientationOfTheGridInDegrees', _.Get('orientationOfTheGrid'),
                _.Get('oneConstant'), _.Get('grib2divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.orientationOfTheGridInDegrees',
            'orientationOfTheGridInDegrees')
    h.add(_.Unsigned('Dx', 4))
    h.add(
        _.Scale('DxInMetres', _.Get('Dx'), _.Get('one'), _.Get('thousand'),
                _.Get('truncateDegrees')))
    h.alias('geography.DxInMetres', 'DxInMetres')
    h.alias('xDirectionGridLength', 'Dx')
    h.add(_.Unsigned('Dy', 4))
    h.add(
        _.Scale('DyInMetres', _.Get('Dy'), _.Get('one'), _.Get('thousand'),
                _.Get('truncateDegrees')))
    h.alias('geography.DyInMetres', 'DyInMetres')
    h.alias('yDirectionGridLength', 'Dy')
    h.add(
        _.Codeflag('projectionCentreFlag', 1,
                   "grib2/tables/[tablesVersion]/3.5.table"))
    h.add(_.Bit('southPoleOnProjectionPlane', _.Get('projectionCentreFlag'),
                7))
    h.add(
        _.Codeflag('scanningMode', 1,
                   "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(
        _.Iterator('ITERATOR', _.Get('polar_stereographic'),
                   _.Get('numberOfPoints'), _.Get('missingValue'),
                   _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'),
                   _.Get('latitudeOfFirstGridPointInDegrees'),
                   _.Get('longitudeOfFirstGridPointInDegrees'),
                   _.Get('southPoleOnProjectionPlane'),
                   _.Get('orientationOfTheGridInDegrees'),
                   _.Get('LaDInDegrees'), _.Get('DxInMetres'),
                   _.Get('DyInMetres'), _.Get('iScansNegatively'),
                   _.Get('jScansPositively'), _.Get('jPointsAreConsecutive'),
                   _.Get('alternativeRowScanning')))
    h.add(
        _.Nearest('NEAREST', _.Get('polar_stereographic'), _.Get('values'),
                  _.Get('radius'), _.Get('Nx'), _.Get('Ny')))
    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Unsigned('Nux', 4))
    h.alias('numberOfUsefulPointsAlongXAxis', 'Nux')
    h.add(_.Unsigned('Ncx', 4))
    h.alias('numberOfPointsAlongXAxisInCouplingArea', 'Ncx')
    h.add(_.Unsigned('Nuy', 4))
    h.alias('numberOfUsefulPointsAlongYAxis', 'Nuy')
    h.add(_.Unsigned('Ncy', 4))
    h.alias('numberOfPointsAlongYAxisInCouplingArea', 'Ncy')
예제 #7
0
def load(h):

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

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

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

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

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

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

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

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

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

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

    h.add(_.Unsigned('numberOfPointsAlongXAxis', 4))
    h.alias('Nx', 'numberOfPointsAlongXAxis')
    h.alias('Ni', 'Nx')
    h.add(_.Unsigned('numberOfPointsAlongYAxis', 4))
    h.alias('Ny', 'numberOfPointsAlongYAxis')
    h.alias('Nj', 'Ny')
    h.add(_.Signed('latitudeOfFirstGridPoint', 4))
    h.alias('La1', 'latitudeOfFirstGridPoint')
    h.add(_.Scale('latitudeOfFirstGridPointInDegrees', _.Get('latitudeOfFirstGridPoint'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfFirstGridPointInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.add(_.Signed('longitudeOfFirstGridPoint', 4))
    h.alias('La1', 'longitudeOfFirstGridPoint')
    h.add(_.Scale('longitudeOfFirstGridPointInDegrees', _.Get('longitudeOfFirstGridPoint'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.add(_.Signed('standardParallelInMicrodegrees', 4))
    h.alias('standardParallel', 'standardParallelInMicrodegrees')
    h.add(_.Scale('standardParallelInDegrees', _.Get('standardParallelInMicrodegrees'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.standardParallelInDegrees', 'standardParallelInDegrees')
    h.add(_.Signed('centralLongitudeInMicrodegrees', 4))
    h.alias('centralLongitude', 'centralLongitudeInMicrodegrees')
    h.add(_.Scale('centralLongitudeInDegrees', _.Get('centralLongitudeInMicrodegrees'), _.Get('one'), _.Get('grib2divider'), _.Get('truncateDegrees')))
    h.alias('geography.centralLongitudeInDegrees', 'centralLongitudeInDegrees')
    h.add(_.Codeflag('resolutionAndComponentFlags', 1, "grib2/tables/[tablesVersion]/3.3.table"))
    h.add(_.Unsigned('xDirectionGridLengthInMillimetres', 4))
    h.alias('Dx', 'xDirectionGridLengthInMillimetres')
    h.add(_.Scale('xDirectionGridLengthInMetres', _.Get('xDirectionGridLengthInMillimetres'), _.Get('one'), _.Get('thousand'), _.Get('truncateDegrees')))
    h.alias('geography.xDirectionGridLengthInMetres', 'xDirectionGridLengthInMetres')
    h.add(_.Unsigned('yDirectionGridLengthInMillimetres', 4))
    h.alias('Dy', 'yDirectionGridLengthInMillimetres')
    h.add(_.Scale('yDirectionGridLengthInMetres', _.Get('yDirectionGridLengthInMillimetres'), _.Get('one'), _.Get('thousand'), _.Get('truncateDegrees')))
    h.alias('geography.yDirectionGridLengthInMetres', 'yDirectionGridLengthInMetres')
    h.add(_.Codeflag('scanningMode', 1, "grib2/tables/[tablesVersion]/3.4.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Bit('alternativeRowScanning', _.Get('scanningMode'), 4))

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

    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(_.Change_scanning_direction('swapScanningX', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('xFirst'), _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(_.Change_scanning_direction('swapScanningY', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('yFirst'), _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')
    h.add(_.Iterator('ITERATOR', _.Get('lambert_azimuthal_equal_area'), _.Get('numberOfPoints'), _.Get('missingValue'), _.Get('values'), _.Get('radius'), _.Get('Nx'), _.Get('Ny'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('standardParallel'), _.Get('centralLongitude'), _.Get('Dx'), _.Get('Dy'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('jPointsAreConsecutive'), _.Get('alternativeRowScanning')))
    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))
예제 #8
0
def load(h):

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

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

    h.add(_.Bit('resolutionAndComponentFlags3', _.Get('resolutionAndComponentFlags'), 5))
    h.add(_.Bit('resolutionAndComponentFlags4', _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(_.Bit('resolutionAndComponentFlags6', _.Get('resolutionAndComponentFlags'), 2))
    h.add(_.Bit('resolutionAndComponentFlags7', _.Get('resolutionAndComponentFlags'), 1))
    h.add(_.Bit('resolutionAndComponentFlags8', _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('latitudeOfLastGridPoint', 3))
    h.add(_.Scale('latitudeOfLastGridPointInDegrees', _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 3))
    h.add(_.Scale('longitudeOfLastGridPointInDegrees', _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Unsigned('iDirectionIncrement', 2))
    h.add(_.Scale('iDirectionIncrementInDegrees', _.Get('iDirectionIncrement'), _.Get('oneConstant'), _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.iDirectionIncrementInDegrees', 'iDirectionIncrementInDegrees')
    h.alias('Di', 'iDirectionIncrement')
    h.add(_.Unsigned('N', 2))
    h.alias('numberOfParallelsBetweenAPoleAndTheEquator', 'N')
    h.alias('geography.N', 'N')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(_.Change_scanning_direction('swapScanningX', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('xFirst'), _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(_.Change_scanning_direction('swapScanningY', _.Get('values'), _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'), _.Get('jScansPositively'), _.Get('yFirst'), _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')

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

    h.add(_.Pad('padding_grid4_1', 4))
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('DiInDegrees', 'iDirectionIncrementInDegrees')
    h.add(_.Global_gaussian('global', _.Get('N'), _.Get('Ni'), _.Get('iDirectionIncrement'), _.Get('latitudeOfFirstGridPoint'), _.Get('longitudeOfFirstGridPoint'), _.Get('latitudeOfLastGridPoint'), _.Get('longitudeOfLastGridPoint'), _.Get('PLPresent'), _.Get('pl')))
    h.add(_.Number_of_points_gaussian('numberOfDataPoints', _.Get('Ni'), _.Get('Nj'), _.Get('PLPresent'), _.Get('pl'), _.Get('N'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('one')))
    h.add(_.Number_of_points_gaussian('numberOfDataPointsExpected', _.Get('Ni'), _.Get('Nj'), _.Get('PLPresent'), _.Get('pl'), _.Get('N'), _.Get('latitudeOfFirstGridPointInDegrees'), _.Get('longitudeOfFirstGridPointInDegrees'), _.Get('latitudeOfLastGridPointInDegrees'), _.Get('longitudeOfLastGridPointInDegrees'), _.Get('zero')))
    h.add(_.Evaluate('legacyGaussSubarea', (_.Get('numberOfDataPoints') != _.Get('numberOfDataPointsExpected'))))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(_.Number_of_values('numberOfValues', _.Get('values'), _.Get('bitsPerValue'), _.Get('numberOfDataPoints'), _.Get('bitmapPresent'), _.Get('bitmap'), _.Get('numberOfCodedValues')))

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

    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))
    h.add(_.Octahedral_gaussian('isOctahedral', _.Get('N'), _.Get('Ni'), _.Get('PLPresent'), _.Get('pl')))
    h.add(_.Gaussian_grid_name('gaussianGridName', _.Get('N'), _.Get('Ni'), _.Get('isOctahedral')))
    h.alias('gridName', 'gaussianGridName')
예제 #9
0
def load(h):

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

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

    h.add(
        _.Bit('resolutionAndComponentFlags3',
              _.Get('resolutionAndComponentFlags'), 5))
    h.add(
        _.Bit('resolutionAndComponentFlags4',
              _.Get('resolutionAndComponentFlags'), 4))
    h.add(_.Bit('uvRelativeToGrid', _.Get('resolutionAndComponentFlags'), 3))
    h.add(
        _.Bit('resolutionAndComponentFlags6',
              _.Get('resolutionAndComponentFlags'), 2))
    h.add(
        _.Bit('resolutionAndComponentFlags7',
              _.Get('resolutionAndComponentFlags'), 1))
    h.add(
        _.Bit('resolutionAndComponentFlags8',
              _.Get('resolutionAndComponentFlags'), 0))
    h.add(_.Signed('latitudeOfLastGridPoint', 3))
    h.add(
        _.Scale('latitudeOfLastGridPointInDegrees',
                _.Get('latitudeOfLastGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.latitudeOfLastGridPointInDegrees',
            'latitudeOfLastGridPointInDegrees')
    h.alias('La2', 'latitudeOfLastGridPoint')
    h.add(_.Signed('longitudeOfLastGridPoint', 3))
    h.add(
        _.Scale('longitudeOfLastGridPointInDegrees',
                _.Get('longitudeOfLastGridPoint'), _.Get('oneConstant'),
                _.Get('grib1divider'), _.Get('truncateDegrees')))
    h.alias('geography.longitudeOfLastGridPointInDegrees',
            'longitudeOfLastGridPointInDegrees')
    h.alias('Lo2', 'longitudeOfLastGridPoint')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Unsigned('iDirectionIncrement', 2))
    h.add(_.Unsigned('jDirectionIncrement', 2))
    h.alias('Dj', 'jDirectionIncrement')
    h.alias('Di', 'iDirectionIncrement')
    h.alias('yFirst', 'latitudeOfFirstGridPointInDegrees')
    h.alias('yLast', 'latitudeOfLastGridPointInDegrees')
    h.alias('xFirst', 'longitudeOfFirstGridPointInDegrees')
    h.alias('xLast', 'longitudeOfLastGridPointInDegrees')
    h.add(_.Codeflag('scanningMode', 1, "grib1/8.table"))
    h.add(_.Bit('iScansNegatively', _.Get('scanningMode'), 7))
    h.add(_.Bit('jScansPositively', _.Get('scanningMode'), 6))
    h.add(_.Bit('jPointsAreConsecutive', _.Get('scanningMode'), 5))
    h.add(_.Constant('alternativeRowScanning', 0))
    h.add(_.Transient('iScansPositively', _.Not(_.Get('iScansNegatively'))))
    h.alias('geography.iScansNegatively', 'iScansNegatively')
    h.alias('geography.jScansPositively', 'jScansPositively')
    h.alias('geography.jPointsAreConsecutive', 'jPointsAreConsecutive')
    h.add(_.Bit('scanningMode4', _.Get('scanningMode'), 4))
    h.add(_.Bit('scanningMode5', _.Get('scanningMode'), 3))
    h.add(_.Bit('scanningMode6', _.Get('scanningMode'), 2))
    h.add(_.Bit('scanningMode7', _.Get('scanningMode'), 1))
    h.add(_.Bit('scanningMode8', _.Get('scanningMode'), 0))
    h.add(
        _.Change_scanning_direction('swapScanningX', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('xFirst'),
                                    _.Get('xLast'), _.Get('x')))
    h.alias('swapScanningLon', 'swapScanningX')
    h.add(
        _.Change_scanning_direction('swapScanningY', _.Get('values'),
                                    _.Get('Ni'), _.Get('Nj'),
                                    _.Get('iScansNegatively'),
                                    _.Get('jScansPositively'), _.Get('yFirst'),
                                    _.Get('yLast'), _.Get('y')))
    h.alias('swapScanningLat', 'swapScanningY')

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

    h.add(_.Signed('Lar1', 3))
    h.add(
        _.Scale('Lar1InDegrees',
                _.Get('latitudeOfFirstGridPointOfReferenceDomain'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.Lar1InDegrees', 'Lar1InDegrees')
    h.alias('La1', 'Lar1')
    h.add(_.Signed('Lor1', 3))
    h.add(
        _.Scale('Lor1InDegrees',
                _.Get('longitudeOfFirstGridPointOfReferenceDomain'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.Lor1InDegrees', 'Lor1InDegrees')
    h.alias('Lo1', 'Lor1')
    h.add(_.Signed('Lar2', 3))
    h.add(
        _.Scale('Lar2InDegrees',
                _.Get('latitudeOfLastGridPointOfReferenceDomain'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.Lar2InDegrees', 'Lar2InDegrees')
    h.alias('La2', 'Lar2')
    h.add(_.Signed('Lor2', 3))
    h.add(
        _.Scale('Lor2InDegrees',
                _.Get('longitudeOfLastGridPointOfReferenceDomain'),
                _.Get('oneConstant'), _.Get('grib1divider'),
                _.Get('truncateDegrees')))
    h.alias('geography.Lor2InDegrees', 'Lor2InDegrees')
    h.alias('Lo2', 'Lor2')
    h.add(
        _.Latlon_increment('jDirectionIncrementInDegrees',
                           _.Get('ijDirectionIncrementGiven'),
                           _.Get('jDirectionIncrement'),
                           _.Get('jScansPositively'),
                           _.Get('latitudeOfFirstGridPointInDegrees'),
                           _.Get('latitudeOfLastGridPointInDegrees'),
                           _.Get('numberOfPointsAlongAMeridian'),
                           _.Get('oneConstant'), _.Get('grib1divider'), 0))
    h.alias('geography.jDirectionIncrementInDegrees',
            'jDirectionIncrementInDegrees')
    h.add(
        _.Latlon_increment('iDirectionIncrementInDegrees',
                           _.Get('ijDirectionIncrementGiven'),
                           _.Get('iDirectionIncrement'),
                           _.Get('iScansPositively'),
                           _.Get('longitudeOfFirstGridPointInDegrees'),
                           _.Get('longitudeOfLastGridPointInDegrees'),
                           _.Get('Ni'), _.Get('oneConstant'),
                           _.Get('grib1divider'), 1))
    h.alias('geography.iDirectionIncrementInDegrees',
            'iDirectionIncrementInDegrees')
    h.alias('latitudeFirstInDegrees', 'latitudeOfFirstGridPointInDegrees')
    h.alias('longitudeFirstInDegrees', 'longitudeOfFirstGridPointInDegrees')
    h.alias('latitudeLastInDegrees', 'latitudeOfLastGridPointInDegrees')
    h.alias('longitudeLastInDegrees', 'longitudeOfLastGridPointInDegrees')
    h.alias('DiInDegrees', 'iDirectionIncrementInDegrees')
    h.alias('DjInDegrees', 'jDirectionIncrementInDegrees')
    h.add(
        _.Number_of_points('numberOfDataPoints', _.Get('Ni'), _.Get('Nj'),
                           _.Get('PLPresent'), _.Get('pl')))
    h.alias('numberOfPoints', 'numberOfDataPoints')
    h.add(
        _.Number_of_values('numberOfValues', _.Get('values'),
                           _.Get('bitsPerValue'), _.Get('numberOfDataPoints'),
                           _.Get('bitmapPresent'), _.Get('bitmap'),
                           _.Get('numberOfCodedValues')))

    if h._missing('Ni'):
        h.add(
            _.Iterator('ITERATOR', _.Get('latlon_reduced'),
                       _.Get('numberOfPoints'), _.Get('missingValue'),
                       _.Get('values'), _.Get('latitudeFirstInDegrees'),
                       _.Get('longitudeFirstInDegrees'),
                       _.Get('latitudeLastInDegrees'), _.Get('loLast'),
                       _.Get('Nj'), _.Get('DjInDegrees'), _.Get('pl')))
        h.add(
            _.Nearest('NEAREST', _.Get('latlon_reduced'), _.Get('values'),
                      _.Get('radius'), _.Get('Nj'), _.Get('pl')))
    else:
        h.add(_.Transient('iteratorDisableUnrotate', 0))
        h.add(
            _.Iterator('ITERATOR', _.Get('latlon'), _.Get('numberOfPoints'),
                       _.Get('missingValue'), _.Get('values'),
                       _.Get('longitudeFirstInDegrees'), _.Get('iInc'),
                       _.Get('Ni'), _.Get('Nj'), _.Get('iScansNegatively'),
                       _.Get('latitudeFirstInDegrees'), _.Get('DjInDegrees'),
                       _.Get('jScansPositively'),
                       _.Get('jPointsAreConsecutive'), _.Get('isRotatedGrid'),
                       _.Get('angleOfRotation'),
                       _.Get('latitudeOfSouthernPoleInDegrees'),
                       _.Get('longitudeOfSouthernPoleInDegrees')))
        h.add(
            _.Nearest('NEAREST', _.Get('regular'), _.Get('values'),
                      _.Get('radius'), _.Get('Ni'), _.Get('Nj')))

    h.add(_.Latlonvalues('latLonValues', _.Get('values')))
    h.alias('latitudeLongitudeValues', 'latLonValues')
    h.add(_.Latitudes('latitudes', _.Get('values'), 0))
    h.add(_.Longitudes('longitudes', _.Get('values'), 0))
    h.add(_.Latitudes('distinctLatitudes', _.Get('values'), 1))
    h.add(_.Longitudes('distinctLongitudes', _.Get('values'), 1))