[go: up one dir, main page]

Skip to content

A Rust crate for building Neutral Landscape Models.

Notifications You must be signed in to change notification settings

tom-draper/nlmrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NLMrs

A Rust crate for building Neutral Landscape Models.

Inspired by nlmpy and nlmr.

Installation

cargo add nlmrs

Example

use nlmrs;

fn main() {
    let arr: Vec<Vec<f64>> = nlmrs::midpoint_displacement(10, 10, 1.);
    println!("{:?}", arr);
}

Export

The export module holds a collection of user-friendly functions to export your 2D NLM vector.

use nlmrs::{distance_gradient, export};

fn main() {
    let arr: Vec<Vec<f64>> = distance_gradient(50, 50);
    export::write_to_csv(arr, "./data/data.csv");
}

Visualization

Running scripts/visualize.py will read any contents of data/data.csv and render them as a matplotlib plot.

Algorithms

Random

random(rows: 100, cols: 100)

Random Element

random_element(rows: 100, cols: 100, n: 50000.)

Planar Gradient

planar_gradient(rows: 100, cols: 100, direction: Some(60.))

Edge Gradient

edge_gradient(rows: 100, cols: 100, direction: Some(140.))

Distance Gradient

distance_gradient(rows: 100, cols: 100)

Wave Gradient

wave_gradient(rows: 100, cols: 100, period: 2.5, direction: Some(90.))

Midpoint Displacement

midpoint_displacement(rows: 100, cols: 100, h: 1.)

Hill Grow

hill_grow(rows: 100, cols: 100, n: 10000, runaway: true, kernel: None, only_grow: false)

Contributions

Contributions, issues and feature requests are welcome.

  • Fork it (https://github.com/tom-draper/nlmrs)
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request