Struct reservoirs::reservoir::Reservoir[][src]

pub struct Reservoir {
    pub mass: Vec<f64>,
    // some fields omitted
}

Struct for recording reservoir characteristics.

Fields

mass: Vec<f64>

Ages (in years) of deposits accumulated in reservoir.

Implementations

impl Reservoir[src]

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 range(self, seed: u64) -> Self[src]

Assign a seed to the random number generator, for reproducibility.

  • seed is a number to convert in an RNG seed using the rand crate.

Examples

use reservoirs::prelude::*;
res = Reservoir::new().range(10101);

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)?;

Trait Implementations

impl Clone for Reservoir[src]

impl Debug for Reservoir[src]

impl Default for Reservoir[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> SetParameter for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,