-
Notifications
You must be signed in to change notification settings - Fork 4
Add guess, inferred components for calibration constants #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
2e0bb60
2483cc5
f98bd5f
d7baa11
5351f3b
68a78f6
6d15478
a4a3c61
4310a03
39e42c7
9786f0b
1410f12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| from trame.widgets import client, vuetify3 as vuetify, html | ||
| from state_manager import state | ||
| from error_manager import add_error | ||
| import copy | ||
|
|
||
|
|
||
|
|
@@ -15,7 +16,26 @@ def convert_sim_to_exp(self, df_sim): | |
| for value in state.simulation_calibration.values(): | ||
| sim_name = value["name"] | ||
| exp_name = value["depends_on"] | ||
| df_sim[exp_name] = df_sim[sim_name] / value["alpha"] + value["beta"] | ||
| df_sim[exp_name] = ( | ||
| df_sim[sim_name] / value["alpha_guess"] + value["beta_guess"] | ||
| ) | ||
| if state.use_inferred_calibration: | ||
| if all( | ||
| inferred_key in value.values() | ||
| for inferred_key in ["alpha_inferred", "beta_inferred"] | ||
| ): | ||
| df_sim[exp_name] = ( | ||
| df_sim[sim_name] / value["alpha_inferred"] | ||
| + value["beta_inferred"] | ||
| ) | ||
| else: | ||
| title = "Inferrred calibration does not exist" | ||
| message = "Attempted to use the inferred calibration values to apply to the simulation points but calibration hasn't been inferred yet. Applying the guess calibration instead." | ||
| add_error( | ||
| title, | ||
| message, | ||
| ) | ||
| print(message) | ||
|
|
||
| def convert_exp_to_sim(self, exp_dict): | ||
| """ | ||
|
|
@@ -38,8 +58,28 @@ def convert_exp_to_sim(self, exp_dict): | |
| ) | ||
| # fill the dictionary | ||
| if exp_name in exp_dict: | ||
| sim_val = (exp_dict[exp_name] - value["beta"]) * value["alpha"] | ||
| sim_dict[sim_name] = sim_val | ||
| if state.use_inferred_calibration: | ||
| sim_dict[sim_name] = ( | ||
| exp_dict[exp_name] - value["beta_guess"] | ||
| ) * value["alpha_guess"] | ||
adhamrait marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if all( | ||
| inferred_key in value.values() | ||
| for inferred_key in ["alpha_inferred", "beta_inferred"] | ||
| ): | ||
| sim_dict[sim_name] = ( | ||
| exp_dict[exp_name] - value["beta_inferred"] | ||
| ) * value["alpha_inferred"] | ||
| else: | ||
| title = "Inferrred calibration does not exist" | ||
| message = ( | ||
| "Attempted to use the inferred calibration values to apply to the experimental points but the calibration hasn't been inferret yet. Applying the guess calibration instead.", | ||
| ) | ||
| add_error( | ||
| title, | ||
| message, | ||
| ) | ||
| print(message) | ||
|
|
||
| return sim_dict | ||
|
|
||
| def panel(self): | ||
|
|
@@ -49,39 +89,110 @@ def panel(self): | |
| title="Control: Calibrate simulation points", | ||
| style="font-size: 20px; font-weight: 500;", | ||
| ): | ||
| with vuetify.VExpansionPanelText(): | ||
| with vuetify.VExpansionPanelText( | ||
| style="font-weight: lighter; font-size: 16px;" | ||
| ): | ||
| with vuetify.VRow(): | ||
| vuetify.VCheckbox( | ||
| v_model="use_inferred_calibration", | ||
| density="compact", | ||
| label="Use inferred calibration", | ||
| ) | ||
| with client.DeepReactive("simulation_calibration"): | ||
| for key in state.simulation_calibration.keys(): | ||
| # create a row for the parameter label | ||
| with vuetify.VRow(): | ||
| html.Small( | ||
| f"<b> {state.simulation_calibration[key]['name']}</b> = α × (<b>{state.simulation_calibration[key]['depends_on']}</b> - β)", | ||
| style="font-weight: lighter; font-size: 70%;", | ||
| ) | ||
| with vuetify.VRow(): | ||
| with vuetify.VCol(): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['alpha']", | ||
| ), | ||
| change="flushState('simulation_calibration')", | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| label="α", | ||
| ) | ||
| with vuetify.VCol(): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['beta']", | ||
| ), | ||
| change="flushState('simulation_calibration')", | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| label="β", | ||
| ) | ||
| with html.Div( | ||
| style="display: flex; align-items: center; margin: 20px; justify-content: space-between;" | ||
| ): | ||
|
||
| html.Small("α = ") | ||
| with vuetify.VCard( | ||
| subtitle="guess", density="comfortable" | ||
| ): | ||
| with vuetify.VCardText(): | ||
| with vuetify.VRow(style="align-items: center"): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['alpha_guess']", | ||
| ), | ||
| change="flushState('simulation_calibration')", | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| ) | ||
| html.Small("±") | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['alpha_uncertainty']", | ||
| ), | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| ) | ||
| with vuetify.VCard(subtitle="inferred"): | ||
| with vuetify.VCardText(): | ||
| with vuetify.VRow(): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['alpha_inferred']", | ||
| ), | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| disabled=True, | ||
| ) | ||
|
|
||
| with html.Div( | ||
| style="display: flex; align-items: center; margin: 20px; justify-content: space-between;" | ||
| ): | ||
| html.Small("β = ") | ||
| with vuetify.VCard( | ||
| subtitle="guess", density="comfortable" | ||
| ): | ||
| with vuetify.VCardText(): | ||
| with vuetify.VRow(style="align-items: center"): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['beta_guess']", | ||
| ), | ||
| change="flushState('simulation_calibration')", | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| ) | ||
| html.Small("±") | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['beta_uncertainty']", | ||
| ), | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| ) | ||
| with vuetify.VCard(subtitle="inferred"): | ||
| with vuetify.VCardText(): | ||
| with vuetify.VRow(): | ||
| vuetify.VTextField( | ||
| v_model_number=( | ||
| f"simulation_calibration['{key}']['beta_inferred']", | ||
| ), | ||
| density="compact", | ||
| hide_details=True, | ||
| hide_spin_buttons=True, | ||
| style="width: 100px;", | ||
| type="number", | ||
| disabled=True, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.