polytope-python 1.0.10__tar.gz → 1.0.11__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.
Files changed (57) hide show
  1. {polytope-python-1.0.10/polytope_python.egg-info → polytope-python-1.0.11}/PKG-INFO +1 -1
  2. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/backends/datacube.py +5 -3
  3. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/backends/fdb.py +9 -2
  4. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/backends/xarray.py +1 -1
  5. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/polytope.py +11 -9
  6. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/exceptions.py +6 -0
  7. polytope-python-1.0.11/polytope_feature/version.py +1 -0
  8. {polytope-python-1.0.10 → polytope-python-1.0.11/polytope_python.egg-info}/PKG-INFO +1 -1
  9. polytope-python-1.0.10/polytope_feature/version.py +0 -1
  10. {polytope-python-1.0.10 → polytope-python-1.0.11}/LICENSE +0 -0
  11. {polytope-python-1.0.10 → polytope-python-1.0.11}/MANIFEST.in +0 -0
  12. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/__init__.py +0 -0
  13. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/__init__.py +0 -0
  14. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/backends/__init__.py +0 -0
  15. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/backends/mock.py +0 -0
  16. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/datacube_axis.py +0 -0
  17. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/index_tree_pb2.py +0 -0
  18. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/tensor_index_tree.py +0 -0
  19. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/__init__.py +0 -0
  20. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_cyclic/__init__.py +0 -0
  21. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_cyclic/datacube_cyclic.py +0 -0
  22. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/__init__.py +0 -0
  23. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/datacube_mappers.py +0 -0
  24. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/__init__.py +0 -0
  25. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix.py +0 -0
  26. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/healpix_nested.py +0 -0
  27. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/local_regular.py +0 -0
  28. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/octahedral.py +0 -0
  29. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/reduced_ll.py +0 -0
  30. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_mappers/mapper_types/regular.py +0 -0
  31. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_merger/__init__.py +0 -0
  32. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_merger/datacube_merger.py +0 -0
  33. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_reverse/__init__.py +0 -0
  34. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_reverse/datacube_reverse.py +0 -0
  35. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_transformations.py +0 -0
  36. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_type_change/__init__.py +0 -0
  37. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/transformations/datacube_type_change/datacube_type_change.py +0 -0
  38. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/datacube/tree_encoding.py +0 -0
  39. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/engine/__init__.py +0 -0
  40. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/engine/engine.py +0 -0
  41. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/engine/hullslicer.py +0 -0
  42. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/options.py +0 -0
  43. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/shapes.py +0 -0
  44. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/__init__.py +0 -0
  45. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/combinatorics.py +0 -0
  46. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/geometry.py +0 -0
  47. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/list_tools.py +0 -0
  48. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_feature/utility/profiling.py +0 -0
  49. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_python.egg-info/SOURCES.txt +0 -0
  50. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_python.egg-info/dependency_links.txt +0 -0
  51. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_python.egg-info/not-zip-safe +0 -0
  52. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_python.egg-info/requires.txt +0 -0
  53. {polytope-python-1.0.10 → polytope-python-1.0.11}/polytope_python.egg-info/top_level.txt +0 -0
  54. {polytope-python-1.0.10 → polytope-python-1.0.11}/pyproject.toml +0 -0
  55. {polytope-python-1.0.10 → polytope-python-1.0.11}/requirements.txt +0 -0
  56. {polytope-python-1.0.10 → polytope-python-1.0.11}/setup.cfg +0 -0
  57. {polytope-python-1.0.10 → polytope-python-1.0.11}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: polytope-python
3
- Version: 1.0.10
3
+ Version: 1.0.11
4
4
  Summary: Polytope datacube feature extraction library
5
5
  Home-page: https://github.com/ecmwf/polytope
6
6
  Author: ECMWF
@@ -148,17 +148,19 @@ class Datacube(ABC):
148
148
  return path
149
149
 
150
150
  @staticmethod
151
- def create(datacube, config={}, axis_options={}, compressed_axes_options=[], alternative_axes=[]):
151
+ def create(datacube, config={}, axis_options={}, compressed_axes_options=[], alternative_axes=[], context=None):
152
152
  # TODO: get the configs as None for pre-determined value and change them to empty dictionary inside the function
153
153
  if type(datacube).__name__ == "DataArray":
154
154
  from .xarray import XArrayDatacube
155
155
 
156
- xadatacube = XArrayDatacube(datacube, axis_options, compressed_axes_options)
156
+ xadatacube = XArrayDatacube(datacube, axis_options, compressed_axes_options, context)
157
157
  return xadatacube
158
158
  if type(datacube).__name__ == "GribJump":
159
159
  from .fdb import FDBDatacube
160
160
 
161
- fdbdatacube = FDBDatacube(datacube, config, axis_options, compressed_axes_options, alternative_axes)
161
+ fdbdatacube = FDBDatacube(
162
+ datacube, config, axis_options, compressed_axes_options, alternative_axes, context
163
+ )
162
164
  return fdbdatacube
163
165
 
164
166
  def check_branching_axes(self, request):
@@ -3,14 +3,19 @@ import operator
3
3
  from copy import deepcopy
4
4
  from itertools import product
5
5
 
6
+ from ...utility.exceptions import BadRequestError
6
7
  from ...utility.geometry import nearest_pt
7
8
  from .datacube import Datacube, TensorIndexTree
8
9
 
9
10
 
10
11
  class FDBDatacube(Datacube):
11
- def __init__(self, gj, config=None, axis_options=None, compressed_axes_options=[], alternative_axes=[]):
12
+ def __init__(
13
+ self, gj, config=None, axis_options=None, compressed_axes_options=[], alternative_axes=[], context=None
14
+ ):
12
15
  if config is None:
13
16
  config = {}
17
+ if context is None:
18
+ context = {}
14
19
 
15
20
  super().__init__(axis_options, compressed_axes_options)
16
21
 
@@ -24,7 +29,9 @@ class FDBDatacube(Datacube):
24
29
 
25
30
  self.gj = gj
26
31
  if len(alternative_axes) == 0:
27
- self.fdb_coordinates = self.gj.axes(partial_request)
32
+ self.fdb_coordinates = self.gj.axes(partial_request, ctx=context)
33
+ if len(self.fdb_coordinates) == 0:
34
+ raise BadRequestError(partial_request)
28
35
  else:
29
36
  self.fdb_coordinates = {}
30
37
  for axis_config in alternative_axes:
@@ -9,7 +9,7 @@ from .datacube import Datacube
9
9
  class XArrayDatacube(Datacube):
10
10
  """Xarray arrays are labelled, axes can be defined as strings or integers (e.g. "time" or 0)."""
11
11
 
12
- def __init__(self, dataarray: xr.DataArray, axis_options=None, compressed_axes_options=[]):
12
+ def __init__(self, dataarray: xr.DataArray, axis_options=None, compressed_axes_options=[], context=None):
13
13
  super().__init__(axis_options, compressed_axes_options)
14
14
  if axis_options is None:
15
15
  axis_options = {}
@@ -39,7 +39,7 @@ class Request:
39
39
 
40
40
 
41
41
  class Polytope:
42
- def __init__(self, datacube, engine=None, options=None):
42
+ def __init__(self, datacube, engine=None, options=None, context=None):
43
43
  from .datacube import Datacube
44
44
  from .engine import Engine
45
45
 
@@ -48,7 +48,11 @@ class Polytope:
48
48
 
49
49
  axis_options, compressed_axes_options, config, alternative_axes = PolytopeOptions.get_polytope_options(options)
50
50
 
51
- self.datacube = Datacube.create(datacube, config, axis_options, compressed_axes_options, alternative_axes)
51
+ self.context = context
52
+
53
+ self.datacube = Datacube.create(
54
+ datacube, config, axis_options, compressed_axes_options, alternative_axes, self.context
55
+ )
52
56
  self.engine = engine if engine is not None else Engine.default()
53
57
  self.time = 0
54
58
 
@@ -56,14 +60,12 @@ class Polytope:
56
60
  """Low-level API which takes a polytope geometry object and uses it to slice the datacube"""
57
61
  return self.engine.extract(self.datacube, polytopes)
58
62
 
59
- def retrieve(self, request: Request, method="standard", context=None):
63
+ def retrieve(self, request: Request, method="standard"):
60
64
  """Higher-level API which takes a request and uses it to slice the datacube"""
61
- if context is None:
62
- context = {}
63
- logging.info("Starting request for %s ", context)
65
+ logging.info("Starting request for %s ", self.context)
64
66
  self.datacube.check_branching_axes(request)
65
67
  request_tree = self.engine.extract(self.datacube, request.polytopes())
66
- logging.info("Created request tree for %s ", context)
67
- self.datacube.get(request_tree, context)
68
- logging.info("Retrieved data for %s ", context)
68
+ logging.info("Created request tree for %s ", self.context)
69
+ self.datacube.get(request_tree, self.context)
70
+ logging.info("Retrieved data for %s ", self.context)
69
71
  return request_tree
@@ -2,6 +2,12 @@ class PolytopeError(Exception):
2
2
  pass
3
3
 
4
4
 
5
+ class BadRequestError(PolytopeError):
6
+ def __init__(self, pre_path):
7
+ self.pre_path = pre_path
8
+ self.message = f"No data for {pre_path} is available on the FDB."
9
+
10
+
5
11
  class AxisOverdefinedError(PolytopeError, KeyError):
6
12
  def __init__(self, axis):
7
13
  self.axis = axis
@@ -0,0 +1 @@
1
+ __version__ = "1.0.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: polytope-python
3
- Version: 1.0.10
3
+ Version: 1.0.11
4
4
  Summary: Polytope datacube feature extraction library
5
5
  Home-page: https://github.com/ecmwf/polytope
6
6
  Author: ECMWF
@@ -1 +0,0 @@
1
- __version__ = "1.0.10"