Skip to content

Commit

Permalink
MAINT: Add more info to plot in model calibration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Oct 16, 2023
1 parent 566cd74 commit 5bef049
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/darsia/multi_image_analysis/model_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def define_objective_function(
"""

# Fetch the injection rate and geometry
injection_rate = options["injection_rate"] # in same units as the input images
injection_rate = options["injection_rate"] # in same units as geometry
geometry = options["geometry"]
regression_type = options.get("regression_type", "ransac").lower()
assert regression_type in ["ransac", "linear"]
Expand Down Expand Up @@ -258,10 +258,13 @@ def objective_function(params: np.ndarray) -> float:

# Cache result for possible post-analysis
self._slope = regression.coef_[0]
self._reference_slope = injection_rate
self._intercept = regression.intercept_

# Measure deffect
# Measure relative defect
defect = effective_injection_rate - injection_rate
if abs(injection_rate) > 1e-15:
defect /= injection_rate
return defect**2

return objective_function
Expand Down Expand Up @@ -305,9 +308,15 @@ def _visualize_model_calibration(
color="black",
linestyle=(0, (5, 5)),
)
plt.plot(
times,
[self._intercept + self._reference_slope * time for time in times],
color="green",
linestyle=(0, (5, 5)),
)
plt.xlabel("time [s]")
plt.ylabel("volume [m**3]")
plt.legend(["rescaled signal", "reference"])
plt.legend(["rescaled signal", "regression", "reference"])
plt.show()

def model_calibration_postanalysis(self) -> float:
Expand Down

0 comments on commit 5bef049

Please sign in to comment.