From 4b898b1ce6d953463015e876028cb9772de09177 Mon Sep 17 00:00:00 2001 From: d3v-null Date: Tue, 25 Jun 2024 11:02:14 +0000 Subject: [PATCH] add test for auto pfb --- src/cli.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 28e3d7a..102b878 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1850,11 +1850,13 @@ impl<'a> BirliContext<'a> { #[cfg(test)] #[cfg(feature = "aoflagger")] mod tests { + use approx::{assert_abs_diff_eq, assert_abs_diff_ne}; use tempfile::tempdir; use crate::{ - test_common::get_1254670392_avg_paths, test_common::get_mwax_data_paths, BirliContext, - VisSelection, + passband_gains::{PFB_COTTER_2014_10KHZ, PFB_JAKE_2022_200HZ}, + test_common::{get_1254670392_avg_paths, get_mwax_data_paths}, + BirliContext, VisSelection, }; #[test] @@ -1975,6 +1977,56 @@ mod tests { assert!(flag_ctx.flag_dc); } + /// pfb gains is cotter by default for legacy correlator. + #[test] + fn test_auto_pfb_legacy() { + let (metafits_path, gpufits_paths) = get_1254670392_avg_paths(); + + #[rustfmt::skip] + let args = vec![ + "birli", + "-m", metafits_path, + "--no-draw-progress", + gpufits_paths[0], + gpufits_paths[1], + ]; + + let BirliContext { prep_ctx, .. } = BirliContext::from_args(&args).unwrap(); + + assert!(prep_ctx.passband_gains.is_some()); + assert_abs_diff_eq!( + prep_ctx.passband_gains.unwrap()[0], + PFB_COTTER_2014_10KHZ[0] + ); + // santiy check + assert_abs_diff_ne!(prep_ctx.passband_gains.unwrap()[0], PFB_JAKE_2022_200HZ[0]); + } + + /// pfb gains is jake by default for mwax correlator. + #[test] + fn test_auto_pfb_mwax() { + let (metafits_path, gpufits_paths) = get_mwax_data_paths(); + + #[rustfmt::skip] + let args = vec![ + "birli", + "-m", metafits_path, + "--no-draw-progress", + gpufits_paths[0], + gpufits_paths[1], + ]; + + let BirliContext { prep_ctx, .. } = BirliContext::from_args(&args).unwrap(); + + assert!(prep_ctx.passband_gains.is_some()); + assert_abs_diff_eq!(prep_ctx.passband_gains.unwrap()[0], PFB_JAKE_2022_200HZ[0]); + // santiy check + assert_abs_diff_ne!( + prep_ctx.passband_gains.unwrap()[0], + PFB_COTTER_2014_10KHZ[0] + ); + } + /// DC flagging is off by default for MWAX inputs. #[test] fn test_no_automatic_dc_flagging() {