summaryrefslogtreecommitdiff
path: root/lib/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/model.py')
-rw-r--r--lib/model.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/model.py b/lib/model.py
index 57507e7..192cea3 100644
--- a/lib/model.py
+++ b/lib/model.py
@@ -938,18 +938,26 @@ class PTAModel:
def get_substates(self):
states = self.states()
for k in self.by_param.keys():
- if k[0] == "TX":
+ if k[0] in states:
if self.pelt.needs_refinement(self.by_param[k]["power_traces"]):
- print(f"PELT: {k} needs refinement")
- penalty = self.pelt.get_penalty_value(
- self.by_param[k]["power_traces"]
- )
- print(
- f" we found {penalty[1]} changepoints with penalty {penalty[0]}"
- )
- self.pelt.calc_raw_states(
- self.by_param[k]["power_traces"], penalty[0]
+ logger.debug(f"PELT: {k} needs refinement")
+ # Assumption: All power traces for this parameter setting
+ # are similar, so determining the penalty for the first one
+ # is sufficient.
+ penalty, changepoints = self.pelt.get_penalty_and_changepoints(
+ self.by_param[k]["power_traces"][0]
)
+ if len(changepoints):
+ logger.debug(
+ f" we found {len(changepoints)} changepoints with penalty {penalty}"
+ )
+ self.pelt.calc_raw_states(
+ self.by_param[k]["power_traces"], penalty
+ )
+ else:
+ logger.debug(
+ f" we found no changepoints with penalty {penalty}"
+ )
return None, None