Example #1
0
    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
Example #2
0
 def setValue(self, target_case):
     if target_case is None or target_case.strip() == "" or target_case == self.getDefaultValue():
         self._custom = False
         ValueModel.setValue(self, self.getDefaultValue())
     else:
         self._custom = True
         ValueModel.setValue(self, target_case)
Example #3
0
 def setValue(self, active_realizations):
     if active_realizations is None or active_realizations.strip() == "" or active_realizations == self.getDefaultValue():
         self._custom = False
         ValueModel.setValue(self, self.getDefaultValue())
     else:
         self._custom = True
         ValueModel.setValue(self, active_realizations)
 def setValue(self, active_realizations):
     if active_realizations is None or active_realizations.strip() == "" or active_realizations == self.getDefaultValue():
         self._custom = False
         ValueModel.setValue(self, self.getDefaultValue())
     else:
         self._custom = True
         ValueModel.setValue(self, active_realizations)
Example #5
0
 def setValue(self, target_case):
     if target_case is None or target_case.strip() == "" or target_case == self.getDefaultValue():
         self._custom = False
         ValueModel.setValue(self, self.getDefaultValue())
     else:
         self._custom = True
         ValueModel.setValue(self, target_case)
Example #6
0
 def __init__(self,
              facade: LibresFacade,
              notifier: ErtNotifier,
              format_mode: bool = False):
     self.facade = facade
     self._format_mode = format_mode
     self._custom = False
     ValueModel.__init__(self, self.getDefaultValue())
     notifier.ertChanged.connect(self._caseChanged)
Example #7
0
    def __init__(self, default_path, is_required=True, must_be_a_directory=False, must_be_a_file=True,
                 must_exist=False, must_be_absolute=False, must_be_executable=False):
        ValueModel.__init__(self, default_path)

        self._path_is_required = is_required
        self._path_must_be_a_directory = must_be_a_directory
        self._path_must_be_a_file = must_be_a_file
        self._path_must_be_executable = must_be_executable
        self._path_must_exist = must_exist
        self._path_must_be_absolute = must_be_absolute
Example #8
0
    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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(
            self._active_realizations_model,
            "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model,
                                           "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument())
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)
Example #9
0
    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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(self._active_realizations_model, "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model, "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument())
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)
Example #10
0
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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(self._active_realizations_model, "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model, "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument())
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)

    def readCurrentRunPath(self):
        current_case = getCurrentCaseName()
        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.getValue()
        try:
            if iteration is None:
                iteration = ''
            iteration = int(iteration)
        except ValueError as e:
            print('Expected a (whole) number in iteration field, got "%s". Error message: %s.'  % (iteration, e))
            return False
        loaded = LoadResultsModel.loadResults(selected_case, realizations, iteration)
        if loaded > 0:
            print('Successfully loaded %d realisations.' % loaded)
        else:
            print('No realisations loaded.')
        return loaded

    def setCurrectCase(self):
        current_case = getCurrentCaseName()
        self._case_combo.setCurrentIndex(self._case_model.indexOf(current_case))
Example #11
0
 def __init__(self, format_mode=False):
     self._format_mode = format_mode
     self._custom = False
     ValueModel.__init__(self, self.getDefaultValue())
     ERT.ertChanged.connect(self._caseChanged)
Example #12
0
 def _caseChanged(self):
     if not self._custom:
         ValueModel.setValue(self, self.getDefaultValue())
Example #13
0
 def __init__(self, format_mode=False):
     self._format_mode = format_mode
     self._custom = False
     ValueModel.__init__(self, self.getDefaultValue())
     ERT.ertChanged.connect(self._caseChanged)
Example #14
0
 def _caseChanged(self):
     if not self._custom:
         ValueModel.setValue(self, self.getDefaultValue())
Example #15
0
 def __init__(self):
     ValueModel.__init__(self, self.getDefaultValue())
     self._custom = False
Example #16
0
 def __init__(self):
     ValueModel.__init__(self, self.getDefaultValue())
     ERT.ertChanged.connect(self._caseChanged)
Example #17
0
 def __init__(self):
     ValueModel.__init__(self, self.getDefaultValue())
     self._custom = False
Example #18
0
 def __init__(self, notifier: ErtNotifier):
     ValueModel.__init__(self, self.getDefaultValue())
     notifier.ertChanged.connect(self._caseChanged)
Example #19
0
 def setValue(self, iter_value):
     ValueModel.setValue(self, iter_value)
Example #20
0
class LoadResultsPanel(QWidget):
    def __init__(self, facade: LibresFacade):
        self.facade = facade
        QWidget.__init__(self)

        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self._dynamic = False

        self.setWindowTitle("Load results manually")
        self.activateWindow()

        layout = QFormLayout()
        current_case = facade.get_current_case_name()

        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.facade)
        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 = ActiveRealizationsModel(self.facade)
        self._active_realizations_field = StringBox(
            self._active_realizations_model, "load_results_manually/Realizations"
        )
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        self._iterations_model = ValueModel(self.iteration_count)
        self._iterations_field = StringBox(
            self._iterations_model, "load_results_manually/iterations"
        )
        self._iterations_field.setValidator(IntegerArgument())
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)

    @property
    def iteration_count(self):
        """@rtype: int"""
        try:
            self.facade.run_path % (0, 0)
        except TypeError:
            return 0

        iteration = 0
        valid_directory = True
        while valid_directory:
            formatted = self.facade.run_path % (0, iteration + 1)
            valid_directory = os.path.exists(formatted)
            if valid_directory:
                iteration += 1

        return iteration

    def readCurrentRunPath(self):
        current_case = self.facade.get_current_case_name()
        run_path = self.facade.run_path
        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.getValue()
        try:
            if iteration is None:
                iteration = ""
            iteration = int(iteration)
        except ValueError as e:
            print(
                (
                    "Expected a (whole) number in iteration field, "
                    f'got "{iteration}". Error message: {e}.'
                )
            )
            return False
        loaded = self.facade.load_from_forward_model(
            selected_case, realizations, iteration
        )

        if loaded > 0:
            print(f"Successfully loaded {loaded} realisations.")
        else:
            print("No realisations loaded.")
        return loaded

    def setCurrectCase(self):
        current_case = self.facade.get_current_case_name()
        self._case_combo.setCurrentIndex(self._case_model.indexOf(current_case))
Example #21
0
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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(self._active_realizations_model, "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model, "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument(from_value=1))
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)

    def readCurrentRunPath(self):
        current_case = getCurrentCaseName()
        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 = getCurrentCaseName()
        self._case_combo.setCurrentIndex(self._case_model.indexOf(current_case))
Example #22
0
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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(self._active_realizations_model, "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model, "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument())
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)

    def readCurrentRunPath(self):
        current_case = getCurrentCaseName()
        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.getValue()
        try:
            if iteration is None:
                iteration = ''
            iteration = int(iteration)
        except ValueError as e:
            print('Expected a (whole) number in iteration field, got "%s". Error message: %s.'  % (iteration, e))
            return False
        loaded = LoadResultsModel.loadResults(selected_case, realizations, iteration)
        if loaded > 0:
            print('Successfully loaded %d realisations.' % loaded)
        else:
            print('No realisations loaded.')
        return loaded

    def setCurrectCase(self):
        current_case = getCurrentCaseName()
        self._case_combo.setCurrentIndex(self._case_model.indexOf(current_case))
Example #23
0
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 = getCurrentCaseName()

        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 = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(
            self._active_realizations_model,
            "load_results_manually/Realizations")
        self._active_realizations_field.setValidator(RangeStringArgument())
        layout.addRow("Realizations to load:", self._active_realizations_field)

        iterations_count = LoadResultsModel.getIterationCount()

        self._iterations_model = ValueModel(iterations_count)
        self._iterations_field = StringBox(self._iterations_model,
                                           "load_results_manually/iterations")
        self._iterations_field.setValidator(IntegerArgument(from_value=1))
        layout.addRow("Iteration to load:", self._iterations_field)

        self.setLayout(layout)

    def readCurrentRunPath(self):
        current_case = getCurrentCaseName()
        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 = getCurrentCaseName()
        self._case_combo.setCurrentIndex(
            self._case_model.indexOf(current_case))
Example #24
0
 def _caseChanged(self):
     ValueModel.setValue(self, self.getDefaultValue())