Skip to content

Commit

Permalink
diode calibration: add different loss func
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Oct 26, 2023
1 parent 7b13030 commit 1ef4343
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lumicks/pylake/force_calibration/detail/diode_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)


def fit_multi_spectra(model, powers, power_spectra):
def fit_multi_spectra(model, powers, power_spectra, loss="gaussian"):
power, num_points_per_block = [
np.hstack([getattr(s, prop) for s in power_spectra])
for prop in ("power", "num_points_per_block")
Expand Down Expand Up @@ -66,7 +66,7 @@ def multi_model(_, fc_min, d_fc_per_power, *other_params):
np.asarray(upper_bounds),
ftol=1e-7,
max_function_evals=10000,
loss_function="gaussian",
loss_function=loss,
)

fc_min, d_fc_per_power, *other_params = solution
Expand Down Expand Up @@ -98,7 +98,7 @@ def multi_model(_, fc_min, d_fc_per_power, *other_params):
return results


def fit_diode_model(model, powers, power_spectra):
def fit_diode_model(model, powers, power_spectra, loss="gaussian"):
power, num_points_per_block = [
np.hstack([getattr(s, prop) for s in power_spectra])
for prop in ("power", "num_points_per_block")
Expand All @@ -116,7 +116,7 @@ def fit_diode_model(model, powers, power_spectra):
diffusion_constants = np.full(fill_value=diffusion_constant, shape=(n_spectra,))

# delta_f_diode, rate_f_diode, max_f_diode, delta_alpha, rate_alpha, max_alpha
filter_params = [8000, 0.1, 15000, 0.4, 0.1, 1.0]
filter_params = [8000, 1, 15000, 0.4, 1, 0.9]
filter_lb = [0, 0, 0, 0, 0, 0]
filter_ub = [50000, 1e6, 50000, 1.0, 1e6, 1.0]

Expand Down Expand Up @@ -156,7 +156,7 @@ def multi_model(_, fc_min, d_fc_per_power, *other_params):
np.asarray(upper_bounds),
ftol=1e-7,
max_function_evals=10000,
loss_function="gaussian",
loss_function=loss,
)

fc_min, d_fc_per_power, *other_params = solution
Expand Down

0 comments on commit 1ef4343

Please sign in to comment.