pub struct VisSelection {
    pub timestep_range: Range<usize>,
    pub coarse_chan_range: Range<usize>,
    pub baseline_idxs: Vec<usize, Global>,
}
Expand description

Keep track of which mwalib indices the values in a jones array, its’ weights and its’ flags came from. Similar to a VisSelection, but requires an mwalib::CorrelatorContext to be fully interpreted

TODO: this definitely needs fine_chans_per_coarse TODO: what about https://doc.rust-lang.org/std/ops/trait.RangeBounds.html insetad of Range?

Fields

timestep_range: Range<usize>

selected range of mwalib timestep indices

coarse_chan_range: Range<usize>

selected range of mwalib coarse channel indices

baseline_idxs: Vec<usize, Global>

selected mwalib baseline indices

Implementations

Produce a VisSelection from a given marlu::mwalib::CorrelatorContext.

  • timesteps are selected from the first common to the last provided.
  • only common coarse channels are selected
  • all baselines are selected

For more details, see mwalib core concepts

Examples
use marlu::{mwalib::CorrelatorContext, VisSelection};

// 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",
];

let corr_ctx = CorrelatorContext::new(&metafits_path, &gpufits_paths).unwrap();
let vis_sel = VisSelection::from_mwalib(&corr_ctx).unwrap();

assert_eq!(vis_sel.timestep_range.len(), 4);
Errors

This will return SelectionError::NoProvidedTimesteps if mwalib has determined that no timesteps have been provided, SelectionError::NoCommonTimesteps if none of the provided gpuboxes have timesteps in common

The selected antenna index pairs corresponding to sel_baselines_idxs

Get the shape of the jones, flag or weight array for this selection

Estimate the memory size in bytes required to store the given selection without redundant pols.

Allocate a jones array to store visibilities for the selection

Errors

can raise SelectionError::InsufficientMemory if not enough memory.

Allocate a flag array to store flags for the selection

Errors

can raise SelectionError::InsufficientMemory if not enough memory.

Allocate a weight array to store weights for the selection

Errors

can raise SelectionError::InsufficientMemory if not enough memory.

Read the visibilities for this selection into the jones array using mwalib, flag visiblities if they are not provided.

Errors

Can raise SelectionError::BadArrayShape if jones_array or flag_array does not match the expected shape of this selection.

Examples
use marlu::{mwalib::CorrelatorContext, VisSelection};

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

// Determine which timesteps and coarse channels we want to use
let img_timestep_idxs = &corr_ctx.common_timestep_indices;
let good_timestep_idxs = &corr_ctx.common_good_timestep_indices;

let mut vis_sel = VisSelection::from_mwalib(&corr_ctx).unwrap();
vis_sel.timestep_range =
    *img_timestep_idxs.first().unwrap()..(*img_timestep_idxs.last().unwrap() + 1);

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

let dims_common = jones_array.dim();

// now try only with good timesteps
vis_sel.timestep_range =
    *good_timestep_idxs.first().unwrap()..(*good_timestep_idxs.last().unwrap() + 1);

// read visibilities out of the gpubox files
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();
vis_sel
    .read_mwalib(&corr_ctx, jones_array.view_mut(), flag_array.view_mut(), false)
    .unwrap();

let dims_good = jones_array.dim();

// different selections have different sized arrays.
assert_ne!(dims_common, dims_good);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.