tonik 0.1.1__py3-none-any.whl → 0.1.3__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/storage.py CHANGED
@@ -156,15 +156,16 @@ class Path(object):
156
156
 
157
157
  xd_index = dict(datetime=slice(self.starttime, self.endtime))
158
158
  with xr.open_dataset(filename, group='original', engine=self.engine) as ds:
159
- rq = ds.loc[xd_index].load()
159
+ rq = ds[feature].loc[xd_index].load()
160
+ rq.attrs = ds.attrs
160
161
 
161
162
  # Stack features
162
163
  if stack_length is not None:
163
164
  logger.debug("Stacking feature...")
164
165
  try:
165
- xdf = rq[feature].rolling(datetime=int(num_periods),
166
- center=False,
167
- min_periods=1).mean()
166
+ xdf = rq.rolling(datetime=int(num_periods),
167
+ center=False,
168
+ min_periods=1).mean()
168
169
  # Return requested timeframe to that defined in initialisation
169
170
  self.starttime += pd.to_timedelta(stack_length)
170
171
  xdf_new = xdf.loc[self.starttime:self.endtime]
@@ -175,8 +176,7 @@ class Path(object):
175
176
  format(stack_length, feature))
176
177
  else:
177
178
  return xdf_new
178
-
179
- return rq[feature]
179
+ return rq
180
180
 
181
181
  def load(self, *args, **kwargs):
182
182
  """
@@ -199,7 +199,7 @@ class Path(object):
199
199
  """
200
200
  filename = self.feature_path(feature)
201
201
  with xr.open_dataset(filename, group='original', engine=self.engine) as ds:
202
- return ds.sizes
202
+ return ds[feature].sizes
203
203
 
204
204
 
205
205
  class Storage(Path):
tonik/xarray2netcdf.py CHANGED
@@ -88,6 +88,8 @@ def xarray2netcdf(xArray, fdir, rootGroupName="original", timedim="datetime",
88
88
  data[indices] = xArray[featureName].values
89
89
  rootGrp.attrs['endtime'] = str(num2date(times[-1], units=rootGrp[timedim].attrs['units'],
90
90
  calendar=rootGrp[timedim].attrs['calendar']))
91
+ rootGrp.attrs['resolution'] = resolution
92
+ rootGrp.attrs['resolution_units'] = 'h'
91
93
  try:
92
94
  _setMetaInfo(featureName, h5f, xArray)
93
95
  except KeyError as e:
@@ -102,7 +104,7 @@ def _create_h5_Structure(defaultGroupName, featureName, h5f, xArray, starttime,
102
104
  coordinates.attrs['units'] = 'hours since 1970-01-01 00:00:00.0'
103
105
  coordinates.attrs['calendar'] = 'gregorian'
104
106
  rootGrp.attrs['starttime'] = str(starttime)
105
- for label, size in xArray.dims.items():
107
+ for label, size in xArray.sizes.items():
106
108
  if not np.issubdtype(xArray[label].dtype, np.datetime64):
107
109
  rootGrp.dimensions[label] = size
108
110
  coordinates = rootGrp.create_variable(label, (label,), float)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tonik
3
- Version: 0.1.1
3
+ Version: 0.1.3
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=ZBVGh4dm_l9xwiBGb33O5QV9MfZeNiEd3DBDAm6DiHk,511
2
+ tonik/api.py,sha256=8YS0WCMlm5xs2N6V8n9BiP87ywJC_BUzYsPvWR9KWJk,6499
3
+ tonik/storage.py,sha256=DNIfNb3oCgICcUI_MADQjQdUqkmZJIu42zCYGRs9ers,11512
4
+ tonik/utils.py,sha256=3nSRU_GnV6arP4e63YHn4oEV8XbqzVAW8FCvQVIwGdg,2757
5
+ tonik/xarray2netcdf.py,sha256=w8ubAWa2yCnk9-JQ_e7CHdfEjvjcK1pXol8Qy_PT2hY,5241
6
+ tonik/xarray2zarr.py,sha256=jTrHFpjN3lEDIJEI6RyPvvbW2jZsfYwGE_LQaZ6dwx8,2099
7
+ tonik/package_data/index.html,sha256=GKDClUhIam_fAYbNfzAolORhSCG3ae1wW3VjWCg4PMk,2732
8
+ tonik-0.1.3.dist-info/METADATA,sha256=DaGP_RFy6luf75DQMr9UA3cfJXlOVJbdHFPU09RCE_4,1938
9
+ tonik-0.1.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
+ tonik-0.1.3.dist-info/entry_points.txt,sha256=VnGfC5qAzpntEHAb5pooUEpYABSgOfQoNhCEtLDJyf8,45
11
+ tonik-0.1.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ tonik-0.1.3.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- tonik/__init__.py,sha256=ZBVGh4dm_l9xwiBGb33O5QV9MfZeNiEd3DBDAm6DiHk,511
2
- tonik/api.py,sha256=8YS0WCMlm5xs2N6V8n9BiP87ywJC_BUzYsPvWR9KWJk,6499
3
- tonik/storage.py,sha256=oy7Nz89zeiZchsqpouttzWhSL6UgenUQZiaMX6SdpsI,11499
4
- tonik/utils.py,sha256=3nSRU_GnV6arP4e63YHn4oEV8XbqzVAW8FCvQVIwGdg,2757
5
- tonik/xarray2netcdf.py,sha256=aZSSMADmS0DpnprT5TBqERGxrycZTPTNuQhxm1rOsh0,5135
6
- tonik/xarray2zarr.py,sha256=jTrHFpjN3lEDIJEI6RyPvvbW2jZsfYwGE_LQaZ6dwx8,2099
7
- tonik/package_data/index.html,sha256=GKDClUhIam_fAYbNfzAolORhSCG3ae1wW3VjWCg4PMk,2732
8
- tonik-0.1.1.dist-info/METADATA,sha256=kSVqgQLr_k3j7s3mfcAnY5nt4LrA-xplhYFiQFLnUIw,1938
9
- tonik-0.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
10
- tonik-0.1.1.dist-info/entry_points.txt,sha256=VnGfC5qAzpntEHAb5pooUEpYABSgOfQoNhCEtLDJyf8,45
11
- tonik-0.1.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- tonik-0.1.1.dist-info/RECORD,,
File without changes