pub struct FromFile<S: Scalar> { /* private fields */ }Expand description
Signal loaded from a CSV file.
Reads time-value pairs from a file and interpolates. This is useful for loading earthquake records, experimental data, etc.
§File Format
The file should be in CSV format with two columns: time and value. Lines starting with ‘#’ are treated as comments.
# Time, Value
0.0, 0.0
0.1, 0.5
0.2, 1.0§Example
use numra_core::signal::{Signal, FromFile};
// Load a CSV file with time,value columns
let signal: FromFile<f64> = FromFile::load("test_data/earthquake.csv").unwrap();
let accel = signal.eval(0.15); // Interpolated value at t=0.15
assert!(accel > 0.0 && accel < 1.0); // Interpolated between 0.5 and 1.0Implementations§
Source§impl<S: Scalar + FromStr> FromFile<S>
impl<S: Scalar + FromStr> FromFile<S>
Sourcepub fn load_with_interpolation<P: AsRef<Path>>(
path: P,
interp: Interpolation,
) -> Result<Self, String>
pub fn load_with_interpolation<P: AsRef<Path>>( path: P, interp: Interpolation, ) -> Result<Self, String>
Load signal data with specified interpolation method.
Sourcepub fn from_csv_string(
content: &str,
interp: Interpolation,
) -> Result<Self, String>
pub fn from_csv_string( content: &str, interp: Interpolation, ) -> Result<Self, String>
Load from raw CSV string content.
Sourcepub fn time_range(&self) -> (S, S)
pub fn time_range(&self) -> (S, S)
Get the time range.
Sourcepub fn as_tabulated(&self) -> &Tabulated<S>
pub fn as_tabulated(&self) -> &Tabulated<S>
Get the underlying tabulated data.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for FromFile<S>
impl<S> RefUnwindSafe for FromFile<S>where
S: RefUnwindSafe,
impl<S> Send for FromFile<S>
impl<S> Sync for FromFile<S>
impl<S> Unpin for FromFile<S>where
S: Unpin,
impl<S> UnsafeUnpin for FromFile<S>
impl<S> UnwindSafe for FromFile<S>where
S: UnwindSafe,
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