pub struct UvfitsWriter { /* private fields */ }
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
sourceimpl UvfitsWriter
impl UvfitsWriter
sourcepub 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<String>,
array_pos: 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<String>,
array_pos: LatLngHeight
) -> Result<Self, UvfitsWriteError>
Create a new uvfits file at the specified path.
This will destroy any existing uvfits file at that path.
If you have a [marlu::mwalib::CorrelatorContext
], then it would be more
convenient to use the from_mwalib
method.
num_timesteps
, num_baselines
and num_chans
are the number of
timesteps, baselines and channels in this uvfits file respectively. This
is counted after averaging.
start_epoch
is a hifitime::Epoch
at the start of the first scan,
and can be calculated from GPS Time using the hifitime library, e.g.
use hifitime::Epoch;
let first_gps_time = 1196175296.0;
let start_epoch = Epoch::from_gpst_seconds(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: reduce number of arguments.
sourcepub fn from_mwalib<T: AsRef<Path>>(
path: T,
corr_ctx: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize],
array_pos: Option<LatLngHeight>,
phase_centre: Option<RADec>,
avg_time: usize,
avg_freq: usize
) -> Result<Self, UvfitsWriteError>
pub fn from_mwalib<T: AsRef<Path>>(
path: T,
corr_ctx: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize],
array_pos: Option<LatLngHeight>,
phase_centre: Option<RADec>,
avg_time: usize,
avg_freq: usize
) -> Result<Self, UvfitsWriteError>
Create a new uvfits file at the specified path using an [marlu::mwalib::CorrelatorContext
]
Details
start epoch is determined by timestep_range.start
which may not necessarily match
the obsid.
Errors
See: UvfitsWriter::new
TODO: reduce number of arguments.
pub fn from_marlu<T: AsRef<Path>>(
path: T,
vis_ctx: &VisContext,
array_pos: Option<LatLngHeight>,
phase_centre: RADec,
obs_name: Option<String>
) -> Result<Self, UvfitsWriteError>
sourcepub fn open(&self) -> Result<FitsFile, Error>
pub fn open(&self) -> Result<FitsFile, Error>
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.
sourcepub 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.
sourcepub 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
[marlu::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
sourcepub fn write_vis_row(
&mut self,
uvfits: &mut FitsFile,
uvw: UVW,
tile_index1: usize,
tile_index2: usize,
epoch: Epoch,
vis: &[f32]
) -> Result<(), UvfitsWriteError>
pub fn write_vis_row(
&mut self,
uvfits: &mut FitsFile,
uvw: UVW,
tile_index1: usize,
tile_index2: usize,
epoch: Epoch,
vis: &[f32]
) -> Result<(), UvfitsWriteError>
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.
Trait Implementations
sourceimpl VisWritable for UvfitsWriter
impl VisWritable for UvfitsWriter
sourcefn write_vis_marlu(
&mut self,
vis: ArrayView3<'_, Jones<f32>>,
weights: ArrayView3<'_, f32>,
vis_ctx: &VisContext,
tiles_xyz_geod: &[XyzGeodetic],
draw_progress: bool
) -> Result<(), IOError>
fn write_vis_marlu(
&mut self,
vis: ArrayView3<'_, Jones<f32>>,
weights: ArrayView3<'_, f32>,
vis_ctx: &VisContext,
tiles_xyz_geod: &[XyzGeodetic],
draw_progress: bool
) -> Result<(), IOError>
Write a chunk of visibilities, contextualised with a VisContext
. Read more
sourcefn write_vis_mwalib(
&mut self,
jones_array: ArrayView3<'_, Jones<f32>>,
weight_array: ArrayView4<'_, f32>,
flag_array: ArrayView4<'_, bool>,
corr_ctx: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize],
avg_time: usize,
avg_freq: usize,
draw_progress: bool
) -> Result<(), IOError>
fn write_vis_mwalib(
&mut self,
jones_array: ArrayView3<'_, Jones<f32>>,
weight_array: ArrayView4<'_, f32>,
flag_array: ArrayView4<'_, bool>,
corr_ctx: &CorrelatorContext,
timestep_range: &Range<usize>,
coarse_chan_range: &Range<usize>,
baseline_idxs: &[usize],
avg_time: usize,
avg_freq: usize,
draw_progress: bool
) -> Result<(), IOError>
use write_vis_marlu instead
Contract the weight and flag arrays along the pol axis, and write using
VisWritable::write_vis_marlu
Read more
Auto Trait Implementations
impl RefUnwindSafe for UvfitsWriter
impl Send for UvfitsWriter
impl Sync for UvfitsWriter
impl Unpin for UvfitsWriter
impl UnwindSafe for UvfitsWriter
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