pub fn flag_jones_array_existing(
    aoflagger: &CxxAOFlagger,
    strategy_filename: &str,
    jones_array: &Array3<Jones<f32>>,
    flag_array: &mut Array3<bool>,
    re_apply_existing: bool,
    draw_progress: bool
)
Expand description

Flag an ndarray of Jones visibilities, given a CxxAOFlagger instance, a [CxxStrategy] filename, returning an [ndarray::Array3] of boolean flags.

Providing some existing flags is optional, however these flags must be the same dimension as the provided Jones array. If these are not provided, an empty flag array is created instead

if [re_apply_existing] is true, then the new flags are binary or’d with the existing flags, otherwise they overwrite them.

Performance

Because of all the memory juggling required to use aoflagger flagmasks, providing existing flagmasks is slower.

Examples

use birli::{FlagContext, flag_jones_array_existing, write_flags,
    mwalib::CorrelatorContext, cxx_aoflagger_new, VisSelection};
use tempfile::tempdir;

// 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();

// create a CxxAOFlagger object to perform AOFlagger operations
let aoflagger = unsafe { cxx_aoflagger_new() };

// specify which coarse_chan and timestep indices we want to load into an image.
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();

// use the default strategy file location for MWA
let strategy_filename = &aoflagger.FindStrategyFileMWA();

// run the strategy on the imagesets, and get the resulting flagmasks for each baseline
flag_jones_array_existing(
   &aoflagger,
   &strategy_filename,
   &jones_array,
   &mut flag_array,
   true,
   false,
);