fgreg commented on a change in pull request #61: SDAP-105 DOMS matchup netcdf 
and csv generation
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/61#discussion_r243467077
 
 

 ##########
 File path: analysis/webservice/algorithms/doms/BaseDomsHandler.py
 ##########
 @@ -560,165 +392,245 @@ def __addNetCDFConstants(dataset):
         dataset.publisher_name = "NASA PO.DAAC"
         dataset.publisher_email = "pod...@podaac.jpl.nasa.gov"
         dataset.publisher_url = "https://podaac.jpl.nasa.gov";
-        dataset.acknowledgment = "DOMS is a NASA/AIST-funded project.  Grant 
number ####."
-
-
-class DomsNetCDFFormatterAlt:
-    @staticmethod
-    def create(executionId, results, params, details):
-        t = tempfile.mkstemp(prefix="doms_", suffix=".nc")
-        tempFileName = t[1]
-
-        dataset = Dataset(tempFileName, "w", format="NETCDF4")
-
-        dataset.matchID = executionId
-        dataset.Matchup_TimeWindow = params["timeTolerance"]
-        dataset.Matchup_TimeWindow_Units = "hours"
-
-        dataset.time_coverage_start = 
datetime.fromtimestamp(params["startTime"] / 1000).strftime('%Y%m%d %H:%M:%S')
-        dataset.time_coverage_end = datetime.fromtimestamp(params["endTime"] / 
1000).strftime('%Y%m%d %H:%M:%S')
-        dataset.depth_min = params["depthMin"]
-        dataset.depth_max = params["depthMax"]
-        dataset.platforms = params["platforms"]
-
-        dataset.Matchup_SearchRadius = params["radiusTolerance"]
-        dataset.Matchup_SearchRadius_Units = "m"
-
-        dataset.bounding_box = params["bbox"]
-        dataset.primary = params["primary"]
-        dataset.secondary = ",".join(params["matchup"])
-
-        dataset.Matchup_ParameterPrimary = params["parameter"] if "parameter" 
in params else ""
-
-        dataset.time_coverage_resolution = "point"
-
-        bbox = geo.BoundingBox(asString=params["bbox"])
-        dataset.geospatial_lat_max = bbox.north
-        dataset.geospatial_lat_min = bbox.south
-        dataset.geospatial_lon_max = bbox.east
-        dataset.geospatial_lon_min = bbox.west
-        dataset.geospatial_lat_resolution = "point"
-        dataset.geospatial_lon_resolution = "point"
-        dataset.geospatial_lat_units = "degrees_north"
-        dataset.geospatial_lon_units = "degrees_east"
-        dataset.geospatial_vertical_min = 0.0
-        dataset.geospatial_vertical_max = params["radiusTolerance"]
-        dataset.geospatial_vertical_units = "m"
-        dataset.geospatial_vertical_resolution = "point"
-        dataset.geospatial_vertical_positive = "down"
-
-        dataset.time_to_complete = details["timeToComplete"]
-        dataset.num_insitu_matched = details["numInSituMatched"]
-        dataset.num_gridded_checked = details["numGriddedChecked"]
-        dataset.num_gridded_matched = details["numGriddedMatched"]
-        dataset.num_insitu_checked = details["numInSituChecked"]
-
-        dataset.date_modified = datetime.now().strftime('%Y%m%d %H:%M:%S')
-        dataset.date_created = datetime.now().strftime('%Y%m%d %H:%M:%S')
-
-        DomsNetCDFFormatterAlt.__addNetCDFConstants(dataset)
-
-        satelliteGroup = dataset.createGroup("SatelliteData")
-        satelliteWriter = DomsNetCDFValueWriter(satelliteGroup)
-
-        insituGroup = dataset.createGroup("InsituData")
-        insituWriter = DomsNetCDFValueWriter(insituGroup)
-
-        matches = DomsNetCDFFormatterAlt.__writeResults(results, 
satelliteWriter, insituWriter)
-
-        satelliteWriter.commit()
-        insituWriter.commit()
-
-        satDim = dataset.createDimension("satellite_ids", size=None)
-        satVar = dataset.createVariable("satellite_ids", "i4", 
("satellite_ids",), chunksizes=(2048,),
-                                        fill_value=-32767)
-
-        satVar[:] = [f[0] for f in matches]
-
-        insituDim = dataset.createDimension("insitu_ids", size=None)
-        insituVar = dataset.createVariable("insitu_ids", "i4", 
("insitu_ids",), chunksizes=(2048,),
-                                           fill_value=-32767)
-        insituVar[:] = [f[1] for f in matches]
-
-        dataset.close()
-
-        f = open(tempFileName, "rb")
-        data = f.read()
-        f.close()
-        os.unlink(tempFileName)
-        return data
+        dataset.acknowledgment = "DOMS is a NASA/AIST-funded project. NRA 
NNH14ZDA001N."
 
     @staticmethod
     def __writeResults(results, satelliteWriter, insituWriter):
         ids = {}
         matches = []
-
         insituIndex = 0
 
         for r in range(0, len(results)):
             result = results[r]
-            satelliteWriter.write(result)
+            satelliteWriter.addData(result)
             for match in result["matches"]:
                 if match["id"] not in ids:
 
 Review comment:
   Now that I wrote that and think about it some more that makes sense. We only 
write the data once but we're keeping track of the matches in the `matches` 
array. Totally makes sense, but maybe add comment here in the code to clarify 
the intent?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to