forked from ghsnd/rdf-ts-snippets-spec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspec.bs
182 lines (155 loc) · 8.15 KB
/
spec.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<pre class="metadata">
Title: RDF Time Series Snippets
Warning: Not Ready
Shortname: RDF-TS-Snippets
Level: none
Status: LD
Repository: dylanvanassche/rdf-ts-snippets-spec
URL: https://dylanvanassche.github.io/rdf-ts-snippets-spec/
Editor: Gerald Haesendonck
Editor: Dylan Van Assche
Editor: Pieter Colpaert
Abstract: An RDF Time Series Snippet is a segment of data points from a time series dataset, typically used for analysis or visualization. The specification uses [SPARQL Common Data Types](https://awslabs.github.io/SPARQL-CDTs/spec/latest.html) coined by AWS Lab to encode the data points in a values literal. The entity can then be used for annotating this snippet, which is a time interval subset of a potentially larger time series.
Markup Shorthands: markdown yes, css no
</pre>
# Introduction # {#intro}
Sensor observations, positioning data, measurements, mobility information... are commonly published as Time Series data with a timestamp and a value.
Representing Time Series data in RDF drastically raises the verbosity, as each data point is often given its own identifier, for which contextual information is repeated on all data points.
With Time Series Snippets, we allow a data publisher to compact the data points in subsets of a Time Series, called the Snippet, by using [SPARQL Common Data Types](https://awslabs.github.io/SPARQL-CDTs/spec/latest.html) such as `cdt:List` and `cdt:Map`.
A first example illustrates the features of a `tss:Snippet`:
<div class="example" id="simple_example_snippet">
```turtle
<snippet/2026-01-01>
a tss:Snippet;
tss:points """[
{ "time": "2026-01-01T06:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.4"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "0"},
{ "time": "2026-01-01T06:59:59Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "1"},
{ "time": "2026-01-01T08:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "5.2"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "2"},
{ "time": "2026-01-01T09:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>, "value": "6.1"^^<http://www.w3.org/2001/XMLSchema#double>, "id": "3"},
]"""^^cdt:List;
tss:from "2026-01-01T00:00:00Z"^^xsd:dateTime;
tss:until "2026-01-01T23:59:59Z"^^xsd:dateTime;
tss:pointType sosa:Observation;
tss:timePath sosa:resultTime;
tss:valuePath sosa:hasSimpleResult;
tss:about [
sosa:madeBySensor <temp_sensor_1>;
sosa:observedProperty <temperature>;
];
.
```
</div>
The intention of Time Series [=Snippets=] is to be a lossless format as, if needed, it can be expanded again.
Example 1 for example can be expanded to this RDF dataset:
<div class="example" id="simple_example_rdf">
```turtle
<0>
a sosa:Observation ;
sosa:madeBySensor <temp_sensor_1> ;
sosa:hasSimpleResult "5.4"^^xsd:decimal ;
sosa:observedProperty <temperature> ;
sosa:resultTime "2026-01-01T06:00:00Z"^^xsd:dateTime .
<1>
a sosa:Observation ;
sosa:madeBySensor <temp_sensor_1> ;
sosa:hasSimpleResult "5.2"^^xsd:decimal ;
sosa:observedProperty <temperature> ;
sosa:resultTime "2026-01-01T06:59:59Z"^^xsd:dateTime .
<2>
a sosa:Observation ;
sosa:madeBySensor <temp_sensor_1> ;
sosa:hasSimpleResult "5.2"^^xsd:decimal ;
sosa:observedProperty <temperature> ;
sosa:resultTime "2026-01-01T08:00:02Z"^^xsd:dateTime .
<3>
a sosa:Observation ;
sosa:madeBySensor <temp_sensor_1> ;
sosa:hasSimpleResult "6.1"^^xsd:decimal ;
sosa:observedProperty <temperature> ;
sosa:resultTime "2026-01-01T09:00:00Z"^^xsd:dateTime .
```
</div>
# Definitions # {#definitions}
A <dfn>Time Series</dfn> is a set of data points ordered by timestamp, where each data point consists of a timestamp and corresponding value.
A <dfn>Snippet</dfn> describes a subset of a [=Time Series=] within a certain period defined by a start and end timestamp, and a description of the entity providing the data points.
A <dfn>Data Point</dfn> is a single point of a [=Time Series=] containing an ISO timestamp, a value with datatype, and optionally an identifier.
# Snippet properties # {#properties}
Each [=Snippet=] SHOULD have the following properties:
- `tss:points`: a `cdt:List` of data points where each data point is a `cdt:Map`.
- `tss:from`: starting timestamp (including) of the period covered by `tss:points`.
- `tss:until`: until this timestamp (excluding) of the period covered by `tss:points`.
- `tss:about`: an entity description which provides the data points in `tss:points`.
- `tss:pointType`: the RDF type of the data points in `tss:points`.
- `tss:timePath`: the term to use for expanding the `time` property in `tss:points`.
- `tss:valuePath`: the term to use for expanding the `value` property in `tss:points`.
Issue: Discuss whether these properties are required or optional. E.g., a publisher might decide to do a lossy conversion for their goal, and not include valuePath, pointType and timePath. However, we can still analyze and visualize the data without that information.
## Paths ## {#paths}
A [=Snippet=] has multiple path descriptions to define the mapping between CDT and RDF.
Each of these path descriptions expect an RDF term to use during expansion.
If nested CDT are used, multiple path descriptions MAY be described, each of type `tss:Path`.
A `tss:Path` MUST have the following properties:
- `tss:term`: the RDF term to use during expansion of the path.
- `tss:path`: the property name to match with the RDF term.
Note: Using the RDF term directly for paths is a shortcut of `tss:Path` which can only be used when a simple datatypes are present.
## Data Points ## {#points}
`tss:points` MUST have a `cdt:List` as datatype. Each [=Data Point=] itself MUST be a `cdt:Map` consisting
of 2 required properties and 1 optional property:
- `time`: the `xsd:dateTime` of the data point
- `value`: the value of the data point with corresponding datatype.
- `id`: the data point identifier, optionally (must be a named node).
All properties of datapoints are expandable to RDF, the RDF terms to use are defined through the path descriptions of a Snippet.
<div class="example" id="ex_points">
```turtle
[
{ "time": "2026-01-01T06:00:00Z"^^xsd:dateTime, "value": "5.4"^^xsd:double, "id": "0" },
{ "time": "2026-01-01T06:59:59Z"^^xsd:dateTime, "value": "5.2"^^xsd:double, "id": "1" },
{ "time": "2026-01-01T08:00:00Z"^^xsd:dateTime, "value": "5.2"^^xsd:double, "id": "2" },
{ "time": "2026-01-01T09:00:00Z"^^xsd:dateTime, "value": "6.1"^^xsd:double, "id": "3" },
]
```
</div>
## Extended Data Points ## {#extended-data-points}
[=Data Point=]s can have extended values as well such as `cdt:Map` to allow complex values to be included.
The RDF expansion is defined for each property in the `cdt:Map` by a `tss:Path`:
<div class="example" id="ex_snippet_advanced_ttl">
```turtle
<snippet/2026-01-01>
a tss:Snippet;
tss:points """[
{
"time": "2026-01-01T06:00:00Z",
"value": "{
"latitude": "50.000000"^^<http://www.w3.org/2001/XMLSchema#double>,
"longitude": "4.000000"^^<http://www.w3.org/2001/XMLSchema#double>,
"temperature": "5.21"^^<http://www.w3.org/2001/XMLSchema#double>
}"^^<http://w3id.org/awslabs/neptune/SPARQL-CDTs/Map>
},
{
"time": "2026-01-01T07:00:00Z",
"value": "{
"latitude": "50.100000"^^<http://www.w3.org/2001/XMLSchema#double>,
"longitude": "4.100000"^^<http://www.w3.org/2001/XMLSchema#double>,
"temperature": "7.61"^^<http://www.w3.org/2001/XMLSchema#double>
}"^^<http://w3id.org/awslabs/neptune/SPARQL-CDTs/Map>
},
{
"time": "2026-01-01T08:00:00Z",
"value": "{
"latitude": "50.200000"^^<http://www.w3.org/2001/XMLSchema#double>,
"longitude": "4.200000"^^<http://www.w3.org/2001/XMLSchema#double>,
"temperature": "4.21"^^<http://www.w3.org/2001/XMLSchema#double>
}"^^<http://w3id.org/awslabs/neptune/SPARQL-CDTs/Map>
}
]"""^^cdt:List;
tss:from "2026-01-01T00:00:00Z"^^xsd:dateTime;
tss:until "2026-01-01T23:59:59Z"^^xsd:dateTime;
tss:pointType sosa:Observation;
tss:timePath sosa:resultTime;
tss:valuePath sosa:hasSimpleResult;
tss:about [
sosa:madeBySensor <temp_sensor_1>;
sosa:observedProperty <temperature>;
];
.
```
</div>