Struct birli::VisSelection
source · [−]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
sourceimpl VisSelection
impl VisSelection
sourcepub fn from_mwalib(
corr_ctx: &CorrelatorContext
) -> Result<VisSelection, SelectionError>
pub fn from_mwalib(
corr_ctx: &CorrelatorContext
) -> Result<VisSelection, SelectionError>
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
sourcepub fn get_ant_pairs(
&self,
meta_ctx: &MetafitsContext
) -> Vec<(usize, usize), Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_ant_pairs(
&self,
meta_ctx: &MetafitsContext
) -> Vec<(usize, usize), Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
The selected antenna index pairs corresponding to sel_baselines_idxs
sourcepub fn get_shape(&self, fine_chans_per_coarse: usize) -> (usize, usize, usize)
pub fn get_shape(&self, fine_chans_per_coarse: usize) -> (usize, usize, usize)
Get the shape of the jones, flag or weight array for this selection
sourcepub fn estimate_bytes_best(&self, fine_chans_per_coarse: usize) -> usize
pub fn estimate_bytes_best(&self, fine_chans_per_coarse: usize) -> usize
Estimate the memory size in bytes required to store the given selection without redundant pols.
sourcepub fn allocate_jones(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<Jones<f32>>, Dim<[usize; 3]>>, SelectionError>
pub fn allocate_jones(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<Jones<f32>>, Dim<[usize; 3]>>, SelectionError>
Allocate a jones array to store visibilities for the selection
Errors
can raise SelectionError::InsufficientMemory
if not enough memory.
sourcepub fn allocate_flags(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<bool>, Dim<[usize; 3]>>, SelectionError>
pub fn allocate_flags(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<bool>, Dim<[usize; 3]>>, SelectionError>
Allocate a flag array to store flags for the selection
Errors
can raise SelectionError::InsufficientMemory
if not enough memory.
sourcepub fn allocate_weights(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>, SelectionError>
pub fn allocate_weights(
&self,
fine_chans_per_coarse: usize
) -> Result<ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>, SelectionError>
Allocate a weight array to store weights for the selection
Errors
can raise SelectionError::InsufficientMemory
if not enough memory.
sourcepub fn read_mwalib(
&self,
corr_ctx: &CorrelatorContext,
jones_array: ArrayBase<ViewRepr<&mut Jones<f32>>, Dim<[usize; 3]>>,
flag_array: ArrayBase<ViewRepr<&mut bool>, Dim<[usize; 3]>>,
draw_progress: bool
) -> Result<(), SelectionError>
pub fn read_mwalib(
&self,
corr_ctx: &CorrelatorContext,
jones_array: ArrayBase<ViewRepr<&mut Jones<f32>>, Dim<[usize; 3]>>,
flag_array: ArrayBase<ViewRepr<&mut bool>, Dim<[usize; 3]>>,
draw_progress: bool
) -> Result<(), SelectionError>
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
sourceimpl Clone for VisSelection
impl Clone for VisSelection
sourcefn clone(&self) -> VisSelection
fn clone(&self) -> VisSelection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VisSelection
impl Debug for VisSelection
sourceimpl Default for VisSelection
impl Default for VisSelection
sourcefn default() -> VisSelection
fn default() -> VisSelection
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for VisSelection
impl Send for VisSelection
impl Sync for VisSelection
impl Unpin for VisSelection
impl UnwindSafe for VisSelection
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more