You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by fg...@apache.org on 2018/09/18 17:40:07 UTC

[incubator-sdap-nexus] branch master updated: updated time series spark to use mean and iso times (#32)

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

fgreg 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 198ed8f  updated time series spark to use mean and iso times (#32)
198ed8f is described below

commit 198ed8f2eda95904527feb46af261cf7bc919f2e
Author: fgreg <fg...@gmail.com>
AuthorDate: Tue Sep 18 10:40:02 2018 -0700

    updated time series spark to use mean and iso times (#32)
---
 analysis/webservice/algorithms_spark/TimeSeriesSpark.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
index e89a00e..a24c2d5 100644
--- a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
+++ b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
@@ -505,6 +505,10 @@ def spark_driver(daysinrange, bounding_polygon, ds, fill=-9999., spark_nparts_ne
 
 def calc_average_on_day(tile_in_spark):
     import shapely.wkt
+    from datetime import datetime
+    from pytz import timezone
+    ISO_8601 = '%Y-%m-%dT%H:%M:%S%z'
+
     (bounding_wkt, dataset, timestamps, fill) = tile_in_spark
     if len(timestamps) == 0:
         return []
@@ -561,7 +565,8 @@ def calc_average_on_day(tile_in_spark):
             'mean': daily_mean,
             'cnt': data_count,
             'std': data_std,
-            'time': int(timeinseconds)
+            'time': int(timeinseconds),
+            'iso_time': datetime.utcfromtimestamp(int(timeinseconds)).replace(tzinfo=timezone('UTC')).strftime(ISO_8601)
         }
         stats_arr.append(stat)
     return stats_arr