-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified: src/fitter/common.rs modified: src/fitter/fit_handler.rs modified: src/fitter/fit_settings.rs modified: src/fitter/main_fitter.rs modified: src/fitter/mod.rs new file: src/fitter/models/exponential.rs modified: src/fitter/models/linear.rs modified: src/fitter/models/mod.rs new file: src/fitter/models/powerlaw.rs new file: src/fitter/models/quadratic.rs modified: src/histoer/histo1d/histogram1d.rs
- Loading branch information
Showing
12 changed files
with
1,264 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,68 @@ | ||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
#[derive(PartialEq, Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
pub struct Data { | ||
pub x: Vec<f64>, | ||
pub y: Vec<f64>, | ||
} | ||
|
||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
pub struct Value { | ||
#[derive(PartialEq, Debug, Clone, serde::Deserialize, serde::Serialize)] | ||
pub struct Parameter { | ||
pub name: String, | ||
pub value: f64, | ||
pub uncertainity: f64, | ||
pub min: f64, | ||
pub max: f64, | ||
pub initial_guess: f64, | ||
pub vary: bool, | ||
pub value: Option<f64>, | ||
pub uncertainity: Option<f64>, | ||
} | ||
|
||
impl Value { | ||
pub fn new(name: String, value: f64, uncertainity: f64) -> Self { | ||
Value { name, value, uncertainity } | ||
impl Default for Parameter { | ||
fn default() -> Self { | ||
Parameter { | ||
name: String::new(), | ||
min: f64::NEG_INFINITY, | ||
max: f64::INFINITY, | ||
initial_guess: 0.0, | ||
vary: true, | ||
value: None, | ||
uncertainity: None, | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
impl Parameter { | ||
pub fn ui(&mut self, ui: &mut egui::Ui) { | ||
ui.label(&self.name); | ||
ui.add( | ||
egui::DragValue::new(&mut self.initial_guess).speed(0.1), // .prefix("Initial Guess: ") | ||
// .suffix(" a.u."), | ||
) | ||
.on_hover_text(format!("Initial guess for the {} parameter", self.name)); | ||
|
||
ui.add( | ||
egui::DragValue::new(&mut self.min) | ||
.speed(0.1) | ||
// .prefix("Min: ") | ||
.range(f64::NEG_INFINITY..=self.max), // .suffix(" a.u."), | ||
) | ||
.on_hover_text(format!("Minimum value for the {} parameter", self.name)); | ||
|
||
ui.add( | ||
egui::DragValue::new(&mut self.max) | ||
.speed(0.1) | ||
// .prefix("Max: ") | ||
.range(self.min..=f64::INFINITY), // .suffix(" a.u."), | ||
) | ||
.on_hover_text(format!("Maximum value for the {} parameter", self.name)); | ||
|
||
ui.checkbox(&mut self.vary, "").on_hover_text(format!( | ||
"Allow the {} parameter to vary during the fitting process", | ||
self.name | ||
)); | ||
|
||
if let Some(value) = self.value { | ||
ui.separator(); | ||
ui.label(format!("{:.3}", value)); | ||
ui.label(format!("{:.3}", self.uncertainity.unwrap_or(0.0))); | ||
} | ||
} | ||
} |
Oops, something went wrong.