Skip to content

Commit f40312b

Browse files
committed
bug fixes
1 parent aac2132 commit f40312b

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

MAPIT/core/Preprocessing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def FormatInput(rawInput,rawInputTimes,rawInventory,rawInventoryTimes,rawOutput,
269269
#of the location then we just remove that
270270
#set as it's not applicable anymore
271271

272-
272+
allIdxToRemove=[[], [], []]
273273
if dataOffset > 0:
274274

275275
#assumes raws are lists based on location
@@ -292,6 +292,7 @@ def FormatInput(rawInput,rawInputTimes,rawInventory,rawInventoryTimes,rawOutput,
292292
if len(idxToRemove) > 0:
293293
rawInput = [v for i, v in enumerate(rawInput) if i not in idxToRemove]
294294
rawInputTimes = [v for i, v in enumerate(rawInputTimes) if i not in idxToRemove]
295+
allIdxToRemove[0] = idxToRemove
295296

296297
idxToRemove=[]
297298
for JR in range(len(rawInventory)):
@@ -308,10 +309,12 @@ def FormatInput(rawInput,rawInputTimes,rawInventory,rawInventoryTimes,rawOutput,
308309
else:
309310
print("Cutoff exceeds total input time, removing inventory")
310311
idxToRemove.append(JR)
312+
311313

312314
if len(idxToRemove) > 0:
313315
rawInventory = [v for i, v in enumerate(rawInventory) if i not in idxToRemove]
314316
rawInventoryTimes = [v for i, v in enumerate(rawInventoryTimes) if i not in idxToRemove]
317+
allIdxToRemove[1] = idxToRemove
315318

316319
idxToRemove=[]
317320
for JR in range(len(rawOutput)):
@@ -333,14 +336,15 @@ def FormatInput(rawInput,rawInputTimes,rawInventory,rawInventoryTimes,rawOutput,
333336
if len(idxToRemove) > 0:
334337
rawOutput = [v for i, v in enumerate(rawOutput) if i not in idxToRemove]
335338
rawOutputTimes = [v for i, v in enumerate(rawOutputTimes) if i not in idxToRemove]
339+
allIdxToRemove[2] = idxToRemove
336340

337341

338342

339343

340344

341345

342346
return rawInput, rawInputTimes, rawInventory, rawInventoryTimes, \
343-
rawOutput, rawOutputTimes
347+
rawOutput, rawOutputTimes, allIdxToRemove
344348

345349
def calcBatchError(calibrationPeriod, ErrorMatrix, batchSize, times, loc, dim0shape):
346350
"""
@@ -366,7 +370,7 @@ def calcBatchError(calibrationPeriod, ErrorMatrix, batchSize, times, loc, dim0sh
366370

367371
# If calibration period is not provided, calculate a single
368372
# set of systematic errors
369-
if calibrationPeriod[loc] is None:
373+
if calibrationPeriod is None or (isinstance(calibrationPeriod, list) and calibrationPeriod[loc] is None):
370374
if ErrorMatrix[loc,1].sum() == 0:
371375
# If systematic RSD is zero, set systematic error variates to zero
372376
sysRSD = np.zeros((batchSize,1,1))

MAPIT/core/StatsProcessor.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self,rawInput, rawInventory, rawOutput, rawInputTimes, rawInventory
121121

122122
self.processedInput, self.processedInputTimes, \
123123
self.processedInventory, self.processedInventoryTimes, \
124-
self.processedOutput, self.processedOutputTimes = Preprocessing.FormatInput(
124+
self.processedOutput, self.processedOutputTimes, idxRemoved = Preprocessing.FormatInput(
125125
rawInput = rawInput,
126126
rawInventory = rawInventory,
127127
rawOutput = rawOutput,
@@ -133,6 +133,22 @@ def __init__(self,rawInput, rawInventory, rawOutput, rawInputTimes, rawInventory
133133
dataOffset = dataOffset,
134134
rebaseToZero = rebaseToZero)
135135

136+
if len(idxRemoved[0]) != 0:
137+
idxs = idxRemoved[0]
138+
self.inputCalibrationPeriod = [v for i, v in enumerate( self.inputCalibrationPeriod) if i not in idxs]
139+
self.inputTypes = [v for i, v in enumerate(self.inputTypes) if i not in idxs]
140+
141+
if len(idxRemoved[1]) != 0:
142+
idxs = idxRemoved[1]
143+
self.inventoryCalibrationPeriod = [v for i, v in enumerate( self.inventoryCalibrationPeriod) if i not in idxs]
144+
145+
if len(idxRemoved[2]) != 0:
146+
idxs = idxRemoved[2]
147+
self.outputCalibrationPeriod = [v for i, v in enumerate( self.outputCalibrationPeriod) if i not in idxs]
148+
self.outputTypes = [v for i, v in enumerate(self.outputTypes) if i not in idxs]
149+
150+
151+
136152
self.inputAppliedError = None
137153
self.inventoryAppliedError = None
138154
self.outputAppliedError = None
@@ -244,6 +260,8 @@ def calcMUF(self):
244260
processedInputTimes = self.processedInputTimes,
245261
processedInventoryTimes = self.processedInventoryTimes,
246262
processedOutputTimes = self.processedOutputTimes,
263+
inputTypes=self.inputTypes,
264+
outputTypes=self.outputTypes,
247265
MBP = self.mbaTime,
248266
doTQDM=self.doTQDM,
249267
ispar = True))
@@ -350,6 +368,8 @@ def calcActiveInventory(self):
350368
processedInputTimes = self.processedInputTimes,
351369
processedInventoryTimes = self.processedInventoryTimes,
352370
processedOutputTimes = self.processedOutputTimes,
371+
inputTypes=self.inputTypes,
372+
outputTypes=self.outputTypes,
353373
MBP = self.mbaTime,
354374
doTQDM=self.doTQDM,
355375
ispar = True))
@@ -466,6 +486,8 @@ def calcSEMUF(self):
466486
processedInputTimes = self.processedInputTimes,
467487
processedInventoryTimes = self.processedInventoryTimes,
468488
processedOutputTimes = self.processedOutputTimes,
489+
inputTypes=self.inputTypes,
490+
outputTypes=self.outputTypes,
469491
MBP = self.mbaTime,
470492
ErrorMatrix = self.totalErrorMatrix,
471493
doTQDM=False, #self.doTQDM
@@ -587,6 +609,8 @@ def calcSITMUF(self):
587609
processedInputTimes = self.processedInputTimes,
588610
processedInventoryTimes = self.processedInventoryTimes,
589611
processedOutputTimes = self.processedOutputTimes,
612+
inputTypes=self.inputTypes,
613+
outputTypes=self.outputTypes,
590614
MBP = self.mbaTime,
591615
MUF = MUFslice,
592616
ErrorMatrix = self.totalErrorMatrix,
@@ -677,15 +701,15 @@ def calcErrors(self):
677701
self.inputAppliedError = Preprocessing.SimErrors(
678702
rawData = self.processedInput,
679703
times = self.processedInputTimes,
680-
calibrationPeriod= self.inputCalibrationPeriod,
704+
calibrationPeriod = self.inputCalibrationPeriod,
681705
ErrorMatrix = self.inputErrorMatrix,
682706
iterations = self.IT,
683707
GUIObject = self.GUIObject)
684708

685709
self.inventoryAppliedError = Preprocessing.SimErrors(
686710
rawData = self.processedInventory,
687711
times = self.processedInventoryTimes,
688-
calibrationPeriod=self.inventoryCalibrationPeriod,
712+
calibrationPeriod = self.inventoryCalibrationPeriod,
689713
ErrorMatrix = self.inventoryErrorMatrix,
690714
iterations = self.IT,
691715
GUIObject = self.GUIObject)
@@ -694,7 +718,7 @@ def calcErrors(self):
694718
self.outputAppliedError = Preprocessing.SimErrors(
695719
rawData = self.processedOutput,
696720
times = self.processedOutputTimes,
697-
calibrationPeriod=self.outputCalibrationPeriod,
721+
calibrationPeriod = self.outputCalibrationPeriod,
698722
ErrorMatrix = self.outputErrorMatrix,
699723
iterations = self.IT,
700724
GUIObject = self.GUIObject)
@@ -707,20 +731,26 @@ def calcErrors(self):
707731
for i in range(self.ntasks):
708732
tasklist.append(gfunc.remote(
709733
rawData = self.processedInput,
734+
times = self.processedInputTimes,
735+
calibrationPeriod = self.inputCalibrationPeriod,
710736
ErrorMatrix = self.inputErrorMatrix,
711737
iterations = self.nbatch,
712738
batchSize = self.nbatch,
713739
dopar=True))
714740

715741
tasklist.append(gfunc.remote(
716742
rawData = self.processedInventory,
743+
times = self.processedInventoryTimes,
744+
calibrationPeriod = self.inventoryCalibrationPeriod,
717745
ErrorMatrix = self.inventoryErrorMatrix,
718746
iterations = self.nbatch,
719747
batchSize = self.nbatch,
720748
dopar=True))
721749

722750
tasklist.append(gfunc.remote(
723751
rawData = self.processedOutput,
752+
times = self.processedOutputTimes,
753+
calibrationPeriod = self.outputCalibrationPeriod,
724754
ErrorMatrix = self.outputErrorMatrix,
725755
iterations = self.nbatch,
726756
batchSize = self.nbatch,

MAPIT/core/StatsTests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ def MUF(inputAppliedError,processedInputTimes,inventoryAppliedError,processedInv
221221
endIdx = np.abs(processedInventoryTimes[j].reshape((-1,)) -
222222
MBP * i).argmin()
223223

224-
if i == 1:
225-
MUF[:, i * MBP:(i + 1) * MBP] -= \
226-
(inventoryAppliedError[j][:, endIdx])[:, np.newaxis]
224+
# if i == 1:
225+
# MUF[:, i * MBP:(i + 1) * MBP] -= \
226+
# (inventoryAppliedError[j][:, endIdx])[:, np.newaxis]
227227

228-
else:
229-
MUF[:, i * MBP:(i + 1) * MBP] -= \
230-
(inventoryAppliedError[j][:, endIdx] - inventoryAppliedError[j][:, startIdx])[:, np.newaxis]
228+
# else:
229+
MUF[:, i * MBP:(i + 1) * MBP] -= \
230+
(inventoryAppliedError[j][:, endIdx] - inventoryAppliedError[j][:, startIdx])[:, np.newaxis]
231231

232232

233233

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
setup(
2121
name="MAPIT", # Required
22-
version="1.4.8-beta", # Required
22+
version="1.4.90-beta", # Required
2323
author="Nathan Shoman", # Optional
2424
author_email="nshoman@sandia.gov", # Optional
2525
install_requires = ["matplotlib","numpy","Pillow","tqdm","scipy","pyside6","ray[default]"],

0 commit comments

Comments
 (0)