Function birli::context_to_jones_array[][src]

pub fn context_to_jones_array(
    context: &CorrelatorContext,
    mwalib_timestep_range: &Range<usize>,
    mwalib_coarse_chan_range: &Range<usize>,
    flag_array: Option<Array3<bool>>
) -> (Array3<Jones<f32>>, Array3<bool>)
Expand description

generate a 3 dimensional array of Jones matrices from an observation’s mwalib::CorrelatorContext, for all baselines, over a given range of mwalib timestep and coarse channel indices.

The dimensions of the array are:

  • timestep
  • channel
  • baseline

An equally sized flag array is also returned with flags indicating when reading via mwalib causes a GPUBoxError.

Details:

Observations can sometimes be too large to fit in memory. This method will only load visibilities from the provided timesteps and coarse channels, in order to enable the visibility to be read in user-defined “chunks” of time or frequency.

The timesteps are indices in the mwalib::CorrelatorContext’s timestep array, which should be a contiguous superset of times from all provided coarse gpubox files. A similar concept applies to coarse channels. Instead of reading visibilities for all known timesteps / coarse channels, it is recommended to use common_coarse_chan_indices and common_timestep_indices, as these ignore timesteps and coarse channels which are missing contiguous data. common_good_timestep_indices is also a good choice to avoid quack time.

For more details, see the documentation.

Note: it doesn’t make sense to ask aoflagger to flag non-contiguous timesteps or coarse channels, and so this interface only allows to ranges to be used. For flagging an obeservation with “picket fence” coarse channels or timesteps, contiguous ranges should be flagged separately.

Examples

use birli::{context_to_jones_array, 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 img_coarse_chan_idxs = &context.common_coarse_chan_indices;
let img_timestep_idxs = &context.common_timestep_indices;
let good_timestep_idxs = &context.common_good_timestep_indices;

let img_timestep_range =
    *img_timestep_idxs.first().unwrap()..(*img_timestep_idxs.last().unwrap() + 1);
let good_timestep_range =
    *good_timestep_idxs.first().unwrap()..(*good_timestep_idxs.last().unwrap() + 1);
let img_coarse_chan_range =
    *img_coarse_chan_idxs.first().unwrap()..(*img_coarse_chan_idxs.last().unwrap() + 1);


// read visibilities out of the gpubox files
let (jones_array, _) = context_to_jones_array(
    &context,
    &img_timestep_range,
    &img_coarse_chan_range,
    None
);

let dims_common = jones_array.dim();

// read visibilities out of the gpubox files
let (jones_array, _) = context_to_jones_array(
    &context,
    &good_timestep_range,
    &img_coarse_chan_range,
    None
);

let dims_good = jones_array.dim();

assert_ne!(dims_common, dims_good);

Assumptions

  • img_coarse_chan_idxs and img_timestep_idxs are contiguous