Crate birli

Source
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::{
    write_flags,
    mwalib::CorrelatorContext,
    get_weight_factor, flag_to_weight_array,
    FlagContext, VisSelection, io::{read_mwalib, 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 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();

// Prepare our flagmasks with known bad antennae
let flag_ctx = FlagContext::from_mwalib(&corr_ctx);

// 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();
flag_ctx.set_flags(
    flag_array.view_mut(),
    &vis_sel.timestep_range,
    &vis_sel.coarse_chan_range,
    &vis_sel.get_ant_pairs(&corr_ctx.metafits_context)
);
let mut jones_array = vis_sel.allocate_jones(fine_chans_per_coarse).unwrap();

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

// write the flags to disk as .mwaf
write_flags(flag_template.to_str().unwrap(),
            &corr_ctx,
            &vis_sel,
            flag_array.view(),
            true,
            None,
            None,
).unwrap();

// write the visibilities to disk as .uvfits
let num_pols = corr_ctx.metafits_context.num_visibility_pols;
let weight_factor = get_weight_factor(&corr_ctx);
let weight_array = flag_to_weight_array(flag_array.view(), weight_factor);
write_uvfits(
    uvfits_out.as_path(),
    &corr_ctx,
    jones_array.view(),
    weight_array.view(),
    &vis_sel.timestep_range,
    &vis_sel.coarse_chan_range,
    &vis_sel.baseline_idxs,
    None,
    None,
    1,
    1,
).unwrap();

§Details

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

Re-exports§

pub use io::mwaf::FlagFileSet;
pub use corrections::correct_cable_lengths;
pub use corrections::correct_geometry;
pub use corrections::ScrunchType;
pub use flags::flag_to_weight_array;
pub use flags::get_weight_factor;
pub use flags::write_flags;
pub use flags::FlagContext;
pub use preprocessing::PreprocessContext;
pub use van_vleck::correct_van_vleck;
pub use cli::BirliContext;
pub use marlu;
pub use marlu::mwalib;
pub use marlu::mwalib::fitsio;
pub use marlu::mwalib::fitsio_sys;
pub use marlu::ndarray;

Modules§

calibration
Calibrating visibilities.
cli
Command Line Interface helpers for Birli
corrections
Corrections that can be performed on visibility data
flags
Methods for manipulating flagmasks and flagging imagesets
io
Input and Ouput data file format modules
passband_gains
Possible choices for polyphase filter bank gains for the MWA.
preprocessing
Crate for preprocessing visibilities
van_vleck
Van Vleck corrections for MWA data.

Macros§

par_azip
Parallelized array zip macro: lock step function application across several arrays and producers.
with_increment_duration
Time a statement and increment the timer given by name in the hashmap of durations

Structs§

Axis
An axis index.
Complex
A complex number in Cartesian form.
CorrelatorContext
This represents the basic metadata and methods for an MWA correlator observation.
Jones
VisSelection
Keep track of which mwalib indices the values in a jones array, its’ weights and its’ flags came from. Similar to a VisContext, but requires an mwalib::CorrelatorContext to be fully interpreted

Enums§

BirliError
An enum of all the errors possible in Birli

Traits§

IndexedParallelIterator
An iterator that supports “random access” to its data, meaning that you can split it at arbitrary indices and draw data from those points.
IntoParallelIterator
IntoParallelIterator implements the conversion to a ParallelIterator.
IntoParallelRefIterator
IntoParallelRefIterator implements the conversion to a ParallelIterator, providing shared references to the data.
IntoParallelRefMutIterator
IntoParallelRefMutIterator implements the conversion to a ParallelIterator, providing mutable references to the data.
ParallelIterator
Parallel version of the standard iterator trait.

Functions§

get_durations
Get the hashmap of durations used internally by Birli for timing functions with with_increment_duration!

Type Aliases§

Array3
three-dimensional array