Skip to content

Commit 4f67f04

Browse files
committed
this, nc vocab
1 parent 5374cc0 commit 4f67f04

File tree

10 files changed

+307
-292
lines changed

10 files changed

+307
-292
lines changed

lib/bald/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,21 @@ def __getitem__(self, item):
253253
if not self.is_http_uri(item):
254254
raise ValueError('{} is not a HTTP URI.'.format(item))
255255
if item not in self.cache:
256+
# null response, as a fall back
257+
self.cache[item] = requests.models.Response()
256258
# now = time.time()
257259
try:
258260
# print('trying: {}'.format(item))
259261

260262
headers = {'Accept': 'application/rdf+xml'}
261263
self.cache[item] = requests.get(item, headers=headers, timeout=7)
262264
except Exception:
263-
# print('retrying: {}'.format(item))
264-
headers = {'Accept': 'text/html'}
265-
self.cache[item] = requests.get(item, headers=headers, timeout=7)
265+
try:
266+
# print('retrying: {}'.format(item))
267+
headers = {'Accept': 'text/html'}
268+
self.cache[item] = requests.get(item, headers=headers, timeout=7)
269+
except Exception:
270+
pass
266271

267272
# print('in {} seconds'.format(time.time() - then))
268273
return self.cache[item]
@@ -566,6 +571,7 @@ def rdfgraph(self):
566571
"""
567572
graph = rdflib.Graph()
568573
graph.bind('bald', 'http://binary-array-ld.net/latest/')
574+
graph.bind('this', self.baseuri + '/')
569575
for prefix_name in self.prefixes():
570576

571577
#strip the double underscore suffix

lib/bald/tests/integration/CDL/array_geo.cdl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ variables:
88
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
99
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
1010
prefix_list:cf__ = "http://def.scitools.org.uk/CFTerms/" ;
11+
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1112
prefix_list:geo__ = "http://www.opengis.net/ont/geosparql#" ;
1213

1314
int temp(pdim0, pdim1) ;
1415
temp:cf__standard_name = "air_temperature" ;
15-
temp:cf__long_name = "Air temperature obs example at point" ;
16+
temp:nc__long_name = "Air temperature obs example at point" ;
1617
temp:rdfs__label = "Air temperature obs example at point" ;
1718
temp:geo__asWKT = "POINT(-77.03524 38.889468)" ;
1819

1920
int pressure(pdim0, pdim1) ;
2021
pressure:cf__standard_name = "air_pressure" ;
21-
pressure:cf__long_name = "Air pressure at UCAR Centre Green" ;
22+
pressure:nc__long_name = "Air pressure at UCAR Centre Green" ;
2223
pressure:rdfs__label = "Air pressure at UCAR Centre Green" ;
2324
pressure:geo__asWKT = "POINT(-105.24584700000003 40.0315278)" ;
2425

lib/bald/tests/integration/CDL/array_multitypes.cdl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ variables:
88
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
99
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
1010
prefix_list:cf__ = "http://def.scitools.org.uk/CFTerms/" ;
11+
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1112
prefix_list:geo__ = "http://www.opengis.net/ont/geosparql#" ;
1213

1314
int temp(pdim0, pdim1) ;
1415
temp:cf__standard_name = "air_temperature" ;
15-
temp:cf__long_name = "Air temperature obs example at point" ;
16+
temp:nc__long_name = "Air temperature obs example at point" ;
1617
temp:rdfs__label = "Air temperature obs example at point" ;
1718
temp:geo__asWKT = "POINT(-77.03524 38.889468)" ;
1819

1920
int pressure(pdim0, pdim1) ;
2021
:rdf__type = "geo__Geometry" ;
2122
pressure:cf__standard_name = "air_pressure" ;
22-
pressure:cf__long_name = "Air pressure at UCAR Centre Green" ;
23+
pressure:nc__long_name = "Air pressure at UCAR Centre Green" ;
2324
pressure:rdfs__label = "Air pressure at UCAR Centre Green" ;
2425
pressure:geo__asWKT = "POINT(-105.24584700000003 40.0315278)" ;
2526

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,115 @@
11
@prefix CFTerms: <http://def.scitools.org.uk/CFTerms/> .
2+
@prefix NetCDF: <http://def.scitools.org.uk/NetCDF/> .
23
@prefix bald: <http://binary-array-ld.net/latest/> .
34
@prefix cf_sname: <http://vocab.nerc.ac.uk/standard_name/> .
4-
@prefix ns1: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
55
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
66
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix this: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
78
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
89
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
910

1011
<file://CDL/GEMS_CO2_Apr2006.cdl> a bald:Container ;
11-
ns1:Conventions "CF-1.0" ;
12-
bald:contains ns1:co2,
13-
ns1:co2_latitude_ref,
14-
ns1:co2_levelist_ref,
15-
ns1:co2_time_ref,
16-
ns1:latitude,
17-
ns1:levelist,
18-
ns1:lnsp,
19-
ns1:lnsp_latitude_ref,
20-
ns1:lnsp_levelist_ref,
21-
ns1:lnsp_time_ref,
22-
ns1:longitude,
23-
ns1:time .
12+
bald:contains this:co2,
13+
this:co2_latitude_ref,
14+
this:co2_levelist_ref,
15+
this:co2_time_ref,
16+
this:latitude,
17+
this:levelist,
18+
this:lnsp,
19+
this:lnsp_latitude_ref,
20+
this:lnsp_levelist_ref,
21+
this:lnsp_time_ref,
22+
this:longitude,
23+
this:time ;
24+
NetCDF:Conventions "CF-1.0" .
2425

25-
ns1:co2 a bald:Array ;
26-
ns1:_FillValue "-32767" ;
27-
bald:references ns1:co2_latitude_ref,
28-
ns1:co2_levelist_ref,
29-
ns1:co2_time_ref,
30-
ns1:longitude ;
26+
this:co2 a bald:Array ;
27+
bald:references this:co2_latitude_ref,
28+
this:co2_levelist_ref,
29+
this:co2_time_ref,
30+
this:longitude ;
3131
bald:shape "(1, 60, 181, 360)" ;
32-
CFTerms:add_offset 403.192219379918 ;
33-
CFTerms:long_name "Carbon Dioxide" ;
3432
CFTerms:missing_value "-32767" ;
35-
CFTerms:scale_factor 0.000981685145029486 ;
3633
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/mass_fraction_of_carbon_dioxide_in_air/> ;
37-
CFTerms:units "kg kg**-1" .
34+
NetCDF:FillValue "-32767" ;
35+
NetCDF:add_offset 403.192219379918 ;
36+
NetCDF:long_name "Carbon Dioxide" ;
37+
NetCDF:scale_factor 0.000981685145029486 ;
38+
NetCDF:units "kg kg**-1" .
3839

39-
ns1:lnsp a bald:Array ;
40-
ns1:_FillValue "-32767" ;
41-
bald:references ns1:lnsp_latitude_ref,
42-
ns1:lnsp_levelist_ref,
43-
ns1:lnsp_time_ref,
44-
ns1:longitude ;
40+
this:lnsp a bald:Array ;
41+
bald:references this:lnsp_latitude_ref,
42+
this:lnsp_levelist_ref,
43+
this:lnsp_time_ref,
44+
this:longitude ;
4545
bald:shape "(1, 60, 181, 360)" ;
46-
CFTerms:add_offset 11.2087164280841 ;
47-
CFTerms:long_name "Logarithm of surface pressure" ;
4846
CFTerms:missing_value "-32767" ;
49-
CFTerms:scale_factor 1.03952457840347e-05 .
47+
NetCDF:FillValue "-32767" ;
48+
NetCDF:add_offset 11.2087164280841 ;
49+
NetCDF:long_name "Logarithm of surface pressure" ;
50+
NetCDF:scale_factor 1.03952457840347e-05 .
5051

51-
ns1:co2_latitude_ref a bald:Reference,
52+
this:co2_latitude_ref a bald:Reference,
5253
bald:Subject ;
53-
bald:array ns1:latitude ;
54+
bald:array this:latitude ;
5455
bald:childBroadcast "(1, 1, 181, 1)" .
5556

56-
ns1:co2_levelist_ref a bald:Reference,
57+
this:co2_levelist_ref a bald:Reference,
5758
bald:Subject ;
58-
bald:array ns1:levelist ;
59+
bald:array this:levelist ;
5960
bald:childBroadcast "(1, 60, 1, 1)" .
6061

61-
ns1:co2_time_ref a bald:Reference,
62+
this:co2_time_ref a bald:Reference,
6263
bald:Subject ;
63-
bald:array ns1:time ;
64+
bald:array this:time ;
6465
bald:childBroadcast "(1, 1, 1, 1)" .
6566

66-
ns1:lnsp_latitude_ref a bald:Reference,
67+
this:lnsp_latitude_ref a bald:Reference,
6768
bald:Subject ;
68-
bald:array ns1:latitude ;
69+
bald:array this:latitude ;
6970
bald:childBroadcast "(1, 1, 181, 1)" .
7071

71-
ns1:lnsp_levelist_ref a bald:Reference,
72+
this:lnsp_levelist_ref a bald:Reference,
7273
bald:Subject ;
73-
bald:array ns1:levelist ;
74+
bald:array this:levelist ;
7475
bald:childBroadcast "(1, 60, 1, 1)" .
7576

76-
ns1:lnsp_time_ref a bald:Reference,
77+
this:lnsp_time_ref a bald:Reference,
7778
bald:Subject ;
78-
bald:array ns1:time ;
79+
bald:array this:time ;
7980
bald:childBroadcast "(1, 1, 1, 1)" .
8081

81-
ns1:latitude a bald:Array,
82+
this:latitude a bald:Array,
8283
bald:Reference ;
83-
bald:array ns1:latitude ;
84+
bald:array this:latitude ;
8485
bald:first_value 90.0 ;
8586
bald:last_value -90.0 ;
8687
bald:shape "(181,)" ;
8788
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/latitude/> ;
88-
CFTerms:units "degrees_north" .
89+
NetCDF:units "degrees_north" .
8990

90-
ns1:levelist a bald:Array,
91+
this:levelist a bald:Array,
9192
bald:Reference ;
92-
bald:array ns1:levelist ;
93+
bald:array this:levelist ;
9394
bald:first_value 1 ;
9495
bald:last_value 60 ;
9596
bald:shape "(60,)" ;
96-
CFTerms:long_name "model_level_number" .
97+
NetCDF:long_name "model_level_number" .
9798

98-
ns1:longitude a bald:Array,
99+
this:longitude a bald:Array,
99100
bald:Reference ;
100-
bald:array ns1:longitude ;
101+
bald:array this:longitude ;
101102
bald:first_value 0.0 ;
102103
bald:last_value 359.0 ;
103104
bald:shape "(360,)" ;
104105
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/longitude/> ;
105-
CFTerms:units "degrees_east" .
106+
NetCDF:units "degrees_east" .
106107

107-
ns1:time a bald:Array,
108+
this:time a bald:Array,
108109
bald:Reference ;
109-
bald:array ns1:time ;
110+
bald:array this:time ;
110111
bald:first_value "2006-04-01T00:00:00"^^xsd:dateTime ;
111112
bald:shape "(1,)" ;
112113
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/time/> ;
113-
CFTerms:units "hours since 1900-01-01 00:00:0.0" .
114+
NetCDF:units "hours since 1900-01-01 00:00:0.0" .
114115

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
@prefix bald: <http://binary-array-ld.net/latest/> .
22
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
33
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <file://CDL/array_reference.cdl/> .
45
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
56
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
67

78
<file://CDL/array_reference.cdl> a bald:Container ;
8-
bald:contains <file://CDL/array_reference.cdl/child_variable>,
9-
<file://CDL/array_reference.cdl/parent_variable> ;
9+
bald:contains this:child_variable,
10+
this:parent_variable ;
1011
bald:isPrefixedBy "prefix_list" .
1112

12-
<file://CDL/array_reference.cdl/parent_variable> a bald:Array ;
13-
bald:references <file://CDL/array_reference.cdl/child_variable> ;
13+
this:parent_variable a bald:Array ;
14+
bald:references this:child_variable ;
1415
bald:shape "(11, 17)" .
1516

16-
<file://CDL/array_reference.cdl/child_variable> a bald:Array,
17+
this:child_variable a bald:Array,
1718
bald:Reference ;
18-
bald:array <file://CDL/array_reference.cdl/child_variable> ;
19+
bald:array this:child_variable ;
1920
bald:shape "(11, 17)" .
2021

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
@prefix bald: <http://binary-array-ld.net/latest/> .
22
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
33
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <http://example.org/base/> .
45
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
56
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
67

78
<http://example.org/base> a bald:Container ;
8-
bald:contains <http://example.org/base/child_variable>,
9-
<http://example.org/base/parent_variable> ;
9+
bald:contains this:child_variable,
10+
this:parent_variable ;
1011
bald:isPrefixedBy "prefix_list" .
1112

12-
<http://example.org/base/parent_variable> a bald:Array ;
13-
bald:references <http://example.org/base/child_variable> ;
13+
this:parent_variable a bald:Array ;
14+
bald:references this:child_variable ;
1415
bald:shape "(11, 17)" .
1516

16-
<http://example.org/base/child_variable> a bald:Array,
17+
this:child_variable a bald:Array,
1718
bald:Reference ;
18-
bald:array <http://example.org/base/child_variable> ;
19+
bald:array this:child_variable ;
1920
bald:shape "(11, 17)" .
2021

0 commit comments

Comments
 (0)