ImperialCollegeLondon / virtual_ecosystem

This repository is the home for the codebase for the Virtual Ecosystem project.
https://virtual-ecosystem.readthedocs.io
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

Add dynamic filled canopy index to LayerStructure. #451

Closed davidorme closed 2 months ago

davidorme commented 2 months ago

Is your feature request related to a problem? Please describe.

The extended LayerStructure object being implemented in #421 and sub-branches #444, #446 and #447 provides indexing across all of the vertical layers in the simulation. However, it only has access to the constant information set up in the model configuration and many models make use of indexing of the occupied canopy layers, not just the complete configured set of canopy layers.

It is possible that many of these methods could be rewritten to handle np.nan in the input data, but at the moment we use a lot of indexing and insertion to only update layers where the canopy in at least one cell is not np.nan. This information needs to be set dynamically from within the plants model, but that update process should be exposed as a method so that it can be set statically in testing.

This information could go into Data, but adding it to LayerStructure keeps the vertical indexing all in one place, and allows the LayerStructure code to provide aggregate indices e.g. above canopy + filled canopy + surface. This should simplify the code and make the layer structure selection much more transparent.

Describe the solution you'd like

A new LayerStructure.set_filled_canopy method, that takes a boolean index of filled canopy layers, and updates all the internal canopy structures.