in analysis/webservice/algorithms/doms/MatchupQuery.py [0:0]
def calc(self, computeOptions, **args):
primary = computeOptions.get_argument("primary", None)
matchup = computeOptions.get_argument("matchup", None)
startTime = computeOptions.get_argument("s", None)
endTime = computeOptions.get_argument("e", None)
bbox = computeOptions.get_argument("b", None)
timeTolerance = computeOptions.get_float_arg("tt")
depth_min = computeOptions.get_float_arg("depthMin", default=None)
depth_max = computeOptions.get_float_arg("depthMax", default=None)
radiusTolerance = computeOptions.get_float_arg("rt")
platforms = computeOptions.get_argument("platforms", None)
if primary is None or len(primary) == 0:
raise Exception("No primary dataset specified")
if matchup is None or len(matchup) == 0:
raise Exception("No matchup datasets specified")
start = self._now()
primarySpec = self.getDataSourceByName(primary)
if primarySpec is None:
raise Exception("Specified primary dataset not found using identifier '%s'" % primary)
primaryData, bounds = self.fetchData([primarySpec], startTime, endTime, bbox, depth_min, depth_max, platforms)
primaryContext = MatchupContext(primaryData)
matchupIds = matchup.split(",")
for matchupId in matchupIds:
matchupSpec = self.getDataSourceByName(matchupId)
if matchupSpec is not None: # Then it's in the in-situ configuration
proc = InsituDatasetProcessor(primaryContext, matchupSpec, startTime, endTime, bbox, depth_min,
depth_max,
platforms, timeTolerance, radiusTolerance)
proc.start()
else: # We assume it to be a Nexus tiled dataset
'''
Single Threaded at the moment...
'''
daysinrange = self._get_tile_service().find_days_in_range_asc(bounds.south, bounds.north, bounds.west,
bounds.east, matchupId,
self.__parseDatetime(startTime) / 1000,
self.__parseDatetime(endTime) / 1000)
tilesByDay = {}
for dayTimestamp in daysinrange:
ds1_nexus_tiles = self._get_tile_service().get_tiles_bounded_by_box_at_time(bounds.south, bounds.north,
bounds.west, bounds.east,
matchupId, dayTimestamp)
# print "***", type(ds1_nexus_tiles)
# print ds1_nexus_tiles[0].__dict__
tilesByDay[dayTimestamp] = ds1_nexus_tiles
primaryContext.processGridded(tilesByDay, matchupId, radiusTolerance, timeTolerance)
matches, numMatches = primaryContext.getFinal(len(matchupIds))
end = self._now()
args = {
"primary": primary,
"matchup": matchupIds,
"startTime": startTime,
"endTime": endTime,
"bbox": bbox,
"timeTolerance": timeTolerance,
"depthMin": depth_min,
"depthMax": depth_max,
"radiusTolerance": radiusTolerance,
"platforms": platforms
}
details = {
"timeToComplete": (end - start),
"numInSituRecords": primaryContext.insituCount,
"numInSituMatched": primaryContext.insituMatches,
"numGriddedChecked": primaryContext.griddedCount,
"numGriddedMatched": primaryContext.griddedMatched
}
with ResultsStorage.ResultsStorage() as resultsStorage:
execution_id = resultsStorage.insertResults(results=matches, params=args, stats=details, startTime=start,
completeTime=end, userEmail="")
return BaseDomsHandler.DomsQueryResults(results=matches, args=args, details=details, bounds=None, count=None,
computeOptions=None, executionId=execution_id)