Skip to content
Snippets Groups Projects
Commit 666f9d05 authored by Kien Le's avatar Kien Le
Browse files

Fix RT130 plot failing

parent 49657765
No related branches found
No related tags found
Loading
...@@ -484,7 +484,7 @@ class PlottingWidget(QtWidgets.QScrollArea): ...@@ -484,7 +484,7 @@ class PlottingWidget(QtWidgets.QScrollArea):
# channel not plotted # channel not plotted
continue continue
c_data = self.plotting_data1[chan_id] c_data = self.plotting_data1[chan_id]
self.get_zoom_data(c_data, chan_id) self.get_zoom_data(c_data, chan_id, self.plotting_data1)
for chan_id in self.plotting_data2: for chan_id in self.plotting_data2:
c_data = self.plotting_data2[chan_id] c_data = self.plotting_data2[chan_id]
self.get_zoom_data(c_data, chan_id) self.get_zoom_data(c_data, chan_id)
...@@ -511,6 +511,10 @@ class PlottingWidget(QtWidgets.QScrollArea): ...@@ -511,6 +511,10 @@ class PlottingWidget(QtWidgets.QScrollArea):
new_min_y = None new_min_y = None
new_max_y = None new_max_y = None
if hasattr(ax, 'x_list'): if hasattr(ax, 'x_list'):
if not hasattr(ax, 'y_list'):
# dotForTime plots have attribute 'x_list' but not
# 'y_list'
continue
total_points = 0 total_points = 0
tr_min_ys = [] tr_min_ys = []
tr_max_ys = [] tr_max_ys = []
......
...@@ -94,6 +94,9 @@ class SOHWidget(plotting_widget.PlottingWidget): ...@@ -94,6 +94,9 @@ class SOHWidget(plotting_widget.PlottingWidget):
if chan_db_info['plotType'] == '': if chan_db_info['plotType'] == '':
continue continue
self.plotting_data1[chan_id]['chan_db_info'] = chan_db_info self.plotting_data1[chan_id]['chan_db_info'] = chan_db_info
self.move_soh_channels_with_link_to_the_end()
for chan_id in self.plotting_data1:
self.get_zoom_data(self.plotting_data1[chan_id], chan_id, self.get_zoom_data(self.plotting_data1[chan_id], chan_id,
self.plotting_data1, True) self.plotting_data1, True)
...@@ -142,18 +145,20 @@ class SOHWidget(plotting_widget.PlottingWidget): ...@@ -142,18 +145,20 @@ class SOHWidget(plotting_widget.PlottingWidget):
# dialog. # dialog.
if chan_id in {'GLO', 'VLO', 'VLA', 'GLA', 'VEL', 'VNS', 'GNS', 'GEL'}: if chan_id in {'GLO', 'VLO', 'VLA', 'GLA', 'VEL', 'VNS', 'GNS', 'GEL'}:
return return
chan_db_info = c_data['chan_db_info'] try:
chan_db_info = c_data['chan_db_info']
except KeyError:
return
plot_type = chan_db_info['plotType'] plot_type = chan_db_info['plotType']
if c_data['samplerate'] <= 1: if c_data['samplerate'] <= 1:
trim_downsample_soh_chan(c_data, self.min_x, self.max_x) trim_downsample_soh_chan(c_data, self.min_x, self.max_x)
else: else:
print("work on later") print("work on later")
apply_convert_factor(c_data, 1) apply_convert_factor(c_data, 1)
linked_ax = None
if chan_db_info['linkedChan'] not in [None, 'None', '']:
linked_ax = plotting_data[chan_db_info['linkedChan']]['ax']
if 'ax' not in c_data: if 'ax' not in c_data:
linked_ax = None
if chan_db_info['linkedChan'] not in [None, 'None', '']:
linked_ax = plotting_data[chan_db_info['linkedChan']]['ax']
ax = getattr(self.plotting, plot_functions[plot_type][1])( ax = getattr(self.plotting, plot_functions[plot_type][1])(
c_data, chan_db_info, chan_id, None, linked_ax) c_data, chan_db_info, chan_id, None, linked_ax)
if ax is None: if ax is None:
...@@ -163,7 +168,7 @@ class SOHWidget(plotting_widget.PlottingWidget): ...@@ -163,7 +168,7 @@ class SOHWidget(plotting_widget.PlottingWidget):
self.axes.append(ax) self.axes.append(ax)
else: else:
getattr(self.plotting, plot_functions[plot_type][1])( getattr(self.plotting, plot_functions[plot_type][1])(
c_data, chan_db_info, chan_id, c_data['ax'], None) c_data, chan_db_info, chan_id, c_data['ax'], linked_ax)
def set_lim(self, first_time=False): def set_lim(self, first_time=False):
""" """
...@@ -176,3 +181,22 @@ class SOHWidget(plotting_widget.PlottingWidget): ...@@ -176,3 +181,22 @@ class SOHWidget(plotting_widget.PlottingWidget):
if not first_time: if not first_time:
self.remove_plot_num_points_text() self.remove_plot_num_points_text()
super().set_lim(first_time) super().set_lim(first_time)
def move_soh_channels_with_link_to_the_end(self):
"""
In order to plot a channel (channel A) that is linked with another
channel (channel B), we need to plot B before we plot A. Because the
order of the channel in the data is not predetermined, we need to
manually move A to the end of the data set. This is, of course,
assuming that channel link is at most one level deep.
"""
channels_to_move = []
for channel, chan_data in self.plotting_data1.items():
try:
linked_channel = chan_data['chan_db_info']['linkedChan']
if linked_channel not in ['', 'None', None]:
channels_to_move.append(channel)
except KeyError:
continue
for channel in channels_to_move:
self.plotting_data1[channel] = self.plotting_data1.pop(channel)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment