Skip to content

Commit

Permalink
fix output files path creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli committed Nov 22, 2023
1 parent baf7082 commit aab1be4
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/cplus_plugin/gui/qgis_cplus_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,9 @@ def run_highest_position_analysis(self):
f" [{dest_crs.authid()}]"
)

output_file = (
f"{self.scenario_directory}/"
f"{SCENARIO_OUTPUT_FILE_NAME}_{str(scenario.uuid)[:4]}.tif"
output_file = os.path.join(
self.scenario_directory,
f"{SCENARIO_OUTPUT_FILE_NAME}_{str(scenario.uuid)[:4]}.tif",
)

# Preparing the input rasters for the highest position
Expand Down Expand Up @@ -1100,8 +1100,8 @@ def run_pathways_analysis(self, models, priority_layers_groups, extent):

file_name = clean_filename(pathway.name.replace(" ", "_"))

output_file = (
f"{new_carbon_directory}/{file_name}_{str(uuid.uuid4())[:4]}.tif"
output_file = os.path.join(
new_carbon_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
)

if suitability_index > 0:
Expand Down Expand Up @@ -1508,7 +1508,9 @@ def run_pathways_normalization(self, models, priority_layers_groups, extent):
FileUtils.create_new_dir(new_ims_directory)
file_name = clean_filename(pathway.name.replace(" ", "_"))

output_file = f"{new_ims_directory}/{file_name}_{str(uuid.uuid4())[:4]}.tif"
output_file = os.path.join(
new_ims_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
)

pathway_layer = QgsRasterLayer(pathway.path, pathway.name)
provider = pathway_layer.dataProvider()
Expand Down Expand Up @@ -1672,7 +1674,9 @@ def run_models_analysis(self, models, priority_layers_groups, extent):
main_task.cancel()
return False

output_file = f"{new_ims_directory}/{file_name}_{str(uuid.uuid4())[:4]}.tif"
output_file = os.path.join(
new_ims_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
)

# Due to the implementation models base class
# model only one of the following blocks will be executed,
Expand Down Expand Up @@ -1832,13 +1836,14 @@ def run_normalization_analysis(self, models, priority_layers_groups, extent):
main_task.cancel()
return False

basenames = []
layers = []
new_ims_directory = f"{self.scenario_directory}/normalized_ims"
FileUtils.create_new_dir(new_ims_directory)
normalized_ims_directory = f"{self.scenario_directory}/normalized_ims"
FileUtils.create_new_dir(normalized_ims_directory)
file_name = clean_filename(model.name.replace(" ", "_"))

output_file = f"{new_ims_directory}/{file_name}_{str(uuid.uuid4())[:4]}.tif"
output_file = os.path.join(
normalized_ims_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
)

model_layer = QgsRasterLayer(model.path, model.name)
provider = model_layer.dataProvider()
Expand Down Expand Up @@ -2065,12 +2070,16 @@ def run_priority_analysis(self, models, priority_layers_groups, extent):
if basenames is []:
return

new_ims_directory = f"{self.scenario_directory}/weighted_ims"
weighted_ims_directory = f"{self.scenario_directory}/weighted_ims"

FileUtils.create_new_dir(new_ims_directory)
FileUtils.create_new_dir(weighted_ims_directory)

file_name = clean_filename(model.name.replace(" ", "_"))
output_file = f"{new_ims_directory}/{file_name}_{str(uuid.uuid4())[:4]}.tif"

output_file = os.path.join(
weighted_ims_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
)

expression = " + ".join(basenames)

# Actual processing calculation
Expand Down

0 comments on commit aab1be4

Please sign in to comment.