diff --git a/mnp/MNP.py b/mnp/MNP.py index 36baa04f32909c30d8a112ad51550c50654cbfe3..eee01823ecc8e9be98334fa6d42d4b3508292c21 100644 --- a/mnp/MNP.py +++ b/mnp/MNP.py @@ -19,7 +19,7 @@ from mnp.preparation.aggregate_land_type_map import ( read_aggregated_map, ) from mnp.preparation.filter_incomplete_cells import filter_incomplete_cells -from mnp.preparation.io_pathways import verify_user_input, InputPathway, OutputPathway +from mnp.preparation.io_pathways import InputPathway, OutputPathway, verify_user_input from mnp.preparation.read_rasters_from_cover import read_rasters_from_cover from mnp.preparation.verify_spatial_data_coverage import verify_spatial_data_coverage from mnp.species_models.species_model import ( @@ -27,16 +27,16 @@ from mnp.species_models.species_model import ( run_species_models, ) from mnp.utils import ( - log_file_to_cover, TEMP_DIR, - create_directories, - copy_input_file, - config_section_to_cover, - list_sources_destinations, add_dynamics_to_config, + config_section_to_cover, + copy_input_file, + create_directories, geo_profile_from_hsi, - log_start_completed, get_logger, + list_sources_destinations, + log_file_to_cover, + log_start_completed, ) DATA_COVERAGE_TIF = "spatial_data_coverage.tif" @@ -67,9 +67,11 @@ def prepare_input(parameters: MNPParameters, input_pathway: InputPathway) -> ( Returns ------- land_types:dict - The land type map as a dictionary with land type codes as key and arrays as values + The land type map as a dictionary with land type codes as key + and arrays as values environmentals - Dictionary with the name of the environmental factor as keys and their corresponding arrays as values + Dictionary with the name of the environmental factor as keys + and their corresponding arrays as values complying_species: set which species have all the needed information required for running parameters:dict @@ -95,18 +97,20 @@ def prepare_input(parameters: MNPParameters, input_pathway: InputPathway) -> ( # Prepare geodata land_types, environmentals = None, None if not input_pathway.hsi_from_disk: - # aggregate land type map if not already done (the task itself checks this) and read from folder + # aggregate land type map if not already done (the task itself checks this) + # and read from folder aggregate_land_type_map(parameters.folders) land_types = read_aggregated_map(folders=parameters.folders) - # Verify spatial overlap of all input in the case of running with environmental variables + # Verify spatial overlap of all input in the case of running with + # environmental variables if input_pathway.has_environmentals: environmentals = read_rasters_from_cover( parameters.folders["environmentals"] ) - # Check if land types and environmentals have enough overlap (at least 95%) and create spatial mask (=cells - # for which there is a value in all rasters) + # Check if land types and environmentals have enough overlap (at least 95%) + # and create spatial mask (=cells with a value in all rasters) verify_spatial_data_coverage(land_types, environmentals, parameters) # filter environmentals (keep only cells within spatial mask) @@ -149,9 +153,10 @@ def evaluate_models( subselection_evaluation: list[SubselectionEvaluation] list with an evaluation object for each species in this run parameters:dict - databases containing all domain parameters, like species traits and group traits + databases containing all domain parameters, eg species traits and group traits land_types:dict - The land type map as a dictionary with land type codes as key and arrays as values + The land type map as a dictionary with land type codes as key and arrays + as values Returns ------- @@ -193,9 +198,11 @@ def run_and_evaluate( Parameters ---------- land_types:dict - The land type map as a dictionary with land type codes as key and arrays as values + The land type map as a dictionary with land type codes as key + and arrays as values environmentals - Dictionary with the name of the environmental factor as keys and their corresponding arrays as values + Dictionary with the name of the environmental factor as keys and + their corresponding arrays as values parameters Returns @@ -264,7 +271,8 @@ def mnp(config: ConfigParser): try: logger.info( - f'Starting MNP run by {os.environ.get("username")} on {os.environ.get("computername")}.' + f'Starting MNP run by {os.environ.get("username")} on ' + '{os.environ.get("computername")}.' ) add_dynamics_to_config(config) input_pathway, output_pathway = verify_user_input(config) @@ -302,4 +310,5 @@ def mnp(config: ConfigParser): shutil.rmtree(TEMP_DIR) print(f"run took {(time.time() - start) / 60:.2f} minutes") + print("Thanks for using MNP") return subselection_evaluations