Skip to main content

CubeWriter

Struct CubeWriter 

Source
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

Source

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.

Source

pub fn open(path: &Path) -> Result<Self, CubeError>

Open an already-initialised output cube (see init_output_cube) for sequential channel writes.

Source

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.

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more