From 6a13444a506d5a6da45b459126987bf5b5b4a261 Mon Sep 17 00:00:00 2001 From: David Orme Date: Mon, 23 Sep 2024 15:37:27 +0100 Subject: [PATCH] Fixes from @MarionBWeinzierl --- pyrealm/demography/canopy.py | 7 +++++-- pyrealm/demography/canopy_functions.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyrealm/demography/canopy.py b/pyrealm/demography/canopy.py index f87b8532..d54ec7c1 100644 --- a/pyrealm/demography/canopy.py +++ b/pyrealm/demography/canopy.py @@ -79,8 +79,8 @@ def __init__( for layer in np.arange(self.n_layers - 1): target_area = (layer + 1) * community.cell_area * (1 - canopy_gap_fraction) - # TODO - the solution here is predictably closer to the upper bracket, might - # be a better algorithm to find the root. + # TODO - the solution here is typically closer to the upper bracket, might + # be a better algorithm to find the root (#293). solution = root_scalar( solve_community_projected_canopy_area, args=( @@ -106,6 +106,9 @@ def __init__( self.layer_heights[layer] = starting_guess = solution.root # Find relative canopy radius at the layer heights + # NOTE - here and in the calls below, validate=False is enforced because the + # Community class structures and code should guarantee valid inputs and so + # turning off the validation internally should simply speed up the code. self.stem_relative_radius: NDArray[np.float32] = ( calculate_relative_canopy_radius_at_z( z=self.layer_heights, diff --git a/pyrealm/demography/canopy_functions.py b/pyrealm/demography/canopy_functions.py index 9fc5426b..08271cf0 100644 --- a/pyrealm/demography/canopy_functions.py +++ b/pyrealm/demography/canopy_functions.py @@ -365,8 +365,9 @@ def calculate_stem_projected_leaf_area_at_z( validate: Boolean flag to suppress argument validation. """ - # TODO - could this merge with the stem crown area function? A lot of overlap, so - # could be much more efficient to return both from one function. + # NOTE: Although the internals of this function overlap a lot with + # calculate_stem_projected_crown_area_at_z, we want that function to be as + # lean as possible, as it used within solve_community_projected_canopy_area. if validate: _validate_z_args(z, crown_area, stem_height, f_g, q_m, z_max)