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, write_flags,
    get_flaggable_timesteps, init_flag_array,
    get_antenna_flags, mwalib::CorrelatorContext, write_uvfits
};
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 paths
let flag_template = tmp_dir.path().join("Flagfile%%%.mwaf");
let uvfits_out = tmp_dir.path().join("1297526432.uvfits");

// 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 = 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);
let baseline_idxs = (0..context.metafits_context.num_baselines).collect::<Vec<_>>();

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

// This functionality is only available with the aoflagger feature
// use birli::{cxx_aoflagger_new, flag_jones_array_existing}
// // create a CxxAOFlagger object to perform AOFlagger operations
// let aoflagger = unsafe { cxx_aoflagger_new() };
//
// // 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();
// write the visibilities to disk as .uvfits
write_uvfits(
    uvfits_out.as_path(),
    &context,
    &jones_array,
    &flag_array,
    &img_timestep_range,
    &img_coarse_chan_range,
    &baseline_idxs,
    None,
).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 io::write_ms;
pub use io::write_uvfits;
pub use corrections::correct_cable_lengths;
pub use corrections::correct_geometry;
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 marlu;
pub use marlu::approx;
pub use marlu::mwalib;
pub use marlu::mwalib::fitsio;
pub use marlu::mwalib::fitsio_sys;
pub use flags::flag_jones_array;

Modules

Corrections that can be performed on visibility data

Methods for manipulating flagmasks and flagging imagesets

Input and Ouput data file format modules

Structs

A complex number in Cartesian form.

mwalib correlator observation context. This represents the basic metadata for a correlator observation.

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.

Binding to C++ std::unique_ptr<T, std::default_delete<T>>.

Enums

An enum of all the errors possible in Birli

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.

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