tonik 0.1.11__tar.gz → 0.1.12__tar.gz
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-0.1.11 → tonik-0.1.12}/PKG-INFO +1 -1
- {tonik-0.1.11 → tonik-0.1.12}/pyproject.toml +1 -1
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/api.py +17 -15
- {tonik-0.1.11 → tonik-0.1.12}/.devcontainer/devcontainer.json +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/.gitignore +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/HOW_TO_RELEASE.md +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/LICENSE +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/README.md +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/docs/grafana_dashboard_screenshot.png +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/docs/grafana_integration.md +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/docs/grafana_login_screenshot.png +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/docs/index.md +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/docs/tonik_example.ipynb +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/Dockerfile_api +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/Dockerfile_grafana +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/dashboards/demo_dashboard.json +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/docker-compose.yml +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/grafana.ini +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/provisioning/dashboards/default.yaml +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/grafana_example/provisioning/datasources/default.yaml +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/mkdocs.yml +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/__init__.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/package_data/index.html +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/storage.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/utils.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/xarray2netcdf.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/src/tonik/xarray2zarr.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/backend_speed_test.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/conftest.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/test_api.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/test_save.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/test_storage.py +0 -0
- {tonik-0.1.11 → tonik-0.1.12}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tonik
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
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
|
|
@@ -58,16 +58,16 @@ class TonikAPI:
|
|
|
58
58
|
dt = dt.replace(tzinfo=None)
|
|
59
59
|
return dt
|
|
60
60
|
|
|
61
|
-
def feature(self,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
async def feature(self,
|
|
62
|
+
group: str,
|
|
63
|
+
name: str,
|
|
64
|
+
starttime: Union[str, None],
|
|
65
|
+
endtime: Union[str, None],
|
|
66
|
+
subdir: SubdirType = None,
|
|
67
|
+
resolution: str = 'full',
|
|
68
|
+
verticalres: int = 10,
|
|
69
|
+
log: bool = False,
|
|
70
|
+
normalise: bool = False):
|
|
71
71
|
_st = self.preprocess_datetime(starttime)
|
|
72
72
|
_et = self.preprocess_datetime(endtime)
|
|
73
73
|
g = Storage(group, rootdir=self.rootdir,
|
|
@@ -102,22 +102,24 @@ class TonikAPI:
|
|
|
102
102
|
dates = np.tile(dates, freq.size)
|
|
103
103
|
df = pd.DataFrame(
|
|
104
104
|
{'dates': dates, 'freqs': freqs, 'feature': vals})
|
|
105
|
-
df
|
|
105
|
+
df['dates'] = pd.to_datetime(df.dates.values).strftime(
|
|
106
|
+
'%Y-%m-%dT%H:%M:%SZ')
|
|
106
107
|
output = df.to_csv(index=False,
|
|
107
108
|
columns=['dates', 'freqs', 'feature'])
|
|
108
109
|
else:
|
|
109
110
|
df = pd.DataFrame(data=feat.to_pandas(), columns=[feat.name])
|
|
110
|
-
df['dates'] = df.index
|
|
111
|
+
df['dates'] = df.index
|
|
111
112
|
if resolution != 'full':
|
|
112
113
|
try:
|
|
113
114
|
current_resolution = pd.Timedelta(
|
|
114
115
|
df['dates'].diff().mean())
|
|
115
116
|
if current_resolution < pd.Timedelta(resolution):
|
|
116
|
-
df = df.resample(pd.Timedelta(resolution)).
|
|
117
|
+
df = df.resample(pd.Timedelta(resolution)).median()
|
|
117
118
|
except ValueError:
|
|
118
119
|
logger.warning(
|
|
119
120
|
f"Cannot resample {feat.name} to {resolution}: e")
|
|
120
121
|
df.rename(columns={feat.name: 'feature'}, inplace=True)
|
|
122
|
+
df['dates'] = df['dates'].dt.strftime('%Y-%m-%dT%H:%M:%SZ')
|
|
121
123
|
output = df.to_csv(index=False, columns=['dates', 'feature'])
|
|
122
124
|
return StreamingResponse(iter([output]),
|
|
123
125
|
media_type='text/csv',
|
|
@@ -144,7 +146,7 @@ class TonikAPI:
|
|
|
144
146
|
d, units='hours since 1970-01-01 00:00:00.0', calendar='gregorian')
|
|
145
147
|
return freq, dates, spec
|
|
146
148
|
|
|
147
|
-
def inventory(self, group: str, subdir: SubdirType = None, tree: bool = True) -> InventoryReturnType:
|
|
149
|
+
async def inventory(self, group: str, subdir: SubdirType = None, tree: bool = True) -> InventoryReturnType:
|
|
148
150
|
sg = Storage(group, rootdir=self.rootdir, create=False)
|
|
149
151
|
try:
|
|
150
152
|
c = sg.get_substore(*subdir)
|
|
@@ -162,7 +164,7 @@ class TonikAPI:
|
|
|
162
164
|
dir_contents.remove('labels.json')
|
|
163
165
|
return [fn.replace('.nc', '').replace('.zarr', '') for fn in dir_contents]
|
|
164
166
|
|
|
165
|
-
def labels(self, group: str, subdir: SubdirType = None, starttime: Optional[str] = None, endtime: Optional[str] = None):
|
|
167
|
+
async def labels(self, group: str, subdir: SubdirType = None, starttime: Optional[str] = None, endtime: Optional[str] = None):
|
|
166
168
|
_st = self.preprocess_datetime(starttime)
|
|
167
169
|
_et = self.preprocess_datetime(endtime)
|
|
168
170
|
sg = Storage(group, rootdir=self.rootdir,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|