Crate birli[][src]

Expand description

Birli is a library of common preprocessing tasks performed in the data pipeline of the Murchison Widefield Array (MWA) Telescope.

Examples

Here’s an example of how to flag some visibility files

use birli::{
    context_to_jones_array, flag_jones_array_existing, write_flags,
    cxx_aoflagger_new, get_flaggable_timesteps, init_flag_array,
    get_antenna_flags, mwalib,
};
use mwalib::CorrelatorContext;
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",
];

// define a temporary directory for output files
let tmp_dir = tempdir().unwrap();

// define our output flag file template
let flag_template = tmp_dir.path().join("Flagfile%%%.mwaf");

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

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

// Determine which timesteps and coarse channels we want to use
let img_coarse_chan_idxs = &context.common_coarse_chan_indices;
let img_timestep_idxs = get_flaggable_timesteps(&context).unwrap();

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

// Prepare our flagmasks with known bad antennae
let flag_array = init_flag_array(
    &context,
    &img_timestep_range,
    &img_coarse_chan_range,
    Some(get_antenna_flags(&context)),
);

// load visibilities into our array of jones matrices
let (mut jones_array, flag_array) = context_to_jones_array(
    &context,
    &img_timestep_range,
    &img_coarse_chan_range,
    Some(flag_array),
);

// 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
let flag_array = flag_jones_array_existing(
    &aoflagger,
    &strategy_filename,
    &jones_array,
    Some(flag_array),
    true,
);

// write the flags to disk as .mwaf
write_flags(&context, &flag_array, flag_template.to_str().unwrap(), &img_coarse_chan_range).unwrap();

Details

Birli reads visibilities with MWALib and uses CXX to bind to the AOFlagger C++ library. For more details about AOFlagger’s interface, check out the aoflagger::AOFlagger documentation

Re-exports

pub use io::mwaf::FlagFileSet;
pub use io::uvfits::UvfitsWriter;
pub use corrections::correct_cable_lengths;
pub use corrections::correct_geometry;
pub use flags::flagmask_or;
pub use flags::get_antenna_flags;
pub use flags::get_flaggable_timesteps;
pub use flags::init_flag_array;
pub use flags::write_flags;
pub use mwa_rust_core;
pub use mwa_rust_core::mwalib;
pub use mwalib::fitsio;
pub use mwalib::fitsio_sys;

Modules

Corrections that can be performed on visibility data

Errors that can occur in Birli

Methods for manipulating flagmasks and flagging imagesets

Input and Ouput data file format modules

Structs

A complex number in Cartesian form.

CXX Wrapper for aoflagger::AOFlagger, the main class for access to the flagger functionality.

CXX Wrapper for aoflagger::FlagMask, a two-dimensional mask of bool flags.

CXX Wrapper for aoflagger::ImageSet, a set of time-frequency ‘images’ which together contain data for one correlated baseline.

CXX Wrapper for aoflagger::Strategy, a flagging strategy definition.

Functions

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.

Create a new CxxAOFlagger instance

Create an aoflagger CxxFlagMask for a from the given flag array view

Get the version of the AOFlagger library from the library itself.

Initialize a vector of length [num_baselines] containing CxxImageSet of dimensions [width] and [height],

Create an aoflagger CxxImageSet for a particular baseline from the given jones array