Support forest vertical profiles in runpointmodel with fast C++ implementation#8
Open
JohannaTrost wants to merge 6 commits intoilyamaclean:mainfrom
Open
Support forest vertical profiles in runpointmodel with fast C++ implementation#8JohannaTrost wants to merge 6 commits intoilyamaclean:mainfrom
JohannaTrost wants to merge 6 commits intoilyamaclean:mainfrom
Conversation
added 6 commits
July 11, 2025 12:35
…time and spatially along the z-axis.
…time and spatially along the forest profile.
…eafOne output from previous time step.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Ilya,
I’ve added new C++ functions to simulate microclimate along the forest profile (i.e., vertically across canopy height). This was originally developed to speed up my own use case, but I thought it might be useful for others as well, so I'm sharing it here :)
Usage
You can now pass a vector of heights to
runpointmodel()via thereqhgtargument, instead of a single value. For example:The output is a named list:
Each element is a 2D array with dimensions
number of time steps × number of heights.New C++ functions
The following C++ functions have been added:
runmodelProfileCalled from
runpointmodel()in R. It callsAboveCanopyProfilefor heights above the vegetation canopy (vegp[1]), andBelowCanopyProfilefor those below. Results are combined into a single output list.AboveCanopyProfileSimilar to
AboveCanopy, but extended to handle multiple heights above the canopy across all time steps.BelowCanopyProfileSimilar to
BelowCanopy, but for heights below the canopy, also across all time steps.Performance improvement
The new implementation significantly improves runtime. Benchmarks show it's 66× faster than looping over heights using the original
runpointmodel.For 58 heights and 8784 timesteps:
Of note, performance could be improved further, e.g., by parallelising the main loop in the C++ code.
Known Issue: Small discrepancies in Microclimate values
The example below compares the new implementation with the previous one (computing microclimate for each height separately). We can observe that the simulations are not identical, although differences seem to be small. So far I haven't found the cause for these discrepancies.