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

nchung 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 7661ac9  SDAP-407: Return depth in CSV and NETCDF matchup outputs 
(#210)
7661ac9 is described below

commit 7661ac9e842c9d5987b45d2aeae4f5b9ccd35cca
Author: Stepheny Perez <[email protected]>
AuthorDate: Thu Oct 27 09:11:56 2022 -0700

    SDAP-407: Return depth in CSV and NETCDF matchup outputs (#210)
    
    * Store depth in database along with results
    
    * Fixed NetCDF converter so depth is present
    
    * Updated changelog
---
 CHANGELOG.md                                              |  1 +
 analysis/webservice/algorithms/doms/BaseDomsHandler.py    |  2 +-
 analysis/webservice/algorithms/doms/DomsInitialization.py |  1 +
 analysis/webservice/algorithms/doms/ResultsStorage.py     | 13 +++++++------
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95ef511..2d47326 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ and this project adheres to [Semantic 
Versioning](https://semver.org/spec/v2.0.0
 - SDAP-405: Added SPURS AWS insitu api to matchup and new platform values to 
OpenAPI matchup spec
 - RabbitMQ monitor script used in Docker quickstart guide
 - Added new option for NCAR so either NCAR or JPL Insitu API can be specified
+- SDAP-407: Added depth to `/domsresults` endpoint
 ### Changed
 - SDAP-390: Changed `/doms` to `/cdms` and `doms_reader.py` to `cdms_reader.py`
 - domslist endpoint points to AWS insitu instead of doms insitu
diff --git a/analysis/webservice/algorithms/doms/BaseDomsHandler.py 
b/analysis/webservice/algorithms/doms/BaseDomsHandler.py
index 2bcb728..904732b 100644
--- a/analysis/webservice/algorithms/doms/BaseDomsHandler.py
+++ b/analysis/webservice/algorithms/doms/BaseDomsHandler.py
@@ -455,7 +455,7 @@ class DomsNetCDFValueWriter:
         timeVar[:] = self.time
 
         # Add depth variable, if present
-        if self.depth:
+        if self.depth and any(self.depth):
             depthVar = self.group.createVariable('depth', 'f4', ('dim',), 
fill_value=-32767.0)
             self.__enrichDepth(depthVar, self.__calcMin(self.depth), 
max(self.depth))
             depthVar[:] = self.depth
diff --git a/analysis/webservice/algorithms/doms/DomsInitialization.py 
b/analysis/webservice/algorithms/doms/DomsInitialization.py
index d1ed5a5..591c5f6 100644
--- a/analysis/webservice/algorithms/doms/DomsInitialization.py
+++ b/analysis/webservice/algorithms/doms/DomsInitialization.py
@@ -164,6 +164,7 @@ class DomsInitializer:
               platform text,
               device text,
               measurement_values map<text, decimal>,
+              depth decimal,
               PRIMARY KEY (execution_id, is_primary, id)
             );
         """
diff --git a/analysis/webservice/algorithms/doms/ResultsStorage.py 
b/analysis/webservice/algorithms/doms/ResultsStorage.py
index a228737..f0a18eb 100644
--- a/analysis/webservice/algorithms/doms/ResultsStorage.py
+++ b/analysis/webservice/algorithms/doms/ResultsStorage.py
@@ -156,9 +156,9 @@ class ResultsStorage(AbstractResultsContainer):
 
         cql = """
            INSERT INTO doms_data
-                (id, execution_id, value_id, primary_value_id, x, y, 
source_dataset, measurement_time, platform, device, measurement_values, 
is_primary)
+                (id, execution_id, value_id, primary_value_id, x, y, 
source_dataset, measurement_time, platform, device, measurement_values, 
is_primary, depth)
            VALUES
-                (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+                (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
         """
         insertStatement = self._session.prepare(cql)
         batch = BatchStatement()
@@ -189,9 +189,9 @@ class ResultsStorage(AbstractResultsContainer):
             result["platform"] if "platform" in result else None,
             result["device"] if "device" in result else None,
             dataMap,
-            1 if primaryId is None else 0
-        )
-                  )
+            1 if primaryId is None else 0,
+            result["depth"]
+        ))
 
         n = 0
         if "matches" in result:
@@ -283,7 +283,8 @@ class ResultsRetrieval(AbstractResultsContainer):
                 "source": row.source_dataset,
                 "device": row.device,
                 "platform": row.platform,
-                "time": row.measurement_time.replace(tzinfo=UTC)
+                "time": row.measurement_time.replace(tzinfo=UTC),
+                "depth": row.depth
             }
         for key in row.measurement_values:
             value = float(row.measurement_values[key])

Reply via email to