goldingn / pop

A Flexible Syntax for Population Dynamic Modelling :koala: :chart_with_upwards_trend:
Other
10 stars 2 forks source link

create classes for landscape structure and landscape dynamics #7

Closed goldingn closed 8 years ago

goldingn commented 8 years ago

To be defined by a distance matrix and patch quality vector (Functions could create these from a raster etc.). Combine this with a dispersal function (which acts on distance) to construct metapopulation dynamic.

Syntax idea:

# exponential dispersal function (withrange of 10km) 
d <- dispersal(adult, expo(d = 10))

# landscape from a simple set of patches
l <- landscape(distance = dists, quality = qual)

# create a landscape dynamic object
ld <- d * l
class(ld)
[1] "landscape_dynamic" "dynamic"           "list" 
goldingn commented 8 years ago

Here's a better syntax:

dispersal objects, with dispersal_transfun objects (special cases of transfun objects) can be added to dynamic objects in the usual way:

d <- dynamic(tr(adult ~ adult, p(0.5)),
             disp(adult, d(30)))

dynamics will also have a structure attribute on which they are defined (by default one patch, with area 1 and no features) which can be accessed and updated by:

structure(d)
## landscape structure with 1 patch
structure(d) <- landscape(distance_matrix, areas, features)
## landscape structure with 23 patches

Doing structure(d) <- NULL should remove the structure (returning it to single patch with area 1 & no features)

goldingn commented 8 years ago

landscape should be a glorified list of patches, with coordinates/distance matrix in the attributes - for symmetry with dynamic/transition classes

goldingn commented 8 years ago

Nope. landscape should be a list of dataframes, with rows in each corresponding to patches. accessor functions for patches should be cannibalised over to landscapes and patch objects made obselete.