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

Feature/animal module - Energy to Mass Conversion #338

Merged
merged 14 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Changed plant resource mass determination to only calculate for the s…
…pecific cell.
TaranRallings committed Nov 16, 2023
commit f840129a47096738ba64f3f6934a98fa6e4622f8
2 changes: 1 addition & 1 deletion virtual_rainforest/models/animals/plant_resources.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ def __init__(self, data: Data, cell_id: int) -> None:
self.data = data
"""A reference to the core data object."""
self.mass_current: float = (
data["layer_leaf_mass"].sum(dim="layers").to_numpy()[cell_id]
data["layer_leaf_mass"].sel(cell_id=cell_id).sum(dim="layers").item()
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you're calculating multiple sums then only using one of them. Could you just calculate the sum you need?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I remember correctly, and I may not be remembering correctly, this is some of @davidorme 's work from the plant module implementation. If he has no objections to the change then I am happy with it.

"""The mass of the plant leaf mass [kg]."""