Skip to content
Snippets Groups Projects

fix bug calculate find_tps_tm when the end time fall into the last 5 minute of a day

Merged Lan Dam requested to merge i81_tps_second_marker into master
3 files
+ 49
45
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -16,7 +16,7 @@ from sohstationviewer.database.extract_data import (
get_color_def, get_color_ranges, get_chan_label,
)
from sohstationviewer.model.handling_data import (
get_each_day_5_min_list, find_tps_tm,
get_start_5mins_of_diff_days, find_tps_tm_idx,
)
from sohstationviewer.view.plotting.plotting_widget import plotting_widget
from sohstationviewer.view.plotting.time_power_squared_processor import (
@@ -53,7 +53,7 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
of five minutes for every day in which each day has 288 of
5 minutes.
"""
self.each_day5_min_list = []
self.start_5mins_of_diff_days = []
"""
tps_t: float - prompt's time on tps's chart to help rulers on other
plotting widgets to identify their location
@@ -118,15 +118,15 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
self.min_x = max(data_time[0], start_tm)
self.max_x = min(data_time[1], end_tm)
self.each_day5_min_list = get_each_day_5_min_list(self.min_x,
self.max_x)
self.start_5mins_of_diff_days = get_start_5mins_of_diff_days(
self.min_x, self.max_x)
for chan_id in self.plotting_data1:
c_data = self.plotting_data1[chan_id]
if 'tps_data' not in c_data:
self.channels.append(chan_id)
channel_processor = TimePowerSquaredProcessor(
chan_id, c_data, self.min_x, self.max_x,
self.each_day5_min_list
self.start_5mins_of_diff_days
)
channel_processor.signals.finished.connect(self.channel_done)
channel_processor.signals.stopped.connect(self.channel_done)
@@ -379,7 +379,8 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
five_min_index = xdata
try:
# identify time for rulers on other plotting widget
self.tps_t = self.each_day5_min_list[day_index, five_min_index]
self.tps_t = self.start_5mins_of_diff_days[
day_index, five_min_index]
format_t = format_time(self.tps_t, self.date_mode, 'HH:MM:SS')
info_str += f"<pre>{format_t}:"
for chan_id in self.plotting_data1:
@@ -405,7 +406,7 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
:param xdata: float - time value in other plot
"""
self.zoom_marker1_shown = False
x_idx, y_idx = find_tps_tm(xdata, self.each_day5_min_list)
x_idx, y_idx = find_tps_tm_idx(xdata, self.start_5mins_of_diff_days)
for rl in self.rulers:
rl.set_data(x_idx, y_idx)
@@ -443,10 +444,12 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
y index (which day) of self.min_x and self.min_y, and set data for
all markers in self.zoom_marker1s and self.zoom_marker2s.
"""
x_idx, y_idx = find_tps_tm(self.min_x, self.each_day5_min_list)
x_idx, y_idx = find_tps_tm_idx(self.min_x,
self.start_5mins_of_diff_days)
for zm1 in self.zoom_marker1s:
zm1.set_data(x_idx, y_idx)
x_idx, y_idx = find_tps_tm(self.max_x, self.each_day5_min_list)
x_idx, y_idx = find_tps_tm_idx(self.max_x,
self.start_5mins_of_diff_days)
for zm2 in self.zoom_marker2s:
zm2.set_data(x_idx, y_idx)
Loading