Step4 心跳刷新 + Step10 输出目录更名与智能寻址优化

This commit is contained in:
DXC
2026-06-12 10:27:47 +08:00
parent 4c9ca2aa03
commit be47b70594
3 changed files with 68 additions and 36 deletions

View File

@ -1374,7 +1374,7 @@ class WaterQualityGUI(QMainWindow):
'step7_index': "6_water_quality_indices/training_spectra_indices.csv",
'step8_ml_train': "7_Supervised_Model_Training/",
'step9_ml_predict': "11_12_13_predictions/Machine_Learning_Prediction/",
'step10_watercolor': "8_WaterIndex_Images/",
'step10_watercolor': "10_WaterIndex_Images/",
'step11_map': "14_visualization/"
}
@ -2286,7 +2286,17 @@ class WaterQualityGUI(QMainWindow):
if step_id not in self.step_default_outputs:
return None
step_outputs = self.step_default_outputs[step_id]
raw = self.step_default_outputs[step_id]
# ★ 兼容扁平化后的纯字符串路径格式
rel_path = None
if isinstance(raw, str):
rel_path = raw
elif isinstance(raw, dict):
rel_path = raw.get(output_type) or list(raw.values())[0]
if not rel_path:
return None
# ★ 掩膜类型列表:这些类型只接受科学数据格式
mask_types = {'water_mask', 'glint_mask', 'boundary_mask'}
@ -2319,12 +2329,11 @@ class WaterQualityGUI(QMainWindow):
# 根据输出类型查找对应的文件
if output_type == 'water_mask':
# 水域掩膜:优先查找NDWI生成的其次是shp生成的
for mask_type in ['water_mask_ndwi', 'water_mask_shp']:
if mask_type in step_outputs:
mask_path = work_path / step_outputs[mask_type]
if mask_path.exists():
return str(mask_path)
# 水域掩膜:直接用统一路径
if rel_path:
mask_path = work_path / rel_path
if mask_path.exists():
return str(mask_path)
elif output_type == 'reference_img':
# 参考影像从step1的配置中获取用户输入的影像路径
if hasattr(self, 'step1_panel'):
@ -2332,32 +2341,29 @@ class WaterQualityGUI(QMainWindow):
if img_path and Path(img_path).exists():
return img_path
elif output_type == 'deglint_image':
# 去耀斑影像:查找step3的各种去耀斑方法输出
deglint_types = ['deglint_kutser', 'deglint_goodman', 'deglint_hedley', 'deglint_sugar']
for deglint_type in deglint_types:
if deglint_type in step_outputs:
deglint_path = work_path / step_outputs[deglint_type]
if deglint_path.exists():
return str(deglint_path)
# 去耀斑影像:直接用统一路径
if rel_path:
deglint_path = work_path / rel_path
if deglint_path.exists():
return str(deglint_path)
# 还要检查插值方法生成的文件
deglint_dir = work_path / "3_deglint"
if deglint_dir.exists():
for file_path in deglint_dir.glob("interpolated_*.bsq"):
return str(file_path)
elif output_type in step_outputs:
# 直接匹配的输出类型
relative_path = step_outputs[output_type]
if relative_path.endswith('/'):
elif rel_path:
# 直接匹配的输出类型(统一使用 rel_path
if rel_path.endswith('/'):
# 是目录
output_path = work_path / relative_path.rstrip('/')
output_path = work_path / rel_path.rstrip('/')
if output_path.exists() and output_path.is_dir():
return str(output_path)
else:
# 是文件
output_path = work_path / relative_path
output_path = work_path / rel_path
if output_path.exists():
return str(output_path)
return None
def scan_work_directory_for_files(self, work_path):