コード例 #1
0
ファイル: __init__.py プロジェクト: lauradomar/iris
 def is_cf_height_constrained(self, comp):
     item_sn = metarelate.Item(('<http://def.scitools.org.uk/cfdatamodel/'
                                'standard_name>'),
                               'standard_name')
     item_h = metarelate.Item(('<http://vocab.nerc.ac.uk/standard_name/'
                               'height>'),
                              'height')
     snprop = metarelate.StatementProperty(item_sn, item_h)
     item_u = metarelate.Item(('<http://def.scitools.org.uk/cfdatamodel/'
                               'units>'),
                              'units')
     uprop = metarelate.StatementProperty(item_u,
                                          metarelate.Item('"m"', 'm'))
     pts_pred = metarelate.Item(('<http://def.scitools.org.uk/cfdatamodel/'
                                 'points>'),
                                'points')
     result = False
     if self.is_cf_constrained(comp):
         props = comp.dim_coord.component.properties
         if len(props) == 3:
             if snprop in props and uprop in props:
                 preds = [prop.predicate for prop in props]
                 if pts_pred in preds:
                     result = True
     return result
コード例 #2
0
def cfname(name, units):
    """Create a new Component for the CF name and units."""

    # Fail if unit not udunits parseable
    # checkunit = Unit(units)
    standard_name = '{p}{c}'.format(p=pre['cfnames'], c=name)
    req = requests.get(standard_name)
    if req.status_code == 200:
        name = standard_name
        pred = '{}standard_name'.format(pre['cfmodel'])
    else:
        pred = '{}long_name'.format(pre['cfmodel'])
    cfun = '{}units'.format(pre['cfmodel'])
    if units == '1':
        units = u'1'
    acfuprop = metarelate.StatementProperty(metarelate.Item(cfun, 'units'),
                                            metarelate.Item(units, units))
    acfnprop = metarelate.StatementProperty(
        metarelate.Item(pred,
                        pred.split('/')[-1]),
        metarelate.Item(name,
                        name.split('/')[-1]))
    cff = '{}Field'.format(pre['cfmodel'])
    acfcomp = metarelate.Component(None, cff, [acfnprop, acfuprop])
    return acfcomp
コード例 #3
0
def property_cf_units():
    data = '<http://def.scitools.org.uk/cfdatamodel/units>'
    notation = 'units'
    name = metarelate.Item(data, notation)

    value = metarelate.Item('m s-1')

    return metarelate.StatementProperty(name, value)
コード例 #4
0
def property_um_stash():
    data = '<http://reference.metoffice.gov.uk/um/f3/stash>'
    notation = 'stash'
    name = metarelate.Item(data, notation)

    data = '<http://reference.metoffice.gov.uk/um/stash/m02s32i202>'
    notation = 'm02s32i202'
    value = metarelate.Item(data, notation)

    return metarelate.StatementProperty(name, value)
コード例 #5
0
def property2_cf_standard_name():
    data = '<http://def.scitools.org.uk/cfdatamodel/standard_name>'
    notation = 'standard_name'
    predicate = metarelate.Item(data, notation)

    data = '<http://vocab.nerc.ac.uk/standard_name/x_wind>'
    notation = 'x_wind'
    rdfobject = metarelate.Item(data, notation)

    return metarelate.StatementProperty(predicate, rdfobject)
コード例 #6
0
def property_cf_standard_name():
    data = '<http://def.scitools.org.uk/cfdatamodel/standard_name>'
    notation = 'standard_name'
    predicate = metarelate.Item(data, notation)

    data = '<http://vocab.nerc.ac.uk/standard_name/' \
        'tendency_of_sea_ice_thickness_due_to_dynamics>'
    notation = 'tendency_of_sea_ice_thickness_due_to_dynamics'
    rdfobject = metarelate.Item(data, notation)

    return metarelate.StatementProperty(predicate, rdfobject)
コード例 #7
0
def grib2_comp(arecord, errs):
    """Create a new Component from the provided GRIB2 parameter. """
    griburi = 'http://codes.wmo.int/grib2/codeflag/4.2/{d}-{c}-{i}'
    griburi = griburi.format(d=arecord.disc, c=arecord.pcat, i=arecord.pnum)
    req = requests.get(griburi)
    if req.status_code != 200:
        errs.append('unrecognised grib2 parameter code: {}'.format(griburi))
    gpd = 'http://codes.wmo.int/def/grib2/parameterId'
    agribprop = metarelate.StatementProperty(
        metarelate.Item(gpd, 'grib2_parameter'), metarelate.Item(griburi))
    gribmsg = 'http://codes.wmo.int/def/codeform/GRIB-message'
    agribcomp = metarelate.Component(None, gribmsg, [agribprop])
    return (agribcomp, errs)
コード例 #8
0
 def test_setattr(self):
     prop = stock.property_cf_units()
     ctype = '<http://def.scitools.org.uk/cfdatamodel/Field>'
     acomp = metarelate.Component(None, com_type=ctype, properties=[prop])
     data = '<http://def.scitools.org.uk/cfdatamodel/standard_name>'
     notation = 'standard_name'
     ptype = metarelate.Item(data, notation)
     data = '<http://vocab.nerc.ac.uk/standard_name/x_wind'
     notation = 'x_wind'
     value = metarelate.Item(data, notation)
     acomp.standard_name = metarelate.StatementProperty(ptype, value)
     self.assertTrue(
         isinstance(acomp.standard_name, metarelate.StatementProperty))
コード例 #9
0
def stash_comp(stashmsi, errs):
    """Create a new Component from the provided stash code. """
    stashuri = '{p}{c}'.format(p=pre['moStCon'], c=stashmsi)
    headers = {
        'content-type': 'application/ld+json',
        'Accept': 'application/ld+json'
    }
    req = requests.get(stashuri, headers=headers)
    if req.status_code != 200:
        errs.append('unrecognised stash code: {}'.format(stashuri))
    pred = metarelate.Item('{}stash'.format(pre['moumdpF3']), 'stash')
    robj = metarelate.Item(stashuri, stashmsi)
    astashprop = metarelate.StatementProperty(pred, robj)
    ppff = '{}UMField'.format(pre['moumdpF3'])
    astashcomp = metarelate.Component(None, ppff, [astashprop])
    return (astashcomp, errs)