Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software_public/passoft/sohstationviewer
1 result
Show changes
Commits on Source (2)
...@@ -457,7 +457,7 @@ class LogInfo(): ...@@ -457,7 +457,7 @@ class LogInfo():
elif "EXTERNAL CLOCK IS UNLOCKED" in line: elif "EXTERNAL CLOCK IS UNLOCKED" in line:
epoch = self.simple_read(line)[1] epoch = self.simple_read(line)[1]
if epoch: if epoch:
self.add_chan_info('GPS Lk/Unlk', epoch, 0, idx) self.add_chan_info('GPS Lk/Unlk', epoch, -1, idx)
elif "EXTERNAL CLOCK IS LOCKED" in line: elif "EXTERNAL CLOCK IS LOCKED" in line:
epoch = self.simple_read(line)[1] epoch = self.simple_read(line)[1]
if epoch: if epoch:
......
# class with all plotting functions # class with all plotting functions
import numpy as np
from sohstationviewer.controller.util import get_val from sohstationviewer.controller.util import get_val
from sohstationviewer.controller.plotting_data import get_masspos_value_colors from sohstationviewer.controller.plotting_data import get_masspos_value_colors
...@@ -75,8 +77,10 @@ class Plotting: ...@@ -75,8 +77,10 @@ class Plotting:
if chan_db_info['valueColors'] in [None, 'None', '']: if chan_db_info['valueColors'] in [None, 'None', '']:
chan_db_info['valueColors'] = '*:W' chan_db_info['valueColors'] = '*:W'
value_colors = chan_db_info['valueColors'].split('|') value_colors = chan_db_info['valueColors'].split('|')
colors = []
for vc in value_colors: for vc in value_colors:
v, c = vc.split(':') v, c = vc.split(':')
colors.append(c)
val = get_val(v) val = get_val(v)
if c == '_': if c == '_':
prev_val = val prev_val = val
...@@ -104,9 +108,14 @@ class Plotting: ...@@ -104,9 +108,14 @@ class Plotting:
total_samples = len(x) total_samples = len(x)
x = sorted(x) x = sorted(x)
if len(colors) != 1:
sample_no_colors = [clr['W']]
else:
sample_no_colors = [clr[colors[0]]]
self.plotting_axes.set_axes_info( self.plotting_axes.set_axes_info(
ax, [total_samples], chan_db_info=chan_db_info, ax, [total_samples], sample_no_colors=sample_no_colors,
linked_ax=linked_ax) chan_db_info=chan_db_info, linked_ax=linked_ax)
if linked_ax is None: if linked_ax is None:
ax.x = x ax.x = x
else: else:
...@@ -168,6 +177,8 @@ class Plotting: ...@@ -168,6 +177,8 @@ class Plotting:
ax.set_ylim(-2, 2) ax.set_ylim(-2, 2)
self.plotting_axes.set_axes_info( self.plotting_axes.set_axes_info(
ax, [len(points_list[0]), len(points_list[1])], ax, [len(points_list[0]), len(points_list[1])],
sample_no_colors=[clr[colors[0]], clr[colors[1]]],
sample_no_pos=[0.25, 0.75],
chan_db_info=chan_db_info, linked_ax=linked_ax) chan_db_info=chan_db_info, linked_ax=linked_ax)
if linked_ax is None: if linked_ax is None:
ax.x = x ax.x = x
...@@ -203,7 +214,8 @@ class Plotting: ...@@ -203,7 +214,8 @@ class Plotting:
x_list = c_data['times'] x_list = c_data['times']
total_x = sum([len(x) for x in x_list]) total_x = sum([len(x) for x in x_list])
self.plotting_axes.set_axes_info( self.plotting_axes.set_axes_info(
ax, [total_x], chan_db_info=chan_db_info, linked_ax=linked_ax) ax, [total_x], sample_no_colors=[clr[color]],
chan_db_info=chan_db_info, linked_ax=linked_ax)
for x in x_list: for x in x_list:
ax.plot(x, [0] * len(x), marker='s', markersize=1.5, ax.plot(x, [0] * len(x), marker='s', markersize=1.5,
...@@ -250,10 +262,7 @@ class Plotting: ...@@ -250,10 +262,7 @@ class Plotting:
self.parent.plotting_bot, plot_h) self.parent.plotting_bot, plot_h)
x_list, y_list = c_data['times'], c_data['data'] x_list, y_list = c_data['times'], c_data['data']
total_x = sum([len(x) for x in x_list])
self.plotting_axes.set_axes_info(
ax, [total_x], chan_db_info=chan_db_info,
info=info, y_list=y_list, linked_ax=linked_ax)
colors = {} colors = {}
if chan_db_info['valueColors'] not in [None, 'None', '']: if chan_db_info['valueColors'] not in [None, 'None', '']:
color_parts = chan_db_info['valueColors'].split('|') color_parts = chan_db_info['valueColors'].split('|')
...@@ -261,12 +270,27 @@ class Plotting: ...@@ -261,12 +270,27 @@ class Plotting:
obj, c = cStr.split(':') obj, c = cStr.split(':')
colors[obj] = c colors[obj] = c
l_color = 'G' l_color = 'G'
d_color = 'W'
has_dot = False has_dot = False
if 'L' in colors: if 'L' in colors:
l_color = colors['L'] l_color = colors['L']
if 'D' in colors: if 'D' in colors:
d_color = colors['D'] d_color = colors['D']
has_dot = True has_dot = True
if chan_id == 'GPS Lk/Unlk':
sample_no_list = []
sample_no_list.append(np.where(y_list[0] == -1)[0].size)
sample_no_list.append(np.where(y_list[0] == 1)[0].size)
sample_no_colors = [clr[d_color], clr[d_color]]
else:
sample_no_list = [sum([len(x) for x in x_list])]
sample_no_colors = [clr[d_color]]
self.plotting_axes.set_axes_info(
ax, sample_no_list, sample_no_colors=sample_no_colors,
chan_db_info=chan_db_info,
info=info, y_list=y_list, linked_ax=linked_ax)
for x, y in zip(x_list, y_list): for x, y in zip(x_list, y_list):
if not has_dot: if not has_dot:
# set marker to be able to click point for info # set marker to be able to click point for info
......
from typing import List from typing import List, Optional, Dict
import numpy as np
from matplotlib.axes import Axes
from matplotlib.patches import ConnectionPatch, Rectangle from matplotlib.patches import ConnectionPatch, Rectangle
from matplotlib.ticker import AutoMinorLocator from matplotlib.ticker import AutoMinorLocator
from matplotlib import pyplot as pl from matplotlib import pyplot as pl
...@@ -10,6 +12,7 @@ from sohstationviewer.controller.plotting_data import ( ...@@ -10,6 +12,7 @@ from sohstationviewer.controller.plotting_data import (
get_gaps, get_time_ticks, get_unit_bitweight) get_gaps, get_time_ticks, get_unit_bitweight)
from sohstationviewer.conf import constants from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import clr
class PlottingAxes: class PlottingAxes:
...@@ -148,24 +151,30 @@ class PlottingAxes: ...@@ -148,24 +151,30 @@ class PlottingAxes:
ax.patch.set_alpha(0) ax.patch.set_alpha(0)
return ax return ax
def set_axes_info(self, ax, sample_no_list, def set_axes_info(self, ax: Axes,
label=None, info='', y_list=None, chan_db_info=None, sample_no_list: List[int],
linked_ax=None): sample_no_colors: List[str] = [clr['W'], clr['W']],
sample_no_pos: List[float] = [0.05, 0.95],
label: Optional[str] = None,
info: str = '',
y_list: Optional[np.ndarray] = None,
chan_db_info: Optional[Dict] = None,
linked_ax: Optional[Axes] = None):
""" """
Draw plot's title, sub title, sample total label, center line, y labels Draw plot's title, sub title, sample total label, center line, y labels
for a channel. for a channel.
:param ax: matplotlib.axes.Axes - axes of a channel :param ax: axes of a channel
:param sample_no_list: [int,] - list of totals of different sample :param sample_no_list: list of totals of different sample groups
groups :param sample_no_colors: list of color to display sample numbers
:param label: str/None - title of the plot. :param sample_no_pos: list of position to display sample numbers
If None, show chan_db_info['label'] top/bottom
:param info: str - additional info to show in sub title which is :param label: title of the plot. If None, show chan_db_info['label']
:param info: additional info to show in sub title which is
smaller and under title on the left side smaller and under title on the left side
:param y: numpy.array - y values of the channel, to show min/max labels :param y: y values of the channel for min/max labels, min/max lines
and min/max lines :param chan_db_info: info of channel from database
:param chan_db_info: dict - info of channel from database :param linked_ax:
:param linked_ax: matplotlib.axes.Axes/None -
if linked_ax is None, this is a main channel, label of channel will if linked_ax is None, this is a main channel, label of channel will
be displayed with title's format, on top right of plot. be displayed with title's format, on top right of plot.
if linked_ax is not None, this is a channel using main channel's if linked_ax is not None, this is a channel using main channel's
...@@ -181,6 +190,7 @@ class PlottingAxes: ...@@ -181,6 +190,7 @@ class PlottingAxes:
if label is None: if label is None:
label = chan_db_info['label'] label = chan_db_info['label']
title_ver_alignment = 'center' title_ver_alignment = 'center'
# set info in subtitle under title # set info in subtitle under title
if linked_ax is not None: if linked_ax is not None:
...@@ -223,7 +233,7 @@ class PlottingAxes: ...@@ -223,7 +233,7 @@ class PlottingAxes:
verticalalignment='center', verticalalignment='center',
rotation='horizontal', rotation='horizontal',
transform=ax.transAxes, transform=ax.transAxes,
color=self.parent.display_color['basic'], color=sample_no_colors[0],
size=self.parent.font_size size=self.parent.font_size
) )
else: else:
...@@ -233,30 +243,31 @@ class PlottingAxes: ...@@ -233,30 +243,31 @@ class PlottingAxes:
# on data created in trim_downsample_chan_with_spr_less_or_equal_1 # on data created in trim_downsample_chan_with_spr_less_or_equal_1
# and won't be changed in set_lim, then don't need to assign a # and won't be changed in set_lim, then don't need to assign a
# variable for it. # variable for it.
# bottom # bottom
ax.text( ax.text(
1.005, 0.25, 1.005, sample_no_pos[0],
sample_no_list[0], sample_no_list[0],
horizontalalignment='left', horizontalalignment='left',
verticalalignment='center', verticalalignment='center',
rotation='horizontal', rotation='horizontal',
transform=ax.transAxes, transform=ax.transAxes,
color=self.parent.display_color['basic'], color=sample_no_colors[0],
size=self.parent.font_size size=self.parent.font_size
) )
# top # top
ax.text( ax.text(
1.005, 0.75, 1.005, sample_no_pos[1],
sample_no_list[1], sample_no_list[1],
horizontalalignment='left', horizontalalignment='left',
verticalalignment='center', verticalalignment='center',
rotation='horizontal', rotation='horizontal',
transform=ax.transAxes, transform=ax.transAxes,
color=self.parent.display_color['basic'], color=sample_no_colors[1],
size=self.parent.font_size size=self.parent.font_size
) )
if linked_ax is not None:
ax.set_yticks([])
return
if y_list is None: if y_list is None:
# draw center line # draw center line
ax.plot([self.parent.min_x, self.parent.max_x], ax.plot([self.parent.min_x, self.parent.max_x],
......