Open aleixab opened 1 month ago
Did you use the very latest version? I think that was due to an issue that arose in the conversion from raster to terra (getting rid of rgdal). I can't reproduce it at my end.
Thanks for the quick reply!
I have been using the latest version of NicheMapR (v3.3.2), but I haven't tried using the latest commit from the main branch yet.
Here are the versions of the packages and R that I am currently using:
> sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] English_Belgium.utf8
time zone: Europe/Brussels
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RNetCDF_2.9-2 geodata_0.6-2 ncdf4_1.23 NicheMapR_3.3.2 terra_1.7-83
Thanks!
Can you try the latest commit and see if you have the same problem?
I ran it using both the newest release and the latest commit, but I keep getting the same output. I also tried running it on a different computer and encountered the same issue. I looked through the function source code but couldn't identify what is causing the problem. One thing I noticed is that some of the links were broken, though I’m not sure if this is expected.
Thank you very much in advance.
It took a while but I tracked down the issue. It was not specific to micro_terra but to when snow was falling on the first day and the default snow density function was in operation. There was a variable ('cursnow') used to calculate snow density that wasn't initialised properly causing the second run to not work properly. The behaviour depends on the compiler it seems - on my system it just resulted in very slightly different values for the first day but on you system it appears to have led to an NA value. The fix is pushed to github now, so see if it works for you.
Thank you for checking and implementing the changes. Initially, I still encountered the same issue with the latest commit: after the first run, the values were below -40. However, after comparing results across different computers, we found that while most of them showed the same -40 issue, one computer produced the correct output.
The only difference we noted was in the computer’s language and region settings. When we switched to the United Kingdom region and English (UK) language, the code ran without issues. However, when set to Belgium and English (Belgium), for example, the problem persisted.
I'm not familiar with why this would cause an error in R in the first place, but I hope this insight will help you identify the issue or assist others facing the same problem.
Feel free to close this issue. Thanks again!
We have encountered an issue where running the micro_terra() function multiple times produces inconsistent outputs.
For example, running:
The second execution returns an incorrect result, despite no changes in inputs or variables. This issue also occurs when running the example provided in the documentation multiple times.
Any guidance and/or interpretations would be appreciated. Thank you very much!