ncsu-landscape-dynamics / rpops

PoPS (Pest or Pathogen Spread) R Package
https://ncsu-landscape-dynamics.github.io/rpops/
GNU General Public License v3.0
10 stars 5 forks source link

using mask in calibrate, validate, and multirun #103

Closed nkruskamp closed 3 years ago

nkruskamp commented 3 years ago

I am trying to incorporate a mask into my model runs. It appears to run successfully in calibrate but fails in validate and is missing from the multirun. It's not clear to me where the code differences are between calibrate and validate, but I can't find where the mask layer is used in configuration and checks.

ChrisJones687 commented 3 years ago

Good catch I will also add tests for this. I currently don't have mask as part of any functions other than validate and calibrate as they are on the ones that have specific calculations that benefit from it. The other functions could use it to set NAs for display purposes. Would pre-masking for display be where you would see if being useful in the other functions?

nkruskamp commented 3 years ago

Yes, for the multirun and other functions that output maps it would save the user a post-processing step of doing the mask themselves and provide for a consistent workflow from calibrate -> validate -> multirun.

Below is error in validate. I don't get this in calibrate. I've gone back through the code but can't find where the difference is between calibrate and validate, but I guess in calibrate the mask file is correctly converted to a SpatRaster object and that doesn't happen in validate. And it appears mask is passed to config but nothing happens in the config code?

Error in { : 
  task 1 failed - "task 1 failed - "unable to find an inherited method for function 'mask' for signature '"SpatRaster", "character"'""
ChrisJones687 commented 3 years ago

It is that SpatRasts are pointer files that break inside of a parallel loop. I will need to have it explicitly assigned like the other SpatRast objects in the validate function.