Hey Andrew!
I really love your package, SAMC. After using the package with a dataset of Burmese pythons and USGS landcover data, I've run into an issue when using the samc::mortality
function that previously wasn't occurring. When I calculate long-term mortality using the mortality
function without setting the time =
argument, my R session crashes... When I run the function with the built-in data there is no problem. I've tried resampling the data to many different resolutions, but nothing helps. Do you have any idea why this wasn't an issue before, when using the very same data? I can upload my data and script to google drive if needed.
Best,
-Alex.
samc::mortality
, print a specific error message for this instead of crashing? Likewise, would inconsistent NA
s in the occupancy and landscape layers also print an error instead of crashing?
raster::mask()
shouldn't affect the dimensions and that NAs were likely my problem, as I didn't force NAs from my landscape layers to my occupancy layer. Once my current job is done (~4 hrs), I'll try to recreate the issue and send you the code. My rasters are rather large, so I'll resample them and send you a link to a google drive folder?
@andrewmarx Hey again! Hope you're doing well. I see you've incorporated multiple absorbing states into the package! This is great news. I'm currently trying to use multiple absorbing states for the python project we used in the IALE workshop. But, I'm curious about the error I'm receiving. When I follow your "multiple absorption" example, I'm able to add the two complimentary layers as samc_obj$abs_states
. But, when I create my own samc object using the data from the workshop, if I try to add complementary layers as $abs_states
, I receive the following error:
Error in .local(x, ...) :
unused arguments (xmn = 0.5, xmx = 628.5, ymn = 0.5, ymx = 472.5, crs = NA)
The original absorption layer I passed samc
to create the object was just a raster addition of two layers, and when I attempted to create the $abs_states
tab, I just added them as a list--just like your example. I've used check()
and all.equal()
to make sure the complimentary layers are meeting the criteria indicated in your example. Unfortunately, I don't have the ability to make this a minimally repeatable example, so I'll have to push this into a GH repo if you'd like to see the code.
@andrewmarx One more question! Rob had provided a function for calculating net flow from samc visitation:
visitationNet <- function(samc, visitation, origin, dest){
require(Matrix)
Q <- samc@p[-nrow(samc@p), -nrow(samc@p)] #get Q only from samc object
nNet <- abs(skewpart(visitation*Q)) #get difference in rates for links using origin row of fundamental
visitNet <- pmax(rowSums(nNet),colSums(nNet)) #get max of rowSums / colSums for nodes
visitNet[c(origin, dest)] <- 2 * visitNet[c(origin, dest)] #set origin/dest = 1
return(visitNet)
}
But the @p
slot is no longer existent. Should I be using the @data@q
slot instead? I tried to modify the function to use that slot, but errors were returned.
The code I'm attempting to run is here:
visit_samc_lox_dest_net <- visitationNet(samc = samc_lox_dest,
visitation = samc::visitation(samc = samc_lox_dest, origin = origin_ever),
origin = origin_ever, dest = origin_lox)
The error it throws is this:
Error in visitationNet(samc = samc_lox_dest, visitation = samc::visitation(samc = samc_lox_dest, :
no slot of name "p" for this object of class "samc"
How can I get Q
from a p
matrix now, with the new updates?