Merge "Issue #1791 Implement bulk getGrids to improve performance. Change-Id: I13ed0e9c803444845c1b3a26600ec923fb7a6e74" into omaha_13.3.1
Former-commit-id: 437a30971b299965540d47f572ad83cd0d7df120
This commit is contained in:
commit
3b65608373
3 changed files with 77 additions and 22 deletions
|
@ -167,30 +167,17 @@ class Procedure (SmartScript.SmartScript):
|
|||
# any grids. We need to do this because the GFE caches the original
|
||||
# version of all grids and there's no way yet to turn this off.
|
||||
|
||||
minTDict = {}
|
||||
maxTDict = {}
|
||||
tDict = {}
|
||||
tdDict = {}
|
||||
|
||||
minTRList = self.getWEInventory("MinT")
|
||||
for tr in minTRList:
|
||||
grid = self.getGrids(MODEL, "MinT", LEVEL, tr, mode = "First")
|
||||
minTDict[tr] = grid
|
||||
minTDict = self.getGrids(MODEL, "MinT", LEVEL, minTRList, mode = "First")
|
||||
|
||||
maxTRList = self.getWEInventory("MaxT")
|
||||
for tr in maxTRList:
|
||||
grid = self.getGrids(MODEL, "MaxT", LEVEL, tr, mode = "First")
|
||||
maxTDict[tr] = grid
|
||||
maxTDict = self.getGrids(MODEL, "MaxT", LEVEL, maxTRList, mode = "First")
|
||||
|
||||
TTRList = self.getWEInventory("T")
|
||||
for tr in TTRList:
|
||||
grid = self.getGrids(MODEL, "T", LEVEL, tr, mode = "First")
|
||||
tDict[tr] = grid
|
||||
tDict = self.getGrids(MODEL, "T", LEVEL, TTRList, mode = "First")
|
||||
|
||||
TdTRList = self.getWEInventory("Td")
|
||||
for tr in TdTRList:
|
||||
grid = self.getGrids(MODEL, "Td", LEVEL, tr, mode = "First")
|
||||
tdDict[tr] = grid
|
||||
tdDict = self.getGrids(MODEL, "Td", LEVEL, TdTRList, mode = "First")
|
||||
|
||||
# get the all locks by other users, so we can detect they are locked
|
||||
# before attempting to modify them
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
# manualSendISC_manualMode
|
||||
# 01/30/13 1559 dgilling Fix TypeError in
|
||||
# getGridCellSwath().
|
||||
# Mar 13, 2013 1791 bsteffen Implement bulk getGrids to
|
||||
# improve performance.
|
||||
#
|
||||
########################################################################
|
||||
import types, string, time, sys
|
||||
|
@ -57,6 +59,7 @@ from java.util import Date
|
|||
from java.nio import FloatBuffer
|
||||
|
||||
from com.raytheon.uf.common.time import SimulatedTime
|
||||
from com.raytheon.uf.common.time import TimeRange as javaTimeRange
|
||||
from com.raytheon.uf.common.dataplugin.gfe.grid import Grid2DByte
|
||||
from com.raytheon.uf.common.dataplugin.gfe.grid import Grid2DFloat
|
||||
from com.raytheon.uf.common.dataplugin.gfe.discrete import DiscreteKey
|
||||
|
@ -355,7 +358,10 @@ class SmartScript(BaseTool.BaseTool):
|
|||
# e.g. "SFC", "MB350", "BL030"
|
||||
# x, y: integer coordinates
|
||||
# timeRange: Must be a special time range object such as
|
||||
# that passed in the argument list as GridTimeRange
|
||||
# that passed in the argument list as GridTimeRange or a list of time
|
||||
# range objects. If it is a list than the return value will be a dict
|
||||
# where the time range objects are keys and the result of getGrids
|
||||
# for each time range is the value.
|
||||
# mode: specifies how to handle the situation if multiple grids
|
||||
# are found within the given time range:
|
||||
# "TimeWtAverage": return time-weighted Average value
|
||||
|
@ -398,10 +404,19 @@ class SmartScript(BaseTool.BaseTool):
|
|||
|
||||
if isinstance(model, DatabaseID.DatabaseID):
|
||||
model = model.modelIdentifier()
|
||||
|
||||
|
||||
timeRangeList = None
|
||||
if isinstance(timeRange, TimeRange.TimeRange):
|
||||
timeRange = timeRange.toJavaObj()
|
||||
|
||||
elif isinstance(timeRange, list):
|
||||
timeRangeList = timeRange
|
||||
timeRangeArray = jep.jarray(len(timeRangeList), javaTimeRange)
|
||||
for i in xrange(len(timeRangeList)):
|
||||
tr = timeRangeList[i]
|
||||
if isinstance(tr, TimeRange.TimeRange):
|
||||
tr = tr.toJavaObj()
|
||||
timeRangeArray[i] = tr
|
||||
timeRange = timeRangeArray
|
||||
# if cache:
|
||||
# for cModel, cElement, cLevel, cMostRecent, cRange, cMode, cResult in \
|
||||
# self.__pythonGrids:
|
||||
|
@ -419,7 +434,17 @@ class SmartScript(BaseTool.BaseTool):
|
|||
"NoData", "No Weather Element for " + exprName)
|
||||
else:
|
||||
return None
|
||||
result = self.__cycler.getCorrespondingResult(parm, timeRange, mode)
|
||||
result = self.__cycler.getCorrespondingResult(parm, timeRange, mode)
|
||||
if timeRangeList is not None:
|
||||
retVal = {}
|
||||
for i in xrange(len(timeRangeList)):
|
||||
iresult = self._getGridsResult(timeRangeList[i], noDataError, mode, result[i])
|
||||
retVal[timeRangeList[i]] = iresult
|
||||
return retVal
|
||||
else:
|
||||
return self._getGridsResult(timeRange, noDataError, mode, result)
|
||||
|
||||
def _getGridsResult(self, timeRange, noDataError, mode, result):
|
||||
retVal = None
|
||||
if result is not None:
|
||||
if len(result) == 0:
|
||||
|
@ -1215,7 +1240,6 @@ class SmartScript(BaseTool.BaseTool):
|
|||
# color. If "on" is 0, turn off the highlight.
|
||||
parm = self.getParm(model, element, level)
|
||||
from com.raytheon.viz.gfe.core.msgs import HighlightMsg
|
||||
from com.raytheon.uf.common.time import TimeRange as javaTimeRange
|
||||
|
||||
trs = jep.jarray(1, javaTimeRange)
|
||||
trs[0] = timeRange.toJavaObj()
|
||||
|
|
|
@ -59,6 +59,8 @@ import com.raytheon.viz.gfe.core.parm.Parm;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 28, 2008 njensen Initial creation
|
||||
* Mar 13, 2013 1791 bsteffen Implement bulk getGrids to improve
|
||||
* performance.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -188,6 +190,48 @@ public class GridCycler {
|
|||
return getCorrespondingResult(argParm, timeRange, mode, dataMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the same basic function as getCorrespondingResult but operates
|
||||
* on an array of timeRanges and returns an array of data(one entry for each
|
||||
* corresponding timeRange).
|
||||
*
|
||||
* @param argParm
|
||||
* the parm to get grids for
|
||||
* @param timeRanges
|
||||
* the requested time ranges
|
||||
* @param mode
|
||||
* "TimeWtAverage", "Average", "Min", "Max", "Sum" -- time
|
||||
* weighted average, average, min, max, or sum of corresponding
|
||||
* grids
|
||||
* @return an IGridData[][] of the data
|
||||
* @throws GFEOperationFailedException
|
||||
*/
|
||||
public IGridData[][] getCorrespondingResult(Parm argParm,
|
||||
TimeRange[] timeRanges, String mode)
|
||||
throws GFEOperationFailedException {
|
||||
// first step is to determine which grids need to be populated.
|
||||
List<IGridData> grids = new ArrayList<IGridData>();
|
||||
for (TimeRange timeRange : timeRanges) {
|
||||
IGridData[] inv = argParm.getGridInventory(timeRange);
|
||||
for (IGridData data : inv) {
|
||||
if (!data.isPopulated()) {
|
||||
grids.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
// next step populate any unpopulated.
|
||||
if (!grids.isEmpty()) {
|
||||
argParm.populateGrids(grids);
|
||||
}
|
||||
// finally just process each range individually.
|
||||
IGridData[][] results = new IGridData[timeRanges.length][];
|
||||
for (int i = 0; i < timeRanges.length; i += 1) {
|
||||
results[i] = getCorrespondingResult(argParm, timeRanges[i],
|
||||
mode);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the given Numeric Python grid in the given parm and timeRange
|
||||
* masked by the given edit area
|
||||
|
|
Loading…
Add table
Reference in a new issue