Struct reservoirs::reservoir::Reservoir [−][src]
Struct for recording reservoir characteristics.
Fields
mass: Vec<f64>
Implementations
impl Reservoir
[src]
pub fn fit_range(
&self,
period: &f64,
boot: usize,
bat: usize,
dur: u64,
input: Range<f64>,
output: Range<f64>,
obs: &[f64],
title: &str
)
[src]
&self,
period: &f64,
boot: usize,
bat: usize,
dur: u64,
input: Range<f64>,
output: Range<f64>,
obs: &[f64],
title: &str
)
pub fn fit_rng(
&self,
period: &f64,
boot: usize,
bat: usize,
input: Range<f64>,
output: Range<f64>,
obs: &[f64]
) -> Vec<Gof>
[src]
&self,
period: &f64,
boot: usize,
bat: usize,
input: Range<f64>,
output: Range<f64>,
obs: &[f64]
) -> Vec<Gof>
Randomly selects rate pairs from ranges input
and output
, and simulates boot
number of accumulation records
in batches of bat
using fit_rate. Returns the selected input/output pair and the mean
goodness-of-fit statistics for each pair from boot
simulations. Called by fit_range.
Examples
use reservoirs::prelude::*; // mean expected deposit age and inherited age by facies let dep = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/dep.csv")?; let iat = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/iat.csv")?; // subset mean ages of debris flows let df: Vec<f64> = dep.iter().filter(|x| x.facies == "DF").map(|x| x.age).collect(); // subset inherited ages let ia: Vec<f64> = iat.iter().map(|x| x.age).collect(); let mut debris_flows = Reservoir::new().input(&0.78)?.output(&0.78)?.inherit(&ia); // fit 10 randomly selected rate pairs (from range 0.01 to 1.0) to observed debris flows // by running 1000 simulations for 30000 years for each pair let gofs = debris_flows.fit_rng(&30000.0, 1000, 10, 0.01..1.0, 0.01..1.0, &df);
pub fn fit_rate(
&self,
period: &f64,
other: &[f64],
boot: usize
) -> (f64, f64, f64)
[src]
&self,
period: &f64,
other: &[f64],
boot: usize
) -> (f64, f64, f64)
Runs boot
number of simulations of length period
on a reservoir.
Returns the mean goodness-of-fit statistics compared to accumulation record other
.
Called by fit_rng and steady. To use,
set characteristics of the reservoir before running.
Examples
use reservoirs::prelude::*; // mean expected deposit age and inherited age by facies let dep = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/dep.csv")?; let iat = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/iat.csv")?; // subset mean ages of debris flows let df: Vec<f64> = dep.iter().filter(|x| x.facies == "DF").map(|x| x.age).collect(); // subset inherited ages let ia: Vec<f64> = iat.iter().map(|x| x.age).collect(); let mut debris_flows = Reservoir::new().input(&0.78)?.output(&0.78)?.inherit(&ia); // run 1000 simulations for 30000 years and compare the fit against observed debris flows let (ks, kp, _) = debris_flows.fit_rate(&30000.0, &df, 1000); println!("K-S fit is {}.", ks); println!("Kuiper fit is {}.", kp);
pub fn fit_steady(
&self,
period: &f64,
boot: usize,
bat: usize,
dur: u64,
rate: Range<f64>,
obs: &[f64],
title: &str
)
[src]
&self,
period: &f64,
boot: usize,
bat: usize,
dur: u64,
rate: Range<f64>,
obs: &[f64],
title: &str
)
pub fn gof(&self, other: &[f64]) -> (f64, f64)
[src]
Compare the accumulated mass in a reservoir to another record. Produces two goodness-of-fit statistics in a tuple: the K-S statistic and the Kuiper statistic, respectively. Called by fit_rate, you can use it on individual records too.
Examples
use reservoirs::prelude::*; // mean expected deposit age and inherited age by facies let dep = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/dep.csv")?; let iat = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/iat.csv")?; // subset mean ages of debris flows let df: Vec<f64> = dep.iter().filter(|x| x.facies == "DF").map(|x| x.age).collect(); // subset inherited ages let ia: Vec<f64> = iat.iter().map(|x| x.age).collect(); let mut debris_flows = Reservoir::new().input(&0.78)?.output(&0.78)?.inherit(&ia); debris_flows = debris_flows.sim(&30000.0)?; let (ks, kp) = debris_flows.gof(&df); println!("K-S fit is {}.", ks); println!("Kuiper fit is {}.", kp);
pub fn inherit(self, ages: &[f64]) -> Self
[src]
Inherited age refers to age of charcoal upon entering the reservoir.
Multiple samples of charcoal from a single deposit produces a vector of inherited ages,
represented by the mean expected age of each charcoal sample in a f64 vector.
The sample age of charcoal is the sum of its inherited age plus transit time through the reservoir.
When simulating a reservoir model, each event entering the reservoir receives
a random amount of inherited age sampled from the vector ages
.
Examples
use reservoirs::prelude::*; // mean expected inherited age by facies let iat = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/iat.csv")?; // subset inherited ages let ia: Vec<f64> = iat.iter().map(|x| x.age).collect(); let res = Reservoir::new().inherit(&ia);
pub fn input(self, rate: &f64) -> Result<Self, ResError>
[src]
Assign an input rate to a reservoir.
Converts a reference to a float 64 rate
into an exponential distribution with lamdba rate
using the rand crate.
Examples
use reservoirs::prelude::*; res = Reservoir::new().input(&0.58)?;
pub fn new() -> Self
[src]
Create reservoirs using a builder pattern. Calling new() creates an empty reservoir. Use the input and output methods to set rates, which start at None. Set inherited age similarly using the method inherit.
Examples
use reservoirs::prelude::*; let mut res = Reservoir::new();
pub fn output(self, rate: &f64) -> Result<Self, ResError>
[src]
Assign an output rate to a reservoir.
Converts a reference to a float 64 rate
into an exponential distribution with lamdba rate
using the rand crate.
Examples
use reservoirs::prelude::*; res = Reservoir::new().output(&0.58)?;
pub fn sim(self, period: &f64) -> Result<Self, ResError>
[src]
Workhorse function for simulating accumulation records in a reservoir.
Runs simulations on reservoir objects created using the builder pattern.
period
specifies the amount of time to simulate accumulation in years.
While generally this is a function called in series by other functions, you can use
it to simulate a single accumulation record for a reservoir.
Examples
use reservoirs::prelude::*; // create reservoirs let mut fines = Reservoir::new().input(&0.75)?.output(&0.75)?; let mut gravels = Reservoir::new().input(&0.54)?.output(&0.54)?; // simulate accumulation for 30000 years fines = fines.sim(&30000.0)?; gravels = gravels.sim(&30000.0)?;
pub fn stereotype(&self, period: &f64, boot: usize, bins: usize) -> Vec<f64>
[src]
pub fn steady(
&self,
period: &f64,
boot: usize,
bat: usize,
rate: Range<f64>,
obs: &[f64]
) -> Vec<Gof>
[src]
&self,
period: &f64,
boot: usize,
bat: usize,
rate: Range<f64>,
obs: &[f64]
) -> Vec<Gof>
Randomly selects a rate from ranges rate
for a steady state reservoir,
and simulates boot
number of accumulation records
in batches of bat
using fit_rate. Returns the selected input/output pair and the mean
goodness-of-fit statistics compared to obs
for each pair from boot
simulations.
Called by fit_steady.
Examples
use reservoirs::prelude::*; // mean expected deposit age and inherited age by facies let dep = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/dep.csv")?; let iat = Sample::read("https://github.com/crumplecup/reservoirs/blob/master/examples/iat.csv")?; // subset mean ages of debris flows let df: Vec<f64> = dep.iter().filter(|x| x.facies == "DF").map(|x| x.age).collect(); // subset inherited ages let ia: Vec<f64> = iat.iter().map(|x| x.age).collect(); let mut debris_flows = Reservoir::new().input(&0.78)?.output(&0.78)?.inherit(&ia); // fit 10 steady state reservoirs with randomly selected rates (from range 0.01 to 1.0) to observed debris flows // by running 1000 simulations for 30000 years for each pair let gofs = debris_flows.steady(&30000.0, 1000, 10, 0.01..1.0, &df);
pub fn transit_times(
&self,
period: &f64,
boot: usize
) -> Result<Quartiles, ResError>
[src]
&self,
period: &f64,
boot: usize
) -> Result<Quartiles, ResError>
Estimate transit time of mass through a reservoir.
period
is period of time in years to simulate accumulation in the reservoir.boot
is the number of simulations to run for estimation.- Returns a result containing a plotters Quartile struct or a ResError.
Examples
use reservoirs::prelude::*; let period: f64 = 30000.0; // length of time to simulate accumulation in the reservoir in years let boot: usize = 1000; // number of simulations to run for estimation let df_rt: f64 = 0.78; // rate for steady state debris-flow accumulation let ff_rt: f64 = 0.63; // rate for steady state fluvial fines accumulation let fg_rt: f64 = 0.58; // rate for steady state fluvial gravels accumulation // to estimate transit times, omit inherit age from charcoal let debris_flows = Reservoir::new().input(&df_rt)?.output(&df_rt)?; let fines = Reservoir::new().input(&ff_rt)?.output(&ff_rt)?; let gravels = Reservoir::new().input(&fg_rt)?.output(&fg_rt)?; // quartiles of transit times let df = debris_flows.transit_times(&period, boot)?; let ff = fines.transit_times(&period, boot)?; let fg = gravels.transit_times(&period, boot)?; plot::whisker_for_facies(&df, &ff, &fg, "examples/transit_times.png")?
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Reservoir
[src]
impl Send for Reservoir
[src]
impl Sync for Reservoir
[src]
impl Unpin for Reservoir
[src]
impl UnwindSafe for Reservoir
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> SetParameter for T
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,