Skip to content

Commit 2117765

Browse files
committed
conformA
1 parent e935ee1 commit 2117765

File tree

9 files changed

+202
-0
lines changed

9 files changed

+202
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
netcdf ogcClassA {
2+
dimensions:
3+
d0 = 1 ;
4+
d1 = 1 ;
5+
variables:
6+
int var0 ;
7+
int var1 ;
8+
9+
data:
10+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
netcdf ogcClassB {
2+
dimensions:
3+
d0 = 1 ;
4+
d1 = 1 ;
5+
variables:
6+
int var0 ;
7+
var0:rdfs__label = "rdfs__label" ;
8+
int var1 ;
9+
var1:rdfs__label = "rdfs__label" ;
10+
int prefix_list ;
11+
prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
12+
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
13+
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
14+
:bald__isPrefixedBy = "prefix_list" ;
15+
data:
16+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
netcdf ogcClassC {
2+
dimensions:
3+
d0 = 1 ;
4+
d1 = 1 ;
5+
variables:
6+
int var0 ;
7+
int var1 ;
8+
:title = "Sample netCDF file definition with alias terms from the netCDF user guide" ;
9+
data:
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
netcdf ogcClassD {
2+
dimensions:
3+
d0 = 1 ;
4+
d1 = 1 ;
5+
variables:
6+
int var0 ;
7+
var0:rdfs__label = "rdfs__label" ;
8+
int var1 ;
9+
var1:rdfs__label = "rdfs__label" ;
10+
int prefix_list ;
11+
prefix_list:bald__ = "http://binary-array-ld.net/latest/" ;
12+
prefix_list:rdf__ = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ;
13+
prefix_list:rdfs__ = "http://www.w3.org/2000/01/rdf-schema#" ;
14+
:bald__isPrefixedBy = "prefix_list" ;
15+
:title = "Sample netCDF file definition with alias terms from the netCDF user guide" ;
16+
data:
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@prefix bald: <http://binary-array-ld.net/latest/> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <http://secret.binary-array-ld.net/identity.nc/> .
5+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
6+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7+
8+
<http://secret.binary-array-ld.net/identity.nc> a bald:Container ;
9+
bald:contains this:var0,
10+
this:var1 .
11+
12+
this:var0 a bald:Subject .
13+
14+
this:var1 a bald:Subject .
15+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@prefix bald: <http://binary-array-ld.net/latest/> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix this: <http://secret.binary-array-ld.net/prefix.nc/> .
5+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
6+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7+
8+
<http://secret.binary-array-ld.net/prefix.nc> a bald:Container ;
9+
bald:contains this:var0,
10+
this:var1 ;
11+
bald:isPrefixedBy "prefix_list" .
12+
13+
this:var0 a bald:Subject ;
14+
rdfs:label rdfs:label .
15+
16+
this:var1 a bald:Subject ;
17+
rdfs:label rdfs:label .
18+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@prefix NetCDF: <http://def.scitools.org.uk/NetCDF/> .
2+
@prefix bald: <http://binary-array-ld.net/latest/> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix this: <http://secret.binary-array-ld.net/alias.nc/> .
6+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
9+
<http://secret.binary-array-ld.net/alias.nc> a bald:Container ;
10+
bald:contains this:var0,
11+
this:var1 ;
12+
NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" .
13+
14+
this:var0 a bald:Subject .
15+
16+
this:var1 a bald:Subject .
17+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@prefix NetCDF: <http://def.scitools.org.uk/NetCDF/> .
2+
@prefix bald: <http://binary-array-ld.net/latest/> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
@prefix this: <http://secret.binary-array-ld.net/attributes.nc/> .
6+
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
7+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
8+
9+
<http://secret.binary-array-ld.net/attributes.nc> a bald:Container ;
10+
bald:contains this:var0,
11+
this:var1 ;
12+
bald:isPrefixedBy "prefix_list" ;
13+
NetCDF:title "Sample netCDF file definition with alias terms from the netCDF user guide" .
14+
15+
this:var0 a bald:Subject ;
16+
rdfs:label rdfs:label .
17+
18+
this:var1 a bald:Subject ;
19+
rdfs:label rdfs:label .
20+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import os
2+
import subprocess
3+
import unittest
4+
5+
import netCDF4
6+
import numpy as np
7+
8+
import bald
9+
from bald.tests import BaldTestCase
10+
11+
class Test(BaldTestCase):
12+
def setUp(self):
13+
self.cdl_path = os.path.join(os.path.dirname(__file__), 'CDL')
14+
self.ttl_path = os.path.join(os.path.dirname(__file__), 'TTL')
15+
self.maxDiff = None
16+
17+
def test_conformance_a(self):
18+
with self.temp_filename('.nc') as tfile:
19+
cdlname = 'ogcClassA.cdl'
20+
cdl_file = os.path.join(self.cdl_path, cdlname)
21+
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
22+
cdl_file_uri = 'http://secret.binary-array-ld.net/identity.nc'
23+
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
24+
ttl = root_container.rdfgraph().serialize(format='n3').decode("utf-8")
25+
if os.environ.get('bald_update_results') is not None:
26+
with open(os.path.join(self.ttl_path, 'ogcClassA.ttl'), 'w') as sf:
27+
sf.write(ttl)
28+
with open(os.path.join(self.ttl_path, 'ogcClassA.ttl'), 'r') as sf:
29+
expected_ttl = sf.read()
30+
self.assertEqual(expected_ttl, ttl)
31+
32+
def test_conformance_b(self):
33+
with self.temp_filename('.nc') as tfile:
34+
cdlname = 'ogcClassB.cdl'
35+
cdl_file = os.path.join(self.cdl_path, cdlname)
36+
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
37+
cdl_file_uri = 'http://secret.binary-array-ld.net/prefix.nc'
38+
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri, cache=self.acache)
39+
ttl = root_container.rdfgraph().serialize(format='n3').decode("utf-8")
40+
if os.environ.get('bald_update_results') is not None:
41+
with open(os.path.join(self.ttl_path, 'ogcClassB.ttl'), 'w') as sf:
42+
sf.write(ttl)
43+
with open(os.path.join(self.ttl_path, 'ogcClassB.ttl'), 'r') as sf:
44+
expected_ttl = sf.read()
45+
self.assertEqual(expected_ttl, ttl)
46+
47+
def test_conformance_c(self):
48+
with self.temp_filename('.nc') as tfile:
49+
cdlname = 'ogcClassC.cdl'
50+
cdl_file = os.path.join(self.cdl_path, cdlname)
51+
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
52+
cdl_file_uri = 'http://secret.binary-array-ld.net/alias.nc'
53+
alias_dict = {'NetCDF': 'http://def.scitools.org.uk/NetCDF'}
54+
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
55+
alias_dict=alias_dict, cache=self.acache)
56+
ttl = root_container.rdfgraph().serialize(format='n3').decode("utf-8")
57+
if os.environ.get('bald_update_results') is not None:
58+
with open(os.path.join(self.ttl_path, 'ogcClassC.ttl'), 'w') as sf:
59+
sf.write(ttl)
60+
with open(os.path.join(self.ttl_path, 'ogcClassC.ttl'), 'r') as sf:
61+
expected_ttl = sf.read()
62+
self.assertEqual(expected_ttl, ttl)
63+
64+
def test_conformance_d(self):
65+
with self.temp_filename('.nc') as tfile:
66+
cdlname = 'ogcClassD.cdl'
67+
cdl_file = os.path.join(self.cdl_path, cdlname)
68+
subprocess.check_call(['ncgen', '-o', tfile, cdl_file])
69+
cdl_file_uri = 'http://secret.binary-array-ld.net/attributes.nc'
70+
alias_dict = {'NetCDF': 'http://def.scitools.org.uk/NetCDF'}
71+
root_container = bald.load_netcdf(tfile, baseuri=cdl_file_uri,
72+
alias_dict=alias_dict, cache=self.acache)
73+
ttl = root_container.rdfgraph().serialize(format='n3').decode("utf-8")
74+
if os.environ.get('bald_update_results') is not None:
75+
with open(os.path.join(self.ttl_path, 'ogcClassD.ttl'), 'w') as sf:
76+
sf.write(ttl)
77+
with open(os.path.join(self.ttl_path, 'ogcClassD.ttl'), 'r') as sf:
78+
expected_ttl = sf.read()
79+
self.assertEqual(expected_ttl, ttl)

0 commit comments

Comments
 (0)