コード例 #1
0
ファイル: text_or_file.py プロジェクト: jepebe/ert
    def __init__(self, setter):
        """
        Takes as argument a setter for the simulation model to set the current
        value of this widget.
        """
        super(TextOrFile, self).__init__()
        self.model_setter = setter

        iteration_weights_path_model = DefaultPathModel("", must_exist=True)
        iteration_weights_path_chooser = PathChooser(iteration_weights_path_model, path_label="Iteration weights file")
        iteration_weights_path_model.observable().attach(DefaultPathModel.PATH_CHANGED_EVENT, self._valueChanged)

        custom_iteration_weights_model = StringModel("1")
        custom_iteration_weights_box = StringBox(custom_iteration_weights_model, "Custom iteration weights", "config/simulation/iteration_weights")
        custom_iteration_weights_box.setValidator(NumberListStringArgument())
        custom_iteration_weights_model.observable().attach(StringModel.VALUE_CHANGED_EVENT, self._valueChanged)

        self.addHelpedWidget("Custom", custom_iteration_weights_box)
        self.addHelpedWidget("File", iteration_weights_path_chooser)

        # It is necessary to set a minimum height in some way;
        # otherwise the input field becomes invisible when the window
        # is resized to minimum vertical size. The value '50' is taken
        # out of thin air, but seems to work.
        self.setMinimumHeight( 50 )
コード例 #2
0
    def getArguments(self, parent=None):
        description = "The MDA Ensemble Smoother requires some information before running:"
        dialog = CustomDialog("MDA Ensemble Smoother", description, parent)

        iterated_target_case_format_model = DefaultNameFormatModel(
            self.getDefaultTargetCaseFormat())
        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())

        iteration_weights_path_model = DefaultPathModel("", must_exist=True)
        iteration_weights_path_chooser = PathChooser(
            iteration_weights_path_model, path_label="Iteration weights file")

        custom_iteration_weights_model = StringModel("1")
        custom_iteration_weights_box = StringBox(
            custom_iteration_weights_model, "Custom iteration weights",
            "config/simulation/iteration_weights")
        custom_iteration_weights_box.setValidator(NumberListStringArgument())

        option_widget = OptionWidget("Relative Weights")
        option_widget.addHelpedWidget("Custom", custom_iteration_weights_box)
        option_widget.addHelpedWidget("File", iteration_weights_path_chooser)

        dialog.addOption(iterated_target_case_format_box)
        dialog.addOption(option_widget)
        dialog.addSpace()
        dialog.addWidget(
            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."), "Note")

        dialog.addButtons()

        success = dialog.showAndTell()

        if success:
            optioned_widget = option_widget.getCurrentWidget()

            if optioned_widget == iteration_weights_path_chooser:
                weights = iteration_weights_path_model.getPath()
            elif optioned_widget == custom_iteration_weights_box:
                weights = custom_iteration_weights_model.getValue()
            else:
                weights = "1"

            return [iterated_target_case_format_model.getValue(), weights]

        raise CancelPluginException("User cancelled!")
コード例 #3
0
ファイル: mda_es.py プロジェクト: chflo/ert
    def getArguments(self, parent=None):
        description = "The MDA Ensemble Smoother requires some information before running:"
        dialog = CustomDialog("MDA Ensemble Smoother", description, parent)

        iterated_target_case_format_model = DefaultNameFormatModel(self.getDefaultTargetCaseFormat())
        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())

        iteration_weights_path_model = DefaultPathModel("", must_exist=True)
        iteration_weights_path_chooser = PathChooser(iteration_weights_path_model, path_label="Iteration weights file")

        custom_iteration_weights_model = StringModel("1")
        custom_iteration_weights_box = StringBox(custom_iteration_weights_model, "Custom iteration weights", "config/simulation/iteration_weights")
        custom_iteration_weights_box.setValidator(NumberListStringArgument())

        option_widget = OptionWidget("Relative Weights")
        option_widget.addHelpedWidget("Custom", custom_iteration_weights_box)
        option_widget.addHelpedWidget("File", iteration_weights_path_chooser)

        dialog.addOption(iterated_target_case_format_box)
        dialog.addOption(option_widget)
        dialog.addSpace()
        dialog.addWidget(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."), "Note")

        dialog.addButtons()

        success = dialog.showAndTell()

        if success:
            optioned_widget = option_widget.getCurrentWidget()

            if optioned_widget == iteration_weights_path_chooser:
                weights = iteration_weights_path_model.getPath()
            elif optioned_widget == custom_iteration_weights_box:
                weights = custom_iteration_weights_model.getValue()
            else:
                weights = "1"

            return [iterated_target_case_format_model.getValue(), weights]

        raise CancelPluginException("User cancelled!")
コード例 #4
0
ファイル: text_or_file.py プロジェクト: chflo/ert
    def __init__(self, setter):
        """
        Takes as argument a setter for the simulation model to set the current
        value of this widget.
        """
        super(TextOrFile, self).__init__()
        self.model_setter = setter

        iteration_weights_path_model = DefaultPathModel("", must_exist=True)
        iteration_weights_path_chooser = PathChooser(iteration_weights_path_model, path_label="Iteration weights file")
        iteration_weights_path_model.observable().attach(DefaultPathModel.PATH_CHANGED_EVENT, self._valueChanged)

        custom_iteration_weights_model = StringModel("1")
        custom_iteration_weights_box = StringBox(custom_iteration_weights_model, "Custom iteration weights", "config/simulation/iteration_weights")
        custom_iteration_weights_box.setValidator(NumberListStringArgument())
        custom_iteration_weights_model.observable().attach(StringModel.VALUE_CHANGED_EVENT, self._valueChanged)

        self.addHelpedWidget("Custom", custom_iteration_weights_box)
        self.addHelpedWidget("File", iteration_weights_path_chooser)
コード例 #5
0
    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
コード例 #6
0
    def __init__(self, setter):
        """
        Takes as argument a setter for the simulation model to set the current
        value of this widget.
        """
        super(TextOrFile, self).__init__()
        self.model_setter = setter

        iteration_weights_path_model = DefaultPathModel("", must_exist=True)
        iteration_weights_path_chooser = PathChooser(
            iteration_weights_path_model, path_label="Iteration weights file")
        iteration_weights_path_model.observable().attach(
            DefaultPathModel.PATH_CHANGED_EVENT, self._valueChanged)

        custom_iteration_weights_model = StringModel("1")
        custom_iteration_weights_box = StringBox(
            custom_iteration_weights_model, "Custom iteration weights",
            "config/simulation/iteration_weights")
        custom_iteration_weights_box.setValidator(NumberListStringArgument())
        custom_iteration_weights_model.observable().attach(
            StringModel.VALUE_CHANGED_EVENT, self._valueChanged)

        self.addHelpedWidget("Custom", custom_iteration_weights_box)
        self.addHelpedWidget("File", iteration_weights_path_chooser)