You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by rk...@apache.org on 2024/07/10 22:53:21 UTC
(sdap-nexus) 25/46: Simple CSV renderer - point cloud only
This is an automated email from the ASF dual-hosted git repository.
rkk pushed a commit to branch tmp-stv
in repository https://gitbox.apache.org/repos/asf/sdap-nexus.git
commit 844e1d85bda27a9aaba866f2e3d7a1ad7c0e5a7b
Author: rileykk <ri...@jpl.nasa.gov>
AuthorDate: Thu Dec 21 11:31:33 2023 -0800
Simple CSV renderer - point cloud only
---
analysis/webservice/algorithms/Tomogram3D.py | 14 ++++++++++++--
analysis/webservice/webmodel/NexusResults.py | 1 -
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/analysis/webservice/algorithms/Tomogram3D.py b/analysis/webservice/algorithms/Tomogram3D.py
index cc3d97c..686dc45 100644
--- a/analysis/webservice/algorithms/Tomogram3D.py
+++ b/analysis/webservice/algorithms/Tomogram3D.py
@@ -69,7 +69,7 @@ class Tomogram3D(NexusCalcHandler):
"output": {
"name": "Output format",
"type": "string",
- "description": "Desired output format. Must be either \"PNG\" or \"GIF\". Required."
+ "description": "Desired output format. Must be one of \"PNG\", \"GIF\", or \"CSV\". Required."
},
"orbit": {
"name": "Orbit settings",
@@ -144,7 +144,7 @@ class Tomogram3D(NexusCalcHandler):
output = compute_options.get_argument('output', None)
- if output not in ['PNG', 'GIF']:
+ if output not in ['PNG', 'GIF', 'CSV']:
raise NexusProcessingException(reason=f'Missing or invalid required parameter: output = {output}', code=400)
orbit_params = compute_options.get_argument('orbit', '30,10')
@@ -628,3 +628,13 @@ class Tomogram3DResults(NexusResults):
buffer.seek(0)
return buffer.read()
+
+ def toCSV(self):
+ df = self.results()[['lon', 'lat', 'elevation', 'tomo_value']]
+
+ buf = BytesIO()
+
+ df.to_csv(buf, header=False, index=False)
+
+ buf.seek(0)
+ return buf.read()
diff --git a/analysis/webservice/webmodel/NexusResults.py b/analysis/webservice/webmodel/NexusResults.py
index 42c1ca0..8b0be6a 100644
--- a/analysis/webservice/webmodel/NexusResults.py
+++ b/analysis/webservice/webmodel/NexusResults.py
@@ -107,7 +107,6 @@ class NexusResults:
self.__meta = self.__meta # Risky
self._extendMeta(self.__meta, minLat, maxLat, minLon, maxLon, ds, startTime, endTime)
- @staticmethod
def filename(self):
return 'download'