mnp.preparation.select_valid_species

Module Contents

Functions

melt_boolean_dataframe

Melts a pandas dataframe and retains rows where the value != True. Parses a message from the combination of the dataframe index, variable and value.

get_valid_species

Inspect all user provided identifiers in the species subselection list(s). Verify that:

get_valid_species_selections

Parse the user provided species selections to a dictionary with the sluggified selection name as keys and a list of valid only species codes as value. Any duplicates in the provided species lists are removed.

API

mnp.preparation.select_valid_species.melt_boolean_dataframe(df: pandas.DataFrame) str

Melts a pandas dataframe and retains rows where the value != True. Parses a message from the combination of the dataframe index, variable and value.

df: boolean Pandas dataframe with species identifiers as index and species criteria as columns.

msg: string separated by newlines

mnp.preparation.select_valid_species.get_valid_species(hsi_from_disk: bool, parameters) set

Inspect all user provided identifiers in the species subselection list(s). Verify that:

  1. user provided identifier is in fact a species, cq reference species_names.csv

  2. species has traits

  3. species is matched to at least one land type

4. species is matched to at least one land type that is employed in the land type raster 4. species has a valid trait group 5. species has a response to each provided abiotic

parameters: Instance of MNPParameters hsi_from_disk: boolean, this run reads HSI from disk

msg: <description of user provided identifiers that fail to meet criteria 1-5 OR success message>, species_codes: <set of species codes for all species that meet criteria 1-5>,

mnp.preparation.select_valid_species.get_valid_species_selections(valid_species: set, parameters) Dict[str, List[str]]

Parse the user provided species selections to a dictionary with the sluggified selection name as keys and a list of valid only species codes as value. Any duplicates in the provided species lists are removed.

parameters: MNPParameters instance valid_species: output from get_valid_species

out: dictionary with slugified species-selection names as keys and list of species codes as values.