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

Modules

  • Calibrating visibilities.
  • Command Line Interface helpers for Birli
  • Corrections that can be performed on visibility data
  • Methods for manipulating flagmasks and flagging imagesets
  • Input and Ouput data file format modules
  • Possible choices for polyphase filter bank gains for the MWA.
  • Crate for preprocessing visibilities

Macros

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

Structs

  • An axis index.
  • 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>>.
  • 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

  • An enum of all the errors possible in Birli

Traits

Functions

Type Definitions