Пример #1
0
    def load_general_setting_values(self):
        normalize_to_bin_width = "on" == ConfigService.getString(
            self.NORMALIZATION).lower()
        show_title = "on" == ConfigService.getString(self.SHOW_TITLE).lower()

        self.view.normalize_to_bin_width.setChecked(normalize_to_bin_width)
        self.view.show_title.setChecked(show_title)
Пример #2
0
    def should_show_on_startup():
        """ Determines if the first time dialog should be shown
        :return: True if the dialog should be shown
        """
        # first check the facility and instrument
        facility = ConfigService.getString(AboutPresenter.FACILITY)
        instrument = ConfigService.getString(AboutPresenter.INSTRUMENT)
        if not facility:
            return True
        else:
            # check we can get the facility and instrument
            try:
                facilityInfo = ConfigService.getFacility(facility)
                instrumentInfo = ConfigService.getInstrument(instrument)
                logger.information("Default facility '{0}', instrument '{1}'\n".format(facilityInfo.name(),
                                                                                       instrumentInfo.name()))
            except RuntimeError:
                # failed to find the facility or instrument
                logger.error("Could not find your default facility '{0}' or instrument '{1}' in facilities.xml, "
                             + "showing please select again.\n".format(facility, instrument))
                return True

        settings = QSettings()
        settings.beginGroup(AboutPresenter.DO_NOT_SHOW_GROUP)
        doNotShowUntilNextRelease =int(settings.value(AboutPresenter.DO_NOT_SHOW, '0'))
        lastVersion = settings.value(AboutPresenter.LAST_VERSION, "")
        settings.endGroup()

        if not doNotShowUntilNextRelease:
            return True

        # Now check if the version has changed since last time
        version = release_notes_url()
        return version != lastVersion
Пример #3
0
def pcolormesh_on_axis(ax, ws, color_norm=None, normalize_by_bin_width=None):
    """
    Plot a pcolormesh plot of the given workspace on the given axis
    :param ax: A matplotlib axes instance
    :param ws: A mantid workspace instance
    :param color_norm: A matplotlib.colours Normalize instance (or any of its subclasses)
    :param normalize_by_bin_width: Optional keyword argument to pass to imshow in the event of a plot restoration
    :return:
    """
    ax.clear()
    ax.set_title(ws.name())
    scale = _get_colorbar_scale() if not color_norm else color_norm

    if use_imshow(ws):
        pcm = ax.imshow(ws,
                        cmap=ConfigService.getString("plots.images.Colormap"),
                        aspect='auto',
                        origin='lower',
                        norm=scale,
                        normalize_by_bin_width=normalize_by_bin_width)
        # remove normalize_by_bin_width from cargs if present so that this can be toggled in future
        for cargs in pcm.axes.creation_args:
            cargs.pop('normalize_by_bin_width')
    else:
        pcm = ax.pcolormesh(
            ws,
            cmap=ConfigService.getString("plots.images.Colormap"),
            norm=scale)

    return pcm
Пример #4
0
    def load_current_setting_values(self):
        background = ConfigService.getString(self.AUTO_BACKGROUND).split(
            " ", 1)
        if self.view.auto_bkg.findText(background[0], Qt.MatchExactly) != -1:
            self.view.auto_bkg.setCurrentText(background[0])
        else:
            self.view.auto_bkg.setCurrentText("LinearBackground")
        if len(background) > 1:
            self.view.background_args.setText(background[1])

        default_peak = ConfigService.getString(self.DEFAULT_PEAK)
        if self.view.default_peak.findText(default_peak,
                                           Qt.MatchExactly) != -1:
            self.view.default_peak.setCurrentText(default_peak)
        else:
            self.view.auto_bkg.setCurrentText("Gaussian")

        fwhm = ConfigService.getString(self.FWHM)
        if fwhm == "":
            self.view.findpeaks_fwhm.setValue(7)
        else:
            self.view.findpeaks_fwhm.setValue(int(fwhm))

        tolerance = ConfigService.getString(self.TOLERANCE)
        if tolerance == "":
            self.view.findpeaks_tol.setValue(4)
        else:
            self.view.findpeaks_tol.setValue(int(tolerance))
Пример #5
0
def get_plot_fig(overplot=None,
                 ax_properties=None,
                 window_title=None,
                 axes_num=1,
                 fig=None):
    """
    Create a blank figure and axes, with configurable properties.
    :param overplot: If true then plotting on figure will plot over previous plotting. If an axis object the overplotting
    will be done on the axis passed in
    :param ax_properties: A dict of axes properties. E.g. {'yscale': 'log'} for log y-axis
    :param window_title: A string denoting the name of the GUI window which holds the graph
    :param axes_num: The number of axes to create on the figure
    :param fig: An optional figure object
    :return: Matplotlib fig and axes objects
    """
    import matplotlib.pyplot as plt

    if fig and overplot:
        fig = fig
    elif fig:
        fig, _, _, _ = create_subplots(axes_num, fig)
    elif overplot:
        # The create subplot below assumes no figure was passed in, this is ensured by the elif above
        # but add an assert which prevents a future refactoring from breaking this assumption
        assert not fig
        fig = plt.gcf()
        if not fig.axes:
            plt.close(fig)
            # The user is likely trying to overplot on a non-existent plot, create one for them
            fig, _, _, _ = create_subplots(axes_num)
    else:
        fig, _, _, _ = create_subplots(axes_num)

    if not ax_properties and not overplot:
        ax_properties = {}
        if ConfigService.getString("plots.xAxesScale").lower() == 'log':
            ax_properties['xscale'] = 'log'
        else:
            ax_properties['xscale'] = 'linear'
        if ConfigService.getString("plots.yAxesScale").lower() == 'log':
            ax_properties['yscale'] = 'log'
        else:
            ax_properties['yscale'] = 'linear'
    if ax_properties:
        for axis in fig.axes:
            axis.set(**ax_properties)
    if window_title:
        fig.canvas.set_window_title(window_title)

    if not overplot:
        if ConfigService.getString("plots.ShowMinorTicks").lower() == "on":
            for ax in fig.axes:
                ax.minorticks_on()

        for ax in fig.axes:
            ax.show_minor_gridlines = ConfigService.getString(
                "plots.ShowMinorGridlines").lower() == "on"

    return fig, fig.axes
    def __init__(self):
        super(PythonInterfacesStartupTest, self).__init__()

        self._app = get_application()

        self._interface_directory = ConfigService.getString('mantidqt.python_interfaces_directory')
        self._interface_scripts = [interface.split("/")[1] for interface in
                                   ConfigService.getString('mantidqt.python_interfaces').split()
                                   if interface.split("/")[1] not in EXCLUDED_SCRIPTS]
Пример #7
0
    def setup_error_bar_group(self):
        error_width = float(ConfigService.getString(self.ERROR_WIDTH))
        capsize = float(ConfigService.getString(self.CAPSIZE))
        cap_thickness = float(ConfigService.getString(self.CAP_THICKNESS))
        error_every = int(ConfigService.getString(self.ERROR_EVERY))

        self.view.error_width.setValue(error_width)
        self.view.capsize.setValue(capsize)
        self.view.cap_thickness.setValue(cap_thickness)
        self.view.error_every.setValue(error_every)
Пример #8
0
 def setup_legend_group(self):
     legend_location = ConfigService.getString(
         PlotProperties.LEGEND_LOCATION.value)
     self.view.legend_location.addItems(self.LEGEND_LOCATION_LIST)
     if legend_location in self.LEGEND_LOCATION_LIST:
         self.view.legend_location.setCurrentIndex(
             self.view.legend_location.findText(legend_location))
     legend_font_size = float(
         ConfigService.getString(PlotProperties.LEGEND_FONT_SIZE.value))
     self.view.legend_font_size.setValue(legend_font_size)
Пример #9
0
def _add_default_plot_kwargs_from_settings(plot_kwargs, errors):
    if 'linestyle' not in plot_kwargs:
        plot_kwargs['linestyle'] = ConfigService.getString("plots.line.Style")
    if 'drawstyle' not in plot_kwargs:
        plot_kwargs['drawstyle'] = ConfigService.getString(
            "plots.line.DrawStyle")
    if 'linewidth' not in plot_kwargs:
        plot_kwargs['linewidth'] = float(
            ConfigService.getString("plots.line.Width"))
    if 'marker' not in plot_kwargs:
        plot_kwargs['marker'] = MARKER_MAP[ConfigService.getString(
            "plots.marker.Style")]
    if 'markersize' not in plot_kwargs:
        plot_kwargs['markersize'] = float(
            ConfigService.getString("plots.marker.Size"))
    if errors:
        if 'capsize' not in plot_kwargs:
            plot_kwargs['capsize'] = float(
                ConfigService.getString("plots.errorbar.Capsize"))
        if 'capthick' not in plot_kwargs:
            plot_kwargs['capthick'] = float(
                ConfigService.getString("plots.errorbar.CapThickness"))
        if 'errorevery' not in plot_kwargs:
            plot_kwargs['errorevery'] = int(
                ConfigService.getString("plots.errorbar.errorEvery"))
        if 'elinewidth' not in plot_kwargs:
            plot_kwargs['elinewidth'] = float(
                ConfigService.getString("plots.errorbar.Width"))
Пример #10
0
    def setup_marker_group(self):
        marker_style = ConfigService.getString(self.MARKER_STYLE)
        self.view.marker_style.addItems(MARKER_STYLES)
        if marker_style in MARKER_STYLES:
            self.view.marker_style.setCurrentIndex(
                self.view.marker_style.findText(marker_style))
        else:
            self.view.marker_style.setCurrentIndex(0)

        marker_size = float(ConfigService.getString(self.MARKER_SIZE))
        self.view.marker_size.setValue(marker_size)
Пример #11
0
    def setup_line_group(self):
        line_style = ConfigService.getString(self.LINE_STYLE)
        self.view.line_style.addItems(VALID_LINE_STYLE)
        if line_style in VALID_LINE_STYLE:
            self.view.line_style.setCurrentIndex(
                self.view.line_style.findText(line_style))
        else:
            self.view.line_style.setCurrentIndex(0)

        line_width = float(ConfigService.getString(self.LINE_WIDTH))
        self.view.line_width.setValue(line_width)
Пример #12
0
    def setup_line_group(self):
        line_style = ConfigService.getString(PlotProperties.LINE_STYLE.value)
        self._setup_style_combo_boxes(line_style, self.view.line_style,
                                      VALID_LINE_STYLE)

        draw_style = ConfigService.getString(PlotProperties.DRAW_STYLE.value)
        self._setup_style_combo_boxes(draw_style, self.view.draw_style,
                                      VALID_DRAW_STYLE)

        line_width = float(
            ConfigService.getString(PlotProperties.LINE_WIDTH.value))
        self.view.line_width.setValue(line_width)
Пример #13
0
    def setup_marker_group(self):
        marker_style = ConfigService.getString(
            PlotProperties.MARKER_STYLE.value)
        if marker_style in MARKER_STYLES.keys():
            self.view.marker_style.setCurrentIndex(
                self.view.marker_style.findText(marker_style))
        else:
            self.view.marker_style.setCurrentIndex(0)

        marker_size = float(
            ConfigService.getString(PlotProperties.MARKER_SIZE.value))
        self.view.marker_size.setValue(marker_size)
Пример #14
0
    def load_general_setting_values(self):
        normalize_to_bin_width = "on" == ConfigService.getString(
            PlotProperties.NORMALIZATION.value).lower()
        show_title = "on" == ConfigService.getString(
            PlotProperties.SHOW_TITLE.value).lower()
        show_legend = "on" == ConfigService.getString(
            PlotProperties.SHOW_LEGEND.value).lower()

        self.view.normalize_to_bin_width.setChecked(normalize_to_bin_width)
        self.view.show_title.setChecked(show_title)
        self.view.show_legend.setChecked(show_legend)
        self.populate_font_combo_box()
Пример #15
0
    def load_current_setting_values(self):
        self.view.prompt_save_on_close.setChecked(CONF.get(self.PROMPT_SAVE_ON_CLOSE))
        self.view.prompt_save_editor_modified.setChecked(CONF.get(self.PROMPT_SAVE_EDITOR_MODIFIED))

        # compare lower-case, because MantidPlot will save it as lower case,
        # but Python will have the bool's first letter capitalised
        pr_enabled = ("true" == ConfigService.getString(self.PR_RECOVERY_ENABLED).lower())
        pr_time_between_recovery = int(ConfigService.getString(self.PR_TIME_BETWEEN_RECOVERY))
        pr_number_checkpoints = int(ConfigService.getString(self.PR_NUMBER_OF_CHECKPOINTS))

        self.view.project_recovery_enabled.setChecked(pr_enabled)
        self.view.time_between_recovery.setValue(pr_time_between_recovery)
        self.view.total_number_checkpoints.setValue(pr_number_checkpoints)
Пример #16
0
    def load_general_setting_values(self):
        normalize_to_bin_width = "on" == ConfigService.getString(
            PlotProperties.NORMALIZATION.value).lower()
        show_title = "on" == ConfigService.getString(
            PlotProperties.SHOW_TITLE.value).lower()
        show_minor_ticks = "on" == ConfigService.getString(
            PlotProperties.SHOW_MINOR_TICKS.value).lower()
        show_minor_gridlines = "on" == ConfigService.getString(
            PlotProperties.SHOW_MINOR_GRIDLINES.value).lower()

        self.view.normalize_to_bin_width.setChecked(normalize_to_bin_width)
        self.view.show_title.setChecked(show_title)
        self.view.show_minor_ticks.setChecked(show_minor_ticks)
        self.view.show_minor_gridlines.setEnabled(show_minor_ticks)
        self.view.show_minor_gridlines.setChecked(show_minor_gridlines)
Пример #17
0
def remove_output_files(list_of_names=None):
    """Removes output files created during a test."""

    # import ConfigService here to avoid:
    # RuntimeError: Pickling of "mantid.kernel._kernel.ConfigServiceImpl"
    # instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)

    from mantid.kernel import ConfigService

    if not isinstance(list_of_names, list):
        raise ValueError("List of names is expected.")
    if not all(isinstance(i, str) for i in list_of_names):
        raise ValueError("Each name should be a string.")

    save_dir_path = ConfigService.getString("defaultsave.directory")
    if save_dir_path != "":  # default save directory set
        all_files = os.listdir(save_dir_path)
    else:
        all_files = os.listdir(os.getcwd())

    for filename in all_files:
        for name in list_of_names:
            if name in filename:
                full_path = os.path.join(save_dir_path, filename)
                if os.path.isfile(full_path):
                    os.remove(full_path)
                break
Пример #18
0
    def _save(self):
        self.__is_saving = True
        try:
            workspaces_to_save = self._get_workspace_names_to_save()

            if self.save_altered_workspaces_only:
                workspaces_to_save = self._filter_unaltered_workspaces(
                    workspaces_to_save)

            # Calculate the size of the workspaces in the project.
            project_size = self._get_project_size(workspaces_to_save)
            warning_size = int(
                ConfigService.getString("projectSaving.warningSize"))
            # If a project is > the value in the properties file, question the user if they want to continue.
            result = None
            if project_size > warning_size:
                result = self._offer_large_size_confirmation()
            if result is None or result != QMessageBox.Cancel:
                plots_to_save = self.plot_gfm.figs

                if self.save_altered_workspaces_only:
                    plots_to_save = self._filter_plots_with_unaltered_workspaces(
                        plots_to_save, workspaces_to_save)

                interfaces_to_save = self.interface_populating_function()
                project_saver = ProjectSaver(self.project_file_ext)
                project_saver.save_project(
                    file_name=self.last_project_location,
                    workspace_to_save=workspaces_to_save,
                    plots_to_save=plots_to_save,
                    interfaces_to_save=interfaces_to_save)
                self.__saved = True
        finally:
            self.__is_saving = False
Пример #19
0
    def __init__(self, parent, view=None, usage_reporting_verification_view = None):
        self.view = view if view else AboutView(parent, self, version_str(), release_date().strip())
        self.usage_reporting_verification_view = usage_reporting_verification_view \
            if usage_reporting_verification_view  else UsageReportingVerificationView(parent, self)
        self.parent = parent
        self.view.clbReleaseNotes.clicked.connect(self.action_open_release_notes)
        self.view.clbSampleDatasets.clicked.connect(self.action_open_download_website)
        self.view.clbMantidIntroduction.clicked.connect(self.action_open_mantid_introduction)
        self.view.clbPythonIntroduction.clicked.connect(self.action_open_python_introduction)
        self.view.clbPythonInMantid.clicked.connect(self.action_open_python_in_mantid)
        self.view.clbExtendingMantid.clicked.connect(self.action_open_extending_mantid)
        self.view.lblPrivacyPolicy.linkActivated.connect(self.action_open_external_link)
        self.view.pbMUD.clicked.connect(self.action_manage_user_directories)
        self.view.pbClose.clicked.connect(self.action_close)
        self.setup_facilities_group()

        # set chkAllowUsageData
        isUsageReportEnabled = ConfigService.getString(self.USAGE_REPORTING, True)
        if isUsageReportEnabled == "0":
            self.view.chkAllowUsageData.setChecked(False)
        self.view.chkAllowUsageData.stateChanged.connect(self.action_usage_data_changed)

        # set do not show
        qSettings = QSettings()
        qSettings.beginGroup(self.DO_NOT_SHOW_GROUP)
        doNotShowUntilNextRelease = int(qSettings.value(self.DO_NOT_SHOW, "0"))
        qSettings.endGroup()
        self.view.chkDoNotShowUntilNextRelease.setChecked(doNotShowUntilNextRelease)
        self.view.chkDoNotShowUntilNextRelease.stateChanged.connect(self.action_do_not_show_until_next_release)
Пример #20
0
 def test_large_file_dialog_does_not_appear_for_small_file(self):
     CreateSampleWorkspace(OutputWorkspace="ws1")
     self.project._get_project_size = mock.MagicMock(return_value=
                                                     int(ConfigService.getString("projectSaving.warningSize")) - 1)
     self.project._offer_large_size_confirmation = mock.MagicMock()
     self.project._save()
     self.assertEqual(self.project._offer_large_size_confirmation.call_count, 0)
Пример #21
0
    def set_mappable(self, mappable):
        """
        When a new plot is created this method should be called with the new mappable
        """
        # sanity check the mappable
        mappable = self._validate_mappable(mappable)
        self.ax.clear()
        try:  # Use current cmap
            cmap = get_current_cmap(self.colorbar)
        except AttributeError:
            # else use default
            cmap = ConfigService.getString("plots.images.Colormap")
        self.colorbar = Colorbar(ax=self.ax, mappable=mappable)
        self.cmin_value, self.cmax_value = mappable.get_clim()
        self.update_clim_text()
        self.cmap_changed(cmap, False)

        mappable_cmap = get_current_cmap(mappable)

        if mappable_cmap.name.endswith('_r'):
            self.crev.setChecked(True)
        else:
            self.crev.setChecked(False)
        self.cmap.setCurrentIndex(
            self.cmap_list.index(mappable_cmap.name.replace('_r', '')))

        self.redraw()
Пример #22
0
def _get_colorbar_scale():
    """Get the scale type (Linear, Log) for the colorbar in image type plots"""
    scale = ConfigService.getString("plots.images.ColorBarScale")
    if scale == "Log":
        return matplotlib.colors.LogNorm()
    else:
        return matplotlib.colors.Normalize()
Пример #23
0
def remove_output_files(list_of_names=None):
    """Removes output files created during a test."""

    # import ConfigService here to avoid:
    # RuntimeError: Pickling of "mantid.kernel._kernel.ConfigServiceImpl"
    # instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)

    from mantid.kernel import ConfigService

    if not isinstance(list_of_names, list):
        raise ValueError("List of names is expected.")
    if not all(isinstance(i, str) for i in list_of_names):
        raise ValueError("Each name should be a string.")

    save_dir_path = ConfigService.getString("defaultsave.directory")
    if save_dir_path != "":  # default save directory set
        all_files = os.listdir(save_dir_path)
    else:
        all_files = os.listdir(os.getcwd())

    for filename in all_files:
        for name in list_of_names:
            if name in filename:
                full_path = os.path.join(save_dir_path, filename)
                if os.path.isfile(full_path):
                    os.remove(full_path)
                break
Пример #24
0
    def setup_checkbox_signals(self):
        self.view.show_invisible_workspaces.setChecked(
            "true" == ConfigService.getString(self.SHOW_INVISIBLE_WORKSPACES).lower())

        self.view.show_invisible_workspaces.stateChanged.connect(self.action_show_invisible_workspaces)
        self.view.project_recovery_enabled.stateChanged.connect(self.action_project_recovery_enabled)
        self.view.time_between_recovery.valueChanged.connect(self.action_time_between_recovery)
        self.view.total_number_checkpoints.valueChanged.connect(self.action_total_number_checkpoints)
Пример #25
0
    def setup_axes_group(self):
        x_axes_scale = ConfigService.getString(self.X_AXES_SCALE)
        y_axes_scale = ConfigService.getString(self.Y_AXES_SCALE)

        self.view.x_axes_scale.addItems(self.AXES_SCALE)
        self.view.y_axes_scale.addItems(self.AXES_SCALE)
        if x_axes_scale in self.AXES_SCALE:
            self.view.x_axes_scale.setCurrentIndex(
                self.view.x_axes_scale.findText(x_axes_scale))
        else:
            self.view.x_axes_scale.setCurrentIndex(0)

        if y_axes_scale in self.AXES_SCALE:
            self.view.y_axes_scale.setCurrentIndex(
                self.view.y_axes_scale.findText(y_axes_scale))
        else:
            self.view.y_axes_scale.setCurrentIndex(0)
Пример #26
0
 def __init__(self, initial_type):
     self._save_directory = ConfigService.getString('defaultsave.directory')
     self._type_factory_dict = {
         BinningType.SaveAsEventData: SaveAsEventData(),
         BinningType.Custom: CustomBinning(),
         BinningType.FromMonitors: BinningFromMonitors()
     }
     self._settings, self._type = self._settings_from_type(initial_type)
Пример #27
0
 def __init__(self, initial_type):
     self._save_directory = ConfigService.getString('defaultsave.directory')
     self._type_factory_dict = {
         BinningType.SAVE_AS_EVENT_DATA: SaveAsEventData(),
         BinningType.CUSTOM: CustomBinning(),
         BinningType.FROM_MONITORS: BinningFromMonitors()
     }
     self._settings, self._type = self._settings_from_type(initial_type)
Пример #28
0
    def setup_axes_group(self):
        x_axes_scale = ConfigService.getString(
            PlotProperties.X_AXES_SCALE.value)
        y_axes_scale = ConfigService.getString(
            PlotProperties.Y_AXES_SCALE.value)

        if x_axes_scale in self.AXES_SCALE:
            self.view.x_axes_scale.setCurrentIndex(
                self.view.x_axes_scale.findText(x_axes_scale))
        else:
            self.view.x_axes_scale.setCurrentIndex(0)

        if y_axes_scale in self.AXES_SCALE:
            self.view.y_axes_scale.setCurrentIndex(
                self.view.y_axes_scale.findText(y_axes_scale))
        else:
            self.view.y_axes_scale.setCurrentIndex(0)
Пример #29
0
    def load_current_setting_values(self):
        self.view.prompt_save_on_close.setChecked(
            CONF.get(self.PROMPT_SAVE_ON_CLOSE))
        self.view.prompt_save_editor_modified.setChecked(
            CONF.get(self.PROMPT_SAVE_EDITOR_MODIFIED))

        # compare lower-case, because MantidPlot will save it as lower case,
        # but Python will have the bool's first letter capitalised
        pr_enabled = ("true" == ConfigService.getString(
            self.PR_RECOVERY_ENABLED).lower())
        pr_time_between_recovery = int(
            ConfigService.getString(self.PR_TIME_BETWEEN_RECOVERY))
        pr_number_checkpoints = int(
            ConfigService.getString(self.PR_NUMBER_OF_CHECKPOINTS))

        self.view.project_recovery_enabled.setChecked(pr_enabled)
        self.view.time_between_recovery.setValue(pr_time_between_recovery)
        self.view.total_number_checkpoints.setValue(pr_number_checkpoints)
Пример #30
0
 def __init__(self):
     super(PythonInterfacesStartupTest, self).__init__()
     import mantidqtinterfaces
     self._interface_directory = os.path.dirname(
         mantidqtinterfaces.__file__)
     self._interface_scripts = [
         interface.split("/")[1] for interface in ConfigService.getString(
             'mantidqt.python_interfaces').split()
     ]
Пример #31
0
 def populate_font_combo_box(self):
     fonts = self.model.get_font_names()
     self.view.plot_font.addItems(fonts)
     current_font = ConfigService.getString(PlotProperties.PLOT_FONT.value)
     if current_font:
         self.view.plot_font.setCurrentText(current_font)
     else:
         self.view.plot_font.setCurrentText(
             self.model.get_current_mpl_font())
Пример #32
0
def pcolormesh_on_axis(ax, ws):
    """
    Plot a pcolormesh plot of the given workspace on the given axis
    :param ax: A matplotlib axes instance
    :param ws: A mantid workspace instance
    :return:
    """
    ax.clear()
    ax.set_title(ws.name())
    if use_imshow(ws):
        pcm = ax.imshow(ws,
                        cmap=ConfigService.getString("plots.images.Colormap"),
                        aspect='auto',
                        origin='lower')
    else:
        pcm = ax.pcolormesh(
            ws, cmap=ConfigService.getString("plots.images.Colormap"))

    return pcm
Пример #33
0
 def setup_images_group(self):
     colormap = ConfigService.getString(PlotProperties.COLORMAP.value)
     if self.view.default_colormap_combo_box.findText(colormap) != -1:
         self.view.default_colormap_combo_box.setCurrentIndex(
             self.view.default_colormap_combo_box.findText(colormap))
         self.view.reverse_colormap_check_box.setChecked(False)
     elif colormap.endswith(
             '_r') and self.view.default_colormap_combo_box.findText(
                 colormap[:-2]):
         self.view.default_colormap_combo_box.setCurrentIndex(
             self.view.default_colormap_combo_box.findText(colormap[:-2]))
         self.view.reverse_colormap_check_box.setChecked(True)
     colorbar_scale = ConfigService.getString(
         PlotProperties.COLORBAR_SCALE.value)
     if colorbar_scale in self.AXES_SCALE:
         self.view.colorbar_scale.setCurrentIndex(
             self.view.colorbar_scale.findText(colorbar_scale))
     else:
         self.view.colorbar_scale.setCurrentIndex(0)
Пример #34
0
 def get_number_of_checkpoints():
     """
     :return: int; The maximum number of checkpoints project recovery should allow
     """
     try:
         return int(ConfigService.getString("projectRecovery.numberOfCheckpoints"))
     except Exception as e:
         if isinstance(e, KeyboardInterrupt):
             raise
         # Fail silently and return 5 (the default)
         return DEFAULT_NUM_CHECKPOINTS
Пример #35
0
    def __init__(self, input_filename=None, group_name=None):

        if isinstance(input_filename, str):

            self._input_filename = input_filename
            try:
                self._hash_input_filename = self.calculate_ab_initio_file_hash()
            except IOError as err:
                logger.error(str(err))
            except ValueError as err:
                logger.error(str(err))

            # extract name of file from the full path in the platform independent way
            filename = os.path.basename(self._input_filename)

            if filename.strip() == "":
                raise ValueError("Name of the file cannot be an empty string.")

        else:
            raise ValueError("Invalid name of input file. String was expected.")

        if isinstance(group_name, str):
            self._group_name = group_name
        else:
            raise ValueError("Invalid name of the group. String was expected.")

        core_name = filename[0:filename.rfind(".")]
        save_dir_path = ConfigService.getString("defaultsave.directory")
        self._hdf_filename = os.path.join(save_dir_path, core_name + ".hdf5")  # name of hdf file

        try:
            self._advanced_parameters = self._get_advanced_parameters()
        except IOError as err:
            logger.error(str(err))
        except ValueError as err:
            logger.error(str(err))

        self._attributes = {}  # attributes for group

        # data  for group; they are expected to be numpy arrays or
        # complex data sets which have the form of Python dictionaries or list of Python
        # dictionaries
        self._data = {}
 def test_get_number_of_checkpoints(self):
     self.assertEqual(int(ConfigService.getString(NO_OF_CHECKPOINTS_KEY)),
                      self.prm.get_number_of_checkpoints())
Пример #37
0
 def __init__(self, initial_type):
     self._save_directory = ConfigService.getString('defaultsave.directory')
     self._type_factory_dict = {BinningType.SaveAsEventData: SaveAsEventData(),
                                BinningType.Custom: CustomBinning(),
                                BinningType.FromMonitors: BinningFromMonitors()}
     self._settings, self._type = self._settings_from_type(initial_type)
Пример #38
0
 def instrument(self):
     return ConfigService.getString('default.instrument')
Пример #39
0
 def save_directory(self):
     return ConfigService.getString('defaultsave.directory')