pub fn correct_cable_lengths(
    context: &CorrelatorContext,
    jones_array: &mut Array3<Jones<f32>>,
    mwalib_coarse_chan_range: &Range<usize>,
    draw_progress: bool
)
Expand description

Perform cable length corrections, given an observation’s [mwalib::CorrelatorContext] and an [’ndarray::Array3] of [TestJones`] visibilities

Cable lengths are determined by the difference between a baseline’s rfInput electrical lengths in the metafits. Complex visibilities are phase-shifted by an angle determined by the electrical length, and the channel’s frequency.

Examples

use birli::{context_to_jones_array, correct_cable_lengths, mwalib::CorrelatorContext};

// define our input files
let metafits_path = "tests/data/1297526432_mwax/1297526432.metafits";
let gpufits_paths = vec![
    "tests/data/1297526432_mwax/1297526432_20210216160014_ch117_000.fits",
    "tests/data/1297526432_mwax/1297526432_20210216160014_ch117_001.fits",
    "tests/data/1297526432_mwax/1297526432_20210216160014_ch118_000.fits",
    "tests/data/1297526432_mwax/1297526432_20210216160014_ch118_001.fits",
];

// Create an mwalib::CorrelatorContext for accessing visibilities.
let context = CorrelatorContext::new(&metafits_path, &gpufits_paths).unwrap();

// Determine which timesteps and coarse channels we want to use
let sel_coarse_chan_idxs = &context.common_coarse_chan_indices;
let sel_timestep_idxs = &context.common_timestep_indices;
let baseline_idxs = (0..context.metafits_context.num_baselines).collect::<Vec<_>>();

let sel_timestep_range =
    *sel_timestep_idxs.first().unwrap()..(*sel_timestep_idxs.last().unwrap() + 1);
let sel_coarse_chan_range =
    *sel_coarse_chan_idxs.first().unwrap()..(*sel_coarse_chan_idxs.last().unwrap() + 1);

// read visibilities out of the gpubox files
let (mut jones_array, _) = context_to_jones_array(
    &context,
    &sel_timestep_range,
    &sel_coarse_chan_range,
    None,
    false,
).unwrap();

correct_cable_lengths(&context, &mut jones_array, &sel_coarse_chan_range, false);

Accuracy

This follows the Cotter implementation of cable length correction, however there is a slower but more accurate version of the calculation which uses f64 values for the sin_cos. According to benchmarks, the Cotter implementation is about 32% faster (5.9 seconds vs 8.6) than the more precise implementation, and they vary by about three parts in four million. Therefore it was decided that the Cotter implementation was more favourable.

Assumptions

  • an Antenna’s rfinput is the same for X and Y