def __init__(self): SimulationConfigPanel.__init__(self, EnsembleSmoother( getQueueConfig( ) )) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_model = TargetCaseModel() self._target_case_field = StringBox(self._target_case_model, "config/simulation/target_case") self._target_case_field.setValidator(ProperNameArgument()) layout.addRow("Target case:", self._target_case_field) self._analysis_module_selector = AnalysisModuleSelector(iterable=False, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._target_case_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout)
class EnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, EnsembleSmoother( getQueueConfig( ) )) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_model = TargetCaseModel() self._target_case_field = StringBox(self._target_case_model, "config/simulation/target_case") self._target_case_field.setValidator(ProperNameArgument()) layout.addRow("Target case:", self._target_case_field) self._analysis_module_selector = AnalysisModuleSelector(iterable=False, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._target_case_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().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_selector.setVisible(show_advanced) self.layout().labelForField(self._analysis_module_selector).setVisible(show_advanced) def getSimulationArguments(self): arguments = {"active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._target_case_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName() } return arguments
def __init__(self, advanced_option=False): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother(), advanced_option) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) # The num_iterations_spinner does not track any external changes (will that ever happen?) num_iterations_spinner = QSpinBox() num_iterations_spinner.setMinimum(1) num_iterations_spinner.setMaximum(100) num_iterations_spinner.setValue(getNumberOfIterations()) addHelpToWidget(num_iterations_spinner, "config/simulation/number_of_iterations") num_iterations_spinner.valueChanged[int].connect(setNumberOfIterations) layout.addRow("Number of iterations:", num_iterations_spinner) self._iterated_target_case_format_model = TargetCaseModel(format_mode=True) self._iterated_target_case_format_field = StringBox(self._iterated_target_case_format_model, "config/simulation/iterated_target_case_format") self._iterated_target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow("Target case format:", self._iterated_target_case_format_field) self._analysis_module_selector = AnalysisModuleSelector(iterable=True, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._iterated_target_case_format_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout)
class MultipleDataAssimilationPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation()) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_format_model = TargetCaseModel(format_mode=True) self._target_case_format_field = StringBox(self._target_case_format_model, "config/simulation/target_case_format") self._target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow("Target case format:", self._target_case_format_field) self._createInputForWeights(layout) self._analysis_module_selector = AnalysisModuleSelector(iterable=False, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._target_case_format_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._relative_iteration_weights_box.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def _createInputForWeights(self, layout): relative_iteration_weights_model = ValueModel(self.getSimulationModel().getWeights()) self._relative_iteration_weights_box = StringBox(relative_iteration_weights_model, 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) relative_iteration_weights_model.valueChanged.connect(self.getSimulationModel().setWeights) normalized_weights_model = ValueModel() 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.getValidationSupport().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_selector.setVisible(show_advanced) self.layout().labelForField(self._analysis_module_selector).setVisible(show_advanced) def getSimulationArguments(self): arguments = {"active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._target_case_format_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName() } return arguments
class IteratedEnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother()) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) # The num_iterations_spinner does not track any external changes (will that ever happen?) num_iterations_spinner = QSpinBox() num_iterations_spinner.setMinimum(1) num_iterations_spinner.setMaximum(100) num_iterations_spinner.setValue(getNumberOfIterations()) addHelpToWidget(num_iterations_spinner, "config/simulation/number_of_iterations") num_iterations_spinner.valueChanged[int].connect(setNumberOfIterations) layout.addRow("Number of iterations:", num_iterations_spinner) self._iterated_target_case_format_model = TargetCaseModel(format_mode=True) self._iterated_target_case_format_field = StringBox(self._iterated_target_case_format_model, "config/simulation/iterated_target_case_format") self._iterated_target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow("Target case format:", self._iterated_target_case_format_field) self._analysis_module_selector = AnalysisModuleSelector(iterable=True, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._iterated_target_case_format_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): analysis_module = self._analysis_module_selector.getSelectedAnalysisModuleName() 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._analysis_module_selector.setVisible(show_advanced) self.layout().labelForField(self._analysis_module_selector).setVisible(show_advanced) def getSimulationArguments(self): arguments = {"active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._iterated_target_case_format_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName() } return arguments
class MultipleDataAssimilationPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, MultipleDataAssimilation) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_format_model = TargetCaseModel(format_mode=True) self._target_case_format_field = StringBox( self._target_case_format_model, "config/simulation/target_case_format") self._target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow("Target case format:", self._target_case_format_field) self.weights = MultipleDataAssimilation.default_weights self._createInputForWeights(layout) self._iter_field = StringBox( IterValueModel(), "config/simulation/iter_num", ) self._iter_field.setValidator(IntegerArgument(from_value=0), ) layout.addRow("Start iteration:", self._iter_field) self._analysis_module_selector = AnalysisModuleSelector( iterable=False, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox( self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator( RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations:", self._active_realizations_field) self._target_case_format_field.getValidationSupport( ).validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport( ).validationChanged.connect(self.simulationConfigurationChanged) self._relative_iteration_weights_box.getValidationSupport( ).validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def _createInputForWeights(self, layout): relative_iteration_weights_model = ValueModel(self.weights) self._relative_iteration_weights_box = StringBox( relative_iteration_weights_model, 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) relative_iteration_weights_model.valueChanged.connect(self.setWeights) normalized_weights_model = ValueModel() 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.getValidationSupport( ).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 getSimulationArguments(self): arguments = { "active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._target_case_format_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName(), "weights": self.weights, "start_iteration": int(self._iter_field.model.getValue()), } return arguments def setWeights(self, weights): str_weights = str(weights) print("Weights changed: %s" % str_weights) self.weights = str_weights
class IteratedEnsembleSmootherPanel(SimulationConfigPanel): def __init__(self, advanced_option=False): SimulationConfigPanel.__init__(self, IteratedEnsembleSmoother( getQueueConfig( )), advanced_option) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) # The num_iterations_spinner does not track any external changes (will that ever happen?) num_iterations_spinner = QSpinBox() num_iterations_spinner.setMinimum(1) num_iterations_spinner.setMaximum(100) num_iterations_spinner.setValue(getNumberOfIterations()) addHelpToWidget(num_iterations_spinner, "config/simulation/number_of_iterations") num_iterations_spinner.valueChanged[int].connect(setNumberOfIterations) layout.addRow("Number of iterations:", num_iterations_spinner) self._iterated_target_case_format_model = TargetCaseModel(format_mode=True) self._iterated_target_case_format_field = StringBox(self._iterated_target_case_format_model, "config/simulation/iterated_target_case_format") self._iterated_target_case_format_field.setValidator(ProperNameFormatArgument()) layout.addRow("Target case format:", self._iterated_target_case_format_field) self._analysis_module_selector = AnalysisModuleSelector(iterable=True, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox(self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator(RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._iterated_target_case_format_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport().validationChanged.connect(self.simulationConfigurationChanged) self.setLayout(layout) def isConfigurationValid(self): analysis_module = self._analysis_module_selector.getSelectedAnalysisModuleName() 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._analysis_module_selector.setVisible(show_advanced) self.layout().labelForField(self._analysis_module_selector).setVisible(show_advanced) def getSimulationArguments(self): arguments = {"active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._iterated_target_case_format_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName() } return arguments
class EnsembleSmootherPanel(SimulationConfigPanel): def __init__(self): SimulationConfigPanel.__init__(self, EnsembleSmoother(getQueueConfig())) layout = QFormLayout() case_selector = CaseSelector() layout.addRow("Current case:", case_selector) run_path_label = QLabel("<b>%s</b>" % getRunPath()) addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel("<b>%d</b>" % getRealizationCount()) addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_model = TargetCaseModel() self._target_case_field = StringBox(self._target_case_model, "config/simulation/target_case") self._target_case_field.setValidator(ProperNameArgument()) layout.addRow("Target case:", self._target_case_field) self._analysis_module_selector = AnalysisModuleSelector( iterable=False, help_link="config/analysis/analysis_module") layout.addRow("Analysis Module:", self._analysis_module_selector) self._active_realizations_model = ActiveRealizationsModel() self._active_realizations_field = StringBox( self._active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator( RangeStringArgument(getRealizationCount())) layout.addRow("Active realizations", self._active_realizations_field) self._target_case_field.getValidationSupport( ).validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport( ).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_selector.setVisible(show_advanced) self.layout().labelForField( self._analysis_module_selector).setVisible(show_advanced) def getSimulationArguments(self): arguments = { "active_realizations": self._active_realizations_model.getActiveRealizationsMask(), "target_case": self._target_case_model.getValue(), "analysis_module": self._analysis_module_selector.getSelectedAnalysisModuleName() } return arguments
class EnsembleSmootherPanel(SimulationConfigPanel): analysis_module_name = "STD_ENKF" def __init__(self, ert: EnKFMain, notifier: ErtNotifier): super().__init__(EnsembleSmoother) self.ert = ert facade = LibresFacade(ert) layout = QFormLayout() self._case_selector = CaseSelector(facade, notifier) layout.addRow("Current case:", self._case_selector) run_path_label = QLabel(f"<b>{facade.run_path}</b>") addHelpToWidget(run_path_label, "config/simulation/runpath") layout.addRow("Runpath:", run_path_label) number_of_realizations_label = QLabel( f"<b>{facade.get_ensemble_size()}</b>") addHelpToWidget(number_of_realizations_label, "config/ensemble/num_realizations") layout.addRow(QLabel("Number of realizations:"), number_of_realizations_label) self._target_case_model = TargetCaseModel(facade, notifier) self._target_case_field = StringBox(self._target_case_model, "config/simulation/target_case") self._target_case_field.setValidator(ProperNameArgument()) layout.addRow("Target case:", self._target_case_field) self._analysis_module_edit = AnalysisModuleEdit( facade, module_name=EnsembleSmootherPanel.analysis_module_name, help_link="config/analysis/analysis_module", ) layout.addRow("Analysis module:", self._analysis_module_edit) active_realizations_model = ActiveRealizationsModel(facade) self._active_realizations_field = StringBox( active_realizations_model, "config/simulation/active_realizations") self._active_realizations_field.setValidator( RangeStringArgument(facade.get_ensemble_size())) layout.addRow("Active realizations", self._active_realizations_field) self.setLayout(layout) self._target_case_field.getValidationSupport( ).validationChanged.connect(self.simulationConfigurationChanged) self._active_realizations_field.getValidationSupport( ).validationChanged.connect( # noqa self.simulationConfigurationChanged) self._case_selector.currentIndexChanged.connect( self._realizations_from_fs) self._realizations_from_fs() # update with the current case def isConfigurationValid(self): return (self._target_case_field.isValid() and self._active_realizations_field.isValid()) def getSimulationArguments(self): arguments = Arguments( mode="ensemble_smoother", target_case=self._target_case_model.getValue(), realizations=self._active_realizations_field.text(), ) return arguments def _realizations_from_fs(self): case = str(self._case_selector.currentText()) mask = get_runnable_realizations_mask(self.ert, case) self._active_realizations_field.model.setValueFromMask(mask)