API for the functional_group module#

The models.animal.functional_group module contains a class that organizes constants and rate equations used by AnimalCohorts in the animal module.

Classes:

FunctionalGroup(name, taxa, diet, ...[, ...])

This is a class of animal functional groups.

Functions:

get_functional_group_by_name(...)

Retrieve a FunctionalGroup by its name from a tuple of FunctionalGroup instances.

import_functional_groups(fg_csv_file, constants)

The function to import pre-defined functional groups.

class virtual_ecosystem.models.animal.functional_group.FunctionalGroup(name: str, taxa: str, diet: str, metabolic_type: str, reproductive_environment: str, reproductive_type: str, development_type: str, development_status: str, offspring_functional_group: str, excretion_type: str, migration_type: str, vertical_occupancy: str, birth_mass: float, adult_mass: float, density_individuals_m2: float | None = None, t_opt: float | None = None, t_max_crit: float | None = None, t_min_crit: float | None = None, constants: AnimalConstants = AnimalConstants())[source]#

This is a class of animal functional groups.

The goal of this class is to collect the correct constants and scaling relationships needed by an animal cohort such that they are accessed at initialization and stored in the AnimalCohort object as attributes. This should result in a system where an animal cohort can be auto-generated with a few keywords and numbers but that this procedure only need run once, at initialization, and that all further references to constants and scaling relationships are accessed through attributes of the AnimalCohort in question.

Attributes:

adult_mass

The mass of the functional group at adulthood.

birth_mass

The mass of the functional group at birth.

broad_diet

The broad trophic category, herbivore, carnivore, omnivore.

cnp_proportions

The proportions of carbon/nitrogen/phosphorus in the functional group, example {"C": 0.8, "N": 0.15, "P": 0.05}.

constants

Animal constants.

conversion_efficiency

The conversion efficiency of the functional group based on diet.

density_individuals_m2

Optional empirical density in individuals per m² for initialization.

development_status

The development status of the functional group.

development_type

The development type of the functional group.

diet

The diet of the functional group.

excretion_type

The excretion type of the functional group.

is_invertebrate

Whether the functional group is an invertebrate.

is_vertebrate

Whether the functional group is a vertebrate.

mechanical_efficiency

The mechanical transfer efficiency of a functional group based on diet.

metabolic_rate_terms

The coefficient and exponent of metabolic rate.

metabolic_type

The metabolic type of the functional group.

migration_type

The migration type of the functional group.

name

The name of the functional group.

offspring_functional_group

The offspring type produced by this functional group in reproduction or metamorphosis.

population_density_terms

The coefficient and exponent terms for the population density scaling.

prey_scaling

The predator-prey mass ratio scaling relationship.

reproductive_environment

The reproductive environment used by the functional group.

reproductive_type

The reproductive type of the functional group.

t_max_crit

Optional upper critical temperature for ectotherms [°C].

t_min_crit

Optional lower critical temperature for ectotherms [°C].

t_opt

Optional optimal activity temperature for ectotherms [°C].

taxa

The taxa of the functional group.

vertical_occupancy

The vertical occupancy type of the functional group.

adult_mass#

The mass of the functional group at adulthood.

birth_mass#

The mass of the functional group at birth.

broad_diet: DietType#

The broad trophic category, herbivore, carnivore, omnivore.

cnp_proportions#

The proportions of carbon/nitrogen/phosphorus in the functional group, example {“C”: 0.8, “N”: 0.15, “P”: 0.05}.

constants#

Animal constants.

conversion_efficiency#

The conversion efficiency of the functional group based on diet.

density_individuals_m2#

Optional empirical density in individuals per m² for initialization.

development_status#

The development status of the functional group.

development_type#

The development type of the functional group.

diet#

The diet of the functional group.

excretion_type#

The excretion type of the functional group.

is_invertebrate: bool#

Whether the functional group is an invertebrate.

is_vertebrate: bool#

Whether the functional group is a vertebrate.

mechanical_efficiency#

The mechanical transfer efficiency of a functional group based on diet.

metabolic_rate_terms#

The coefficient and exponent of metabolic rate.

metabolic_type#

The metabolic type of the functional group.

migration_type#

The migration type of the functional group.

name#

The name of the functional group.

offspring_functional_group#

The offspring type produced by this functional group in reproduction or metamorphosis.

population_density_terms#

The coefficient and exponent terms for the population density scaling.

prey_scaling#

The predator-prey mass ratio scaling relationship.

reproductive_environment#

The reproductive environment used by the functional group.

reproductive_type#

The reproductive type of the functional group.

t_max_crit#

Optional upper critical temperature for ectotherms [°C].

t_min_crit#

Optional lower critical temperature for ectotherms [°C].

t_opt#

Optional optimal activity temperature for ectotherms [°C].

taxa#

The taxa of the functional group.

vertical_occupancy#

The vertical occupancy type of the functional group.

virtual_ecosystem.models.animal.functional_group.get_functional_group_by_name(functional_groups: Iterable[FunctionalGroup], name: str) FunctionalGroup[source]#

Retrieve a FunctionalGroup by its name from a tuple of FunctionalGroup instances.

Parameters:
  • functional_groups – Tuple of FunctionalGroup instances.

  • name – The name of the FunctionalGroup to retrieve.

Returns:

The FunctionalGroup instance with the matching name.

Raises:

ValueError – If no FunctionalGroup with the given name is found.

virtual_ecosystem.models.animal.functional_group.import_functional_groups(fg_csv_file: Path, constants: AnimalConstants) list[FunctionalGroup][source]#

The function to import pre-defined functional groups.

This function is a first-pass of how we might import pre-defined functional groups, the specific options of which can be found in functional_group.py. This allows a user to set out a basic outline of functional groups that accept our definitions of parameters and scaling relationships based on those traits.

TODO: A structure for user-selection of which traits to employ. TODO: density test

Parameters:
  • fg_csv_file – The location of the csv file holding the functional group definitions.

  • constants – An object providing animal model constants.

Returns:

A list of the FunctionalGroup instances created by the import.