diff --git a/docs/source/api/demography_api.md b/docs/source/api/demography_api.md index c327e76b..459345c4 100644 --- a/docs/source/api/demography_api.md +++ b/docs/source/api/demography_api.md @@ -27,18 +27,26 @@ kernelspec: :members: ``` -## The {mod}`~pyrealm.demography.community` module +## The {mod}`~pyrealm.demography.t_model_functions` module ```{eval-rst} -.. automodule:: pyrealm.demography.community +.. automodule:: pyrealm.demography.t_model_functions :autosummary: :members: ``` -## The {mod}`~pyrealm.demography.t_model_functions` module +## The {mod}`~pyrealm.demography.crown` module ```{eval-rst} -.. automodule:: pyrealm.demography.t_model_functions +.. automodule:: pyrealm.demography.crown + :autosummary: + :members: +``` + +## The {mod}`~pyrealm.demography.community` module + +```{eval-rst} +.. automodule:: pyrealm.demography.community :autosummary: :members: ``` diff --git a/docs/source/users/demography/crown.md b/docs/source/users/demography/crown.md index 3e8d8a3a..a107675e 100644 --- a/docs/source/users/demography/crown.md +++ b/docs/source/users/demography/crown.md @@ -94,7 +94,7 @@ ax2.set_aspect("equal") The examples below show the calculation of crown profiles for a set of plant functional types (PFTs) with differing crown trait values. We first need to create a -:class:`~pyrealm.demography.flora.Flora` object that defines those PFTs. +{class}`~pyrealm.demography.flora.Flora` object that defines those PFTs. ```{code-cell} flora = Flora( @@ -223,6 +223,9 @@ for pft_idx, offset, colour in zip((0, 1, 2), (0, 5, 12), ("r", "g", "b")): linestyle=":", ) + ax.set_xlabel("Crown profile") + ax.set_ylabel("Height above ground (m)") + ax.set_aspect(aspect=1) ``` @@ -275,8 +278,6 @@ for pft_idx, offset, colour in zip((0, 1, 2), (0, 5, 10), ("r", "g", "b")): color=colour, linestyle="--", ) -``` - -```{code-cell} - + ax.set_xlabel("Projected area (m2)") + ax.set_ylabel("Height above ground (m)") ``` diff --git a/pyrealm/demography/crown.py b/pyrealm/demography/crown.py index ed93fa32..61a60ce1 100644 --- a/pyrealm/demography/crown.py +++ b/pyrealm/demography/crown.py @@ -391,6 +391,12 @@ class CrownProfile: projected_leaf_area: NDArray[np.float32] = field(init=False) """An array of the projected leaf area of stems at z heights""" + # Information attributes + _n_pred: int = field(init=False) + """The number of predictions per stem.""" + _n_stems: int = field(init=False) + """The number of stems.""" + def __post_init__( self, stem_traits: StemTraits | Flora, @@ -431,3 +437,18 @@ def __post_init__( stem_height=stem_allometry.stem_height, z_max=stem_allometry.crown_z_max, ) + + # Set the number of observations per stem (one if dbh is 1D, otherwise size of + # the first axis) + if self.relative_crown_radius.ndim == 1: + self._n_pred = 1 + else: + self._n_pred = self.relative_crown_radius.shape[0] + + self._n_stems = stem_traits._n_stems + + def __repr__(self) -> str: + return ( + f"CrownProfile: Prediction for {self._n_stems} stems " + f"at {self._n_pred} observations." + ) diff --git a/pyrealm/demography/t_model_functions.py b/pyrealm/demography/t_model_functions.py index ecdbdf17..dbedb70f 100644 --- a/pyrealm/demography/t_model_functions.py +++ b/pyrealm/demography/t_model_functions.py @@ -715,6 +715,7 @@ class StemAllometry: """Crown radius scaling factor (-)""" crown_z_max: NDArray[np.float32] = field(init=False) """Height of maximum crown radius (metres)""" + # Information attributes _n_pred: int = field(init=False) """The number of predictions per stem.""" @@ -789,7 +790,7 @@ def __post_init__( def __repr__(self) -> str: return ( - f"StemAllometry: Prediction for {self._n_stems} stems at se" + f"StemAllometry: Prediction for {self._n_stems} stems " f"at {self._n_pred} DBH values." ) @@ -860,6 +861,12 @@ class StemAllocation: delta_foliage_mass: NDArray[np.float32] = field(init=False) """Predicted increase in foliar mass from growth allocation (g C)""" + # Information attributes + _n_pred: int = field(init=False) + """The number of predictions per stem.""" + _n_stems: int = field(init=False) + """The number of stems.""" + def __post_init__( self, stem_traits: Flora | StemTraits, @@ -936,6 +943,6 @@ def __post_init__( def __repr__(self) -> str: return ( - f"StemAllocation: Prediction for {self._n_stems} stems" + f"StemAllocation: Prediction for {self._n_stems} stems " f"at {self._n_pred} observations." )