mnp.evaluation package
Submodules
- class mnp.evaluation.qgis_templates.EnvironmentalFactorTemplate
Bases:
QgisLayerTemplate
For reading the environmental factor qgis layer template
- class mnp.evaluation.qgis_templates.HSITemplate
Bases:
QgisLayerTemplate
For reading the HSI qgis layer template
- class mnp.evaluation.qgis_templates.LandTypeMapTemplate(land_type_id_to_code_name: dict)
Bases:
QgisLayerTemplate
Template for categorical land type map
- class mnp.evaluation.qgis_templates.PopulationMapTemplate(species_model: SpeciesModel)
Bases:
QgisLayerTemplate
Template for a species populations map, identifying individual populations, as well as keypopulation/non-keypopulation distinction
- Parameters:
species_model (SpeciesModel) – Instance of SpeciesModel class
- class mnp.evaluation.qgis_templates.QgisLayerTemplate
Bases:
object
Class for qgis layer file templates. Holds location of template files and methods to find&replace text in a template and to write a template to file.
- find_replace(key: str, value: str | int)
Find and replace in template lines. Used to modify a template towards a specific species
- Parameters:
key (str) – target text to replace
value (str | int) – replacement text
- read_template_lines(template_type: str)
Read a template type from file. Currently supported: * abiotic_factor template * hsi template * populations template * land_types
- Parameters:
template_type (str) – key for reading a specific template from file. Currently supported choices are: [environmental_factor, fraction_key_populations_map, hsi, population_map]
- write_to_file(destination)
Write template to file
- Parameters:
destination (str) – full path, filename and extension for the template
- mnp.evaluation.qgis_templates.get_land_type_color(land_type_code: str) str
Return default colour for a SNL Natuurtype beheertype code.
- Parameters:
land_type_code –
- mnp.evaluation.qgis_templates.rand_web_color_hex() str
” Generate random color. See: https://blog.stigok.com/2019/06/22/generate-random-color-codes-python.html
- class mnp.evaluation.subselection_evaluation.SubselectionEvaluation(name: str, species_codes: set[str])
Bases:
object
Class for holding classes that evaluate and generate output for a subselection of species. Creates tables and raster layer files in the cover output/<subselection_name> directory
- Parameters:
name (str) – name of the subselection
species_codes (List[str]) – list of species codes for the species belonging to this subselection
- mnp.evaluation.subselection_evaluation.create_output(evaluation: SubselectionEvaluation)
Create each of the given species subselection’s output tables, maps or other outputs.
- Parameters:
evaluation (SubselectionEvaluation) – The subselection evaluation instance to create outputs for.
- class mnp.evaluation.subselection_output.AssignedSpeciesMap(subselection_evaluation: SubselectionEvaluation, parameters: MNPParameters, land_types: dict, output_path: str = '')
Bases:
SubselectionMap
Species GeoMap with the number of species assigned to the combined land types in each pixel location Ook wel bekend als de TOEKENNINGSKAART.
- Parameters:
species_codes (list[str]) – list with species codes
geospatial_profile (DefaultGTiffProfile) – profile of geospatial output
output_path (str) – output path
land_types (dict) – output from read_aggregated_map()
- content = 'assigned species based on land type'
- create()
Calculate an array where each cell value identifies the number of distinct species from this subselection assigned to all land_types occuring in that cell.
- Parameters:
suitability_indexes (pd.DataFrame) – DataFrame with land type suitability indexes
land_types (dict) – dictionary with land type NPZ files read from file as values, output from read_aggregated_map()
- to_file()
- write_explanatory_table()
Write CSV file with species count per land type
- Parameters:
parameters (MNPParameters) – output from make_parameters
land_types (dict) – dictionary with land type NPZ files read from file as values, output from read_aggregated_map()
- class mnp.evaluation.subselection_output.DetailedTable(subselection_evaluation: SubselectionEvaluation, species_models: ReferenceType, output_path: str)
Bases:
Table
Output table for a species subselection, where rows are species and columns carry information regarding the performance of the species in the model run.
- Parameters:
subselection_species_codes (list[str]) – list of species codes for which this table will be construed
- add_to_table_data(master_dict: dict, species_obj: SpeciesModel)
Add data from a species model object to the table
- Parameters:
master_dict (dict) – dictionary with species model properties
species_obj (SpeciesModel) – A speciesModel instance
- create()
Create the detailed table.
- Parameters:
species_models (list[SpeciesModel]) – list of SpeciesModel objects, from which information on the species performance in the model run is extracted.
- class mnp.evaluation.subselection_output.HotSpotsMap(geospatial_profile: DefaultGTiffProfile, assigned_species_map: AssignedSpeciesMap, key_population_count_map: KeyPopulationsCountMap, output_path: str = '')
Bases:
SubselectionMap
Fraction key populations map.
- Parameters:
geospatial_profile (DefaultGTiffProfile) – profile of geospatial output
output_path (str) – output path
- content = 'fraction of assigned species with a population reaching at least a key population in size'
- create()
Calculate Hotspots map, also known as fraction key populations map
- Parameters:
assigned_species_map (AssignedSpeciesMap) – Map with assigned species count per pixel
key_population_count_map (KeyPopulationsCountMap) – Map with key population count per pixel
- save_qml()
Add QGIS QML template file to output for file formatting
- to_file()
- class mnp.evaluation.subselection_output.KeyPopulationsCountMap(geospatial_profile: DefaultGTiffProfile, subselection_evaluation: SubselectionEvaluation, species_models: ReferenceType, output_path: str = '')
Bases:
SubselectionMap
Species GeoMap with the number of keypopulations exisiting at each pixel location
- Parameters:
geospatial_profile (DefaultGTiffProfile) – profile of geospatial output
output_path (str) – output path
- content = 'key population count'
- create()
- class mnp.evaluation.subselection_output.LandTypeMap(subselection_evaluation: SubselectionEvaluation, land_types: dict, parameters: MNPParameters, output_path: str = '')
Bases:
SubselectionOutput
QGIS qlr file pointing to the land-types map in <cover>inputland_typesland_types.tif QLR file is populated with land types only that are coupled to one or more species in the species subselection.
- create()
- save_qlr()
- to_file()
- class mnp.evaluation.subselection_output.QGisLayers(subselection_evaluation: SubselectionEvaluation, layer_type: str, species_models: ReferenceType, output_path: str)
Bases:
SubselectionOutput
- create()
Create QGIS QLR layer files for the tif files of the species in the subselection.
- Concerns:
- outputhsi<species_code>.tif –>
outputspecies_subselections<selection_name>hsi_maps<species_code>.qlr
- outputenvironmental_factor<species_code>.tif –>
outputspecies_subselections<selection_name>environmental_factor_maps<species_code>.qlr
- outputclustering<species_code>.tif –>
outputspecies_subselections<selection_name>population_maps<species_code>.qlr
- Parameters:
layer_type (str) – currently supported are [hsi, environmental_factor, habitats]
species_models (list[SpeciesModel]) – list of SpeciesModel objects
- Return type:
*.qlr on disk
- to_file()
- class mnp.evaluation.subselection_output.SubselectionMap(geospatial_profile: DefaultGTiffProfile, output_path: str = '')
Bases:
SubselectionOutput
- abstract create()
- to_file()
- class mnp.evaluation.subselection_output.SubselectionOutput(output_path: str)
Bases:
ABC
Abstact base class for all classes that have to generate output for a subselection of species.
- abstract create()
- abstract to_file()
- class mnp.evaluation.subselection_output.SummaryTable(detailed_table: DetailedTable, output_path: str)
Bases:
Table
Output table for a species subselection. Table contains viability classes as rownames, species group names as columns and values are counts for each viability-class/species-group combination.
- create()
Create the summary table.
- Parameters:
detailed_table (pd.DataFrame) – table from the DetailedTable class
- name = 'summary_table.csv'
- class mnp.evaluation.subselection_output.Table(output_path)
Bases:
SubselectionOutput
Basic properties of all output tables.
- abstract create()
- to_file()
Write the table to CSV file.
- mnp.evaluation.subselection_output.add_output_to_subselection(evaluation: ~mnp.evaluation.subselection_evaluation.SubselectionEvaluation, output_pathway: ~mnp.preparation.io_pathways.OutputPathway, parameters: ~mnp.config.MNPParameters, species_models: list[~mnp.species_models.species_model.SpeciesModel], land_types: dict[slice(<class 'str'>, <class 'scipy.sparse._base.sparray'>, None)])
- mnp.evaluation.subselection_output.identify_land_types_per_species(suitability_indexes: DataFrame, species_codes: set[str], land_types: dict)
Identify how many species are coupled to each land type, considering only the species in this particular subselection and only the land types available in this MNP run.
- Parameters:
species_codes (set[str]) – set of species code strings
land_types (dict) – dictionary with land type NPZ files read from file as values, output from read_aggregated_map()
suitability_indexes (pd.DataFrame) – DataFrame with land type suitability indexes
- Return type:
Dictionary with species_codes as keys and list of land_types as values