You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by tl...@apache.org on 2022/04/06 22:18:31 UTC

[incubator-sdap-nexus] branch master updated: SDAP-318 Updated timeSeriesSpark algorithm to find tiles by bounding box instead of polygon (#156)

This is an automated email from the ASF dual-hosted git repository.

tloubrieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git


The following commit(s) were added to refs/heads/master by this push:
     new 6ca2660  SDAP-318 Updated timeSeriesSpark algorithm to find tiles by bounding box instead of polygon (#156)
6ca2660 is described below

commit 6ca26605ef10606772972424033ef96d5b8a5605
Author: Kevin <ke...@gmail.com>
AuthorDate: Wed Apr 6 15:18:27 2022 -0700

    SDAP-318 Updated timeSeriesSpark algorithm to find tiles by bounding box instead of polygon (#156)
---
 .../tests/algorithms_spark/test_timeseriesspark.py |  4 ++--
 .../webservice/algorithms_spark/TimeSeriesSpark.py | 22 +++++++++++++---------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/analysis/tests/algorithms_spark/test_timeseriesspark.py b/analysis/tests/algorithms_spark/test_timeseriesspark.py
index bbb1a32..fe6d1fe 100644
--- a/analysis/tests/algorithms_spark/test_timeseriesspark.py
+++ b/analysis/tests/algorithms_spark/test_timeseriesspark.py
@@ -136,7 +136,7 @@ def test_calc_average_on_day():
         tile_service.get_bounding_box.return_value = box(-90, -45, 90, 45)
         tile_service.get_min_time.return_value = 1627490285
         tile_service.get_max_time.return_value = 1627490285
-        tile_service.get_tiles_bounded_by_polygon.return_value = [test_tile]
+        tile_service.get_tiles_bounded_by_box.return_value = [test_tile]
         tile_service.mask_tiles_to_polygon.return_value = [test_tile]
         return tile_service_factory
 
@@ -147,7 +147,7 @@ def test_calc_average_on_day():
         pass
 
     # Spark tile format: (polygon string, ds name, list of time stamps, fill value)
-    spark_tile = ('POLYGON((-34.98 29.54, -30.1 29.54, -30.1 31.00, -34.98 31.00, -34.98 29.54))', 
+    spark_tile = (wkt.loads('POLYGON((-34.98 29.54, -30.1 29.54, -30.1 31.00, -34.98 31.00, -34.98 29.54))'), 
                     'dataset', timestamps, -9999.)
 
     avg_args = dict(
diff --git a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
index 7740f53..0287592 100644
--- a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
+++ b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
@@ -449,7 +449,7 @@ class TimeSeriesResults(NexusResults):
 
 def spark_driver(daysinrange, bounding_polygon, ds, tile_service_factory, metrics_callback, normalize_dates, fill=-9999.,
                  spark_nparts=1, sc=None):
-    nexus_tiles_spark = [(bounding_polygon.wkt, ds,
+    nexus_tiles_spark = [(bounding_polygon, ds,
                           list(daysinrange_part), fill)
                          for daysinrange_part
                          in np.array_split(daysinrange, spark_nparts)]
@@ -470,18 +470,22 @@ def calc_average_on_day(tile_service_factory, metrics_callback, normalize_dates,
     from pytz import timezone
     ISO_8601 = '%Y-%m-%dT%H:%M:%S%z'
 
-    (bounding_wkt, dataset, timestamps, fill) = tile_in_spark
+    (bounding_polygon, dataset, timestamps, fill) = tile_in_spark
     if len(timestamps) == 0:
         return []
     tile_service = tile_service_factory()
-    ds1_nexus_tiles = \
-        tile_service.get_tiles_bounded_by_polygon(shapely.wkt.loads(bounding_wkt),
-                                                  dataset,
-                                                  timestamps[0],
-                                                  timestamps[-1],
-                                                  rows=5000,
-                                                  metrics_callback=metrics_callback)
 
+    ds1_nexus_tiles = \
+        tile_service.get_tiles_bounded_by_box(bounding_polygon.bounds[1], 
+                                            bounding_polygon.bounds[3],
+                                            bounding_polygon.bounds[0],
+                                            bounding_polygon.bounds[2],
+                                            dataset,
+                                            timestamps[0],
+                                            timestamps[-1],
+                                            rows=5000,
+                                            metrics_callback=metrics_callback)
+    
     calculation_start = datetime.now()
 
     tile_dict = {}