ilyamaclean / microclimf

Fast above, below or within canopy gridded microclimate modelling with R
5 stars 4 forks source link

unknown issue causes runmicro() to crash #4

Open dklinges9 opened 2 weeks ago

dklinges9 commented 2 weeks ago

Hi Ilya,

Given the C++ core of the models now, I have a harder time debugging issues that crop up. It seems that some errors cause an R session to crash rather than displaying an error message.

In this zip folder uploaded to Google Drive, I have a script (runmicro_test.R) and two sets of files (stored in /test and /test2). As executed in the script, using the files in /test works fine. Yet using files in /test2 causes runmicro() to crash. Both sets of files enable vegp to be created properly, and the point model via runpointmodel() works.

If you're able to take a crack at this and figure out what's going wrong, that'd be greatly appreciated. I've pasted my sessionInfo() below-- I've tried this already on two machines, both in R 4.2.3 and R 4.3.2, and the model crashes in both versions.

Thanks, Dave

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.4.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        R6_2.5.1          codetools_0.2-19  tidyselect_1.2.1  lattice_0.21-9    magrittr_2.0.3    glue_1.7.0        tibble_3.2.1     
 [9] microclimf_0.2.0  pkgconfig_2.0.3   dplyr_1.1.4       generics_0.1.3    lifecycle_1.0.4   cli_3.6.3         fansi_1.0.6       terra_1.7-78     
[17] grid_4.3.2        vctrs_0.6.5       ncdf4_1.23        compiler_4.3.2    rstudioapi_0.16.0 tools_4.3.2       sp_2.1-2          pillar_1.9.0     
[25] Rcpp_1.0.13       rlang_1.1.4
dklinges9 commented 2 weeks ago

an update: subsetting the micropoint output avoids crashing. micro <- subsetpointmodel(micro, tstep = "month", what = "tmax")

Normally I would think this would suggest memory-limitation issues, but given that I'm predicting across just a 9 x 10 pixel scene, for one year, and have been testing in an R session with 100 GB of memory, I don't think memory is the issue.

ilyamaclean commented 1 week ago

Could you fix this line of code in the example:

climdata <- climdata %>% dplyr::filter(obs_time %in% tme)

dklinges9 commented 1 week ago

Hi Ilya,

Thanks for the prompt reply. that line was just to subset the climate timeseries, so the model would run faster (and ultimately crash sooner). I just removed that subsetting, as it wasn't causing the model to crash. Here in this updated Google Drive link is the updated code is the updated script, with the same data.

Model still causing R to crash