Skip to content

Commit

Permalink
Improvement of interface post processor performance (#746)
Browse files Browse the repository at this point in the history
* update dict converstion in DataSet, fix HistorySetSampling

* update test and regold for issue #739

* remove unused xml files

* PointSet is handled differently in the _convertToDict of DataSets
  • Loading branch information
wangcj05 authored and alfoa committed Sep 6, 2018
1 parent d42b144 commit 2e456ca
Show file tree
Hide file tree
Showing 35 changed files with 124 additions and 718 deletions.
39 changes: 22 additions & 17 deletions framework/DataObjects/DataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,25 +998,30 @@ def _convertToDict(self):
dataDict['dims'] = self.getDimensions()
dataDict['metadata'] = self.getMeta(general=True)
# main data
## initialize with np arrays of objects
dataDict['data'] = dict((var,np.zeros(self.size,dtype=object)) for var in self.vars+self.indexes)
## loop over realizations to get distinct values without NaNs
for var in self.vars:
# how we get and store variables depends on the dimensionality of the variable
dims=self.getDimensions(var)[var]
# if scalar (no dims and not an index), just grab the values
if len(dims)==0 and var not in self.indexes:
if self.type == "PointSet":
## initialize with np arrays of objects
dataDict['data'] = dict((var,np.zeros(self.size,dtype=object)) for var in self.vars)
for var in self.vars:
dataDict['data'][var] = self.asDataset()[var].values
continue
# otherwise, need to remove NaNs, so loop over slices
else:
dataDict['data'] = dict((var,np.zeros(self.size,dtype=object)) for var in self.vars+self.indexes)
# need to remove NaNs, so loop over slices
for s,rlz in enumerate(self.sliceByIndex(self.sampleTag)):
# get data specific to this var for this realization (slice)
data = rlz[var]
# need to drop indexes for which no values are present
for index in dims:
data = data.dropna(index)
dataDict['data'][index][s] = data[index].values
dataDict['data'][var][s] = data.values
## loop over realizations to get distinct values without NaNs
for var in self.vars:
# how we get and store variables depends on the dimensionality of the variable
dims=self.getDimensions(var)[var]
# if scalar (no dims and not an index), just grab the values
if len(dims)==0 and var not in self.indexes:
dataDict['data'][var] = self.asDataset()[var].values
continue
# get data specific to this var for this realization (slice)
data = rlz[var]
# need to drop indexes for which no values are present
for index in dims:
data = data.dropna(index)
dataDict['data'][index][s] = data[index].values
dataDict['data'][var][s] = data.values
return dataDict

def _convertToXrDataset(self):
Expand Down
3 changes: 2 additions & 1 deletion framework/PostProcessorFunctions/HistorySetSampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def run(self,inputDic):
self.raiseAnError(IOError, 'HistorySetSampling Interfaced Post-Processor ' + str(self.name) + ' : not recognized samplingType')

for var in outData.keys():
outputDic['data'][var] = np.zeros(inputDic['numberRealizations'], dtype=object)
if hist == 0:
outputDic['data'][var] = np.zeros(inputDic['numberRealizations'], dtype=object)
outputDic['data'][var][hist] = outData[var]

if 'ProbabilityWeight' in inputDic['data'].keys():
Expand Down
1 change: 1 addition & 0 deletions framework/PostProcessors/InterfacedPostProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def run(self, inputIn):
'" : The input object "'+ inp.name +'" provided is of the wrong type. Got "'+
inp.type + '" but expected "'+self.returnFormat("input") + '"!')
inputDic= self.inputToInternal(inputIn)
self.raiseADebug('InterfacedPostProcessor Post-Processor '+ self.name +' : start to run')
outputDic = self.postProcessor.run(inputDic)
return outputDic

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
y,x,z,time
4.34359778869,3.24346738646,4.15626305329,0.0
8.70873346803,4.54560146877,4.74821383001,0.0544444444444
14.9350741187,7.5098172182,7.3944487416,0.108888888889
22.9312220448,12.3226460228,15.3278350715,0.163333333333
26.2689310028,18.0422627229,32.5071756938,0.217777777778
11.6874705955,19.4888099493,49.5699281169,0.272222222222
-8.36348704689,11.6636017187,45.4112588876,0.326666666667
-13.3433117535,1.49496346427,35.2325304154,0.381111111111
-12.3516934344,-4.84420932516,31.3951750805,0.435555555556
-10.6857759075,-7.79953251639,30.8501670182,0.49
time,x,y,z
0.0,3.24346738646,4.34359778869,4.15626305329
0.0544444444444,4.54560144726,8.70873348729,4.74821381305
0.108888888889,7.50981721821,14.9350741187,7.3944487416
0.163333333333,12.3226460228,22.9312220448,15.3278350715
0.217777777778,18.0422627229,26.2689310028,32.5071756938
0.272222222222,19.4888099493,11.6874705955,49.5699281169
0.326666666667,11.6636017187,-8.36348704689,45.4112588876
0.381111111111,1.49496346427,-13.3433117535,35.2325304154
0.435555555556,-4.84420933392,-12.3516934332,31.3951750587
0.49,-7.79953251639,-10.6857759075,30.8501670182

This file was deleted.

Loading

0 comments on commit 2e456ca

Please sign in to comment.