Skip to main content

NetCdfWriter

Struct NetCdfWriter 

Source
pub struct NetCdfWriter { /* private fields */ }
Expand description

NetCDF file writer.

Provides methods for creating and writing NetCDF files.

Implementations§

Source§

impl NetCdfWriter

Source

pub fn create(path: impl AsRef<Path>, version: NetCdfVersion) -> Result<Self>

Create a new NetCDF file for writing.

§Arguments
  • path - Path to the NetCDF file
  • version - NetCDF format version
§Errors

Returns error if the file cannot be created.

Source

pub const fn metadata(&self) -> &NetCdfMetadata

Get the file metadata.

Source

pub fn add_dimension(&mut self, dimension: Dimension) -> Result<()>

Add a dimension.

§Errors

Returns error if not in define mode or dimension already exists.

Source

pub fn add_variable(&mut self, variable: Variable) -> Result<()>

Add a variable.

§Errors

Returns error if not in define mode, variable already exists, or variable dimensions don’t exist.

Source

pub fn add_global_attribute(&mut self, attribute: Attribute) -> Result<()>

Add a global attribute.

§Errors

Returns error if not in define mode.

Source

pub fn add_variable_attribute( &mut self, var_name: &str, attribute: Attribute, ) -> Result<()>

Add a variable attribute.

§Errors

Returns error if not in define mode or variable doesn’t exist.

Source

pub fn end_define_mode(&mut self) -> Result<()>

End define mode and enter data mode.

After calling this, you can write data but cannot add dimensions, variables, or attributes.

§Errors

Returns error if already in data mode or if metadata is invalid.

Source

pub fn write_f32(&mut self, var_name: &str, data: &[f32]) -> Result<()>

Write f32 data to a variable.

§Errors

Returns error if in define mode, variable doesn’t exist, or data size doesn’t match variable size.

Source

pub fn write_f64(&mut self, var_name: &str, data: &[f64]) -> Result<()>

Write f64 data to a variable.

§Errors

Returns error if in define mode, variable doesn’t exist, or data size doesn’t match variable size.

Source

pub fn write_i32(&mut self, var_name: &str, data: &[i32]) -> Result<()>

Write i32 data to a variable.

§Errors

Returns error if in define mode, variable doesn’t exist, or data size doesn’t match variable size.

Source

pub fn close(self) -> Result<()>

Finalize and close the file.

Trait Implementations§

Source§

impl Debug for NetCdfWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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