Skip to content

Commit

Permalink
Remove autocorrelation considerations for DI cal.
Browse files Browse the repository at this point in the history
Autocorrelations will only be calibrated and written out as part of a
to-be-written solutions-apply command.

Fix one test passing --cpu to SimulateVisArgs when it was not expected.
  • Loading branch information
cjordan committed Apr 6, 2022
1 parent 5781f9a commit 70a623f
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 59 deletions.
7 changes: 0 additions & 7 deletions src/calibrate/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ pub struct CalibrateUserArgs {
#[clap(short, long, help = MODEL_FILENAME_HELP.as_str(), help_heading = "OUTPUT FILES")]
pub model_filename: Option<PathBuf>,

/// When writing out calibrated visibilities, don't include
/// auto-correlations.
#[clap(long, help_heading = "OUTPUT FILES")]
pub ignore_autos: bool,

/// When writing out calibrated visibilities, average this many timesteps
/// together. Also supports a target time resolution (e.g. 8s). The value
/// must be a multiple of the input data's time resolution. The default is
Expand Down Expand Up @@ -350,7 +345,6 @@ impl CalibrateUserArgs {
source_list_type,
outputs,
model_filename,
ignore_autos,
output_vis_time_average,
output_vis_freq_average,
num_sources,
Expand Down Expand Up @@ -389,7 +383,6 @@ impl CalibrateUserArgs {
source_list_type: cli_args.source_list_type.or(source_list_type),
outputs: cli_args.outputs.or(outputs),
model_filename: cli_args.model_filename.or(model_filename),
ignore_autos: cli_args.ignore_autos || ignore_autos,
output_vis_time_average: cli_args
.output_vis_time_average
.or(output_vis_time_average),
Expand Down
5 changes: 0 additions & 5 deletions src/calibrate/di/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ pub(crate) fn di_calibrate(

info!("Writing visibilities...");

// TODO(dev): support and test autos
if params.using_autos {
panic!("not supperted yet... or are they?");
}

let ant_pairs: Vec<(usize, usize)> = params.get_ant_pairs();
let int_time: Duration = Duration::from_f64(obs_context.time_res.unwrap(), Unit::Second);

Expand Down
24 changes: 0 additions & 24 deletions src/calibrate/params/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ pub(crate) struct CalibrateParams {
/// flagged.
pub(crate) tile_to_unflagged_cross_baseline_map: HashMap<(usize, usize), usize>,

/// Are auto-correlations being included?
pub(crate) using_autos: bool,

/// The names of the unflagged tiles.
pub(crate) unflagged_tile_names: Vec<String>,

Expand Down Expand Up @@ -218,7 +215,6 @@ impl CalibrateParams {
source_list_type,
outputs,
model_filename,
ignore_autos,
output_vis_time_average,
output_vis_freq_average,
num_sources,
Expand Down Expand Up @@ -850,11 +846,6 @@ impl CalibrateParams {
(time_factor, freq_factor)
};

let using_autos = if ignore_autos {
false
} else {
obs_context.autocorrelations_present
};
// XXX(Dev): TileBaselineMaps logic might fit inside FlagContext
let tile_baseline_maps = TileBaselineMaps::new(total_num_tiles, &flagged_tiles);

Expand Down Expand Up @@ -976,7 +967,6 @@ impl CalibrateParams {
flagged_fine_chans,
tile_to_unflagged_cross_baseline_map: tile_baseline_maps
.tile_to_unflagged_cross_baseline_map,
using_autos,
unflagged_tile_names,
unflagged_tile_xyzs,
array_position,
Expand Down Expand Up @@ -1018,19 +1008,6 @@ impl CalibrateParams {
.fold(0, |acc, tb| acc + tb.range.len())
}

/// The number of unflagged baselines, including auto-correlation
/// "baselines" if these are included.
// TODO(dev): this is only used in tests
#[allow(dead_code)]
pub(crate) fn get_num_unflagged_baselines(&self) -> usize {
let n = self.unflagged_tile_xyzs.len();
if self.using_autos {
(n * (n + 1)) / 2
} else {
(n * (n - 1)) / 2
}
}

/// The number of unflagged cross-correlation baselines.
pub(crate) fn get_num_unflagged_cross_baselines(&self) -> usize {
let n = self.unflagged_tile_xyzs.len();
Expand All @@ -1042,7 +1019,6 @@ impl CalibrateParams {
/// and 1 are unflagged, then the first baseline is (0,1), and the first
/// element here is (0,1).
pub(crate) fn get_ant_pairs(&self) -> Vec<(usize, usize)> {
// TODO(Dev): support autos
self.tile_to_unflagged_cross_baseline_map
.keys()
.cloned()
Expand Down
2 changes: 1 addition & 1 deletion src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) struct ObsContext {
pub(crate) flagged_tiles: Vec<usize>,

/// Are auto-correlations present in the visibility data?
pub(crate) autocorrelations_present: bool,
pub(crate) _autocorrelations_present: bool,

/// The dipole gains for each tile in the array. The first axis is unflagged
/// antenna, the second dipole index. These will typically all be of value
Expand Down
2 changes: 1 addition & 1 deletion src/data_formats/ms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ impl MS {
tile_names,
tile_xyzs,
flagged_tiles,
autocorrelations_present,
_autocorrelations_present: autocorrelations_present,
dipole_gains,
time_res,
// XXX(Dev): no way to get array_pos from MS AFAIK
Expand Down
2 changes: 1 addition & 1 deletion src/data_formats/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl RawDataReader {
tile_names,
tile_xyzs,
flagged_tiles,
autocorrelations_present: true,
_autocorrelations_present: true,
dipole_gains: Some(dipole_gains),
time_res,
array_position: Some(LatLngHeight::new_mwa()),
Expand Down
2 changes: 1 addition & 1 deletion src/data_formats/raw/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ fn test_mwaf_flags() {

// Iterate over the arrays, where are the differences? They should be
// primes.
let num_bls = params.get_num_unflagged_baselines();
let num_bls = params.get_num_unflagged_cross_baselines();
let num_freqs = params.get_obs_context().fine_chan_freqs.len();
// Unfortunately we have to conditionally select either the auto or cross
// visibilities.
Expand Down
2 changes: 1 addition & 1 deletion src/data_formats/uvfits/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl UvfitsReader {
tile_names,
tile_xyzs,
flagged_tiles,
autocorrelations_present: metadata.autocorrelations_present,
_autocorrelations_present: metadata.autocorrelations_present,
dipole_gains,
time_res,
// XXX(Dev): Can this be obtained from the ARRAY{X,Y,Z} keys? (geocentric, wgs84)
Expand Down
18 changes: 2 additions & 16 deletions tests/integration/calibrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn test_1090008640_woden() {

#[test]
#[serial]
fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos() {
fn test_1090008640_di_calibrate_writes_vis_uvfits() {
let tmp_dir = TempDir::new().expect("couldn't make tmp dir").into_path();
let args = get_reduced_1090008640(true, false);
let data = args.data.unwrap();
Expand All @@ -202,7 +202,6 @@ fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos() {
"--source-list", &args.source_list.unwrap(),
"--outputs", &format!("{}", out_vis_path.display()),
"--model-filename", &format!("{}", cal_model.display()),
"--ignore-autos",
]);

// Run di-cal and check that it succeeds
Expand All @@ -222,20 +221,14 @@ fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos() {
gcount.parse::<usize>().unwrap(),
exp_timesteps * exp_baselines
);
// let pcount: String = get_required_fits_key!(&mut out_vis, &hdu0, "PCOUNT").unwrap();
// assert_eq!(pcount.parse::<usize>().unwrap(), 5);
// let floats_per_pol: String = get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS2").unwrap();
// assert_eq!(floats_per_pol.parse::<usize>().unwrap(), 3);
// let num_pols: String = get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS3").unwrap();
// assert_eq!(num_pols.parse::<usize>().unwrap(), 4);
let num_fine_freq_chans: String =
get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS4").unwrap();
assert_eq!(num_fine_freq_chans.parse::<usize>().unwrap(), exp_channels);
}

#[test]
#[serial]
fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos_avg_freq() {
fn test_1090008640_di_calibrate_writes_vis_uvfits_avg_freq() {
let tmp_dir = TempDir::new().expect("couldn't make tmp dir").into_path();
let args = get_reduced_1090008640(true, false);
let data = args.data.unwrap();
Expand All @@ -253,7 +246,6 @@ fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos_avg_freq() {
"--source-list", &args.source_list.unwrap(),
"--outputs", &format!("{}", out_vis_path.display()),
"--model-filename", &format!("{}", cal_model.display()),
"--ignore-autos",
"--output-vis-freq-average", &format!("{}", freq_avg_factor)
]);

Expand All @@ -274,12 +266,6 @@ fn test_1090008640_di_calibrate_writes_vis_uvfits_noautos_avg_freq() {
gcount.parse::<usize>().unwrap(),
exp_timesteps * exp_baselines
);
// let pcount: String = get_required_fits_key!(&mut out_vis, &hdu0, "PCOUNT").unwrap();
// assert_eq!(pcount.parse::<usize>().unwrap(), 5);
// let floats_per_pol: String = get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS2").unwrap();
// assert_eq!(floats_per_pol.parse::<usize>().unwrap(), 3);
// let num_pols: String = get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS3").unwrap();
// assert_eq!(num_pols.parse::<usize>().unwrap(), 4);
let num_fine_freq_chans: String =
get_required_fits_key!(&mut out_vis, &hdu0, "NAXIS4").unwrap();
assert_eq!(num_fine_freq_chans.parse::<usize>().unwrap(), exp_channels);
Expand Down
1 change: 0 additions & 1 deletion tests/integration/modelling/calibrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ fn test_1090008640_calibrate_model() {
"--source-list", &srclist,
"--outputs", &format!("{}", sols.display()),
"--model-filename", &format!("{}", cal_model.display()),
"--ignore-autos",
]);

// Run di-cal and check that it succeeds
Expand Down
1 change: 0 additions & 1 deletion tests/integration/modelling/simulate_vis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ fn test_1090008640_simulate_vis_cpu_gpu_match() {
"--output-model-file", &format!("{}", output_path.display()),
"--num-timesteps", &format!("{}", num_timesteps),
"--num-fine-channels", &format!("{}", num_chans),
"--cpu",
]);
let result = simulate_vis(sim_args, true, false);
assert!(result.is_ok(), "result={:?} not ok", result.err().unwrap());
Expand Down

0 comments on commit 70a623f

Please sign in to comment.