NvecNAs: Convert population size in unsuitable cells to NA

View source: R/Nvec_NAs.R

NvecNAsR Documentation

Convert population size in unsuitable cells to NA

Description

converts cells in Nvec form to NA if their underlying hab suit is NA for that time point

Usage

NvecNAs(ph, l)

Arguments

ph

pophist object

l

landscape containing the rasters

Details

returns a pophist object where the Nvecs matrix (population size through time) has been altered such that population size in glaciated cells is recorded as NA. All other components of the returned pophist object are unaltered from ph. Useful for calculation of biotic velocity using enmSdm::bioticVelocity().

Value

a pophist object where population size in unsuitable cells at each time point is recorded as NA

See Also

getpophist2.cells, pophistToArray, bioticVelocity

Examples

library(holoSimCell)
parms <- drawParms(control = system.file("extdata/ashpaper","Ash_priors.csv",package="holoSimCell"))
load(file=paste0(system.file(package="holoSimCell"),"/extdata/landscapes/",pollenPulls[[1]]$file))
refpops <- pollenPulls[[1]]$refs
avgCellsz <- mean(c(res(landscape$sumrast)))

ph = getpophist2.cells(h = landscape$details$ncells, xdim = landscape$details$x.dim, ydim = landscape$details$y.dim,
                       landscape=landscape,
                       refs=refpops,   
                       refsz=parms$ref_Ne,
                       lambda=parms$lambda,
                       mix=parms$mix,  
                       shortscale=parms$shortscale*avgCellsz,  
                       shortshape=parms$shortshape, 
                       longmean=parms$longmean*avgCellsz,  
                       ysz=res(landscape$sumrast)[2], 
                       xsz=res(landscape$sumrast)[1], 
                       K = parms$Ne) 

times_1k <- seq(-21000,0,by=990)
   
pharray <- pophistToArray(NvecNAs(ph, landscape), times = times_1G)
   
metrics <- c('centroid', 'nsQuants', 'summary')

BV_permill_all <- bioticVelocity(
  x=pharray$pophistAsArray,
  times = times_1G,
  atTimes = times_1k,
  longitude=pharray$longitude,
  latitude=pharray$latitude,
  metrics=metrics,
  quants=c(0.05, 0.1, 0.9, 0.95),
  onlyInSharedCells = FALSE)


stranda/holoSimCell documentation built on Aug. 4, 2023, 1:12 p.m.