pub struct NcFile { /* private fields */ }Expand description
A NetCDF Classic format file in memory
Holds all dimensions, variables (with data), and global attributes.
Can be read from and written to any Read/Write stream.
Implementations§
Source§impl NcFile
impl NcFile
Sourcepub fn add_dimension(&mut self, name: &str, length: Option<usize>) -> Result<()>
pub fn add_dimension(&mut self, name: &str, length: Option<usize>) -> Result<()>
Add a dimension
length = Some(n)for a fixed dimension of size nlength = Nonefor the unlimited (record) dimension
Only one unlimited dimension is allowed per file.
Sourcepub fn add_variable(
&mut self,
name: &str,
data_type: NcDataType,
dim_names: &[&str],
) -> Result<()>
pub fn add_variable( &mut self, name: &str, data_type: NcDataType, dim_names: &[&str], ) -> Result<()>
Add a variable
Dimension names must already be defined via add_dimension.
Sourcepub fn add_global_attribute(&mut self, name: &str, value: NcValue) -> Result<()>
pub fn add_global_attribute(&mut self, name: &str, value: NcValue) -> Result<()>
Add a global attribute
Sourcepub fn add_variable_attribute(
&mut self,
var_name: &str,
attr_name: &str,
value: NcValue,
) -> Result<()>
pub fn add_variable_attribute( &mut self, var_name: &str, attr_name: &str, value: NcValue, ) -> Result<()>
Add a variable attribute
Sourcepub fn set_variable_f64(&mut self, var_name: &str, data: &[f64]) -> Result<()>
pub fn set_variable_f64(&mut self, var_name: &str, data: &[f64]) -> Result<()>
Set variable data from f64 slice
Sourcepub fn set_variable_f32(&mut self, var_name: &str, data: &[f32]) -> Result<()>
pub fn set_variable_f32(&mut self, var_name: &str, data: &[f32]) -> Result<()>
Set variable data from f32 slice
Sourcepub fn set_variable_i32(&mut self, var_name: &str, data: &[i32]) -> Result<()>
pub fn set_variable_i32(&mut self, var_name: &str, data: &[i32]) -> Result<()>
Set variable data from i32 slice
Sourcepub fn set_variable_text(&mut self, var_name: &str, text: &str) -> Result<()>
pub fn set_variable_text(&mut self, var_name: &str, text: &str) -> Result<()>
Set variable data as text (for NC_CHAR variables)
Sourcepub fn dimensions(&self) -> &[NcDimension]
pub fn dimensions(&self) -> &[NcDimension]
Get dimensions
Sourcepub fn global_attributes(&self) -> &[(String, NcValue)]
pub fn global_attributes(&self) -> &[(String, NcValue)]
Get global attributes
Sourcepub fn variable_names(&self) -> Vec<&str>
pub fn variable_names(&self) -> Vec<&str>
Get variable names
Sourcepub fn variable(&self, name: &str) -> Result<&NcVariable>
pub fn variable(&self, name: &str) -> Result<&NcVariable>
Get a variable by name
Sourcepub fn num_records(&self) -> usize
pub fn num_records(&self) -> usize
Get number of records (unlimited dimension length)
Sourcepub fn write_to<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<()>
Write the NetCDF file to a writer
Sourcepub fn read_from<R: Read + Seek>(reader: &mut R) -> Result<Self>
pub fn read_from<R: Read + Seek>(reader: &mut R) -> Result<Self>
Read a NetCDF Classic file from a reader
Sourcepub fn read_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn read_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Read from a file path
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NcFile
impl RefUnwindSafe for NcFile
impl Send for NcFile
impl Sync for NcFile
impl Unpin for NcFile
impl UnsafeUnpin for NcFile
impl UnwindSafe for NcFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.