class EnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, EnsembleSmoother()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) # re_run_path_model = RerunPathModel() # re_run_path_label = ActiveLabel(re_run_path_model, "Rerunpath", "config/simulation/rerunpath") # layout.addRow(re_run_path_label.getLabel(), re_run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) target_case_model = TargetCaseModel() self.target_case_field = StringBox(target_case_model, "Target case", "config/simulation/target_case") self.target_case_field.setValidator(ProperNameArgument()) layout.addRow(self.target_case_field.getLabel(), self.target_case_field) analysis_module_model = AnalysisModuleModel() self.analysis_module_choice = ComboChoice(analysis_module_model, "Analysis Module", "config/analysis/analysis_module") layout.addRow(self.analysis_module_choice.getLabel(), self.analysis_module_choice) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.target_case_field.validationChanged.connect(self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): return self.target_case_field.isValid() and self.active_realizations_field.isValid() def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced) self.analysis_module_choice.setVisible(show_advanced) self.layout().labelForField(self.analysis_module_choice).setVisible(show_advanced)
class LoadResultsPanel(QWidget): def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Load results manually") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Select case:",self.__case_combo) self.__active_realizations_model = LoadResultsRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Realizations to load", "load_results_manually/Realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) self.__iterations_count = LoadResultsModel().getIterationCount() self._iterations_model = LoadResultsIterationsModel(self.__iterations_count) self._iterations_field = StringBox(self._iterations_model, "Iteration to load", "load_results_manually/iterations") self._iterations_field.setValidator(RangeStringArgument()) layout.addRow(self._iterations_field.getLabel(), self._iterations_field) self.setLayout(layout) def load(self): all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] realizations = self.__active_realizations_model.getActiveRealizationsMask() iterations = self._iterations_model.getActiveRealizationsMask() LoadResultsModel().loadResults(selected_case, realizations, iterations)
class EnsembleExperimentPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, EnsembleExperiment()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) runpath_model = RunPathModel() runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath") layout.addRow(runpath_label.getLabel(), runpath_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument(number_of_realizations_model.getValue())) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): return self.active_realizations_field.isValid() def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced)
class IteratedEnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) num_iterations_model = NumberOfIterationsModel() num_iterations_spinner = IntegerSpinner(num_iterations_model, "Number of iterations", "config/simulation/number_of_iterations") layout.addRow(num_iterations_spinner.getLabel(), num_iterations_spinner) iterated_target_case_format_model = TargetCaseFormatModel() self.iterated_target_case_format_field = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") self.iterated_target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) iterated_analysis_module_model = IteratedAnalysisModuleModel() self.iterated_analysis_module_choice = ComboChoice(iterated_analysis_module_model, "Analysis Module", "config/analysis/iterated_analysis_module") self.variables_popup_button = QToolButton() self.variables_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self.variables_popup_button.clicked.connect(self.showVariablesPopup) self.variables_popup_button.setMaximumSize(20, 20) self.variables_layout = QHBoxLayout() self.variables_layout.addWidget(self.iterated_analysis_module_choice, 0, Qt.AlignLeft) self.variables_layout.addWidget(self.variables_popup_button, 0, Qt.AlignLeft) self.variables_layout.setContentsMargins(QMargins(0,0,0,0)) self.variables_layout.addStretch() layout.addRow(self.iterated_analysis_module_choice.getLabel(), self.variables_layout) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.iterated_target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): analysis_module = IteratedAnalysisModuleModel().getCurrentChoice() return self.iterated_target_case_format_field.isValid() and self.active_realizations_field.isValid() and analysis_module is not None def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced) self.iterated_analysis_module_choice.setVisible(show_advanced) self.layout().labelForField(self.variables_layout).setVisible(show_advanced) self.variables_popup_button.setVisible(show_advanced) def showVariablesPopup(self): analysis_module_name = IteratedAnalysisModuleModel().getCurrentChoice() if analysis_module_name is not None: variable_dialog = AnalysisModuleVariablesPanel(analysis_module_name) dialog = ClosableDialog("Edit variables", variable_dialog, self.parent()) dialog.exec_()
class LoadResultsPanel(QWidget): def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Load results manually") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() run_path_text = QTextEdit() run_path_text.setText(self.readCurrentRunPath()) run_path_text.setDisabled(True) run_path_text.setFixedHeight(80) layout.addRow("Load data from current run path: ",run_path_text) self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Load into case:",self.__case_combo) self.__active_realizations_model = LoadResultsRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Realizations to load", "load_results_manually/Realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) self.__iterations_count = LoadResultsModel().getIterationCount() self._iterations_model = LoadResultsIterationsModel(self.__iterations_count) self._iterations_field = StringBox(self._iterations_model, "Iteration to load", "load_results_manually/iterations") self._iterations_field.setValidator(IntegerArgument()) layout.addRow(self._iterations_field.getLabel(), self._iterations_field) self.setLayout(layout) def readCurrentRunPath(self): current_case = CaseSelectorModel().getCurrentChoice() run_path = LoadResultsModel().getCurrentRunPath() run_path = run_path.replace("<ERTCASE>",current_case) run_path = run_path.replace("<ERT-CASE>",current_case) return run_path def load(self): all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] realizations = self.__active_realizations_model.getActiveRealizationsMask() iteration = self._iterations_model.getActiveIteration() LoadResultsModel().loadResults(selected_case, realizations, iteration) def setCurrectCase(self): current_case = CaseSelectorModel().getCurrentChoice() self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case))
class ExportPanel(QWidget): updateExportButton = pyqtSignal(str, bool) runExport = pyqtSignal(dict) def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Select case:", self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:", self.__keywords) self.__active_realizations_model = ExportRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect( self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button = QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath() + "/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:", self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model = [] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected() def selectFileDirectory(self): directory = QFileDialog().getExistingDirectory( self, "Directory", self.__file_name.text(), QFileDialog.ShowDirsOnly) if str(directory).__len__() > 0: self.__file_name.setText(str(directory)) def updateFileExportType(self, keyword): self.__file_type_combo.clear() if self.__export_keyword_model.isGenKw(keyword): self.__file_type_model = self.__gen_kw_file_types elif self.__export_keyword_model.isGenParamKw(keyword): self.__file_type_model = self.__gen_data_file_types elif self.__export_keyword_model.isGenDataKw(keyword): self.__file_type_model = self.__gen_data_file_types else: self.__file_type_model = self.__field_kw_file_types self.__file_type_combo.addItems(self.__file_type_model) def export(self): keyword = self.__kw_model[self.__keywords.currentIndex()] report_step = self.getReportStep(keyword) all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] path = self.__file_name.text() iactive = self.__active_realizations_model.getActiveRealizationsMask() file_type_key = self.__file_type_model[ self.__file_type_combo.currentIndex()] values = { "keyword": keyword, "report_step": report_step, "iactive": iactive, "file_type_key": file_type_key, "path": path, "selected_case": selected_case } self.runExport.emit(values) def getReportStep(self, key): report_step = 0 if self.__dynamic: report_step = self.__report_step.text() if self.__export_keyword_model.isGenParamKw(key): return report_step if self.__export_keyword_model.isGenDataKw(key): report_step = self.__gen_data_report_step_model[ self.__gen_data_report_step.currentIndex()] return report_step def keywordSelected(self): key = self.__kw_model[self.__keywords.currentIndex()] self.updateFileExportType(key) self.__dynamic = False if self.__export_keyword_model.isFieldKw(key): self.__dynamic = self.__export_keyword_model.isDynamicField(key) self.__report_step.setVisible(self.__dynamic) self.layout().labelForField(self.__report_step).setVisible( self.__dynamic) self.__gen_data_report_step.setVisible( self.__export_keyword_model.isGenDataKw(key)) self.layout().labelForField(self.__gen_data_report_step).setVisible( self.__export_keyword_model.isGenDataKw(key)) if self.__export_keyword_model.isGenDataKw(key): data = self.__export_keyword_model.getGenDataReportSteps(key) self.__gen_data_report_step_model = data self.__gen_data_report_step.clear() self.__gen_data_report_step.addItems( self.__gen_data_report_step_model) def setSelectedCase(self, selected_case): self.__case_combo.setCurrentIndex( self.__case_model.indexOf(selected_case)) def validateExportDialog(self): validRealizations = False if self.__active_realizations_field.isValid(): validRealizations = True path = str(self.__file_name.text()) validPath = len(path) > 0 if validRealizations and validPath: self.updateExportButton.emit("export", True) else: self.updateExportButton.emit("export", False)
class IteratedEnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel( number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) num_iterations_model = NumberOfIterationsModel() num_iterations_spinner = IntegerSpinner( num_iterations_model, "Number of iterations", "config/simulation/number_of_iterations") layout.addRow(num_iterations_spinner.getLabel(), num_iterations_spinner) iterated_target_case_format_model = TargetCaseFormatModel() self.iterated_target_case_format_field = StringBox( iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") self.iterated_target_case_format_field.setValidator( ProperNameFormatArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) iterated_analysis_module_model = IteratedAnalysisModuleModel() self.iterated_analysis_module_choice = ComboChoice( iterated_analysis_module_model, "Analysis Module", "config/analysis/iterated_analysis_module") self.variables_popup_button = QToolButton() self.variables_popup_button.setIcon( util.resourceIcon("ide/small/cog_edit.png")) self.variables_popup_button.clicked.connect(self.showVariablesPopup) self.variables_popup_button.setMaximumSize(20, 20) self.variables_layout = QHBoxLayout() self.variables_layout.addWidget(self.iterated_analysis_module_choice, 0, Qt.AlignLeft) self.variables_layout.addWidget(self.variables_popup_button, 0, Qt.AlignLeft) self.variables_layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.variables_layout.addStretch() layout.addRow(self.iterated_analysis_module_choice.getLabel(), self.variables_layout) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox( active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.iterated_target_case_format_field.validationChanged.connect( self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect( self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): analysis_module = IteratedAnalysisModuleModel().getCurrentChoice() return self.iterated_target_case_format_field.isValid( ) and self.active_realizations_field.isValid( ) and analysis_module is not None def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField( self.active_realizations_field).setVisible(show_advanced) self.iterated_analysis_module_choice.setVisible(show_advanced) self.layout().labelForField( self.variables_layout).setVisible(show_advanced) self.variables_popup_button.setVisible(show_advanced) def showVariablesPopup(self): analysis_module_name = IteratedAnalysisModuleModel().getCurrentChoice() if analysis_module_name is not None: variable_dialog = AnalysisModuleVariablesPanel( analysis_module_name) dialog = ClosableDialog("Edit variables", variable_dialog, self.parent()) dialog.exec_()
class MultipleDataAssimilationPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) target_case_format_model = TargetCaseFormatModel() self._target_case_format_field = StringBox(target_case_format_model, "Target case format", "config/simulation/target_case_format") self._target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self._target_case_format_field.getLabel(), self._target_case_format_field) iterated_target_case_format_model = DefaultNameFormatModel(()) iterated_target_case_format_box = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") iterated_target_case_format_box.setValidator(ProperNameFormatArgument()) self._createInputForWeights(layout) analysis_module_model = AnalysisModuleModel() self._analysis_module_choice = ComboChoice(analysis_module_model, "Analysis Module", "config/analysis/analysis_module") self._variables_popup_button = QToolButton() self._variables_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self._variables_popup_button.clicked.connect(self.showVariablesPopup) self._variables_popup_button.setMaximumSize(20, 20) self._variables_layout = QHBoxLayout() self._variables_layout.addWidget(self._analysis_module_choice, 0, Qt.AlignLeft) self._variables_layout.addWidget(self._variables_popup_button, 0, Qt.AlignLeft) self._variables_layout.setContentsMargins(QMargins(0,0,0,0)) self._variables_layout.addStretch() layout.addRow(self._analysis_module_choice.getLabel(), self._variables_layout) active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self._active_realizations_field.getLabel(), self._active_realizations_field) self._target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self._relative_iteration_weights_box.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def _createInputForWeights(self, layout): relative_iteration_weights_model = StringModel(self.getSimulationModel().getWeights()) self._relative_iteration_weights_box = StringBox(relative_iteration_weights_model, "Custom iteration weights", help_link="config/simulation/iteration_weights", continuous_update=True) self._relative_iteration_weights_box.setValidator(NumberListStringArgument()) layout.addRow("Relative Weights:", self._relative_iteration_weights_box) def updateModelWithRelativeWeights(): weights = relative_iteration_weights_model.getValue() self.getSimulationModel().setWeights(weights) relative_iteration_weights_model.observable().attach(StringModel.VALUE_CHANGED_EVENT, updateModelWithRelativeWeights) normalized_weights_model = StringModel() normalized_weights_model.setValue("") normalized_weights_widget = ActiveLabel(normalized_weights_model, help_link="config/simulation/iteration_weights") layout.addRow('Normalized weights:', normalized_weights_widget) def updateVisualizationOfNormalizedWeights(): if self._relative_iteration_weights_box.isValid(): weights = MultipleDataAssimilation.parseWeights(relative_iteration_weights_model.getValue()) normalized_weights = MultipleDataAssimilation.normalizeWeights(weights) normalized_weights_model.setValue(", ".join("%.2f" % x for x in normalized_weights)) else: normalized_weights_model.setValue("The weights are invalid!") self._relative_iteration_weights_box.validationChanged.connect(updateVisualizationOfNormalizedWeights) updateVisualizationOfNormalizedWeights() # To normalize the default weights def isConfigurationValid(self): return self._target_case_format_field.isValid() and self._active_realizations_field.isValid() and self._relative_iteration_weights_box.isValid() def toggleAdvancedOptions(self, show_advanced): self._active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self._active_realizations_field).setVisible(show_advanced) self._analysis_module_choice.setVisible(show_advanced) self.layout().labelForField(self._variables_layout).setVisible(show_advanced) self._variables_popup_button.setVisible(show_advanced) def showVariablesPopup(self): analysis_module_name = AnalysisModuleModel().getCurrentChoice() if analysis_module_name is not None: variable_dialog = AnalysisModuleVariablesPanel(analysis_module_name) dialog = ClosableDialog("Edit variables", variable_dialog, self.parent()) dialog.exec_()
class SensitivityStudyPanel(SimulationConfigPanel): ''' Panel for setting parameters for sensitivity study. ''' def __init__(self): ''' Fills in the input panel for sensitivity study parameters. ''' SimulationConfigPanel.__init__(self, SensitivityStudy()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) runpath_model = RunPathModel() runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath") layout.addRow(runpath_label.getLabel(), runpath_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) sensitivity_target_case_format_model = SensitivityTargetCaseFormatModel() self.iterated_target_case_format_field = StringBox(sensitivity_target_case_format_model, "Target case format", "config/simulation/sensitivity_target_case_format") self.iterated_target_case_format_field.setValidator(ProperNameFormatStringArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) self.parameters_popup_button = QToolButton() self.parameters_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self.parameters_popup_button.clicked.connect(self.showParametersPopup) self.parameters_popup_button.setMaximumSize(20, 20) layout.addRow("Parameters:", self.parameters_popup_button) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument(number_of_realizations_model.getValue())) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): ''' Check if the given input configuration is valid, and that all needed data is given. ''' return self.active_realizations_field.isValid() def showParametersPopup(self): parameter_panel = SensitivityStudyParametersPanel() dialog = ClosableDialog("Sensitivity Study Parameters", parameter_panel, self.parent()) dialog.exec_() def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced)
class ExportPanel(QWidget): def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Select case:",self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:",self.__keywords) self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button= QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(QDir.currentPath()+"/export") self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:",self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected() def selectFileDirectory(self): directory = QFileDialog().getExistingDirectory(self, "Directory", QDir.currentPath(), QFileDialog.ShowDirsOnly) self.__file_name.setText(str(directory)) def updateFileExportType(self): keyword = self.__kw_model[self.__keywords.currentIndex()] self.__file_type_combo.clear() if self.__export_keyword_model.isGenKw(keyword): self.__file_type_model = self.__gen_kw_file_types else: self.__file_type_model = self.__field_kw_file_types self.__file_type_combo.addItems(self.__file_type_model) def export(self): report_step = 0 if self.__dynamic: report_step = self.__report_step.text() keyword = self.__kw_model[self.__keywords.currentIndex()] all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] file_name = self.createExportFilNameMask(keyword, selected_case) iactive = self.__active_realizations_model.getActiveRealizationsMask() file_type_key = self.__file_type_model[self.__file_type_combo.currentIndex()] state = EnkfStateType.FORECAST if self.__export_keyword_model.isFieldKw(keyword): self.exportField(keyword, file_name, iactive, file_type_key, report_step, state, selected_case) elif self.__export_keyword_model.isGenKw(keyword): self.exportGenKw(keyword, file_name, iactive, file_type_key, report_step, state, selected_case) def exportGenKw(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case): ExportModel().exportGenKw(keyword, file_name, iactive, file_type_key, report_step, state, selected_case) def exportField(self, keyword, file_name, iactive, file_type_key, report_step, state, selected_case): if file_type_key == "Eclipse GRDECL": file_type = EnkfFieldFileFormatEnum.ECL_GRDECL_FILE else: file_type = EnkfFieldFileFormatEnum.RMS_ROFF_FILE result = ExportModel().exportField(keyword, file_name, iactive, file_type, report_step, state, selected_case) if not result: QMessageBox.warning(self, "Warning",'''Something did not work!''',QMessageBox.Ok); def createExportFilNameMask(self, keyword, current_case): path = self.__file_name.text() impl_type = None if self.__export_keyword_model.isFieldKw(keyword): impl_type = ExportKeywordModel().getImplementationType(keyword) elif self.__export_keyword_model.isGenKw(keyword): impl_type = "Gen_Kw" path = str(path) + "/" + str(current_case) + "/" + str(impl_type) + "/" + str(keyword) if not QDir(path).exists(): os.makedirs(path); return path def keywordSelected(self): self.updateFileExportType() key = self.__kw_model[self.__keywords.currentIndex()] if self.__export_keyword_model.isFieldKw(key): self.__dynamic = ExportKeywordModel().isDynamicField(key) else: self.__dynamic = False self.__report_step.setVisible(self.__dynamic) self.layout().labelForField(self.__report_step).setVisible(self.__dynamic)
class SensitivityStudyPanel(SimulationConfigPanel): ''' Panel for setting parameters for sensitivity study. ''' def __init__(self): ''' Fills in the input panel for sensitivity study parameters. ''' SimulationConfigPanel.__init__(self, SensitivityStudy()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) runpath_model = RunPathModel() runpath_label = ActiveLabel(runpath_model, "Runpath", "config/simulation/runpath") layout.addRow(runpath_label.getLabel(), runpath_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel( number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) sensitivity_target_case_format_model = SensitivityTargetCaseFormatModel( ) self.iterated_target_case_format_field = StringBox( sensitivity_target_case_format_model, "Target case format", "config/simulation/sensitivity_target_case_format") self.iterated_target_case_format_field.setValidator( ProperNameFormatStringArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) self.parameters_popup_button = QToolButton() self.parameters_popup_button.setIcon( util.resourceIcon("ide/small/cog_edit.png")) self.parameters_popup_button.clicked.connect(self.showParametersPopup) self.parameters_popup_button.setMaximumSize(20, 20) layout.addRow("Parameters:", self.parameters_popup_button) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox( active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator( RangeStringArgument(number_of_realizations_model.getValue())) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.active_realizations_field.validationChanged.connect( self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): ''' Check if the given input configuration is valid, and that all needed data is given. ''' return self.active_realizations_field.isValid() def showParametersPopup(self): parameter_panel = SensitivityStudyParametersPanel() dialog = ClosableDialog("Sensitivity Study Parameters", parameter_panel, self.parent()) dialog.exec_() def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField( self.active_realizations_field).setVisible(show_advanced)
class ExportPanel(QWidget): updateExportButton = pyqtSignal(str, bool) runExport = pyqtSignal(dict) def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex(self.__case_model.indexOf(current_case)) layout.addRow("Select case:",self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:",self.__keywords) self.__active_realizations_model = ExportRealizationsModel(EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox(self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect(self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button= QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath()+"/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:",self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model=[] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected() def selectFileDirectory(self): directory = QFileDialog().getExistingDirectory(self, "Directory", self.__file_name.text(), QFileDialog.ShowDirsOnly) if str(directory).__len__() > 0: self.__file_name.setText(str(directory)) def updateFileExportType(self, keyword): self.__file_type_combo.clear() if self.__export_keyword_model.isGenKw(keyword): self.__file_type_model = self.__gen_kw_file_types elif self.__export_keyword_model.isGenParamKw(keyword): self.__file_type_model = self.__gen_data_file_types elif self.__export_keyword_model.isGenDataKw(keyword): self.__file_type_model = self.__gen_data_file_types else: self.__file_type_model = self.__field_kw_file_types self.__file_type_combo.addItems(self.__file_type_model) def export(self): keyword = self.__kw_model[self.__keywords.currentIndex()] report_step = self.getReportStep(keyword) all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] path = self.__file_name.text() iactive = self.__active_realizations_model.getActiveRealizationsMask() file_type_key = self.__file_type_model[self.__file_type_combo.currentIndex()] values = {"keyword":keyword, "report_step":report_step, "iactive":iactive,"file_type_key":file_type_key, "path":path , "selected_case" : selected_case} self.runExport.emit(values) def getReportStep(self, key): report_step = 0 if self.__dynamic: report_step = self.__report_step.text() if self.__export_keyword_model.isGenParamKw(key): return report_step if self.__export_keyword_model.isGenDataKw(key): report_step = self.__gen_data_report_step_model[self.__gen_data_report_step.currentIndex()] return report_step def keywordSelected(self): key = self.__kw_model[self.__keywords.currentIndex()] self.updateFileExportType(key) self.__dynamic = False if self.__export_keyword_model.isFieldKw(key): self.__dynamic = self.__export_keyword_model.isDynamicField(key) self.__report_step.setVisible(self.__dynamic) self.layout().labelForField(self.__report_step).setVisible(self.__dynamic) self.__gen_data_report_step.setVisible(self.__export_keyword_model.isGenDataKw(key)) self.layout().labelForField(self.__gen_data_report_step).setVisible(self.__export_keyword_model.isGenDataKw(key)) if self.__export_keyword_model.isGenDataKw(key): data = self.__export_keyword_model.getGenDataReportSteps(key) self.__gen_data_report_step_model = data self.__gen_data_report_step.clear() self.__gen_data_report_step.addItems(self.__gen_data_report_step_model) def setSelectedCase(self, selected_case): self.__case_combo.setCurrentIndex(self.__case_model.indexOf(selected_case)) def validateExportDialog(self): validRealizations = False if self.__active_realizations_field.isValid(): validRealizations = True path = str(self.__file_name.text()) validPath = len(path) > 0 if validRealizations and validPath: self.updateExportButton.emit("export", True) else: self.updateExportButton.emit("export", False)
class IteratedEnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel( number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations" ) layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) num_iterations_model = NumberOfIterationsModel() num_iterations_spinner = IntegerSpinner( num_iterations_model, "Number of iterations", "config/simulation/number_of_iterations" ) layout.addRow(num_iterations_spinner.getLabel(), num_iterations_spinner) iterated_target_case_format_model = TargetCaseFormatModel() self.iterated_target_case_format_field = StringBox( iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format" ) self.iterated_target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self.iterated_target_case_format_field.getLabel(), self.iterated_target_case_format_field) iterated_analysis_module_model = IteratedAnalysisModuleModel() self.iterated_analysis_module_choice = ComboChoice( iterated_analysis_module_model, "Analysis Module", "config/analysis/iterated_analysis_module" ) layout.addRow(self.iterated_analysis_module_choice.getLabel(), self.iterated_analysis_module_choice) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox( active_realizations_model, "Active realizations", "config/simulation/active_realizations" ) self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.iterated_target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): analysis_module = IteratedAnalysisModuleModel().getCurrentChoice() return ( self.iterated_target_case_format_field.isValid() and self.active_realizations_field.isValid() and analysis_module is not None ) def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced) self.iterated_analysis_module_choice.setVisible(show_advanced) self.layout().labelForField(self.iterated_analysis_module_choice).setVisible(show_advanced)
class LoadResultsPanel(QWidget): def __init__(self): QWidget.__init__(self) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Load results manually") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() run_path_text = QTextEdit() run_path_text.setText(self.readCurrentRunPath()) run_path_text.setDisabled(True) run_path_text.setFixedHeight(80) layout.addRow("Load data from current run path: ", run_path_text) self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Load into case:", self.__case_combo) self.__active_realizations_model = LoadResultsRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Realizations to load", "load_results_manually/Realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) self.__iterations_count = LoadResultsModel().getIterationCount() self._iterations_model = LoadResultsIterationsModel( self.__iterations_count) self._iterations_field = StringBox(self._iterations_model, "Iteration to load", "load_results_manually/iterations") self._iterations_field.setValidator(IntegerArgument()) layout.addRow(self._iterations_field.getLabel(), self._iterations_field) self.setLayout(layout) def readCurrentRunPath(self): current_case = CaseSelectorModel().getCurrentChoice() run_path = LoadResultsModel().getCurrentRunPath() run_path = run_path.replace("<ERTCASE>", current_case) run_path = run_path.replace("<ERT-CASE>", current_case) return run_path def load(self): all_cases = self.__case_model.getAllItems() selected_case = all_cases[self.__case_combo.currentIndex()] realizations = self.__active_realizations_model.getActiveRealizationsMask( ) iteration = self._iterations_model.getActiveIteration() LoadResultsModel().loadResults(selected_case, realizations, iteration) def setCurrectCase(self): current_case = CaseSelectorModel().getCurrentChoice() self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case))
class MultipleDataAssimilationPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation()) layout = QFormLayout() case_model = CaseSelectorModel() case_selector = ComboChoice(case_model, "Current case", "init/current_case_selection") layout.addRow(case_selector.getLabel(), case_selector) run_path_model = RunPathModel() run_path_label = ActiveLabel(run_path_model, "Runpath", "config/simulation/runpath") layout.addRow(run_path_label.getLabel(), run_path_label) number_of_realizations_model = EnsembleSizeModel() number_of_realizations_label = ActiveLabel(number_of_realizations_model, "Number of realizations", "config/ensemble/num_realizations") layout.addRow(number_of_realizations_label.getLabel(), number_of_realizations_label) target_case_format_model = TargetCaseFormatModel() self.target_case_format_field = StringBox(target_case_format_model, "Target case format", "config/simulation/target_case_format") self.target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow(self.target_case_format_field.getLabel(), self.target_case_format_field) iterated_target_case_format_model = DefaultNameFormatModel(()) iterated_target_case_format_box = StringBox(iterated_target_case_format_model, "Target case format", "config/simulation/iterated_target_case_format") iterated_target_case_format_box.setValidator(ProperNameFormatArgument()) self.option_widget = TextOrFile(self.getSimulationModel().setWeights) layout.addRow("Relative Weights:", self.option_widget) layout.addRow('Note:', QLabel("Example Custom Relative Weights: '8,4,2,1'\n" "This means MDA-ES will half the weight\n" "applied to the Observation Errors from one\n" "iteration to the next across 4 iterations.")) analysis_module_model = AnalysisModuleModel() self.analysis_module_choice = ComboChoice(analysis_module_model, "Analysis Module", "config/analysis/analysis_module") self.variables_popup_button = QToolButton() self.variables_popup_button.setIcon(util.resourceIcon("ide/small/cog_edit.png")) self.variables_popup_button.clicked.connect(self.showVariablesPopup) self.variables_popup_button.setMaximumSize(20, 20) self.variables_layout = QHBoxLayout() self.variables_layout.addWidget(self.analysis_module_choice, 0, Qt.AlignLeft) self.variables_layout.addWidget(self.variables_popup_button, 0, Qt.AlignLeft) self.variables_layout.setContentsMargins(QMargins(0,0,0,0)) self.variables_layout.addStretch() layout.addRow(self.analysis_module_choice.getLabel(), self.variables_layout) active_realizations_model = ActiveRealizationsModel() self.active_realizations_field = StringBox(active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.active_realizations_field.setValidator(RangeStringArgument()) layout.addRow(self.active_realizations_field.getLabel(), self.active_realizations_field) self.target_case_format_field.validationChanged.connect(self.simulationConfigurationChanged) self.active_realizations_field.validationChanged.connect(self.simulationConfigurationChanged) self.option_widget.validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): return self.target_case_format_field.isValid() and self.active_realizations_field.isValid() and self.option_widget.isValid() def toggleAdvancedOptions(self, show_advanced): self.active_realizations_field.setVisible(show_advanced) self.layout().labelForField(self.active_realizations_field).setVisible(show_advanced) self.analysis_module_choice.setVisible(show_advanced) self.layout().labelForField(self.variables_layout).setVisible(show_advanced) self.variables_popup_button.setVisible(show_advanced) def showVariablesPopup(self): analysis_module_name = AnalysisModuleModel().getCurrentChoice() if analysis_module_name is not None: variable_dialog = AnalysisModuleVariablesPanel(analysis_module_name) dialog = ClosableDialog("Edit variables", variable_dialog, self.parent()) dialog.exec_()