polytope-python 2.1.8__py3-none-any.whl → 2.1.10__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.
@@ -1,2 +1,2 @@
1
1
  # Do not change! Do not track in version control!
2
- __version__ = "2.1.8"
2
+ __version__ = "2.1.10"
@@ -19,6 +19,7 @@ class QuadTreeSlicer(Engine):
19
19
  # TODO: maybe we create the quadtree as soon as we have an unstructured slicer type and return it
20
20
  # to the slicer somehow?
21
21
  quad_tree = QuadTree()
22
+ # NOTE: the points here are assumed to be lat/lon implicitly
22
23
  points = [tuple(point) for point in points]
23
24
  quad_tree.build_point_tree(points)
24
25
  self.points = points
@@ -27,17 +28,29 @@ class QuadTreeSlicer(Engine):
27
28
  def extract_single(self, datacube, polytope):
28
29
  # extract a single polygon
29
30
  # if need to find nearest points, then take alternative slicing method using quadtree to find nearest point
31
+ axes = polytope.axes()
32
+ assert len(axes) == 2
33
+ assert "latitude" in axes and "longitude" in axes
34
+ revert_axes = not (list(axes) == ["latitude", "longitude"])
30
35
  if use_rust:
31
36
  if len(datacube.nearest_search) == 0:
32
- polytope_points = [tuple(point) for point in polytope.points]
37
+ if revert_axes:
38
+ polytope_points = [tuple(reversed(point)) for point in polytope.points]
39
+ else:
40
+ polytope_points = [tuple(point) for point in polytope.points]
33
41
  polygon_points = self.quad_tree.query_polygon(self.points, 0, polytope_points)
34
42
  else:
35
43
  k = datacube.nearest_search[tuple(polytope.axes())][1]
36
- nn_points = [tuple(pt) for pt in datacube.nearest_search[tuple(polytope.axes())][0]]
44
+ if revert_axes:
45
+ nn_points = [tuple(reversed(pt)) for pt in datacube.nearest_search[tuple(polytope.axes())][0]]
46
+ else:
47
+ nn_points = [tuple(pt) for pt in datacube.nearest_search[tuple(polytope.axes())][0]]
37
48
  polygon_points = []
38
49
  for nn_pt in nn_points:
39
50
  polygon_points.extend(self.quad_tree.k_nearest_neighbor(nn_pt, k, self.points))
40
51
  else:
52
+ if revert_axes:
53
+ polytope.points = [tuple(reversed(point)) for point in polytope.points]
41
54
  polygon_points = self.quad_tree.query_polygon(polytope)
42
55
  return polygon_points
43
56
 
@@ -1,12 +1,11 @@
1
1
  import argparse
2
+ import logging
2
3
  from abc import ABC
3
4
  from typing import Dict, List, Literal, Optional, Tuple, Union
4
5
 
5
6
  from conflator import ConfigModel, Conflator
6
7
  from pydantic import ConfigDict
7
8
 
8
- from polytope_feature.datacube.switching_grid_helper import lookup_grid_config
9
-
10
9
 
11
10
  class TransformationConfig(ConfigModel):
12
11
  model_config = ConfigDict(extra="forbid")
@@ -111,9 +110,12 @@ class PolytopeOptions(ABC):
111
110
  replaced = replace_grid_config_in_options(config_options, pre_path)
112
111
  if replaced:
113
112
  axis_config = config_options.axis_config
114
- except Exception:
115
- # Fail silently and continue with original config
116
- pass
113
+ except Exception as e:
114
+ logging.warning(
115
+ "Dynamic grid replacement failed for georef '%s': %s. Using static grid config.",
116
+ pre_path.get("georef", "unknown"),
117
+ e,
118
+ )
117
119
  return (
118
120
  axis_config,
119
121
  compressed_axes_config,
@@ -151,6 +153,8 @@ def gridspec_to_grid_config(gridspec, md5hash):
151
153
 
152
154
 
153
155
  def replace_grid_config_in_options(options, req):
156
+ from polytope_feature.datacube.switching_grid_helper import lookup_grid_config
157
+
154
158
  gridspec, md5hash = lookup_grid_config(req)
155
159
  grid_config = gridspec_to_grid_config(gridspec, md5hash)
156
160
  if grid_config is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polytope-python
3
- Version: 2.1.8
3
+ Version: 2.1.10
4
4
  Summary: Polytope datacube feature extraction library
5
5
  Author-email: "European Centre for Medium-Range Weather Forecasts (ECMWF)" <software.support@ecmwf.int>
6
6
  Maintainer-email: James Hawkes <James.Hawkes@ecmwf.int>, Mathilde Leuridan <Mathilde.Leuridan@ecmwf.int>
@@ -1,6 +1,6 @@
1
1
  polytope_feature/__init__.py,sha256=1OP0y5Ubza4LaBUhegJvJe24u-8zZGrEzAgwPJVqZlk,58
2
- polytope_feature/_version.py,sha256=ihCTfvA20gwPoIcNhKAsDkildKDuhkPRooZtPJV1kCE,72
3
- polytope_feature/options.py,sha256=sL-LURTJKEE649O4Y15SHqClCxZxwrVJLwjVsy5ZGX8,5467
2
+ polytope_feature/_version.py,sha256=PTSbSNjNSIlYEdXoqg2g_qXtr5OnizmLG6uPiwJ3fDU,73
3
+ polytope_feature/options.py,sha256=_dBIRLpNAuwxhTO5I18SQ4csjOpOgH9LqdgFLaTyJGE,5635
4
4
  polytope_feature/polytope.py,sha256=TM4X4nxAio0fgLC8vjhzXcJjylZRVS5nRTv4LdbPziM,9805
5
5
  polytope_feature/shapes.py,sha256=ZhMrHTNEqEgnpMTDU1Rd5zjJeyRBQMYNDRoKqDd2Ejs,16473
6
6
  polytope_feature/datacube/__init__.py,sha256=jfDehbaWSfhOPDHkxaj4UA33sTh-W6n6_B5BLTKRgAo,33
@@ -49,7 +49,7 @@ polytope_feature/engine/hullslicer.py,sha256=1B710iKNfe7pjEQdeUGNmSqE7YjUJ-Zyuuy
49
49
  polytope_feature/engine/optimised_point_in_polygon_slicer.py,sha256=SOHm-0tQK6AQ62sd7lMCEbryQF2aiuxgNsl_d3V-DBs,5025
50
50
  polytope_feature/engine/optimised_quadtree_slicer.py,sha256=ecf5Uhd0bmgCPyQXYZixeE-eZH42wyN_vnWslwqmAu8,3847
51
51
  polytope_feature/engine/point_in_polygon_slicer.py,sha256=tnoA-4cMU6WYljq0XVoNDE9ap5ssmSNLjkqVN_of6Zc,4371
52
- polytope_feature/engine/quadtree_slicer.py,sha256=DA6-ni1YCqwbbABCJUj3hnAizeKmvP9umep6Rk-YeDY,3244
52
+ polytope_feature/engine/quadtree_slicer.py,sha256=-Vs3TWSb6FsdckNqGBOhLVNzMKdpaegfG4NnlOLcFLA,3939
53
53
  polytope_feature/engine/slicing_tools.py,sha256=a-bzBgnSbSlJLkd22JrIAntIDuOkUanwhlegp2iwvVQ,5349
54
54
  polytope_feature/utility/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  polytope_feature/utility/combinatorics.py,sha256=Vucp-78wpw8wTDiGv889w_kdYbFsHafcCAwgsg2MzYc,1586
@@ -58,8 +58,8 @@ polytope_feature/utility/exceptions.py,sha256=cIgX7YiARpfPsjxax0dGQmkg9vfinEUVj2
58
58
  polytope_feature/utility/geometry.py,sha256=DHCYFKJWC7BBbMwnCQlcQVzYp8T_e-RZVuSbKPo7-60,1063
59
59
  polytope_feature/utility/list_tools.py,sha256=0WeWCRzm8jHdcM_1BPu1s-yr5D0UUmtQIVe4HHGfRJk,760
60
60
  polytope_feature/utility/profiling.py,sha256=PS8z7u6xyiBMlbcddOO5LS6ua8E1CJOzi3CtDaDv7p4,322
61
- polytope_python-2.1.8.dist-info/licenses/LICENSE,sha256=VtcDVlw8N6T2GAxlk6b-8OvqAG_V751y269wWcv_lEU,11379
62
- polytope_python-2.1.8.dist-info/METADATA,sha256=100JnJyAWDZg95Xs1e9KALrggn3RfT77cY26SDv5wm8,11616
63
- polytope_python-2.1.8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
64
- polytope_python-2.1.8.dist-info/top_level.txt,sha256=4I919dNk-eQpuqcYHdiBpwAZcNrWeMPYuROzfpqmGRk,17
65
- polytope_python-2.1.8.dist-info/RECORD,,
61
+ polytope_python-2.1.10.dist-info/licenses/LICENSE,sha256=VtcDVlw8N6T2GAxlk6b-8OvqAG_V751y269wWcv_lEU,11379
62
+ polytope_python-2.1.10.dist-info/METADATA,sha256=_4e1g28EOcuD60GUYBvSYF7ZPXmlBmhiiSaEugquw5Q,11617
63
+ polytope_python-2.1.10.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
64
+ polytope_python-2.1.10.dist-info/top_level.txt,sha256=4I919dNk-eQpuqcYHdiBpwAZcNrWeMPYuROzfpqmGRk,17
65
+ polytope_python-2.1.10.dist-info/RECORD,,