예제 #1
0
def simple_component2_cf():
    properties = [property2_cf_standard_name(),
                  property_cf_units()]
    uri = '<http://www.metarelate.net/test/component/test_c002>'
    ctype = '<http://def.scitools.org.uk/cfdatamodel/Field>'
    return metarelate.Component(uri, com_type=ctype,
                                properties=properties)
예제 #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 component_view_graph(request, component_id):
    """"""
    component = metarelate.Component(None)
    component.shaid = component_id
    component.populate_from_uri(fuseki_process)
    response = HttpResponse(content_type="image/svg+xml")
    graph = component.dot()
    response.write(graph.create_svg())
    return response
예제 #4
0
def component(request, component_id):
    """"""
    component = metarelate.Component(None)
    component.shaid = component_id
    component.populate_from_uri(fuseki_process)
    shaid = component.shaid
    #form = forms.ComponentMetadata(initial=component.__dict__)
    con_dict = {'component': component, 'shaid': shaid}  #, 'form':form}
    context = RequestContext(request, con_dict)
    response = render_to_response('viewcomponent.html', context)
    return response
예제 #5
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)
예제 #6
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))
예제 #7
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)
예제 #8
0
 def test_comp_type(self):
     with self.assertRaises(TypeError):
         metarelate.Component('uri', components=['acomp'])
예제 #9
0
 def test_prop_type(self):
     with self.assertRaises(TypeError):
         metarelate.Component('uri', properties=['aprop'])
예제 #10
0
 def test_uri_only(self):
     comp = metarelate.Component('uri')
예제 #11
0
def simple_component_um():
    uri = '<http://www.metarelate.net/test/component/test_c002>'
    ctype='<http://reference.metoffice.gov.uk/um/f3/UMField>'
    return metarelate.Component(uri, com_type=ctype,
                                properties=[property_um_stash()])