polytope-python 1.0.23__tar.gz → 1.0.26__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.
- {polytope-python-1.0.23/polytope_python.egg-info → polytope-python-1.0.26}/PKG-INFO +1 -1
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/datacube_axis.py +29 -8
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/reduced_ll.py +9 -3
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_type_change/datacube_type_change.py +47 -1
- polytope-python-1.0.26/polytope_feature/version.py +1 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26/polytope_python.egg-info}/PKG-INFO +1 -1
- polytope-python-1.0.23/polytope_feature/version.py +0 -1
- {polytope-python-1.0.23 → polytope-python-1.0.26}/LICENSE +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/MANIFEST.in +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/datacube.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/fdb.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/mock.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/xarray.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/index_tree_pb2.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/tensor_index_tree.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_cyclic/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_cyclic/datacube_cyclic.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/datacube_mappers.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix_nested.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/local_regular.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/octahedral.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/regular.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_merger/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_merger/datacube_merger.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_reverse/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_reverse/datacube_reverse.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_transformations.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/transformations/datacube_type_change/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/tree_encoding.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/engine/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/engine/engine.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/engine/hullslicer.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/options.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/polytope.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/shapes.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/__init__.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/combinatorics.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/exceptions.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/geometry.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/list_tools.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/utility/profiling.py +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/SOURCES.txt +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/dependency_links.txt +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/not-zip-safe +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/requires.txt +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/top_level.txt +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/pyproject.toml +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/requirements.txt +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/setup.cfg +0 -0
- {polytope-python-1.0.23 → polytope-python-1.0.26}/setup.py +0 -0
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/datacube_axis.py
RENAMED
|
@@ -5,6 +5,7 @@ from typing import Any, List
|
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import pandas as pd
|
|
8
|
+
import xarray as xr
|
|
8
9
|
|
|
9
10
|
from .transformations.datacube_cyclic.datacube_cyclic import DatacubeAxisCyclic
|
|
10
11
|
from .transformations.datacube_mappers.datacube_mappers import DatacubeMapper
|
|
@@ -142,22 +143,39 @@ class DatacubeAxis(ABC):
|
|
|
142
143
|
)
|
|
143
144
|
return indexes_between_ranges
|
|
144
145
|
|
|
146
|
+
@staticmethod
|
|
147
|
+
def values_type(values):
|
|
148
|
+
type_ = None
|
|
149
|
+
if isinstance(values, xr.core.variable.IndexVariable) or isinstance(values, xr.core.variable.Variable):
|
|
150
|
+
# If we have some xarray variable, transform them to actual variable type
|
|
151
|
+
values = np.array(values)
|
|
152
|
+
type_ = values.dtype.type
|
|
153
|
+
else:
|
|
154
|
+
if len(values) == 0:
|
|
155
|
+
# If we have no values (newly created axis), default to a float
|
|
156
|
+
values = np.array(values)
|
|
157
|
+
type_ = values.dtype.type
|
|
158
|
+
else:
|
|
159
|
+
type_ = type(values[0])
|
|
160
|
+
return type_
|
|
161
|
+
|
|
145
162
|
@staticmethod
|
|
146
163
|
def create_standard(name, values, datacube):
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
val_type = DatacubeAxis.values_type(values)
|
|
165
|
+
|
|
166
|
+
DatacubeAxis.check_axis_type(name, val_type)
|
|
149
167
|
if datacube._axes is None:
|
|
150
|
-
datacube._axes = {name: deepcopy(_type_to_axis_lookup[
|
|
168
|
+
datacube._axes = {name: deepcopy(_type_to_axis_lookup[val_type])}
|
|
151
169
|
else:
|
|
152
|
-
datacube._axes[name] = deepcopy(_type_to_axis_lookup[
|
|
170
|
+
datacube._axes[name] = deepcopy(_type_to_axis_lookup[val_type])
|
|
171
|
+
|
|
153
172
|
datacube._axes[name].name = name
|
|
154
173
|
datacube.axis_counter += 1
|
|
155
174
|
|
|
156
175
|
@staticmethod
|
|
157
|
-
def check_axis_type(name,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
raise ValueError(f"Could not create a mapper for index type {values.dtype.type} for axis {name}")
|
|
176
|
+
def check_axis_type(name, val_type):
|
|
177
|
+
if val_type not in _type_to_axis_lookup:
|
|
178
|
+
raise ValueError(f"Could not create a mapper for index type {val_type} for axis {name}")
|
|
161
179
|
|
|
162
180
|
|
|
163
181
|
transformations_order = [
|
|
@@ -302,10 +320,13 @@ _type_to_axis_lookup = {
|
|
|
302
320
|
np.int64: IntDatacubeAxis(),
|
|
303
321
|
np.datetime64: PandasTimestampDatacubeAxis(),
|
|
304
322
|
np.timedelta64: PandasTimedeltaDatacubeAxis(),
|
|
323
|
+
pd.Timedelta: PandasTimedeltaDatacubeAxis(),
|
|
305
324
|
np.float64: FloatDatacubeAxis(),
|
|
306
325
|
np.float32: FloatDatacubeAxis(),
|
|
307
326
|
np.int32: IntDatacubeAxis(),
|
|
308
327
|
np.str_: UnsliceableDatacubeAxis(),
|
|
309
328
|
str: UnsliceableDatacubeAxis(),
|
|
310
329
|
np.object_: UnsliceableDatacubeAxis(),
|
|
330
|
+
int: IntDatacubeAxis(),
|
|
331
|
+
float: FloatDatacubeAxis(),
|
|
311
332
|
}
|
|
@@ -22,8 +22,11 @@ class ReducedLatLonMapper(DatacubeMapper):
|
|
|
22
22
|
raise NotImplementedError("Reduced lat-lon grid with first axis in decreasing order is not supported")
|
|
23
23
|
|
|
24
24
|
def first_axis_vals(self):
|
|
25
|
+
start_lat = 90
|
|
26
|
+
if self._resolution == 3601:
|
|
27
|
+
start_lat = 89.973092
|
|
25
28
|
resolution = 180 / (self._resolution - 1)
|
|
26
|
-
vals = [-
|
|
29
|
+
vals = [round(start_lat - i * resolution, 12) for i in range(self._resolution)]
|
|
27
30
|
return vals
|
|
28
31
|
|
|
29
32
|
def map_first_axis(self, lower, upper):
|
|
@@ -5084,8 +5087,11 @@ class ReducedLatLonMapper(DatacubeMapper):
|
|
|
5084
5087
|
def second_axis_vals(self, first_val):
|
|
5085
5088
|
first_idx = self._first_axis_vals.index(first_val[0])
|
|
5086
5089
|
Ny = self.lon_spacing()[first_idx]
|
|
5087
|
-
|
|
5088
|
-
|
|
5090
|
+
if Ny != 0:
|
|
5091
|
+
second_spacing = 360 / Ny
|
|
5092
|
+
return [i * second_spacing for i in range(Ny)]
|
|
5093
|
+
else:
|
|
5094
|
+
raise ValueError("Requested latitude value is not within reduced latitude-longitude grid bounds")
|
|
5089
5095
|
|
|
5090
5096
|
def map_second_axis(self, first_val, lower, upper):
|
|
5091
5097
|
axis_lines = self.second_axis_vals(first_val)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from copy import deepcopy
|
|
2
2
|
from importlib import import_module
|
|
3
3
|
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
4
6
|
from ..datacube_transformations import DatacubeAxisTransformation
|
|
5
7
|
|
|
6
8
|
|
|
@@ -75,4 +77,48 @@ class TypeChangeStrToInt(DatacubeAxisTypeChange):
|
|
|
75
77
|
return tuple(values)
|
|
76
78
|
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
class TypeChangeStrToTimestamp(DatacubeAxisTypeChange):
|
|
81
|
+
def __init__(self, axis_name, new_type):
|
|
82
|
+
self.axis_name = axis_name
|
|
83
|
+
self._new_type = new_type
|
|
84
|
+
|
|
85
|
+
def transform_type(self, value):
|
|
86
|
+
try:
|
|
87
|
+
return pd.Timestamp(value)
|
|
88
|
+
except ValueError:
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def make_str(self, value):
|
|
92
|
+
values = []
|
|
93
|
+
for val in value:
|
|
94
|
+
values.append(val.strftime("%Y%m%d"))
|
|
95
|
+
return tuple(values)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class TypeChangeStrToTimedelta(DatacubeAxisTypeChange):
|
|
99
|
+
def __init__(self, axis_name, new_type):
|
|
100
|
+
self.axis_name = axis_name
|
|
101
|
+
self._new_type = new_type
|
|
102
|
+
|
|
103
|
+
def transform_type(self, value):
|
|
104
|
+
try:
|
|
105
|
+
hours = int(value[:2])
|
|
106
|
+
mins = int(value[2:])
|
|
107
|
+
return pd.Timedelta(hours=hours, minutes=mins)
|
|
108
|
+
except ValueError:
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
def make_str(self, value):
|
|
112
|
+
values = []
|
|
113
|
+
for val in value:
|
|
114
|
+
hours = int(val.total_seconds() // 3600)
|
|
115
|
+
mins = int((val.total_seconds() % 3600) // 60)
|
|
116
|
+
values.append(f"{hours:02d}{mins:02d}")
|
|
117
|
+
return tuple(values)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
_type_to_datacube_type_change_lookup = {
|
|
121
|
+
"int": "TypeChangeStrToInt",
|
|
122
|
+
"date": "TypeChangeStrToTimestamp",
|
|
123
|
+
"time": "TypeChangeStrToTimedelta",
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.26"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.0.23"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/__init__.py
RENAMED
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/datacube.py
RENAMED
|
File without changes
|
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/mock.py
RENAMED
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/backends/xarray.py
RENAMED
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/index_tree_pb2.py
RENAMED
|
File without changes
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/tensor_index_tree.py
RENAMED
|
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
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_feature/datacube/tree_encoding.py
RENAMED
|
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
|
{polytope-python-1.0.23 → polytope-python-1.0.26}/polytope_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|