Function birli::io::write_uvfits[][src]

pub fn write_uvfits<T: AsRef<Path>>(
    path: T,
    context: &CorrelatorContext,
    jones_array: &Array3<Jones<f32>>,
    flag_array: &Array3<bool>,
    mwalib_timestep_range: &Range<usize>,
    mwalib_coarse_chan_range: &Range<usize>,
    mwalib_baseline_idxs: &[usize],
    array_pos: Option<LatLngHeight>
) -> Result<(), IOError>
Expand description

Write the given ndarrays of flags and Jones matrix visibilities to a uvfits file.

mwalib timestep, coarse channel and baseline indices are needed to map between indices in the arrays and indices according to mwalib, which are not the same.

Examples

use tempfile::tempdir;
use birli::{
    get_flaggable_timesteps,
    context_to_jones_array,
    write_uvfits,
    marlu::mwalib::CorrelatorContext
};

// define our input files
let metafits_path = "tests/data/1196175296_mwa_ord/1196175296.metafits";
let gpufits_paths = vec![
    "tests/data/1196175296_mwa_ord/1196175296_20171201145440_gpubox01_00.fits",
];

// define a temporary directory for output files
let tmp_dir = tempdir().unwrap();

// define our output flag file template
let uvfits_out = tmp_dir.path().join("synthetic.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_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_idxs = &context.common_coarse_chan_indices;
let img_coarse_chan_range =
    *img_coarse_chan_idxs.first().unwrap()..(*img_coarse_chan_idxs.last().unwrap() + 1);


// generate an array of jones matrices
let (jones_array, flag_array) = context_to_jones_array(
    &context,
    &img_timestep_range,
    &img_coarse_chan_range,
    None,
);

// write the visibilities to disk as .uvfits

let baseline_idxs = (0..context.metafits_context.num_baselines).collect::<Vec<_>>();

write_uvfits(
    uvfits_out.as_path(),
    &context,
    &jones_array,
    &flag_array,
    &img_timestep_range,
    &img_coarse_chan_range,
    &baseline_idxs,
    None,
)
.unwrap();

Errors

See: UvfitsWriter

TODO: replace all these args with birli_context