imgal 0.3.0

A fast and open-source scientific image processing and algorithm library.
Documentation
use std::f64::consts::LN_2;

use ndarray::Array1;

use crate::distribution::normalized_gaussian;

/// Create a 1D Gaussian instrument response function (IRF).
///
/// # Description
///
/// Creates a Gaussian IRF by converting "full width at half maximum" (FWHM)
/// parameters into a normalized Gaussian distribution. The FWHM is converted to
/// standard deviation using the relationship:
///
/// ```text
/// σ = FWHM / (2 × √(2 × ln(2)))
/// ```
///
/// Where `ln(2) ≈ 0.693147` is the natural logarithm of `2`.
///
/// # Arguments
///
/// * `bins`: The number of discrete points to sample the Gaussian distribution.
/// * `time_range`: The total time range over which to simulate the IRF.
/// * `irf_center`: The temporal position of the IRF peak within the time range.
/// * `irf_width`: The full width at half maximum (FWHM) of the IRF.
/// * `threads`: The requested number of threads to use for parallel execution.
///   If `None` or `Some(1)` sequential execution is used. If `Some(0)`, then
///   the maximum available parallelism is used. Thread counts are clamped to
///   the systems maximum.
///
/// # Returns
///
/// * `Array1<f64>`: The simulated 1D IRF curve array.
#[inline]
pub fn gaussian_irf_1d(
    bins: usize,
    time_range: f64,
    irf_center: f64,
    irf_width: f64,
    threads: Option<usize>,
) -> Array1<f64> {
    let sigma = irf_width / (2.0 * (2.0 * LN_2).sqrt());
    normalized_gaussian(sigma, bins, time_range, irf_center, threads)
}