-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise and document functionality of canopy and crown #328
Revise and document functionality of canopy and crown #328
Conversation
…utes and docstrings to __init__
…so accept an array of heights
…rown-properties' into 315-calculate-light-extinction-interception
…pdate-documentation-for-canopy-and-crown
…pdate-documentation-for-canopy-and-crown
for more information, see https://pre-commit.ci
…://github.com/ImperialCollegeLondon/pyrealm into 316-update-documentation-for-canopy-and-crown
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #328 +/- ##
===========================================
- Coverage 95.29% 94.90% -0.39%
===========================================
Files 28 34 +6
Lines 1720 2554 +834
===========================================
+ Hits 1639 2424 +785
- Misses 81 130 +49 ☔ View full report in Codecov by Sentry. |
canopy_gap_fraction=canopy_gap_fraction, | ||
max_stem_height=self.max_stem_height, | ||
solver_tolerance=solver_tolerance, | ||
) | ||
|
||
self._calculate_canopy(community=community) | ||
|
||
def _calculate_canopy(self, community: Community) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to see the individual operations in _calculate_canopy()
broken out into separate methods for testability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see why.
The reason I haven't is because there are two trivial calculations and then a chain of calculations that build on each other. It could be split into calculate_leaf_area_index
and calculate_light_transmission
but both of those would be much cleaner as methods of Canopy
rather than standalone functions as the signatures are a bit unwieldy if we don't pass in the content of self
.
If we do that then we have:
class Canopy:
...
def _calculate_canopy(self, ...):
...
self._calculate_leaf_area_index()
self._calculate_light_transmission()
def _calculate_leaf_area_index(self, ...):
...
def _calculate_light_transmission(self, ...):
...
That's still all chained together - it's not immediately clear to me that there is a huge advantage. Did you mean to break them out into standalone functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j-emberton I think I'll leave it as is because I'm going to be revisiting this section in #337.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Just reviewing all this now.
Is this still draft PR? Aside from a little (suggested) restructuring in |
That's tricky - this isn't complete or final.
But it feels like it's just going to keep sprawling, so I'm tempted to address the issues and bank this and add bit size issues to fix the above. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok to me.
I 've added another comment regarding helping people understand what the list of valid str attributes that can be passed but its not a deal breaker.
Description
This issue:
Revises the crown and canopy modules. The main changes are
crown
intocanopy
:solve_canopy_area_filling_height
crown
:get_crown_xy
. I'm not 100% convinced about the API of this yet, but think it's useful.canopy
model to try and generalise how it works and fixed some bugs.Updates the user facing documentation for the crown and canopy modules.
Updates the existing tests to the new structures. Doesn't add any tests as yet.
Some things to note:
I've made the open PR Calculate canopy light extinction and interception #318 outdated. That PR is currently hanging with errors that I think are fixed in here and this PR includes all the code from Calculate canopy light extinction and interception #318. That turned out to be necessary because I needed to fix the code to I write the docs.
I've updated the way in which the metadata in the markdown notebooks is handled:
jupyter
itself can add metadata to notebooks and code cells. Because we are using Myst Markdown throughjupytext
, that has its own filtering mechanism that controls what actually gets preserved in the file. That's now caused all of our markdown files to get minor changes (hence the 47 files changed 😱 ).There are really only a few files that matter: the crown and canopy docs (
docs/source/users/demography/...
, the crown and canopy modules (pyrealm/demography/...
) and the minor rearrangements in the tests.Things to do (maybe not in this PR)
Will fix both #316 and #315
Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks