Skip to content
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

Add CrownProfile class #311

Merged
merged 13 commits into from
Sep 30, 2024
Merged

Add CrownProfile class #311

merged 13 commits into from
Sep 30, 2024

Conversation

davidorme
Copy link
Collaborator

@davidorme davidorme commented Sep 30, 2024

Description

This PR:

  • Adds the CrownProfile class, which takes:
    • a set of stems as Flora or StemTraits,
    • a set of allometry values for those stems as a StemAllometry instance, and
    • an array of vertical heights, and
    • returns an object with attributes for crown radii and projected area values.
  • Update the naming of attributes and code to use crown systematically when referring to individual stem predictions, retaining canopy for the community wide combination of multiple stems in the Canopy class.
  • Relocates two functions from canopy_functions.py to flora.py - these calculate PFT traits (and in fact flora.py would be better as traits.py) and moving them avoids circular imports.
    • calculate_(canopy/crown)_q_m
    • calculate_(canopy/crown)_z_max_proportion
  • Relocates two functions from canopy_functions.py to t_model_functions.py - these calculate scaling allometries like the other functions in this module and moving them avoids circular imports.
    • calculate_(canopy/crown)_z_max
    • calculate_(canopy/crown)_r0
  • Adds a simple high level test that CrownProfile makes the same predictions as more detailed tests using the underlying functions.

Fixes #309

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • [] Tests added that prove fix is effective or that feature works

@davidorme davidorme linked an issue Sep 30, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (29c49f8) to head (502968d).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #311      +/-   ##
===========================================
+ Coverage    95.84%   95.87%   +0.03%     
===========================================
  Files           34       34              
  Lines         2404     2427      +23     
===========================================
+ Hits          2304     2327      +23     
  Misses         100      100              
Flag Coverage Δ
95.87% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

pyrealm/demography/canopy.py Outdated Show resolved Hide resolved
pyrealm/demography/canopy_functions.py Show resolved Hide resolved
tests/unit/demography/test_canopy_functions.py Outdated Show resolved Hide resolved
@davidorme
Copy link
Collaborator Author

@MarionBWeinzierl I've renamed those files as suggested and updated the references in docs and code.

@j-emberton j-emberton self-requested a review September 30, 2024 15:05
Copy link
Collaborator

@j-emberton j-emberton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing the docstrings.

@davidorme davidorme merged commit 81b3c21 into develop Sep 30, 2024
12 checks passed
@davidorme davidorme deleted the 309-add-canopyprofile-class branch September 30, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Add CanopyProfile class
4 participants