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

Perform cable length corrections, given an observation’s marlu::mwalib::CorrelatorContext and an [ndarray::Array3] of [crate::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::{correct_cable_lengths, mwalib::CorrelatorContext, VisSelection};

// 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 corr_ctx = CorrelatorContext::new(&metafits_path, &gpufits_paths).unwrap();

// Determine which timesteps and coarse channels we want to use
let vis_sel = VisSelection::from_mwalib(&corr_ctx).unwrap();

// Create a blank array to store flags and visibilities
let fine_chans_per_coarse = corr_ctx.metafits_context.num_corr_fine_chans_per_coarse;
let mut flag_array = vis_sel.allocate_flags(fine_chans_per_coarse).unwrap();
let mut jones_array = vis_sel.allocate_jones(fine_chans_per_coarse).unwrap();

// read visibilities out of the gpubox files
vis_sel
    .read_mwalib(&corr_ctx, jones_array.view_mut(), flag_array.view_mut(), false)
    .unwrap();

correct_cable_lengths(&corr_ctx, &mut jones_array, &vis_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