Package 'mpbutils'

Title: Utilities for Mountain Pine Beetle Simulation Modelling
Description: Utilities for mountain pine beetle (MPB) simulation modelling.
Authors: Eliot J B McIntire [aut, cre] , Alex M Chubaty [aut]
Maintainer: Eliot J B McIntire <[email protected]>
License: GPL-3
Version: 0.1.3.9002
Built: 2024-11-14 05:45:34 UTC
Source: https://github.com/PredictiveEcology/mpbutils

Help Index


Create a set of binary stacks from quantitative stacks

Description

This is for converting forecasted abundance stacks in a list of simList objects into a list of binary stacks (presence/absence)

This is for converting forecasted abundance stack in a simList object into a binary stack (presence/absence)

The mask will occur with values of NA or values of 0.

Usage

binaryStacks(
  sims,
  thresholdAttackTreesMinDetectable = 1.4,
  thresholdPineProportion = 0.3,
  stackName = "predictedStack",
  propPineRasName = "propPineRas"
)

binaryStack(
  stk,
  propPineRas,
  thresholdAttackTreesMinDetectable = 1.4,
  thresholdPineProportion = 0.3
)

maskWPine(ras, propPineRas, thresholdPineProportion)

Arguments

sims

a list of simLists

thresholdAttackTreesMinDetectable

A scalar that delineates presence from an absense. Default is 1.4, which was derived from initial efforts to find a single value that works in all years.

thresholdPineProportion

A scalar. Values on the propPineRas that are below this threshold will be masked out, i.e., set to NA.

stackName

Character string. The name of the stack inside the simLists to use

propPineRasName

Character string. The name of the RasterLayer inside the simLists to use for proportion Pine.

stk

A stack of abundance

propPineRas

A RasterLayer that has values between 0 and 1, representing the proportion of pine cover in the pixel.

ras

A RasterLayer of abundance


Cleans the predicted raster

Description

Cleans the predicted raster

Usage

cleanUpPredictionRas(
  rasLog,
  propPineRas,
  thresholdAttackTreesMinDetectable = 1.4,
  thresholdPineProportion = 0.3
)

Arguments

rasLog

A RasterLayer of predicted mass attack, on a log scale

propPineRas

A RasterLayer of proportion pine cover.

thresholdAttackTreesMinDetectable

A scalar. This will have come from an optim call to estimate this using AUC and ROC. THIS IS NOT ON A LOG SCALE. It will be logged internally.

thresholdPineProportion

A scalar. The proportion of pine

years

A scalar indicating how many years are included in the rasLog

Value

A RasterLayer with ever


Calculate cumulative sum of a stack, with optional log

Description

Calculate cumulative sum of a stack, with optional log

Usage

cumulativeMap(stk, log = TRUE)

Arguments

stk

a RasterStack

log

Logical. Will take log(map) + 1


MPB red top growth function

Description

From Cooke and Carroll (2017).

Usage

growthFunction(x, s, dataset, growthData)

Arguments

x

beetle density

s

climate suitability factor

dataset

dataset name used for fitting: one of "Berryman1979_fit", "Berryman1979_forced", "Boone2011".

growthData

MPB red top growth data with which to fit.


2Dt kernel

Description

This is a 2-dimensional t-distribution that can be used for dispersal of natural entities. It has many characteristics (see Clark et al 1999)

Usage

kernel_twoDT(dist, mu, p)

kernel_twoDT_mean(mu, m)

Arguments

dist

A vector of distances

mu

The first parameter of the 2Dt kernel. This represents about 0.9 of the mean dispersal distance

p

The second parameter of the 2Dt kernel. This changes the shape.

Value

A vector of probabilities

References

Clark, J. S., M. Silman, R. Kern, E. Macklin, and J. HilleRisLambers. 1999. Seed dispersal near and far: patterns across temperate and tropical forests. Ecology 80:1475–1494.


Create study area based o ecoregion selection

Description

Create study area based o ecoregion selection

Usage

mpbStudyArea(ecoregions = c(112, 120, 122, 124, 126), targetCRS, cPath, dPath)

Arguments

ecoregions

numeric vector indicating which ecoregions to be included as part of the study area. Derived from http://sis.agr.gc.ca/cansis/nsdb/ecostrat/region/ecoregion_shp.zip.

targetCRS

target CRS string to use for reprojecting ecodistrict (study area) polygons.

cPath

cache path

dPath

destination path

Value

an sf object


MPB recruitment function

Description

From Cooke & Carroll (2017).

Usage

xt(xtminus1, cs, dataset, massAttacksMap, growthData)

Arguments

xtminus1

previous year's attack density

cs

climate suitability factor

dataset

dataset name used for fitting: one of "Berryman1979_fit", "Berryman1979_forced", "Boone2011".

massAttacksMap

RasterLayer of red attack densities

growthData

MPB red top growth data with which to fit.