Fix panel internal titles and step calls (Step3)
This commit is contained in:
@ -98,8 +98,8 @@ class WaterIndexWorker(QThread):
|
||||
self.progress.emit(msg, pct)
|
||||
|
||||
|
||||
class Step9WaterColorPanel(QWidget):
|
||||
"""步骤9:水色指数反演(直接处理 BSQ 影像)"""
|
||||
class Step10MapPanel(QWidget):
|
||||
"""步骤10:专题图生成"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -1211,8 +1211,8 @@ class ChartBrowserDialog(QDialog):
|
||||
QMessageBox.critical(self, "错误", f"保存失败:\n{str(e)}")
|
||||
|
||||
|
||||
class VisualizationPanel(QWidget):
|
||||
"""可视化分析面板 - 重构版:左侧目录树 + 右侧图像查看器"""
|
||||
class Step11VizPanel(QWidget):
|
||||
"""步骤11:可视化展示"""
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.work_dir = None
|
||||
@ -79,8 +79,8 @@ class ReportGenerateThread(QThread):
|
||||
self.failed.emit(f"{e}\n{traceback.format_exc()}")
|
||||
|
||||
|
||||
class ReportGenerationPanel(QWidget):
|
||||
"""Word 报告生成面板。AI 配置统一由 AISettingsDialog 管理,本面板不持有配置状态。"""
|
||||
class Step12ReportPanel(QWidget):
|
||||
"""步骤12:分析报告生成。AI 配置统一由 AISettingsDialog 管理,本面板不持有配置状态。"""
|
||||
|
||||
def __init__(self, main_window=None, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -18,7 +18,7 @@ from src.gui.components.custom_widgets import FileSelectWidget
|
||||
from src.gui.styles import ModernStylesheet
|
||||
|
||||
|
||||
class Step5Panel(QWidget):
|
||||
class Step5CleanPanel(QWidget):
|
||||
"""步骤5:数据清洗"""
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
@ -135,18 +135,16 @@ class Step5Panel(QWidget):
|
||||
self.output_file.set_path("")
|
||||
|
||||
def run_step(self):
|
||||
"""独立运行步骤4"""
|
||||
# 验证输入
|
||||
"""独立运行步骤5"""
|
||||
csv_path = self.csv_file.get_path()
|
||||
if not csv_path:
|
||||
QMessageBox.warning(self, "输入错误", "请选择水质参数文件!")
|
||||
return
|
||||
|
||||
# 获取主窗口并运行步骤
|
||||
main_window = self.window()
|
||||
if hasattr(main_window, 'run_single_step'):
|
||||
config = {'step4': self.get_config()}
|
||||
main_window.run_single_step('step4', config)
|
||||
config = {'step5': self.get_config()}
|
||||
main_window.run_single_step('step5', config)
|
||||
|
||||
def reset_preview(self, message="请选择CSV文件并点击刷新预览"):
|
||||
"""重置预览表格"""
|
||||
@ -17,8 +17,8 @@ from src.gui.components.custom_widgets import FileSelectWidget
|
||||
from src.gui.styles import ModernStylesheet
|
||||
|
||||
|
||||
class Step6Panel(QWidget):
|
||||
"""步骤6:光谱特征"""
|
||||
class Step6FeaturePanel(QWidget):
|
||||
"""步骤6:光谱特征提取"""
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.init_ui()
|
||||
@ -1,3 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Step7 面板 - 水质指数计算
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pandas as pd
|
||||
@ -35,7 +41,7 @@ def get_resource_path(relative_path: str) -> str:
|
||||
return str(base_dir / os.path.basename(relative_path))
|
||||
|
||||
|
||||
class Step7Panel(QWidget):
|
||||
class Step7IndexPanel(QWidget):
|
||||
COLOR_RATIO = QColor(255, 255, 255)
|
||||
COLOR_CONCENTRATION = QColor(220, 240, 255)
|
||||
COLOR_HEADER = QColor(245, 245, 245)
|
||||
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Step9 面板 - 机器学习建模
|
||||
Step8 面板 - 机器学习建模
|
||||
"""
|
||||
|
||||
import os
|
||||
@ -41,8 +41,8 @@ def get_resource_path(relative_path: str) -> str:
|
||||
return str(base_dir / os.path.basename(relative_path))
|
||||
|
||||
|
||||
class Step9Panel(QWidget):
|
||||
"""步骤9:机器学习建模"""
|
||||
class Step8MlTrainPanel(QWidget):
|
||||
"""步骤8:机器学习建模"""
|
||||
COLOR_RATIO = QColor(255, 255, 255)
|
||||
COLOR_CONCENTRATION = QColor(220, 240, 255)
|
||||
COLOR_HEADER = QColor(245, 245, 245)
|
||||
@ -343,82 +343,7 @@ class Step9Panel(QWidget):
|
||||
QMessageBox.warning(self, "提示", "请先选择输入特征提取CSV文件")
|
||||
return
|
||||
|
||||
formula_names = config['formula_names']
|
||||
if not formula_names:
|
||||
QMessageBox.warning(self, "提示", "请至少勾选一个公式")
|
||||
return
|
||||
|
||||
output_mode = config['output_mode']
|
||||
|
||||
try:
|
||||
from src.core.steps.data_preparation_step import DataPreparationStep
|
||||
|
||||
spec_df = pd.read_csv(training_path)
|
||||
x_col, y_col = self._get_coord_cols(spec_df)
|
||||
|
||||
formula_csv_path = self.builtin_formula_path
|
||||
if not formula_csv_path or not os.path.exists(formula_csv_path):
|
||||
possible_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'gui', 'model', 'waterindex.csv')
|
||||
if os.path.exists(possible_path):
|
||||
formula_csv_path = possible_path
|
||||
|
||||
work_dir = self._get_work_dir()
|
||||
|
||||
indices_csv_path = DataPreparationStep.calculate_water_quality_indices(
|
||||
training_csv_path=training_path,
|
||||
formula_csv_file=formula_csv_path,
|
||||
formula_names=formula_names,
|
||||
output_file=None,
|
||||
enabled=True,
|
||||
output_dir=work_dir if work_dir else os.getcwd(),
|
||||
)
|
||||
|
||||
if indices_csv_path and os.path.exists(indices_csv_path):
|
||||
output_df = pd.read_csv(indices_csv_path)
|
||||
else:
|
||||
output_df = spec_df
|
||||
|
||||
track_a_path = None
|
||||
track_b_dir = None
|
||||
|
||||
if output_mode in (0, 1):
|
||||
track_a_dir = os.path.join(work_dir, "9_supervised_modeling") if work_dir else "9_supervised_modeling"
|
||||
os.makedirs(track_a_dir, exist_ok=True)
|
||||
track_a_path = os.path.join(track_a_dir, "training_spectra_indices.csv")
|
||||
|
||||
if output_mode in (0, 2):
|
||||
track_b_dir = os.path.join(work_dir, "11_12_13_predictions", "Traditional_Indices") if work_dir else "11_12_13_predictions/Traditional_Indices"
|
||||
os.makedirs(track_b_dir, exist_ok=True)
|
||||
|
||||
saved = []
|
||||
if output_mode in (0, 1):
|
||||
output_df.to_csv(track_a_path, index=False, float_format='%.6f')
|
||||
saved.append(f"宽表: {track_a_path}")
|
||||
|
||||
if output_mode in (0, 2):
|
||||
coord_x = spec_df[x_col].values if x_col in spec_df.columns else np.arange(len(spec_df))
|
||||
coord_y = spec_df[y_col].values if y_col in spec_df.columns else np.zeros(len(spec_df))
|
||||
|
||||
for formula_name in formula_names:
|
||||
if formula_name not in output_df.columns:
|
||||
continue
|
||||
single_df = pd.DataFrame({
|
||||
'x_coord': coord_x,
|
||||
'y_coord': coord_y,
|
||||
'value': output_df[formula_name].values,
|
||||
})
|
||||
safe_name = formula_name.replace('/', '_').replace(' ', '_')
|
||||
out_path = os.path.join(track_b_dir, f"{safe_name}_prediction.csv")
|
||||
single_df.to_csv(out_path, index=False, float_format='%.6f')
|
||||
saved.append(f"单文件目录: {track_b_dir}")
|
||||
|
||||
QMessageBox.information(
|
||||
self, "计算完成",
|
||||
f"已保存 {len(saved)} 个输出目标:\n" + "\n".join(saved)
|
||||
)
|
||||
|
||||
except ImportError as e:
|
||||
QMessageBox.critical(self, "依赖错误", f"无法导入模块:\n{e}")
|
||||
except Exception as e:
|
||||
import traceback
|
||||
QMessageBox.critical(self, "计算失败", f"原因: {str(e)}\n{traceback.format_exc()}")
|
||||
main_window = self.window()
|
||||
if hasattr(main_window, 'run_single_step'):
|
||||
pipeline_config = {'step8': config}
|
||||
main_window.run_single_step('step8', pipeline_config)
|
||||
@ -19,8 +19,8 @@ from src.gui.components.custom_widgets import FileSelectWidget
|
||||
from src.gui.styles import ModernStylesheet
|
||||
|
||||
|
||||
class Step10MlPanel(QWidget):
|
||||
"""步骤11:机器学习预测"""
|
||||
class Step9MlPredictPanel(QWidget):
|
||||
"""步骤9:机器学习预测"""
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.external_models_dict = {} # {subdir_name: model_obj, ...}
|
||||
Reference in New Issue
Block a user