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

rkk 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 219be54  SDAP-479: Fix cdmssubset failing if standard/variable name 
not available (#268)
219be54 is described below

commit 219be54607b123fb9273c0b9806269bebd340c4f
Author: Riley Kuttruff <[email protected]>
AuthorDate: Thu Sep 7 13:50:19 2023 -0700

    SDAP-479: Fix cdmssubset failing if standard/variable name not available 
(#268)
    
    * SDAP-479: Subset will not fail is standard/variable name not given (CSV)
    
    * Raise error if neither name is defined
    
    ---------
    
    Co-authored-by: rileykk <[email protected]>
---
 CHANGELOG.md                                     |  1 +
 analysis/webservice/algorithms/doms/subsetter.py | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e8712e8..dee3ded 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@ and this project adheres to [Semantic 
Versioning](https://semver.org/spec/v2.0.0
 ### Fixed
 - SDAP-474: Fixed bug in CSV attributes where secondary dataset would be 
rendered as comma separated characters
 - SDAP-475: Bug fixes for `/timeSeriesSpark` and `/timeAvgMapSpark`
+- SDAP-479: Fixed `/cdmssubset` failure for variables without specified 
standard_name. 
 - Status code for results endpoint if execution id is not found fixed to be 
`404` instead of `500`.
 ### Security
 
diff --git a/analysis/webservice/algorithms/doms/subsetter.py 
b/analysis/webservice/algorithms/doms/subsetter.py
index 0dca80f..bf63fc8 100644
--- a/analysis/webservice/algorithms/doms/subsetter.py
+++ b/analysis/webservice/algorithms/doms/subsetter.py
@@ -203,14 +203,25 @@ class 
DomsResultsRetrievalHandler(BaseDomsHandler.BaseDomsQueryCalcHandler):
 
             tile = tile[0]
 
+            def get_best_name(variable):
+                if variable.standard_name:
+                    return variable.standard_name
+                elif variable.variable_name:
+                    return variable.variable_name
+                else:
+                    raise NexusProcessingException(
+                        reason=f'Variable in subsetted data does not have 
defined name',
+                        code=500
+                    )
+
             for nexus_point in tile.nexus_point_generator():
                 if tile.is_multi:
                     data_points = {
-                        tile.variables[idx].standard_name: 
nexus_point.data_vals[idx]
+                        get_best_name(tile.variables[idx]): 
nexus_point.data_vals[idx]
                         for idx in range(len(tile.variables))
                     }
                 else:
-                    data_points = {tile.variables[0].standard_name: 
nexus_point.data_vals}
+                    data_points = {get_best_name(tile.variables[0]): 
nexus_point.data_vals}
                 data.append({
                     'latitude': nexus_point.latitude,
                     'longitude': nexus_point.longitude,

Reply via email to