pub struct CubeWriter { /* private fields */ }Expand description
A streaming writer that holds an initialised output cube open for the lifetime
of a processing run, so channels can be written one at a time without the
per-call file open/close overhead of write_channel.
cfitsio drives a single file through one internal cursor and is not
thread-safe, so a CubeWriter must be owned and driven by a single thread
(the consumer end of the streaming pipeline in main).
Implementations§
Source§impl CubeWriter
impl CubeWriter
Sourcepub fn create(
input_path: &Path,
output_path: &Path,
target_beams: &[Option<Beam>],
mode: CubeMode,
meta: &CubeMeta,
) -> Result<Self, CubeError>
pub fn create( input_path: &Path, output_path: &Path, target_beams: &[Option<Beam>], mode: CubeMode, meta: &CubeMeta, ) -> Result<Self, CubeError>
Create a fresh output cube from input_path’s primary header and hold the
FITS handle open for streaming channel writes.
Unlike init_output_cube (create → close → reopen), the single handle
stays open from creation through every CubeWriter::write_channel_as
until CubeWriter::finish, so cfitsio writes the data unit exactly once
— avoiding the wasted full zero-fill pass a create-close incurs on the data
unit of a multi-GB cube. Only data-unit gaps no channel covered are
zero-filled on the final close.
Primary-header beam keywords (BMAJ/BMIN/BPA/CASAMBM) are written up front;
in Natural mode the BEAMS extension is buffered and appended by finish.
Sourcepub fn open(path: &Path) -> Result<Self, CubeError>
pub fn open(path: &Path) -> Result<Self, CubeError>
Open an already-initialised output cube (see init_output_cube) for
sequential channel writes.
Sourcepub fn write_channel_as<T: CubeElem>(
&mut self,
chan: usize,
data: &Array2<T>,
meta: &CubeMeta,
) -> Result<(), CubeError>
pub fn write_channel_as<T: CubeElem>( &mut self, chan: usize, data: &Array2<T>, meta: &CubeMeta, ) -> Result<(), CubeError>
Write one frequency channel plane (precision T) into the open cube.
Sourcepub fn write_channel(
&mut self,
chan: usize,
data: &Array2<f32>,
meta: &CubeMeta,
) -> Result<(), CubeError>
pub fn write_channel( &mut self, chan: usize, data: &Array2<f32>, meta: &CubeMeta, ) -> Result<(), CubeError>
Write one f32 frequency channel plane (see CubeWriter::write_channel_as).
Sourcepub fn finish(self) -> Result<(), CubeError>
pub fn finish(self) -> Result<(), CubeError>
Finish the cube: append the buffered BEAMS extension (Natural mode) and close the FITS file exactly once.
Must be called after the final channel write. The single close zero-fills
only the data-unit gaps no channel covered; creating the BEAMS extension
here (not at create) keeps the primary data unit written in one pass.