Struct birli::io::uvfits::UvfitsWriter [−][src]
pub struct UvfitsWriter { /* fields omitted */ }
Expand description
A helper struct to write out a uvfits file.
Note: only a single contiguous spectral window is supported.
TODO: make writer and reader a single class?
Implementations
pub fn new<T: AsRef<Path>>(
path: T,
num_timesteps: usize,
num_baselines: usize,
num_chans: usize,
start_epoch: Epoch,
fine_chan_width_hz: f64,
centre_freq_hz: f64,
centre_freq_chan: usize,
phase_centre: RADec,
obs_name: Option<&str>,
array_pos: Option<LatLngHeight>
) -> Result<Self, UvfitsWriteError>
pub fn new<T: AsRef<Path>>(
path: T,
num_timesteps: usize,
num_baselines: usize,
num_chans: usize,
start_epoch: Epoch,
fine_chan_width_hz: f64,
centre_freq_hz: f64,
centre_freq_chan: usize,
phase_centre: RADec,
obs_name: Option<&str>,
array_pos: Option<LatLngHeight>
) -> Result<Self, UvfitsWriteError>
Create a new uvfits file at the specified path.
This will destroy any existing uvfits file at that path
num_timesteps
, num_baselines
and num_chans
are the number of
timesteps, baselines and channels in this uvfits file respectively.
start_epoch
can be calculated from GPS Time using the hifitime library, e.g.
use marlu::time;
let first_gps_time = 1196175296.0;
let start_epoch = time::gps_to_epoch(first_gps_time);
centre_freq_hz
is center frequency of the center fine channel of the
spectral window being written to this file. [Hz]
centre_freq_chan
is the index (from zero) of the center frequency of
the center fine channel of the spectral] window being written to this
file.
phase_centre
is a RADec
of the observation’s phase center, used to
populate the OBSRA
and OBSDEC
keys.
obs_name
an optional name for the object under observation. Used to
populate the OBJECT
keys.
Errors
Will return an UvfitsWriteError
if:
- there is an existing file at
path
which cannot be removed. - a fits operation fails.
TODO: replace all these args with birli_context
pub fn from_mwalib<T: AsRef<Path>>(
path: T,
context: &CorrelatorContext,
mwalib_timestep_range: &Range<usize>,
mwalib_coarse_chan_range: &Range<usize>,
mwalib_baseline_idxs: &[usize],
array_pos: Option<LatLngHeight>
) -> Result<Self, UvfitsWriteError>
pub fn from_mwalib<T: AsRef<Path>>(
path: T,
context: &CorrelatorContext,
mwalib_timestep_range: &Range<usize>,
mwalib_coarse_chan_range: &Range<usize>,
mwalib_baseline_idxs: &[usize],
array_pos: Option<LatLngHeight>
) -> Result<Self, UvfitsWriteError>
Create a new uvfits file at the specified path using an [mwalib::CorrelatorContext
]
Details
start epoch is determined by mwalib_timestep_range.start
which may not necessarily match
the obsid.
Errors
See: UvfitsWriter::new
Opens the associated uvfits file in edit mode, returning the FitsFile struct.
Closing the file can be achieved by drop
ing all references to the
FitsFile
Errors
Will return an fitsio::errors::Error
if the file can’t be edited.
pub fn write_uvfits_antenna_table<T: AsRef<str>>(
self,
antenna_names: &[T],
positions: &[XyzGeodetic]
) -> Result<(), UvfitsWriteError>
pub fn write_uvfits_antenna_table<T: AsRef<str>>(
self,
antenna_names: &[T],
positions: &[XyzGeodetic]
) -> Result<(), UvfitsWriteError>
Write the antenna table to a uvfits file. Assumes that the array location is MWA.
positions
are the XyzGeodetic coordinates
of the MWA tiles. These positions need to have the MWA’s “centre” XYZ
coordinates subtracted to make them local XYZ.
Self
must have only have a single HDU when this function is called
(true when using methods only provided by Self
).
Derived from cotter.
Errors
Will return an UvfitsWriteError
if a fits operation fails.
pub fn write_ants_from_mwalib(
self,
context: &MetafitsContext
) -> Result<(), UvfitsWriteError>
pub fn write_ants_from_mwalib(
self,
context: &MetafitsContext
) -> Result<(), UvfitsWriteError>
Write the antenna table to a uvfits file using the provided
[mwalib::CorrelatorContext
]
self
must have only have a single HDU when this function is called
(true when using methods only provided by Self
).
latitude_rad
Optionally override the latitude of the array [Radians]
Errors
Write a visibility row into the uvfits file.
uvfits
must have been opened in write mode and currently have HDU 0
open. The FitsFile must be supplied to this function to force the
caller to think about calling this function efficiently; opening the
file for every call would be a problem, and keeping the file open in
UvfitsWriter would mean the struct is not thread safe.
tile_index1
and tile_index2
are expected to be zero indexed; they
are made one indexed by this function.
Errors
Will return an UvfitsWriteError
if a fits operation fails.
TODO: Assumes that all fine channels are written in vis.
This needs to
be updated to add visibilities to an existing uvfits row.
Write visibilty and weight rows into the uvfits file from the provided
[mwalib::CorrelatorContext
].
Details
uvfits
must have been opened in write mode and currently have HDU 0
open. The FitsFile must be supplied to this function to force the
caller to think about calling this function efficiently; opening the
file for every call would be a problem, and keeping the file open in
UvfitsWriter would mean the struct is not thread safe.
baseline_idxs
the baseline indices (according to mwalib)
which should be written to the file
jones_array
a ndarray::Array3
of Jones
visibilities with dimensions
[timestep][channel][baselines]
flag_array
a ndarray::Array3
of boolean flags with dimensions
identical dimensions to jones_array
mwalib_timestep_range
the range of timestep indices (according to mwalib)
which are used in the visibility and flag arrays
mwalib_coarse_chan_range
the range of coarse channel indices (according to mwalib)
which are used in the visibility and flag arrays
mwalib_baseline_idxs
the baseline indices (according to mwalib) used
in the visibility and flag arrays
TODO: handle averaging
Errors
Will return an UvfitsWriteError
if a fits operation fails.
TODO: replace all these args with birli_context
Trait Implementations
fn write_vis_mwalib(
&mut self,
jones_array: ArrayView3<'_, Jones<f32>>,
weight_array: ArrayView3<'_, f32>,
context: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize]
) -> Result<(), IOError>
fn write_vis_mwalib(
&mut self,
jones_array: ArrayView3<'_, Jones<f32>>,
weight_array: ArrayView3<'_, f32>,
context: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize]
) -> Result<(), IOError>
Write visibilities and weights from the arrays. Timestep, coarse channel and baseline indices are needed for labelling the visibility Read more