13 unstable releases (4 breaking)
0.6.1 | Apr 21, 2022 |
---|---|
0.6.0 | Jan 7, 2022 |
0.5.1 | Dec 13, 2021 |
0.5.0 | Oct 27, 2021 |
0.1.0 | Nov 25, 2019 |
#320 in Images
61 downloads per month
Used in bubbles
105KB
2.5K
SLoC
integrustio
This crate provides an azimuthal integrator and distortion corrector for diffraction data acquired with 2D detectors. This is mainly redo of the great Python library pyFAI in the Rust programming language.
This is library is intended to be used mainly in the SNBL integration server Bubble. Integrustio does not try to redo all the possible integration algorithms implemented in pyFAI, its goal is to choose one robust enough to be used for the data measured at SNBL.
Currently the BoundingBox with pixel splitting is chosen.
Usage examples
- Poni parser:
use integrustio::poni::Poni;
use std::path::Path;
use std::fmt;
fn read_poni<P: AsRef<Path> + fmt::Debug>(path: P) {
let test = path;
let poni2 = match Poni::read_file(&test) {
Ok(poni) => poni,
Err(e) => panic!("Could not read file {:?}: {}", test, e),
};
}
- Distortion correction together with the Spine file:
use std::io;
use integrustio::spline::Spline;
use integrustio::distortion::Distortion;
use std::io::BufReader;
use std::fs::File;
use cryiorust::frame::{Array, Frame};
use cryiorust::cbf::Cbf;
use std::path::Path;
fn correct_file<P: AsRef<Path>>(frame: P, spline: P) -> io::Result<Array> {
let frame = Cbf::read_file(frame)?;
let spline = Spline::init(BufReader::new(File::open(spline)?), frame.array())?;
let mut d = Distortion::new();
d.init(frame.array(), &spline);
let corrected_array: Array = d.correct(frame.array())?;
Ok(corrected_array)
}
- Integration:
use integrustio::integrator::{Integrable, IntegrationType, Integrator, Diffractogram};
use integrustio::poni::Poni;
use cryiorust::cbf::Cbf;
use cryiorust::frame::{Frame, FrameResult};
use std::path::Path;
fn integrate<P: AsRef<Path>>(frame: P, poni: P) -> FrameResult<Diffractogram> {
let frame = Cbf::read_file(frame)?;
let ranges = [0., 0.];
let data = Integrable {
array: frame.array(),
radial_range: &ranges,
azimuthal_range: &ranges,
integration_type: IntegrationType::Radial,
};
let mut i = Integrator::new();
i.set_poni(Poni::read_file(poni)?);
i.set_radial_bins(3500);
i.set_polarization(0.99);
i.init(frame.array());
Ok(i.integrate(&data).unwrap())
}
License: GPL-3.0+
Dependencies
~29MB
~444K SLoC