Skip to content

Commit

Permalink
split off peel gpu
Browse files Browse the repository at this point in the history
refactor PeelWeightParams
derive lambdas from chanblocks
derive array pos, dut from obs_context
derive unflagged_xyzs from tile_baseline_flags
  • Loading branch information
d3v-null committed Nov 26, 2024
1 parent 3967b69 commit 2576dde
Show file tree
Hide file tree
Showing 4 changed files with 1,229 additions and 1,259 deletions.
166 changes: 22 additions & 144 deletions src/cli/peel/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ fn get_reduced_1090008640() -> PeelArgs {
}
}

#[track_caller]
// should be 40kHz, 2s raw
fn get_merged_1090008640(extra_argv: Vec<String>) -> PeelArgs {
fn get_merged_1090008640(extra_argv: Vec<String>) -> PeelParams {
let args = get_reduced_1090008640();
let temp_dir = tempdir().expect("Couldn't make tempdir");
let arg_file = temp_dir.path().join("peel.toml");
Expand All @@ -47,7 +46,10 @@ fn get_merged_1090008640(extra_argv: Vec<String>) -> PeelArgs {
write!(&mut f, "{ser}").unwrap();
let mut argv = vec!["peel".to_string(), arg_file.display().to_string()];
argv.extend(extra_argv);
PeelArgs::parse_from(argv).merge().unwrap()
let params = PeelArgs::parse_from(argv).merge().unwrap().parse().unwrap();
drop(f);
drop(temp_dir);
params
}

// testing the frequency averaging args all works together:
Expand All @@ -57,13 +59,12 @@ fn get_merged_1090008640(extra_argv: Vec<String>) -> PeelArgs {

#[test]
fn frequency_averaging_defaults() {
let args = get_merged_1090008640(vec![]);
let PeelParams {
input_vis_params: InputVisParams { spw: input_spw, .. },
output_vis_params,
low_res_spw,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec![]);
let output_freq_average_factor = match output_vis_params {
Some(OutputVisParams {
output_freq_average_factor,
Expand All @@ -78,13 +79,12 @@ fn frequency_averaging_defaults() {

#[test]
fn frequency_averaging_explicit_output() {
let args = get_merged_1090008640(vec!["--output-vis-freq-average=80kHz".to_string()]);
let PeelParams {
input_vis_params: InputVisParams { spw: input_spw, .. },
output_vis_params,
low_res_spw,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec!["--output-vis-freq-average=80kHz".to_string()]);
let output_freq_average_factor = match output_vis_params {
Some(OutputVisParams {
output_freq_average_factor,
Expand All @@ -99,16 +99,15 @@ fn frequency_averaging_explicit_output() {

#[test]
fn frequency_averaging_explicit_output_iono() {
let args = get_merged_1090008640(vec![
"--output-vis-freq-average=80kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let PeelParams {
input_vis_params: InputVisParams { spw: input_spw, .. },
output_vis_params,
low_res_spw,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec![
"--output-vis-freq-average=80kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let output_freq_average_factor = match output_vis_params {
Some(OutputVisParams {
output_freq_average_factor,
Expand All @@ -123,17 +122,16 @@ fn frequency_averaging_explicit_output_iono() {

#[test]
fn frequency_averaging_explicit_in_out() {
let args = get_merged_1090008640(vec![
"--freq-average=80kHz".to_string(),
"--output-vis-freq-average=160kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let PeelParams {
input_vis_params: InputVisParams { spw: input_spw, .. },
output_vis_params,
low_res_spw,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec![
"--freq-average=80kHz".to_string(),
"--output-vis-freq-average=160kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let output_freq_average_factor = match output_vis_params {
Some(OutputVisParams {
output_freq_average_factor,
Expand All @@ -148,17 +146,16 @@ fn frequency_averaging_explicit_in_out() {

#[test]
fn frequency_averaging_explicit() {
let args = get_merged_1090008640(vec![
"--freq-average=80kHz".to_string(),
"--output-vis-freq-average=160kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let PeelParams {
input_vis_params: InputVisParams { spw: input_spw, .. },
output_vis_params,
low_res_spw,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec![
"--freq-average=80kHz".to_string(),
"--output-vis-freq-average=160kHz".to_string(),
"--iono-freq-average=320kHz".to_string(),
]);
let output_freq_average_factor = match output_vis_params {
Some(OutputVisParams {
output_freq_average_factor,
Expand All @@ -175,13 +172,12 @@ fn frequency_averaging_explicit() {
// time res will be clipped to 2s
#[test]
fn time_averaging_explicit_output_clip() {
let args = get_merged_1090008640(vec!["--output-vis-time-average=4s".to_string()]);
let PeelParams {
input_vis_params: InputVisParams { time_res, .. },
output_vis_params,
iono_time_average_factor,
..
} = args.parse().unwrap();
} = get_merged_1090008640(vec!["--output-vis-time-average=4s".to_string()]);
let output_time_average_factor = match output_vis_params {
Some(OutputVisParams {
output_time_average_factor,
Expand All @@ -200,121 +196,3 @@ fn time_averaging_explicit_output_clip() {
// --output-vis-time-average - output averaging settings
//
// this requires test data with more than one timestep
//
// #[test]
// fn time_averaging_defaults() {
// let args = get_merged_1090008640(vec![]);
// let PeelParams {
// input_vis_params: InputVisParams { time_res, .. },
// output_vis_params,
// iono_time_average_factor,
// ..
// } = args.parse().unwrap();
// let output_time_average_factor = match output_vis_params {
// Some(OutputVisParams {
// output_time_average_factor,
// ..
// }) => output_time_average_factor,
// _ => panic!("Expected OutputVisParams::Single"),
// };
// assert_abs_diff_eq!(time_res.to_seconds(), 2.0);
// assert_eq!(iono_time_average_factor.get(), 4);
// assert_eq!(output_time_average_factor.get(), 1);
// }

// #[test]
// fn time_averaging_explicit_output() {
// let args = get_merged_1090008640(vec!["--output-vis-time-average=4s".to_string()]);
// let PeelParams {
// input_vis_params: InputVisParams { time_res, .. },
// output_vis_params,
// iono_time_average_factor,
// ..
// } = args.parse().unwrap();
// let output_time_average_factor = match output_vis_params {
// Some(OutputVisParams {
// output_time_average_factor,
// ..
// }) => output_time_average_factor,
// _ => panic!("Expected OutputVisParams::Single"),
// };
// assert_abs_diff_eq!(time_res.to_seconds(), 2.0);
// assert_eq!(iono_time_average_factor.get(), 4);
// assert_eq!(output_time_average_factor.get(), 2);
// }

// #[test]
// fn time_averaging_explicit_output_iono() {
// let args = get_merged_1090008640(vec![
// "--output-vis-time-average=4s".to_string(),
// "--iono-time-average=16s".to_string(),
// ]);
// let PeelParams {
// input_vis_params: InputVisParams { time_res, .. },
// output_vis_params,
// iono_time_average_factor,
// ..
// } = args.parse().unwrap();
// let output_time_average_factor = match output_vis_params {
// Some(OutputVisParams {
// output_time_average_factor,
// ..
// }) => output_time_average_factor,
// _ => panic!("Expected OutputVisParams::Single"),
// };
// assert_abs_diff_eq!(time_res.to_seconds(), 2.0);
// assert_eq!(iono_time_average_factor.get(), 8);
// assert_eq!(output_time_average_factor.get(), 2);
// }

// #[test]
// fn time_averaging_explicit_in_out() {
// // enable logging
// use env_logger::Env;
// env_logger::Builder::from_env(Env::default().default_filter_or("debug")).init();
// let args = get_merged_1090008640(vec![
// "--time-average=4s".to_string(),
// "--output-vis-time-average=16s".to_string(),
// ]);
// let PeelParams {
// input_vis_params: InputVisParams { time_res, .. },
// output_vis_params,
// iono_time_average_factor,
// ..
// } = args.parse().unwrap();
// let output_time_average_factor = match output_vis_params {
// Some(OutputVisParams {
// output_time_average_factor,
// ..
// }) => output_time_average_factor,
// _ => panic!("Expected OutputVisParams::Single"),
// };
// assert_abs_diff_eq!(time_res.to_seconds(), 4.0);
// assert_eq!(iono_time_average_factor.get(), 2);
// assert_eq!(output_time_average_factor.get(), 8);
// }

// #[test]
// fn time_averaging_explicit() {
// let args = get_merged_1090008640(vec![
// "--time-average=4s".to_string(),
// "--output-vis-time-average=16s".to_string(),
// "--iono-time-average=32s".to_string(),
// ]);
// let PeelParams {
// input_vis_params: InputVisParams { time_res, .. },
// output_vis_params,
// iono_time_average_factor,
// ..
// } = args.parse().unwrap();
// let output_time_average_factor = match output_vis_params {
// Some(OutputVisParams {
// output_time_average_factor,
// ..
// }) => output_time_average_factor,
// _ => panic!("Expected OutputVisParams::Single"),
// };
// assert_abs_diff_eq!(time_res.to_seconds(), 4.0);
// assert_eq!(iono_time_average_factor.get(), 4);
// assert_eq!(output_time_average_factor.get(), 8);
// }
Loading

0 comments on commit 2576dde

Please sign in to comment.