Skip to content

Commit c80adea

Browse files
committed
this, nc vocab
1 parent 48d1b71 commit c80adea

9 files changed

+235
-224
lines changed

lib/bald/__init__.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,21 @@ def __getitem__(self, item):
254254
if not self.is_http_uri(item):
255255
raise ValueError('{} is not a HTTP URI.'.format(item))
256256
if item not in self.cache:
257+
# null response, as a fall back
258+
self.cache[item] = requests.models.Response()
257259
# now = time.time()
258260
try:
259261
# print('trying: {}'.format(item))
260262

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

268273
# print('in {} seconds'.format(time.time() - then))
269274
return self.cache[item]
@@ -577,7 +582,7 @@ def rdfgraph(self):
577582
"""
578583
graph = rdflib.Graph()
579584
graph.bind('bald', 'http://binary-array-ld.net/latest/')
580-
graph.bind('ns1', self.baseuri + '/')
585+
graph.bind('this', self.baseuri + '/')
581586
for prefix_name in self.prefixes():
582587

583588
#strip the double underscore suffix

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ 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
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1314

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ 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
prefix_list:nc__ = "http://def.scitools.org.uk/NetCDF/" ;
1314

lib/bald/tests/integration/TTL/GEMS_CO2_Apr2006.ttl

+43-43
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
@prefix NetCDF: <http://def.scitools.org.uk/NetCDF/> .
33
@prefix bald: <http://binary-array-ld.net/latest/> .
44
@prefix cf_sname: <http://vocab.nerc.ac.uk/standard_name/> .
5-
@prefix ns1: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
65
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
76
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix this: <file://CDL/GEMS_CO2_Apr2006.cdl/> .
88
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
99
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1010

1111
<file://CDL/GEMS_CO2_Apr2006.cdl> a bald:Container ;
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 ;
2424
NetCDF:Conventions "CF-1.0" .
2525

26-
ns1:co2 a bald:Array ;
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)" ;
3232
CFTerms:missing_value "-32767" ;
3333
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/mass_fraction_of_carbon_dioxide_in_air/> ;
@@ -37,77 +37,77 @@ ns1:co2 a bald:Array ;
3737
NetCDF:scale_factor 0.000981685145029486 ;
3838
NetCDF:units "kg kg**-1" .
3939

40-
ns1:lnsp a bald:Array ;
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)" ;
4646
CFTerms:missing_value "-32767" ;
4747
NetCDF:FillValue "-32767" ;
4848
NetCDF:add_offset 11.2087164280841 ;
4949
NetCDF:long_name "Logarithm of surface pressure" ;
5050
NetCDF:scale_factor 1.03952457840347e-05 .
5151

52-
ns1:co2_latitude_ref a bald:Reference,
52+
this:co2_latitude_ref a bald:Reference,
5353
bald:Subject ;
54-
bald:array ns1:latitude ;
54+
bald:array this:latitude ;
5555
bald:childBroadcast "(1, 1, 181, 1)" .
5656

57-
ns1:co2_levelist_ref a bald:Reference,
57+
this:co2_levelist_ref a bald:Reference,
5858
bald:Subject ;
59-
bald:array ns1:levelist ;
59+
bald:array this:levelist ;
6060
bald:childBroadcast "(1, 60, 1, 1)" .
6161

62-
ns1:co2_time_ref a bald:Reference,
62+
this:co2_time_ref a bald:Reference,
6363
bald:Subject ;
64-
bald:array ns1:time ;
64+
bald:array this:time ;
6565
bald:childBroadcast "(1, 1, 1, 1)" .
6666

67-
ns1:lnsp_latitude_ref a bald:Reference,
67+
this:lnsp_latitude_ref a bald:Reference,
6868
bald:Subject ;
69-
bald:array ns1:latitude ;
69+
bald:array this:latitude ;
7070
bald:childBroadcast "(1, 1, 181, 1)" .
7171

72-
ns1:lnsp_levelist_ref a bald:Reference,
72+
this:lnsp_levelist_ref a bald:Reference,
7373
bald:Subject ;
74-
bald:array ns1:levelist ;
74+
bald:array this:levelist ;
7575
bald:childBroadcast "(1, 60, 1, 1)" .
7676

77-
ns1:lnsp_time_ref a bald:Reference,
77+
this:lnsp_time_ref a bald:Reference,
7878
bald:Subject ;
79-
bald:array ns1:time ;
79+
bald:array this:time ;
8080
bald:childBroadcast "(1, 1, 1, 1)" .
8181

82-
ns1:latitude a bald:Array,
82+
this:latitude a bald:Array,
8383
bald:Reference ;
84-
bald:array ns1:latitude ;
84+
bald:array this:latitude ;
8585
bald:first_value 90.0 ;
8686
bald:last_value -90.0 ;
8787
bald:shape "(181,)" ;
8888
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/latitude/> ;
8989
NetCDF:units "degrees_north" .
9090

91-
ns1:levelist a bald:Array,
91+
this:levelist a bald:Array,
9292
bald:Reference ;
93-
bald:array ns1:levelist ;
93+
bald:array this:levelist ;
9494
bald:first_value 1 ;
9595
bald:last_value 60 ;
9696
bald:shape "(60,)" ;
9797
NetCDF:long_name "model_level_number" .
9898

99-
ns1:longitude a bald:Array,
99+
this:longitude a bald:Array,
100100
bald:Reference ;
101-
bald:array ns1:longitude ;
101+
bald:array this:longitude ;
102102
bald:first_value 0.0 ;
103103
bald:last_value 359.0 ;
104104
bald:shape "(360,)" ;
105105
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/longitude/> ;
106106
NetCDF:units "degrees_east" .
107107

108-
ns1:time a bald:Array,
108+
this:time a bald:Array,
109109
bald:Reference ;
110-
bald:array ns1:time ;
110+
bald:array this:time ;
111111
bald:first_value "2006-04-01T00:00:00"^^xsd:dateTime ;
112112
bald:shape "(1,)" ;
113113
CFTerms:standard_name <http://vocab.nerc.ac.uk/standard_name/time/> ;

lib/bald/tests/integration/TTL/array_reference.ttl

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
@prefix ns1: <file://CDL/array_reference.cdl/> .
33
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
44
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix this: <file://CDL/array_reference.cdl/> .
56
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
67
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
78

89
<file://CDL/array_reference.cdl> a bald:Container ;
9-
bald:contains ns1:child_variable,
10-
ns1:parent_variable ;
10+
bald:contains this:child_variable,
11+
this:parent_variable ;
1112
bald:isPrefixedBy "prefix_list" .
1213

13-
ns1:parent_variable a bald:Array ;
14-
bald:references ns1:child_variable ;
14+
this:parent_variable a bald:Array ;
15+
bald:references this:child_variable ;
1516
bald:shape "(11, 17)" .
1617

17-
ns1:child_variable a bald:Array,
18+
this:child_variable a bald:Array,
1819
bald:Reference ;
19-
bald:array ns1:child_variable ;
20+
bald:array this:child_variable ;
2021
bald:shape "(11, 17)" .
2122

lib/bald/tests/integration/TTL/array_reference_withbase.ttl

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
@prefix ns1: <http://example.org/base/> .
33
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
44
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix this: <http://example.org/base/> .
56
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
67
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
78

89
<http://example.org/base> a bald:Container ;
9-
bald:contains ns1:child_variable,
10-
ns1:parent_variable ;
10+
bald:contains this:child_variable,
11+
this:parent_variable ;
1112
bald:isPrefixedBy "prefix_list" .
1213

13-
ns1:parent_variable a bald:Array ;
14-
bald:references ns1:child_variable ;
14+
this:parent_variable a bald:Array ;
15+
bald:references this:child_variable ;
1516
bald:shape "(11, 17)" .
1617

17-
ns1:child_variable a bald:Array,
18+
this:child_variable a bald:Array,
1819
bald:Reference ;
19-
bald:array ns1:child_variable ;
20+
bald:array this:child_variable ;
2021
bald:shape "(11, 17)" .
2122

Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
11
@prefix bald: <http://binary-array-ld.net/latest/> .
22
@prefix metce: <http://codes.wmo.int/common/observation-type/METCE/2013/> .
3-
@prefix ns1: <file://CDL/multi_array_reference.cdl/> .
43
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
54
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix this: <file://CDL/multi_array_reference.cdl/> .
66
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
77
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
88

99
<file://CDL/multi_array_reference.cdl> a bald:Container ;
10-
bald:contains ns1:data_variable1,
11-
ns1:data_variable1_pdim0_ref,
12-
ns1:data_variable2,
13-
ns1:data_variable2_pdim0_ref,
14-
ns1:list_collection,
15-
ns1:location_reference_system,
16-
ns1:location_variable,
17-
ns1:pdim0,
18-
ns1:pdim1,
19-
ns1:set_collection ;
10+
bald:contains this:data_variable1,
11+
this:data_variable1_pdim0_ref,
12+
this:data_variable2,
13+
this:data_variable2_pdim0_ref,
14+
this:list_collection,
15+
this:location_reference_system,
16+
this:location_variable,
17+
this:pdim0,
18+
this:pdim1,
19+
this:set_collection ;
2020
bald:isPrefixedBy "prefix_list" .
2121

22-
ns1:data_variable1 a bald:Array ;
23-
ns1:long_name "Gerald" ;
24-
ns1:obtype metce:SamplingObservation ;
25-
bald:references ns1:data_variable1_pdim0_ref,
26-
ns1:location_variable,
27-
ns1:pdim1 ;
22+
this:data_variable1 a bald:Array ;
23+
this:long_name "Gerald" ;
24+
this:obtype metce:SamplingObservation ;
25+
bald:references this:data_variable1_pdim0_ref,
26+
this:location_variable,
27+
this:pdim1 ;
2828
bald:shape "(11, 17)" .
2929

30-
ns1:data_variable2 a bald:Array ;
31-
ns1:long_name "Imelda" ;
32-
ns1:obtype metce:SamplingObservation ;
33-
bald:references ns1:data_variable2_pdim0_ref,
34-
ns1:location_variable,
35-
ns1:pdim1 ;
30+
this:data_variable2 a bald:Array ;
31+
this:long_name "Imelda" ;
32+
this:obtype metce:SamplingObservation ;
33+
bald:references this:data_variable2_pdim0_ref,
34+
this:location_variable,
35+
this:pdim1 ;
3636
bald:shape "(11, 17)" .
3737

38-
ns1:list_collection a bald:Subject ;
39-
bald:references ( ns1:data_variable1_pdim0_ref ns1:data_variable2_pdim0_ref ) .
38+
this:list_collection a bald:Subject ;
39+
bald:references this:data_variable1_pdim0_ref,
40+
this:data_variable2_pdim0_ref .
4041

41-
ns1:set_collection a bald:Subject ;
42-
bald:references ns1:data_variable1_pdim0_ref,
43-
ns1:data_variable2_pdim0_ref .
42+
this:set_collection a bald:Subject ;
43+
bald:references this:data_variable1_pdim0_ref,
44+
this:data_variable2_pdim0_ref .
4445

45-
ns1:location_reference_system a bald:Subject ;
46-
ns1:pcode "4897" ;
47-
bald:array ns1:location_reference_system .
46+
this:location_reference_system a bald:Subject ;
47+
this:pcode "4897" ;
48+
bald:array this:location_reference_system .
4849

49-
ns1:data_variable1_pdim0_ref a bald:Reference,
50+
this:data_variable1_pdim0_ref a bald:Reference,
5051
bald:Subject ;
51-
bald:array ns1:pdim0 ;
52+
bald:array this:pdim0 ;
5253
bald:childBroadcast "(11, 1)" .
5354

54-
ns1:data_variable2_pdim0_ref a bald:Reference,
55+
this:data_variable2_pdim0_ref a bald:Reference,
5556
bald:Subject ;
56-
bald:array ns1:pdim0 ;
57+
bald:array this:pdim0 ;
5758
bald:childBroadcast "(11, 1)" .
5859

59-
ns1:location_variable a bald:Array,
60+
this:location_variable a bald:Array,
6061
bald:Reference ;
61-
bald:array ns1:location_variable ;
62-
bald:references ns1:location_reference_system ;
62+
bald:array this:location_variable ;
63+
bald:references this:location_reference_system ;
6364
bald:shape "(11, 17)" .
6465

65-
ns1:pdim0 a bald:Array,
66+
this:pdim0 a bald:Array,
6667
bald:Reference ;
67-
bald:array ns1:pdim0 ;
68+
bald:array this:pdim0 ;
6869
bald:shape "(11,)" .
6970

70-
ns1:pdim1 a bald:Array,
71+
this:pdim1 a bald:Array,
7172
bald:Reference ;
72-
bald:array ns1:pdim1 ;
73+
bald:array this:pdim1 ;
7374
bald:shape "(17,)" .
7475

0 commit comments

Comments
 (0)