Skip to content
Snippets Groups Projects
Commit 5eddcfc3 authored by y.zobus's avatar y.zobus
Browse files

fix: :bug: When the plot creation for wavefronts fails, a warning is thrown instead of an error

When the plot creation for wavefronts fails, a warning is thrown instead of an error. This avoids crahsing the report generation
parent 5ae2dafb
No related branches found
No related tags found
1 merge request!129fix: :bug: When the plot creation for wavefronts fails, a warning is thrown instead of an error
......@@ -33,7 +33,7 @@ fn main() -> OpmResult<()> {
let energy_1w = Energy::new::<joule>(100.0);
let energy_2w = Energy::new::<joule>(50.0);
let beam_dist_1w = Hexapolar::new(Length::new::<millimeter>(76.05493), 6)?;
let beam_dist_1w = Hexapolar::new(Length::new::<millimeter>(76.05493), 0)?;
let beam_dist_2w = beam_dist_1w.clone();
let refr_index_hk9l = RefrIndexSellmeier1::new(
......
#![warn(missing_docs)]
//! Wavefront measurment node
use image::{DynamicImage, ImageBuffer, RgbImage};
use image::{DynamicImage, RgbImage};
use log::warn;
use nalgebra::{DVector, DVectorSlice, MatrixXx3};
use plotters::style::RGBAColor;
......@@ -207,7 +207,12 @@ impl Optical for WaveFront {
));
if let Some(wf_data) = wf_data_opt {
//todo! for all wavelengths
wf_data.wavefront_error_maps[0].to_plot(&file_path, (1000, 850), PltBackEnd::BMP)
Ok(wf_data.wavefront_error_maps[0]
.to_plot(&file_path, (1000, 850), PltBackEnd::BMP)
.unwrap_or_else(|e| {
warn!("Could not export plot: {e}",);
None
}))
} else {
warn!("Wavefront diagram: no wavefront data for export available",);
Ok(None)
......@@ -276,11 +281,15 @@ impl PdfReportable for WaveFrontData {
self.wavefront_error_maps[0].rms
)));
//todo! for all wavefronts!
let img =
self.wavefront_error_maps[0].to_plot(Path::new(""), (1000, 850), PltBackEnd::Buf)?;
let img = self.wavefront_error_maps[0]
.to_plot(Path::new(""), (1000, 850), PltBackEnd::Buf)
.unwrap_or_else(|e| {
warn!("Could not create plot for pdf creation: {e}",);
None
});
layout.push(
genpdf::elements::Image::from_dynamic_image(DynamicImage::ImageRgb8(
img.unwrap_or_else(ImageBuffer::default),
img.unwrap_or_default(),
))
.map_err(|e| format!("adding of image failed: {e}"))?,
);
......@@ -346,7 +355,6 @@ impl Plottable for WaveFrontErrorMap {
};
let plt_series = PlotSeries::new(&plt_data, RGBAColor(255, 0, 0, 1.), None);
Ok(Some(vec![plt_series]))
// Ok(self.bin_or_triangulate_data(plt_type, &plt_data))
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment