Exemple #1
0
 def trigger(self):
     if self._run_widget is None:
         self._run_widget = RunAnalysisPanel()
     self._dialog = ClosableDialog("Run Analysis", self._run_widget,
                                   self.parent())
     self._dialog.addButton("Run", self.run)
     self._dialog.exec_()
Exemple #2
0
class RunAnalysisTool(Tool):
    def __init__(self, ert, notifier):
        self.ert = ert
        self.notifier = notifier
        super().__init__("Run analysis", "tools/run_analysis",
                         resourceIcon("formula.svg"))
        self._run_widget = None
        self._dialog = None
        self._selected_case_name = None

    def trigger(self):
        if self._run_widget is None:
            self._run_widget = RunAnalysisPanel(self.ert, self.notifier)
        self._dialog = ClosableDialog("Run analysis", self._run_widget,
                                      self.parent())
        self._dialog.addButton("Run", self.run)
        self._dialog.exec_()

    def run(self):
        target = self._run_widget.target_case()
        source = self._run_widget.source_case()

        if len(target) == 0:
            self._report_empty_target()
            return

        try:
            analyse(self.ert, target, source)
            error = None
        except ErtAnalysisError as e:
            error = str(e)
        except Exception as e:
            error = f"Uknown exception occured with error: {str(e)}"

        msg = QMessageBox()
        msg.setWindowTitle("Run analysis")
        msg.setStandardButtons(QMessageBox.Ok)

        if not error:
            msg.setIcon(QMessageBox.Information)
            msg.setText(f"Successfully ran analysis for case '{source}'.")
            msg.exec_()
        else:
            msg.setIcon(QMessageBox.Warning)
            msg.setText(f"Unable to run analysis for case '{source}'.\n"
                        f"The following error occured: {error}")
            msg.exec_()
            return

        self.notifier.ertChanged.emit()
        self._dialog.accept()

    def _report_empty_target(self):
        msg = QMessageBox()
        msg.setWindowTitle("Invalid target")
        msg.setIcon(QMessageBox.Warning)
        msg.setText("Target case can not be empty")
        msg.setStandardButtons(QMessageBox.Ok)
        msg.exec_()
Exemple #3
0
class RunAnalysisTool(Tool):
    def __init__(self):
        super(RunAnalysisTool, self).__init__("Run Analysis",
                                              "tools/run_analysis",
                                              resourceIcon("ide/table_import"))
        self._run_widget = None
        self._dialog = None
        self._selected_case_name = None

    def trigger(self):
        if self._run_widget is None:
            self._run_widget = RunAnalysisPanel()
        self._dialog = ClosableDialog("Run Analysis", self._run_widget,
                                      self.parent())
        self._dialog.addButton("Run", self.run)
        self._dialog.exec_()

    def run(self):
        target = self._run_widget.target_case()
        source = self._run_widget.source_case()

        if len(target) == 0:
            self._report_empty_target()
            return

        success = analyse(target, source)

        msg = QMessageBox()
        msg.setWindowTitle("Run Analysis")
        msg.setStandardButtons(QMessageBox.Ok)

        if success:
            msg.setIcon(QMessageBox.Information)
            msg.setText(
                "Successfully ran analysis for case '{}'.".format(source))
            msg.exec_()
        else:
            msg.setIcon(QMessageBox.Warning)
            msg.setText("Unable to run analysis for case '{}'.".format(source))
            msg.exec_()
            return

        ert_shared.ERT.ertChanged.emit()
        self._dialog.accept()

    def _report_empty_target(self):
        msg = QMessageBox()
        msg.setWindowTitle("Invalid Target")
        msg.setIcon(QMessageBox.Warning)
        msg.setText("Target case can not be empty")
        msg.setStandardButtons(QMessageBox.Ok)
        msg.exec_()
Exemple #4
0
class RunAnalysisTool(Tool):
    def __init__(self):
        super(RunAnalysisTool, self).__init__("Run Analysis",
                                              "tools/run_analysis",
                                              resourceIcon("ide/table_import"))
        self._run_widget = None
        self._dialog = None
        self._selected_case_name = None

    def trigger(self):
        if self._run_widget is None:
            self._run_widget = RunAnalysisPanel()
        self._dialog = ClosableDialog("Run Analysis", self._run_widget,
                                      self.parent())
        self._dialog.addButton("Run", self.run)
        self._dialog.exec_()

    def run(self):
        target = self._run_widget.target_case()
        source = self._run_widget.source_case()

        ert = ERT.ert
        fs_manager = ert.getEnkfFsManager()
        es_update = ESUpdate(ert)

        target_fs = fs_manager.getFileSystem(target)
        source_fs = fs_manager.getFileSystem(source)
        run_context = ErtRunContext.ensemble_smoother_update(
            source_fs,
            target_fs,
        )
        success = es_update.smootherUpdate(run_context)

        if not success:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Warning)
            msg.setWindowTitle("Run Analysis")
            msg.setText("Unable to run analysis for case '%s'." % source)
            msg.setStandardButtons(QMessageBox.Ok)
            msg.exec_()
            return

        ERT.ertChanged.emit()
        self._dialog.accept()
Exemple #5
0
class RunAnalysisTool(Tool):
    def __init__(self):
        super(RunAnalysisTool, self).__init__("Run Analysis", "tools/run_analysis", resourceIcon("ide/table_import"))
        self._run_widget = None
        self._dialog = None
        self._selected_case_name = None
        self.setVisible(False)


    def trigger(self):
        if self._run_widget is None:
            self._run_widget = RunAnalysisPanel()
        self._dialog = ClosableDialog("Run Analysis", self._run_widget, self.parent())
        self._dialog.addButton("Run", self.run)
        self._dialog.exec_()

    def run(self):
        target = self._run_widget.target_case()
        source = self._run_widget.source_case()

        ert = ERT.ert
        fs_manager = ert.getEnkfFsManager() 
        es_update = ESUpdate(ert)

        target_fs = fs_manager.getFileSystem(target)
        source_fs = fs_manager.getFileSystem(source)
        success = es_update.smootherUpdate( source_fs , target_fs )

        if not success:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Warning)
            msg.setWindowTitle("Run Analysis")
            msg.setText("Unable to run analysis for case '%s'." % source)
            msg.setStandardButtons(QMessageBox.Ok)
            msg.exec_()
            return

        ERT.ertChanged.emit()
        self._dialog.accept()

    def toggleAdvancedMode(self, advanced_mode):
        self.setVisible(advanced_mode)
Exemple #6
0
 def trigger(self):
     if self._run_widget is None:
         self._run_widget = RunAnalysisPanel()
     self._dialog = ClosableDialog("Run Analysis", self._run_widget, self.parent())
     self._dialog.addButton("Run", self.run)
     self._dialog.exec_()