コード例 #1
0
ファイル: plot_window.py プロジェクト: clementetienam/ert
    def __init__(self, config_file, storage_client, parent):
        QMainWindow.__init__(self, parent)

        if storage_client:
            self._api = storage_client
        else:
            self._api = PlotApi(ERT.enkf_facade)

        self.setMinimumWidth(850)
        self.setMinimumHeight(650)

        self.setWindowTitle("Plotting - {}".format(config_file))
        self.activateWindow()
        self._key_definitions = self._api.all_data_type_keys()
        self._plot_customizer = PlotCustomizer(self, self._key_definitions)

        self._plot_customizer.settingsChanged.connect(self.keySelected)

        self._central_tab = QTabWidget()

        central_widget = QWidget()
        central_layout = QVBoxLayout()
        central_layout.setContentsMargins(0, 0, 0, 0)
        central_widget.setLayout(central_layout)

        central_layout.addWidget(self._central_tab)

        self.setCentralWidget(central_widget)

        self._plot_widgets = []
        """:type: list of PlotWidget"""

        self.addPlotWidget(ENSEMBLE, EnsemblePlot())
        self.addPlotWidget(STATISTICS, StatisticsPlot())
        self.addPlotWidget(HISTOGRAM, HistogramPlot())
        self.addPlotWidget(GAUSSIAN_KDE, GaussianKDEPlot())
        self.addPlotWidget(DISTRIBUTION, DistributionPlot())
        self.addPlotWidget(CROSS_CASE_STATISTICS, CrossCaseStatisticsPlot())

        self._central_tab.currentChanged.connect(self.currentPlotChanged)

        cases = self._api.get_all_cases_not_running()
        case_names = [case["name"] for case in cases if not case["hidden"]]

        self._data_type_keys_widget = DataTypeKeysWidget(self._key_definitions)
        self._data_type_keys_widget.dataTypeKeySelected.connect(
            self.keySelected)
        self.addDock("Data types", self._data_type_keys_widget)
        self._case_selection_widget = CaseSelectionWidget(case_names)
        self._case_selection_widget.caseSelectionChanged.connect(
            self.keySelected)
        self.addDock("Plot case", self._case_selection_widget)

        current_plot_widget = self._plot_widgets[
            self._central_tab.currentIndex()]
        self._data_type_keys_widget.selectDefault()
        self._updateCustomizer(current_plot_widget)
コード例 #2
0
    def api(self):
        config_file = "snake_oil.ert"

        rc = ResConfig(user_config_file=config_file)
        rc.convertToCReference(None)
        ert = EnKFMain(rc)
        facade = LibresFacade(ert)
        api = PlotApi(facade)
        return api
コード例 #3
0
def api(tmpdir, source_root):
    with tmpdir.as_cwd():
        test_data_root = source_root / "test-data" / "local"
        test_data_dir = os.path.join(test_data_root, "snake_oil")
        shutil.copytree(test_data_dir, "test_data")
        os.chdir("test_data")
        config_file = "snake_oil.ert"
        rc = ResConfig(user_config_file=config_file)
        rc.convertToCReference(None)
        ert = EnKFMain(rc)
        facade = LibresFacade(ert)
        api = PlotApi(facade)
        yield api
コード例 #4
0
class PlotWindow(QMainWindow):


    def __init__(self, config_file, parent):
        QMainWindow.__init__(self, parent)

        self._api = PlotApi(ERT.enkf_facade)

        self.setMinimumWidth(850)
        self.setMinimumHeight(650)

        self.setWindowTitle("Plotting - {}".format(config_file))
        self.activateWindow()
        self._key_definitions = self._api.all_data_type_keys()
        self._plot_customizer = PlotCustomizer(self, self._key_definitions)

        self._plot_customizer.settingsChanged.connect(self.keySelected)

        self._central_tab = QTabWidget()

        central_widget = QWidget()
        central_layout = QVBoxLayout()
        central_layout.setContentsMargins(0, 0, 0, 0)
        central_widget.setLayout(central_layout)

        central_layout.addWidget(self._central_tab)

        self.setCentralWidget(central_widget)

        self._plot_widgets = []
        """:type: list of PlotWidget"""

        self.addPlotWidget(ENSEMBLE, EnsemblePlot())
        self.addPlotWidget(STATISTICS, StatisticsPlot())
        self.addPlotWidget(HISTOGRAM, HistogramPlot())
        self.addPlotWidget(GAUSSIAN_KDE, GaussianKDEPlot())
        self.addPlotWidget(DISTRIBUTION, DistributionPlot())
        self.addPlotWidget(CROSS_CASE_STATISTICS, CrossCaseStatisticsPlot())

        self._central_tab.currentChanged.connect(self.currentPlotChanged)


        cases = self._api.get_all_cases_not_running()
        case_names = [case["name"] for case in cases if not case["hidden"]]


        self._data_type_keys_widget = DataTypeKeysWidget(self._key_definitions)
        self._data_type_keys_widget.dataTypeKeySelected.connect(self.keySelected)
        self.addDock("Data types", self._data_type_keys_widget)
        self._case_selection_widget = CaseSelectionWidget(case_names)
        self._case_selection_widget.caseSelectionChanged.connect(self.keySelected)
        self.addDock("Plot case", self._case_selection_widget)

        current_plot_widget = self._plot_widgets[self._central_tab.currentIndex()]
        self._data_type_keys_widget.selectDefault()
        self._updateCustomizer(current_plot_widget)


    def currentPlotChanged(self):
        key_def = self.getSelectedKey()
        key = key_def["key"]

        for plot_widget in self._plot_widgets:
            index = self._central_tab.indexOf(plot_widget)

            if index == self._central_tab.currentIndex() \
                    and plot_widget._plotter.dimensionality == key_def["dimensionality"]:
                self._updateCustomizer(plot_widget)
                cases = self._case_selection_widget.getPlotCaseNames()
                case_to_data_map = {case: self._api.data_for_key(case, key)[key] for case in cases}
                if len(key_def["observations"]) > 0:
                    observations = self._api.observations_for_obs_keys(cases[0], key_def["observations"])
                else:
                    observations = None

                plot_config = PlotConfig.createCopy(self._plot_customizer.getPlotConfig())
                plot_config.setTitle(key)
                plot_context = PlotContext(plot_config, cases, key)

                if key_def["has_refcase"]:
                    plot_context.refcase_data = self._api.refcase_data(key)

                plot_widget.updatePlot(plot_context, case_to_data_map, observations)