Example #1
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!")
Example #2
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)