Skip to content

Commit f724814

Browse files
committed
new histogram fill logic-- in dev but much faster and shouldnt crash with a large dataset
modified: Cargo.lock modified: Cargo.toml modified: src/histoer/histo1d/histogram1d.rs modified: src/histoer/histo1d/statistics.rs modified: src/histoer/histo2d/histogram2d.rs modified: src/histoer/histo2d/statistics.rs modified: src/histoer/histogrammer.rs deleted: src/histogram_scripter/configure_auxillary_detectors.rs modified: src/histogram_scripter/histogram_script.rs deleted: src/histogram_scripter/histogram_ui_elements.rs modified: src/histogram_scripter/manual_histogram_script.rs modified: src/histogram_scripter/mod.rs modified: src/util/processer.rs
1 parent 34ffd82 commit f724814

File tree

13 files changed

+644
-1396
lines changed

13 files changed

+644
-1396
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ env_logger = "0.11.5"
3333
# performant will make the compile times slower but should make the histogrammer faster
3434
polars = { version = "0.43.1", features = ["lazy", "parquet", "performant"] }
3535
polars-lazy = { version = "0.43.1", features = ["hist"] }
36+
rayon = "1.10.0"
3637
hashbrown = { version = "=0.14.5", features = ["raw"] } #needed until polars fixes
3738

3839
rfd = "0.15"

src/histoer/histo1d/histogram1d.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ impl Histogram {
4646
self.underflow = 0;
4747
}
4848

49-
// Add a value to the histogram
5049
pub fn fill(&mut self, value: f64, current_step: usize, total_steps: usize) {
5150
if value >= self.range.0 && value < self.range.1 {
5251
let index = ((value - self.range.0) / self.bin_width) as usize;
@@ -71,14 +70,12 @@ impl Histogram {
7170
self.bins = counts;
7271
}
7372

74-
// Get the bin edges
7573
pub fn get_bin_edges(&self) -> Vec<f64> {
7674
(0..=self.bins.len())
7775
.map(|i| self.range.0 + i as f64 * self.bin_width)
7876
.collect()
7977
}
8078

81-
// Convert histogram bins to line points
8279
pub fn update_line_points(&mut self) {
8380
self.line.points = self
8481
.bins
@@ -93,7 +90,6 @@ impl Histogram {
9390
.collect();
9491
}
9592

96-
// Get the bin index for a given x position.
9793
pub fn get_bin_index(&self, x: f64) -> Option<usize> {
9894
if x < self.range.0 || x > self.range.1 {
9995
return None;
@@ -104,7 +100,6 @@ impl Histogram {
104100
Some(bin_index)
105101
}
106102

107-
// Get the bin centers between the start and end x values (inclusive)
108103
pub fn get_bin_centers_between(&self, start_x: f64, end_x: f64) -> Vec<f64> {
109104
let start_bin = self.get_bin_index(start_x).unwrap_or(0);
110105
let end_bin = self.get_bin_index(end_x).unwrap_or(self.bins.len() - 1);
@@ -114,7 +109,6 @@ impl Histogram {
114109
.collect()
115110
}
116111

117-
// Get the bin counts between the start and end x values (inclusive)
118112
pub fn get_bin_counts_between(&self, start_x: f64, end_x: f64) -> Vec<f64> {
119113
let start_bin = self.get_bin_index(start_x).unwrap_or(0);
120114
let end_bin = self.get_bin_index(end_x).unwrap_or(self.bins.len() - 1);
@@ -124,7 +118,6 @@ impl Histogram {
124118
.collect()
125119
}
126120

127-
// Get bin counts and bin center at x value
128121
pub fn get_bin_count_and_center(&self, x: f64) -> Option<(f64, f64)> {
129122
self.get_bin_index(x).map(|bin| {
130123
let bin_center = self.range.0 + (bin as f64 * self.bin_width) + self.bin_width * 0.5;
@@ -219,7 +212,6 @@ impl Histogram {
219212
self.fits.temp_fit = Some(fitter);
220213
}
221214

222-
// Draw the histogram, fit lines, markers, and stats
223215
pub fn draw(&mut self, plot_ui: &mut egui_plot::PlotUi) {
224216
// update the histogram and fit lines with the log setting and draw
225217
let log_y = self.plot_settings.egui_settings.log_y;
@@ -305,7 +297,6 @@ impl Histogram {
305297
}
306298
}
307299

308-
// Renders the histogram using egui_plot
309300
pub fn render(&mut self, ui: &mut egui::Ui) {
310301
// Display progress bar while hist is being filled
311302
self.plot_settings.progress_ui(ui);

src/histoer/histo1d/statistics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl Histogram {
5555
format!("Integral: {}", integral),
5656
format!("Mean: {:.2}", mean),
5757
format!("Stdev: {:.2}", stdev),
58-
// format!("Overflow: {:}", self.overflow),
59-
// format!("Underflow: {:}", self.underflow),
58+
format!("Overflow: {:}", self.overflow),
59+
format!("Underflow: {:}", self.underflow),
6060
];
6161

6262
for entry in stats_entries.iter() {

src/histoer/histo2d/histogram2d.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ impl Histogram2D {
7676
}
7777

7878
// Update progress if it's being tracked
79-
self.plot_settings.progress = Some(current_step as f32 / total_steps as f32);
79+
let progress = current_step as f32 / total_steps as f32;
80+
self.plot_settings.progress = Some(progress);
8081

81-
if self.plot_settings.progress.is_some() && (current_step % (total_steps) / 10) == 0 {
82-
self.plot_settings.recalculate_image = true;
83-
}
82+
// // Recalculate the image at each 10% increment
83+
// if (progress * 100.0) as u32 % 10 == 0 && progress > 0.0 {
84+
// self.plot_settings.recalculate_image = true;
85+
// }
8486
}
8587

8688
// get the bin index for a given x value

src/histoer/histo2d/statistics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl Histogram2D {
106106
format!("Integral: {}", stats.0),
107107
format!("Mean: ({:.2}, {:.2})", stats.1, stats.3),
108108
format!("Stdev: ({:.2}, {:.2})", stats.2, stats.4),
109-
// format!("Overflow: ({:}, {:})", self.overflow.0, self.overflow.1),
110-
// format!("Underflow: ({:}, {:})", self.underflow.0, self.underflow.1),
109+
format!("Overflow: ({:}, {:})", self.overflow.0, self.overflow.1),
110+
format!("Underflow: ({:}, {:})", self.underflow.0, self.underflow.1),
111111
];
112112

113113
for entry in stats_entries.iter() {

0 commit comments

Comments
 (0)