Commit b14d4b16 authored by Matt Cumber's avatar Matt Cumber
Browse files

Re #30905 Added Frames

Added a new column. Also fixed a bug. Updated run info to explicitly state DAQ periods. Added checks for missing data
parent 01362b34
......@@ -107,7 +107,8 @@ void LoadMuonNexus::init() {
declareProperty(
std::make_unique<ArrayProperty<std::string>>("PeriodsInformation"),
"An array of strings which hold period information. This array is in the "
"format ['NumberOfSequences', 'Labels', 'TotalFrames']. Empty strings "
"format ['NumberOfSequences', 'Labels', 'Frames', 'TotalFrames']. Empty "
"strings "
"show no value "
"could be read from file.");
}
......
......@@ -125,6 +125,7 @@ void MuonNexusReader::readFromFile(const string &filename) {
// Try to read in period information
std::vector<std::string> periodInformation{"period_sequences", "period_labels",
"frames_period_requested",
"frames_period_raw"};
try {
handle.openGroup("beam", "NXbeam");
......@@ -135,11 +136,13 @@ void MuonNexusReader::readFromFile(const string &filename) {
int temp = 0;
handle.readData(info, temp);
tempString = std::to_string(temp);
} else if (info == "frames_period_raw") {
} else if (info == "frames_period_requested" ||
info == "frames_period_raw") {
std::vector<int> temp;
handle.readData(info, temp);
for (const auto &value : temp)
tempString += std::to_string(value) + ";";
tempString.erase(tempString.length() - 1); // Remove final ;
} else {
handle.readData(info, tempString);
}
......
......@@ -12,7 +12,7 @@ from Muon.GUI.Common import thread_model
from Muon.GUI.Common.run_selection_dialog import RunSelectionDialog
from Muon.GUI.Common.thread_model_wrapper import ThreadModelWrapper
from Muon.GUI.Common.utilities.run_string_utils import run_string_to_list
from Muon.GUI.Common.muon_period_info import MuonPeriodInfoWidget
from Muon.GUI.Common.muon_period_info import MuonPeriodInfoWidget, HEADER_COLUMN_MAP, PERIOD_INFO_NOT_FOUND
class GroupingTabPresenter(object):
......@@ -287,9 +287,33 @@ class GroupingTabPresenter(object):
def _add_period_info_to_widget(self):
self.period_info_widget.number_of_sequences = self._model._data.periods_info[0]
total_frames = self._model._data.periods_info[2].split(';')
for index, name in enumerate(self._model._data.periods_info[1].split(';')):
self.period_info_widget.add_period_to_table(name, total_frames[index])
names = self._model._data.periods_info[HEADER_COLUMN_MAP["Name"]].split(';')
frames = self._model._data.periods_info[HEADER_COLUMN_MAP["Frames"]].split(';')
total_frames = self._model._data.periods_info[HEADER_COLUMN_MAP["Total Frames"]].split(';')
names, frames, total_frames, count = self._fix_up_period_info_lists(names, frames, total_frames)
for i in range(count):
self.period_info_widget.add_period_to_table(names[i], frames[i], total_frames[i])
def _fix_up_period_info_lists(self, names, frames, total_frames):
# First find number of periods
count = max(len(names), len(frames), len(total_frames))
# Then make sure lists are correct size
if len(names) != count:
if names[0] == "":
names = [PERIOD_INFO_NOT_FOUND] * count
else:
names += [PERIOD_INFO_NOT_FOUND] * count-len(names)
if len(frames) != count:
if frames[0] == "":
frames = [PERIOD_INFO_NOT_FOUND] * count
else:
frames += [PERIOD_INFO_NOT_FOUND] * count - len(frames)
if len(total_frames) != count:
if total_frames[0] == "":
total_frames = [PERIOD_INFO_NOT_FOUND] * count
else:
total_frames += [PERIOD_INFO_NOT_FOUND] * count - len(total_frames)
return names, frames, total_frames, count
# ------------------------------------------------------------------------------------------------------------------
# Observer / Observable
......
......@@ -35,7 +35,7 @@ class HomeRunInfoWidgetPresenter(HomeTabSubWidget):
self._view.add_text_line("Average Temperature (K) : "+str(self._model.get_average_temperature()))
self._view.add_text_line(self.create_text_line("Sample Temperature (K) ", "sample_temp"))
self._view.add_text_line(self.create_text_line("Sample Magnetic Field (G)", "sample_magn_field"))
self._view.add_text_line("Number of Periods : " + str(self._model.get_periods()))
self._view.add_text_line("Number of DAQ Periods : " + str(self._model.get_periods()))
def create_text_line(self, name, log_name):
log = self._model.get_log_value(log_name)
......
......@@ -7,9 +7,14 @@
from qtpy import QtWidgets, PYQT4, QtCore
from Muon.GUI.Common.utilities import table_utils
HEADERS = ["Period Number", "Name", "Total Frames"]
HEADERS = ["Period Number", "Name", "Frames", "Total Frames"]
HEADER_STYLE = "QHeaderView { font-weight: bold; }"
COLUMN_COUNT = 3
COLUMN_COUNT = 4
HEADER_COLUMN_MAP = {"Period Number": 0,
"Name": 1,
"Frames": 2,
"Total Frames": 3}
PERIOD_INFO_NOT_FOUND = "Not found"
class MuonPeriodInfoWidget(QtWidgets.QWidget):
......@@ -40,12 +45,13 @@ class MuonPeriodInfoWidget(QtWidgets.QWidget):
else:
self.label.setText("Number of period cycles not found")
def add_period_to_table(self, name, total_frames):
def add_period_to_table(self, name, frames, total_frames):
row_num = self._num_rows()
self.table.insertRow(row_num)
self.table.setItem(row_num, 0, self._new_text_widget(str(row_num + 1))) # Set period number
self.table.setItem(row_num, 1, self._new_text_widget(name)) # Set name
self.table.setItem(row_num, 2, self._new_text_widget(total_frames)) # Set name
self.table.setItem(row_num, HEADER_COLUMN_MAP["Period Number"], self._new_text_widget(str(row_num + 1))) # Set period number
self.table.setItem(row_num, HEADER_COLUMN_MAP["Name"], self._new_text_widget(name)) # Set name
self.table.setItem(row_num, HEADER_COLUMN_MAP["Frames"], self._new_text_widget(frames)) # Set frames
self.table.setItem(row_num, HEADER_COLUMN_MAP["Total Frames"], self._new_text_widget(total_frames)) # Set total frames
def _new_text_widget(self, text):
new_widget = table_utils.ValidatedTableItem(lambda text: True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment