StemStochiometry basic structure.#825
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #825 +/- ##
===========================================
+ Coverage 94.08% 94.22% +0.13%
===========================================
Files 78 79 +1
Lines 6172 6320 +148
===========================================
+ Hits 5807 5955 +148
Misses 365 365 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
davidorme
left a comment
There was a problem hiding this comment.
Yup - that looks good!
| n_weighted_avg = np.dot( | ||
| self.data["ecto_supply_limit_n"][cell_id] | ||
| + self.data["arbuscular_supply_limit_n"][cell_id], | ||
| cohorts.n_individuals, |
There was a problem hiding this comment.
Should this be n_individuals * total tissue mass or crown_area?
| if self.n_surplus[cohort] > self.n_tissue_deficit[cohort]: | ||
| # If there is sufficient surplus N to cover the existing deficit, the | ||
| # amount of the deficit is subtracted from the surplus which persists until | ||
| # the next update. All tissue types are updated to the ideal N ratios. | ||
| self.n_surplus[cohort] = ( | ||
| self.n_surplus[cohort] - self.n_tissue_deficit[cohort] |
There was a problem hiding this comment.
Handle with .max() and the subtract to get remaining surplus
davidorme
left a comment
There was a problem hiding this comment.
@sallymatson Looks really good - very clean coding. Changes are mostly either "more comments" or minor structural changes.
The bigger one is the setup of the Tissues abstract class, which I think we can finesse a bit. I've called in @dalonsoa to just check this isn't an "everything looks like a nail" issue.
There was a problem hiding this comment.
This looks good - it's nicely structured and seems really coherent with the rest of the existing test suite.
The only thing I'd add are more comments in the test code to walk through what is happening. These really don't have to be extensive but even # now create the XYZ object to test ABC style comments make it much easier to pick tests up if they need updating.
| n_avaiable_per_cohort = n_weighted_avg / sum(n_weighted_avg) | ||
| n_available_per_stem = np.divide( | ||
| n_avaiable_per_cohort, cohorts.n_individuals | ||
| ) |
There was a problem hiding this comment.
| n_avaiable_per_cohort = n_weighted_avg / sum(n_weighted_avg) | |
| n_available_per_stem = np.divide( | |
| n_avaiable_per_cohort, cohorts.n_individuals | |
| ) | |
| n_available_per_cohort = n_weighted_avg / sum(n_weighted_avg) | |
| n_available_per_stem = np.divide( | |
| n_available_per_cohort, cohorts.n_individuals | |
| ) |
Co-authored-by: arne-scheire <97458577+arne-exe@users.noreply.github.com>
Co-authored-by: arne-scheire <97458577+arne-exe@users.noreply.github.com> Co-authored-by: David Orme <davidorme@users.noreply.github.com>
davidorme
left a comment
There was a problem hiding this comment.
LGTM - basic structure of the class is now very clean looking and all the stretch goals are clearly noted for later PRs.
|
We should also add the stochiometric data into the CommunityDataExporter... |
Description
This PR adds a new module,
Stochiometry, to track plant NP values. The class stricture includes a baseclassFoliagewhich has subclasses for each tissue type. TheFoliagemodels store the element quantity, ideal ratios, and perform simple calculations using these values. The set of tissues for a cohort is stored in theStemStochiometryclass. This class has further fuctionality which can balance element surplus/deficit, and perform calculations across the whole plant foliage groups.The next steps for stochiometry include expanding the initialization so that each PFT can specify the initial ratios (#899), dealing with mortality (#800), and creating more robust tests to ensure all cases are covered (#801).
Fixes #749
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks