Example #1
0
def get_current_run_filename(instrument):
    """
    If instrument is supported, attempts to find the file on the ISIS network which
    contains the data from its current (most up-to-date) run.
    """

    instrument_directory = get_instrument_directory(instrument)
    if instrument_directory is None:
        return ""

    file_path = _instrument_data_directory(instrument_directory) + FILE_SEP
    autosave_file_name = file_path + "autosave.run"
    current_run_filename = ""
    if not check_file_exists(autosave_file_name):
        raise ValueError("Cannot find file : " + autosave_file_name)
    with open(autosave_file_name, 'r') as autosave_file:
        for line in autosave_file:
            line.replace(" ", "")
            file_name = file_path + line
            if check_file_exists(FileFinder.getFullPath(file_name)):
                current_run_filename = file_name
    if current_run_filename == "":
        # Default to auto_A (replicates MuonAnalysis 1.0 behaviour)
        current_run_filename = file_path + instrument_directory + "auto_A.tmp"
        warning("Failed to find latest run, defaulting to " +
                current_run_filename)

    return current_run_filename
Example #2
0
 def _reset_data_file_warning_and_action(self):
     message_box.warning(
         'The file does not contain correctly formatted data, resetting to default data file.'
         'See "https://docs.mantidproject.org/nightly/interfaces/muon/'
         'Muon%20Elemental%20Analysis.html" for more information.')
     self.ptable.set_peak_datafile(None)
     self._generate_element_widgets()
Example #3
0
    def select_data_file(self):
        old_lines = deepcopy(list(self.element_lines.keys()))

        filename = QtWidgets.QFileDialog.getOpenFileName()
        if isinstance(filename, tuple):
            filename = filename[0]
        filename = str(filename)
        if filename:
            self.ptable.set_peak_datafile(filename)

        try:
            self._generate_element_widgets()
        except ValueError:
            message_box.warning(
                'The file does not contain correctly formatted data, resetting to default data file.'
                'See "https://docs.mantidproject.org/nightly/interfaces/'
                'Muon%20Elemental%20Analysis.html" for more information.')
            self.ptable.set_peak_datafile(None)
            self._generate_element_widgets()

        for element in old_lines:
            if element in self.element_widgets.keys():
                self.ptable.select_element(element)
            else:
                self._remove_element_lines(element)
        self._update_checked_data()
 def set_peak_datafile(self, filename=None):
     try:
         if filename:
             self.model.peak_data_file = filename
         else:
             self.model.peak_data_file = self.model.get_default_peak_data_file()
         self.set_buttons()
     except Exception as error:
         message_box.warning(error)
    def show_table(self, table_name):
        if table_name == "":
            message_box.warning("ERROR : No selected table", None)
            return
        elif not check_if_workspace_exist(table_name):
            message_box.warning(f"ERROR : {table_name} Table does not exist",
                                None)
            return

        self.popup_table = EAAutoPopupTable(table_name)

        table = retrieve_ws(table_name)
        columns = table.getColumnNames()
        self.popup_table.create_table(columns)
        table_entries = self.extract_rows(table_name)
        for entry in table_entries:
            self.popup_table.add_entry_to_table(entry)
        self.popup_table.show()
    def get_parameters_for_find_peaks(self):
        parameters = {}
        try:
            parameters["min_energy"] = float(self.min_energy_line_edit.text())
            parameters["max_energy"] = float(self.max_energy_line_edit.text())
            parameters["threshold"] = float(self.threshold_line_edit.text())
            parameters["default_width"] = self.default_peak_checkbox.isChecked(
            )
            if not parameters["default_width"]:
                parameters["min_width"] = float(
                    self.min_width_line_edit.text())
                parameters["max_width"] = float(
                    self.max_width_line_edit.text())
                parameters["estimate_width"] = float(
                    self.estimate_width_line_edit.text())
                if parameters["min_width"] > parameters["max_width"]:
                    raise ValueError(
                        "Minimum peak width is greater than maximum peak width"
                    )
                if parameters["min_width"] > parameters["estimate_width"] or \
                        parameters["estimate_width"] > parameters["max_width"]:
                    raise ValueError(
                        "Estimated peak width must be between minimum and maximum peak width"
                    )
            if parameters["min_energy"] > parameters["max_energy"]:
                raise ValueError(
                    "Minimum energy is greater than maximum energy")

        except ValueError as error:
            message_box.warning(f"Invalid arguments for peak finding: {error}")
            return None

        group_workspace_name = self.group_combobox.currentText()
        detector = self.detector_combobox.currentText()
        workspace_name = f"{group_workspace_name}; {detector}"
        if detector == "All":
            workspace_name = group_workspace_name
        if group_workspace_name == "" and detector == "":
            message_box.warning("No workspace selected")
            return None
        parameters["workspace"] = workspace_name
        parameters["plot_peaks"] = self.plot_peaks_checkbox.isChecked()

        return parameters
Example #7
0
 def warning_popup(self, message):
     warning(message, parent=self)
Example #8
0
 def _default_exception_callback(self, message):
     warning(message)
 def set_peak_datafile(self, filename):
     try:
         self.model.peak_data_file = filename
         self.set_buttons()
     except Exception as error:
         message_box.warning(error)
Example #10
0
 def warning_popup(self, message):
     message_box.warning(str(message), parent=self)
Example #11
0
 def show_warning(self, msg):
     """
     Display a warning on that something went wrong
     :param msg: The message to include
     """
     warning(msg, self)
Example #12
0
 def _default_exception_callback(self, message):
     warning(message)
 def display_warning_box(self, message):
     warning(message, self)
Example #14
0
 def warning_popup(self, message):
     warning(message, parent=self)
Example #15
0
 def warning(self, msg):
     message_box.warning(msg)
 def handle_calculation_error(self, error):
     message_box.warning("ERROR: " + str(error), None)
     self.handle_warnings()
     self.calculation_finished_notifier.notify_subscribers()
     self.update_view_notifier.notify_subscribers()
     self.update_match_table_notifier.notify_subscribers()
 def handle_warnings(self):
     while not self.warnings.empty():
         warning = self.warnings.get()
         message_box.warning("WARNING: " + str(warning), None)
Example #18
0
 def warning_popup(message):
     warning(message)
Example #19
0
        self.setCentralWidget(self.grid)

        self.setWindowTitle("plot test")

    def add(self):
        self.n += 1
        self.test.add_subplot(str(self.n))
        self.test.plot(str(self.n), self.ws, specNum=self.n)


def setUpSubplot():
    ws = mantid.LoadMuonNexus("MUSR00062260", OutputWorkspace="ws")
    return ws


def qapp():
    if QtGui.QApplication.instance():
        _app = QtGui.QApplication.instance()
    else:
        _app = QtGui.QApplication(sys.argv)
    return _app


app = qapp()
try:
    window = plotTestGui()
    window.show()
    app.exec_()
except RuntimeError as error:
    message_box.warning(str(error))
Example #20
0
 def warning_popup(message):
     warning(message)
Example #21
0
 def warning_popup(message):
     message_box.warning(str(message))
Example #22
0
 def display_warning_box(self, message):
     warning(message, self)
 def warning_popup(message):
     message_box.warning(str(message))
Example #24
0
 def warning_popup(self, message: str) -> None:
     """Displays a warning message."""
     warning(message, parent=self)