Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MNP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Model for Nature Policy 🌿🦋🦆
MNP
Commits
d9d56fc0
Commit
d9d56fc0
authored
1 month ago
by
Roelofsen, Hans
Browse files
Options
Downloads
Patches
Plain Diff
refactor(MNP): extra message when MNP finished
parent
84d09e03
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mnp/MNP.py
+27
-18
27 additions, 18 deletions
mnp/MNP.py
with
27 additions
and
18 deletions
mnp/MNP.py
+
27
−
18
View file @
d9d56fc0
...
...
@@ -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,
lik
e species traits and group traits
databases containing all domain parameters, e
g
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
:
.
2
f
}
minutes
"
)
print
(
"
Thanks for using MNP
"
)
return
subselection_evaluations
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment