Commit 8fa07c3b authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Added input parameters check of SERA_creating_industrial_cells.py

Checks added to GDE_TOOLS_read_config_file.py
parent 5b4a5c4c
......@@ -374,6 +374,84 @@ def check_parameters(config, section_name):
else:
if not config[section_name]["decimal_places_costs"].isnumeric():
raise IOError("ERROR!! decimal_places_costs NEEDS TO BE A POSITIVE INTEGER!!")
elif section_name == "SERA_creating_industrial_cells":
if not config.has_option("SERA_creating_industrial_cells", "countries"):
raise IOError("ERROR!! countries PARAMETER MISSING FROM CONFIG FILE!!")
if not config.has_option("SERA_creating_industrial_cells", "col_lon"):
raise IOError("ERROR!! col_lon PARAMETER MISSING FROM CONFIG FILE!!")
if not config.has_option("SERA_creating_industrial_cells", "col_lat"):
raise IOError("ERROR!! col_lat PARAMETER MISSING FROM CONFIG FILE!!")
if not config.has_option("SERA_creating_industrial_cells", "width_EW"):
raise IOError("ERROR!! width_EW PARAMETER MISSING FROM CONFIG FILE!!")
else:
if not config[section_name]["width_EW"].isnumeric():
raise IOError("ERROR!! width_EW NEEDS TO BE A POSITIVE INTEGER!!")
if not config.has_option("SERA_creating_industrial_cells", "width_NS"):
raise IOError("ERROR!! width_NS PARAMETER MISSING FROM CONFIG FILE!!")
else:
if not config[section_name]["width_NS"].isnumeric():
raise IOError("ERROR!! width_NS NEEDS TO BE A POSITIVE INTEGER!!")
if not config.has_option("SERA_creating_industrial_cells", "precision_points"):
raise IOError("ERROR!! precision_points PARAMETER MISSING FROM CONFIG FILE!!")
else:
if not config[section_name]["precision_points"].isnumeric():
raise IOError("ERROR!! precision_points NEEDS TO BE A POSITIVE INTEGER!!")
if not config.has_option("SERA_creating_industrial_cells", "id_str"):
raise IOError("ERROR!! id_str PARAMETER MISSING FROM CONFIG FILE!!")
if not config.has_option("SERA_creating_industrial_cells", "export_type"):
raise IOError("ERROR!! export_type PARAMETER MISSING FROM CONFIG FILE!!")
else:
if (config[section_name]["export_type"].lower() != "shp") and (
config[section_name]["export_type"].lower() != "gpkg"
):
raise IOError("ERROR!! export_type PARAMETER NOT RECOGNISED!!")
if not config.has_option("SERA_creating_industrial_cells", "in_crs"):
raise IOError("ERROR!! in_crs PARAMETER MISSING FROM CONFIG FILE!!")
if not config.has_option("SERA_creating_industrial_cells", "consistency_checks"):
raise IOError("ERROR!! consistency_checks PARAMETER MISSING FROM CONFIG FILE!!")
else:
check_if_param_is_True_or_False(
config["SERA_creating_industrial_cells"]["consistency_checks"],
"consistency_checks",
)
if not config.has_option("SERA_creating_industrial_cells", "autoadjust"):
raise IOError("ERROR!! autoadjust PARAMETER MISSING FROM CONFIG FILE!!")
else:
check_if_param_is_True_or_False(
config["SERA_creating_industrial_cells"]["autoadjust"], "autoadjust"
)
if not config.has_option("SERA_creating_industrial_cells", "verbose"):
raise IOError("ERROR!! verbose PARAMETER MISSING FROM CONFIG FILE!!")
else:
check_if_param_is_True_or_False(
config["SERA_creating_industrial_cells"]["verbose"], "verbose"
)
if not config.has_option("SERA_creating_industrial_cells", "consistency_tol_dist"):
raise IOError("ERROR!! consistency_tol_dist PARAMETER MISSING FROM CONFIG FILE!!")
else:
try:
val = float(config[section_name]["consistency_tol_dist"])
if val <= 0.0:
raise IOError(
"ERROR!! consistency_tol_dist PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
except:
raise IOError(
"ERROR!! consistency_tol_dist PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
if not config.has_option("SERA_creating_industrial_cells", "consistency_tol_area"):
raise IOError("ERROR!! consistency_tol_area PARAMETER MISSING FROM CONFIG FILE!!")
else:
try:
val = float(config[section_name]["consistency_tol_area"])
if val <= 0.0:
raise IOError(
"ERROR!! consistency_tol_area PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
except:
raise IOError(
"ERROR!! consistency_tol_area PARAMETER NEEDS TO BE A POSITIVE REAL NUMBER"
)
else:
raise IOError("ERROR IN check_parameters(): " + section_name + " NOT RECOGNISED!!")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment