-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Quetzal-framework/develop
feat: dispersal kernel refactoring, examples and documentation
- Loading branch information
Showing
21 changed files
with
395 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "quetzal/quetzal.hpp" | ||
#include <iostream> | ||
#include <mp-units/ostream.h> | ||
|
||
using namespace quetzal; | ||
|
||
int main() | ||
{ | ||
// Shorten notation | ||
using namespace mp_units::si::unit_symbols; // SI system: km, m, s | ||
using quetzal::demography::dispersal_kernel::Gaussian; | ||
using quetzal::geography::lonlat; | ||
|
||
// Dispersal kernels operate on distances between geographic coordinates | ||
constexpr auto source = lonlat(2.25, 48.9176); | ||
constexpr auto target = lonlat(2.25, 48.95); | ||
constexpr auto distance = source.great_circle_distance_to(target) * km; | ||
|
||
// Used to parametrize the kernel | ||
constexpr auto param = Gaussian<>::param_type {.a=1000.*m}; | ||
|
||
// Compute quantities | ||
auto p = Gaussian<>::pdf(distance, param); | ||
auto d = Gaussian<>::mean_dispersal_distance(param); | ||
|
||
std::cout << "Dispersal from " << source << " to " << target << " :\n" | ||
<< "distance is " << distance << "\n" | ||
<< "probability is " << p << "\n" | ||
<< "mean dispersal distance is " << d << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "quetzal/quetzal.hpp" | ||
#include <filesystem> | ||
#include <cassert> | ||
|
||
using namespace quetzal; | ||
|
||
int main() | ||
{ | ||
auto file1 = std::filesystem::current_path() / "data/bio1.tif"; | ||
auto file2 = std::filesystem::current_path() / "data/bio12.tif"; | ||
|
||
// The raster have 10 bands that we will assign to 2001 ... 2010. | ||
std::vector<int> times(10); | ||
std::iota(times.begin(), times.end(), 2001); | ||
|
||
// Initialize the landscape: for each var a key and a file, for all a time series. | ||
using landscape_type = quetzal::geography::landscape<>; | ||
auto env = quetzal::geography::landscape<>::from_files( { {"bio1", file1}, {"bio12", file2} }, times ); | ||
std::cout << env << std::endl; | ||
|
||
// // Embed default demographic quantities along vertices (N_{xt}) and edges (Phi_{xyt}) | ||
// auto graph1 = env.to_4_neighborhood_graph<>(); | ||
// auto graph2 = env.to_8_neighborhood_graph<>(); | ||
// auto graph3 = env.to_complete_graph<>(); | ||
|
||
// auto weights graph.edges() | ||
// | [](const & e){ return { graph.source(e), graph.target(e)}; } | ||
// | [](const & p){ return { env.to_latlon(s), graph.to_latlon(t)}; } | ||
// | [](const & p){ return x.great_circle_distance_to(y);} | ||
// | [](const & d){ return quetzal::demography::dispersal_kernel::ExponentialPower(d, {.a=1., .b=5.5});} | ||
// | []() | ||
} |
Oops, something went wrong.