ImperialCollegeLondon / ImperialCollegeLondon/virtual_ecosystem
Implement the BaseDisturbance model
Open
@dalonsoa is already working on this.
Since Feb 23, 2026.
- Dominant language
- Python
- Stars
- 20
- Forks
- 5
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 34
Description
Likewise, it should follow largely this structure:
class BaseDisturbance(ABC)
disturbance_name: str
"""A name for the disturbance (eg. 'logging') that is used to key the disturbance in the DisturbanceRegistry and config."""
disturbed_models: list[str]
"""A list of model names that this disturbance will affect."""
data_variables_disturbed: list[str]
"""A list of data variables that will be updated."""
def __init__(self, data: Data, models: dict[str: BaseModel], timing: DisturbanceTiming, **kwargs):
"""Creates an instance."""
self.data = data
self.models = models
self.timing = timing
# check that the self.models contains cls.disturbed_models. This is checked
# when the class is registered (does the BaseModel exist _at all_) but also needs
# to be checked at runtime (is the BaseModel in _this simulation__).
def __init_subclass__(self, disturbance_name: str, disturbed_models: list[str]):
"""Checks the disturbed models and variables are all known and adds the disturbance to the registry."""
@classmethod
def from_config(cls, config: Config) -> BaseDisturbance:
"""Factory method to create instance from a Config instance."""
@abstractmethod
def disturb(self, time_index):
if not self.timing.check_run(time_index):
return
# Otherwise, do stuff to self.data and self.models
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.