use crate::ev_augmentation::{AugmentationError, AugmentationResult, Validatable};
use crate::ev_filtering::downsampling::DownsamplingFilter;
#[derive(Debug, Clone)]
pub struct DecimateAugmentation {
pub n: usize,
}
impl DecimateAugmentation {
pub fn new(n: usize) -> Self {
Self { n }
}
pub fn description(&self) -> String {
format!("n={}", self.n)
}
}
impl Validatable for DecimateAugmentation {
fn validate(&self) -> AugmentationResult<()> {
if self.n == 0 {
Err(AugmentationError::InvalidConfig(
"Decimation factor must be positive".to_string(),
))
} else {
Ok(())
}
}
}
use polars::prelude::*;
pub fn apply_decimate_polars(
df: LazyFrame,
config: &DecimateAugmentation,
) -> PolarsResult<LazyFrame> {
let filter = DownsamplingFilter::spatial_decimation(config.n);
crate::ev_filtering::downsampling::apply_downsampling_filter_polars(df, &filter)
}