tonik 0.1.13__py3-none-any.whl → 0.1.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tonik/package_data/index.html +147 -76
- tonik/storage.py +7 -3
- {tonik-0.1.13.dist-info → tonik-0.1.15.dist-info}/METADATA +2 -2
- tonik-0.1.15.dist-info/RECORD +12 -0
- {tonik-0.1.13.dist-info → tonik-0.1.15.dist-info}/WHEEL +1 -1
- tonik-0.1.13.dist-info/RECORD +0 -12
- {tonik-0.1.13.dist-info → tonik-0.1.15.dist-info}/entry_points.txt +0 -0
- {tonik-0.1.13.dist-info → tonik-0.1.15.dist-info}/licenses/LICENSE +0 -0
tonik/package_data/index.html
CHANGED
|
@@ -1,93 +1,164 @@
|
|
|
1
|
+
<!-- TonikAPI index.html -->
|
|
1
2
|
<!DOCTYPE html>
|
|
2
3
|
<html lang="en">
|
|
3
4
|
<head>
|
|
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
|
-
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>TonikAPI</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
margin: 20px;
|
|
11
|
+
background-color: #f9f9f9;
|
|
12
|
+
line-height: 1.6;
|
|
13
|
+
}
|
|
14
|
+
header {
|
|
15
|
+
background-color: #007ACC;
|
|
16
|
+
color: #fff;
|
|
17
|
+
padding: 20px;
|
|
18
|
+
text-align: center;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
}
|
|
21
|
+
section {
|
|
22
|
+
background-color: #fff;
|
|
23
|
+
margin-top: 20px;
|
|
24
|
+
padding: 20px;
|
|
25
|
+
border-radius: 8px;
|
|
26
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
27
|
+
}
|
|
28
|
+
h2 {
|
|
29
|
+
color: #007ACC;
|
|
30
|
+
}
|
|
31
|
+
code {
|
|
32
|
+
background-color: #eef;
|
|
33
|
+
padding: 2px 4px;
|
|
34
|
+
border-radius: 4px;
|
|
35
|
+
}
|
|
36
|
+
pre {
|
|
37
|
+
background-color: #eef;
|
|
38
|
+
padding: 10px;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
overflow-x: auto;
|
|
41
|
+
}
|
|
42
|
+
a.button {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
padding: 10px 15px;
|
|
45
|
+
margin: 5px 0;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
text-decoration: none;
|
|
48
|
+
background-color: #007ACC;
|
|
49
|
+
color: #fff;
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
}
|
|
52
|
+
table {
|
|
53
|
+
width: 100%;
|
|
54
|
+
border-collapse: collapse;
|
|
55
|
+
margin-bottom: 20px;
|
|
56
|
+
}
|
|
57
|
+
table, th, td {
|
|
58
|
+
border: 1px solid #ddd;
|
|
59
|
+
}
|
|
60
|
+
th, td {
|
|
61
|
+
padding: 8px;
|
|
62
|
+
text-align: left;
|
|
63
|
+
}
|
|
64
|
+
th {
|
|
65
|
+
background-color: #f2f2f2;
|
|
66
|
+
}
|
|
67
|
+
footer {
|
|
68
|
+
text-align: center;
|
|
69
|
+
margin-top: 40px;
|
|
70
|
+
color: #666;
|
|
71
|
+
font-size: 0.9em;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
36
74
|
</head>
|
|
37
75
|
<body>
|
|
76
|
+
<header>
|
|
77
|
+
<h1>TonikAPI</h1>
|
|
78
|
+
<p>Query, transform, and extract features from multidimensional data stores</p>
|
|
79
|
+
</header>
|
|
38
80
|
|
|
39
|
-
<
|
|
40
|
-
<h1>Tonik</h1>
|
|
41
|
-
<p>Tonik - API</p>
|
|
42
|
-
</header>
|
|
43
|
-
|
|
44
|
-
<section>
|
|
81
|
+
<section>
|
|
45
82
|
<h2>Overview</h2>
|
|
46
83
|
<p>
|
|
47
|
-
|
|
84
|
+
TonikAPI is designed for efficient retrieval, transformation, and feature extraction of time-series and spectrogram-like data stored in hierarchical formats. It supports subdirectory traversal, resampling, log-scaling, and normalization.
|
|
85
|
+
</p>
|
|
86
|
+
<p>
|
|
87
|
+
This API is especially suited for applications in seismology, geophysics, and related fields.
|
|
48
88
|
</p>
|
|
89
|
+
</section>
|
|
49
90
|
|
|
91
|
+
<section>
|
|
50
92
|
<h2>Endpoints</h2>
|
|
93
|
+
<table>
|
|
94
|
+
<thead>
|
|
95
|
+
<tr>
|
|
96
|
+
<th>Endpoint</th>
|
|
97
|
+
<th>Method</th>
|
|
98
|
+
<th>Description</th>
|
|
99
|
+
</tr>
|
|
100
|
+
</thead>
|
|
101
|
+
<tbody>
|
|
102
|
+
<tr>
|
|
103
|
+
<td><code>/feature</code></td>
|
|
104
|
+
<td>GET</td>
|
|
105
|
+
<td>Returns time series or spectrogram features for a given group, variable, and time range.</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr>
|
|
108
|
+
<td><code>/inventory</code></td>
|
|
109
|
+
<td>GET</td>
|
|
110
|
+
<td>Lists available datasets or subdirectories within a group.</td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td><code>/labels</code></td>
|
|
114
|
+
<td>GET</td>
|
|
115
|
+
<td>Fetches labels associated with a dataset for a specified time range.</td>
|
|
116
|
+
</tr>
|
|
117
|
+
</tbody>
|
|
118
|
+
</table>
|
|
119
|
+
</section>
|
|
120
|
+
|
|
121
|
+
<section>
|
|
122
|
+
<h2>Feature Request Example</h2>
|
|
123
|
+
<p>Example query for retrieving a feature:</p>
|
|
124
|
+
<pre>GET /feature?group=testgroup&name=rms&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00&resolution=1h&log=true&normalise=true</pre>
|
|
51
125
|
<p>
|
|
52
|
-
|
|
126
|
+
<a class="button" href="#" onclick="alert('Simulate API call using curl or your browser.')">Try Feature Query</a>
|
|
53
127
|
</p>
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
128
|
+
<pre>curl "http://localhost:8003/feature?group=testgroup&name=rms&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00&resolution=1h&log=true&normalise=true"</pre>
|
|
129
|
+
</section>
|
|
130
|
+
|
|
131
|
+
<section>
|
|
132
|
+
<h2>Inventory and Labels</h2>
|
|
133
|
+
<p>Query inventory of datasets:</p>
|
|
134
|
+
<pre>GET /inventory?group=testgroup</pre>
|
|
135
|
+
<p>Query labels for a dataset:</p>
|
|
136
|
+
<pre>GET /labels?group=testgroup&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00</pre>
|
|
137
|
+
</section>
|
|
138
|
+
|
|
139
|
+
<section>
|
|
140
|
+
<h2>Python Example</h2>
|
|
141
|
+
<p>You can query the TonikAPI directly from Python using <code>requests</code>:</p>
|
|
142
|
+
<pre><code>import requests
|
|
143
|
+
|
|
144
|
+
params = {
|
|
145
|
+
"group": "testgroup",
|
|
146
|
+
"name": "rms",
|
|
147
|
+
"starttime": "2023-01-01T00:00:00",
|
|
148
|
+
"endtime": "2023-01-02T00:00:00",
|
|
149
|
+
"resolution": "1h",
|
|
150
|
+
"log": "true",
|
|
151
|
+
"normalise": "true"
|
|
152
|
+
}
|
|
58
153
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</pre>
|
|
65
|
-
To do the same with Python using requests you can use the following code:
|
|
66
|
-
<pre>
|
|
67
|
-
import requests
|
|
68
|
-
url = "http://your.host.server:yourport/inventory"
|
|
69
|
-
response = requests.get(url)
|
|
70
|
-
response.json()
|
|
71
|
-
</pre>
|
|
72
|
-
<h3>Requesting data</h3>
|
|
73
|
-
The following example shows how to request RSAM data for station WIZ at volcano Whakaari
|
|
74
|
-
between 2019-12-01 and 2019-12-31. The return format is CSV.
|
|
75
|
-
<pre>
|
|
76
|
-
curl -X GET "http://your.host.server:yourport/feature?name=rsam&starttime=2019-12-01T00:00:00&endtime=2019-12-31T00:00:00&subdir=Whakaari&subdir=WIZ"
|
|
77
|
-
</pre>
|
|
78
|
-
To do the same with Python using pandas you can use the following code:
|
|
79
|
-
<pre>
|
|
80
|
-
import pandas as pd
|
|
81
|
-
feature="rsam"
|
|
82
|
-
starttime="2019-12-01T00:00:00"
|
|
83
|
-
endtime="2019-12-31T00:00:00"
|
|
84
|
-
volcano="Whakaari"
|
|
85
|
-
site="WIZ"
|
|
86
|
-
url = f"http://your.host.server:yourport/feature?name={feature}&starttime={starttime}&endtime={endtime}&subdir={volcano}&subdir={site}"
|
|
87
|
-
pd.read_csv(url, parse_dates=True, index_col=0)
|
|
88
|
-
</pre>
|
|
89
|
-
</section>
|
|
90
|
-
</section>
|
|
154
|
+
response = requests.get("http://localhost:8003/feature", params=params)
|
|
155
|
+
with open("rms_feature.csv", "w") as f:
|
|
156
|
+
f.write(response.text)
|
|
157
|
+
</code></pre>
|
|
158
|
+
</section>
|
|
91
159
|
|
|
160
|
+
<footer>
|
|
161
|
+
<p>© 2025 TonikAPI. Built with precision using FastAPI + Pandas + Xarray.</p>
|
|
162
|
+
</footer>
|
|
92
163
|
</body>
|
|
93
164
|
</html>
|
tonik/storage.py
CHANGED
|
@@ -112,7 +112,7 @@ class Path(object):
|
|
|
112
112
|
self.children[feature] = Path(feature + file_ending, self.path)
|
|
113
113
|
return _feature_path
|
|
114
114
|
|
|
115
|
-
def __call__(self, feature, group='original'):
|
|
115
|
+
def __call__(self, feature, group='original', attributes_only=False):
|
|
116
116
|
"""
|
|
117
117
|
Request a particular feature
|
|
118
118
|
|
|
@@ -120,11 +120,15 @@ class Path(object):
|
|
|
120
120
|
:type feature: str
|
|
121
121
|
|
|
122
122
|
"""
|
|
123
|
+
filename = self.feature_path(feature)
|
|
124
|
+
|
|
125
|
+
if attributes_only:
|
|
126
|
+
with xr.open_dataset(filename, group=group, engine=self.engine) as ds:
|
|
127
|
+
return ds.attrs
|
|
128
|
+
|
|
123
129
|
if self.endtime < self.starttime:
|
|
124
130
|
raise ValueError('Startime has to be smaller than endtime.')
|
|
125
131
|
|
|
126
|
-
filename = self.feature_path(feature)
|
|
127
|
-
|
|
128
132
|
logger.debug(
|
|
129
133
|
f"Reading feature {feature} between {self.starttime} and {self.endtime}")
|
|
130
134
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: tonik
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: Store time series data as HDF5 files and access them through an API.
|
|
5
5
|
Project-URL: Homepage, https://tsc-tools.github.io/tonik
|
|
6
6
|
Project-URL: Issues, https://github.com/tsc-tools/tonik/issues
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
tonik/__init__.py,sha256=dov-nMeGFBzLspmj4rWKjC4r736vmaPDgMEkHSUfP98,523
|
|
2
|
+
tonik/api.py,sha256=XDKiz1AzYNBOwYfaRxpMgqGRDAPJEE6wWJyBxuYPRLc,7751
|
|
3
|
+
tonik/storage.py,sha256=vFxIrY92cSYOYOpNXHxCAjdXgkrRytaRDpudtK0glmg,10608
|
|
4
|
+
tonik/utils.py,sha256=9eSVKIbs8TIZlJCz_-B7FrvOUQCQHO3K52v4Heus-uE,6135
|
|
5
|
+
tonik/xarray2netcdf.py,sha256=gDNT6nxnRbXPeRqZ3URW5oXY3Nfh3TCrfueE-eUrIoY,5181
|
|
6
|
+
tonik/xarray2zarr.py,sha256=RhCnS6g3yqe8mrEXhD_4PCN0EI3QPhp5X7ui_wvb_jY,2445
|
|
7
|
+
tonik/package_data/index.html,sha256=ZCZ-BtGRERsL-6c_dfY43qd2WAaggH7xereennGL6ww,4372
|
|
8
|
+
tonik-0.1.15.dist-info/METADATA,sha256=fgLopxgfF1ooNHl2DEYN3dFivpSknlfRrAL2eledYKo,2143
|
|
9
|
+
tonik-0.1.15.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
|
|
10
|
+
tonik-0.1.15.dist-info/entry_points.txt,sha256=mT3B4eBE8SHlAeMhFnZGor9-YkVtoWM1NVHVuypJ-uY,74
|
|
11
|
+
tonik-0.1.15.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
12
|
+
tonik-0.1.15.dist-info/RECORD,,
|
tonik-0.1.13.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
tonik/__init__.py,sha256=dov-nMeGFBzLspmj4rWKjC4r736vmaPDgMEkHSUfP98,523
|
|
2
|
-
tonik/api.py,sha256=XDKiz1AzYNBOwYfaRxpMgqGRDAPJEE6wWJyBxuYPRLc,7751
|
|
3
|
-
tonik/storage.py,sha256=IklM_atZD4rebUsnXsUj5JldSHU2LqmuqME03PHp_UI,10441
|
|
4
|
-
tonik/utils.py,sha256=9eSVKIbs8TIZlJCz_-B7FrvOUQCQHO3K52v4Heus-uE,6135
|
|
5
|
-
tonik/xarray2netcdf.py,sha256=gDNT6nxnRbXPeRqZ3URW5oXY3Nfh3TCrfueE-eUrIoY,5181
|
|
6
|
-
tonik/xarray2zarr.py,sha256=RhCnS6g3yqe8mrEXhD_4PCN0EI3QPhp5X7ui_wvb_jY,2445
|
|
7
|
-
tonik/package_data/index.html,sha256=GKDClUhIam_fAYbNfzAolORhSCG3ae1wW3VjWCg4PMk,2732
|
|
8
|
-
tonik-0.1.13.dist-info/METADATA,sha256=MNuL04Q7howEYqs_HbnLxQtIXLAoLhN5nEC9GcE3uk4,2143
|
|
9
|
-
tonik-0.1.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
tonik-0.1.13.dist-info/entry_points.txt,sha256=mT3B4eBE8SHlAeMhFnZGor9-YkVtoWM1NVHVuypJ-uY,74
|
|
11
|
-
tonik-0.1.13.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
12
|
-
tonik-0.1.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|