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():
elif "EXTERNAL CLOCK IS UNLOCKED" in line:
epoch = self.simple_read(line)[1]
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:
epoch = self.simple_read(line)[1]
if epoch:
......
# class with all plotting functions
import numpy as np
from sohstationviewer.controller.util import get_val
from sohstationviewer.controller.plotting_data import get_masspos_value_colors
......@@ -75,8 +77,10 @@ class Plotting:
if chan_db_info['valueColors'] in [None, 'None', '']:
chan_db_info['valueColors'] = '*:W'
value_colors = chan_db_info['valueColors'].split('|')
colors = []
for vc in value_colors:
v, c = vc.split(':')
colors.append(c)
val = get_val(v)
if c == '_':
prev_val = val
......@@ -104,9 +108,14 @@ class Plotting:
total_samples = len(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(
ax, [total_samples], chan_db_info=chan_db_info,
linked_ax=linked_ax)
ax, [total_samples], sample_no_colors=sample_no_colors,
chan_db_info=chan_db_info, linked_ax=linked_ax)
if linked_ax is None:
ax.x = x
else:
......@@ -168,6 +177,8 @@ class Plotting:
ax.set_ylim(-2, 2)
self.plotting_axes.set_axes_info(
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)
if linked_ax is None:
ax.x = x
......@@ -203,7 +214,8 @@ class Plotting:
x_list = c_data['times']
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, 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:
ax.plot(x, [0] * len(x), marker='s', markersize=1.5,
......@@ -250,10 +262,7 @@ class Plotting:
self.parent.plotting_bot, plot_h)
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 = {}
if chan_db_info['valueColors'] not in [None, 'None', '']:
color_parts = chan_db_info['valueColors'].split('|')
......@@ -261,12 +270,27 @@ class Plotting:
obj, c = cStr.split(':')
colors[obj] = c
l_color = 'G'
d_color = 'W'
has_dot = False
if 'L' in colors:
l_color = colors['L']
if 'D' in colors:
d_color = colors['D']
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):
if not has_dot:
# 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.ticker import AutoMinorLocator
from matplotlib import pyplot as pl
......@@ -10,6 +12,7 @@ from sohstationviewer.controller.plotting_data import (
get_gaps, get_time_ticks, get_unit_bitweight)
from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import clr
class PlottingAxes:
......@@ -148,24 +151,30 @@ class PlottingAxes:
ax.patch.set_alpha(0)
return ax
def set_axes_info(self, ax, sample_no_list,
label=None, info='', y_list=None, chan_db_info=None,
linked_ax=None):
def set_axes_info(self, ax: Axes,
sample_no_list: List[int],
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
for a channel.
:param ax: matplotlib.axes.Axes - axes of a channel
:param sample_no_list: [int,] - list of totals of different sample
groups
:param label: str/None - title of the plot.
If None, show chan_db_info['label']
:param info: str - additional info to show in sub title which is
:param ax: axes of a channel
:param sample_no_list: list of totals of different sample groups
:param sample_no_colors: list of color to display sample numbers
:param sample_no_pos: list of position to display sample numbers
top/bottom
: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
:param y: numpy.array - y values of the channel, to show min/max labels
and min/max lines
:param chan_db_info: dict - info of channel from database
:param linked_ax: matplotlib.axes.Axes/None -
:param y: y values of the channel for min/max labels, min/max lines
:param chan_db_info: info of channel from database
:param linked_ax:
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.
if linked_ax is not None, this is a channel using main channel's
......@@ -181,6 +190,7 @@ class PlottingAxes:
if label is None:
label = chan_db_info['label']
title_ver_alignment = 'center'
# set info in subtitle under title
if linked_ax is not None:
......@@ -223,7 +233,7 @@ class PlottingAxes:
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=self.parent.display_color['basic'],
color=sample_no_colors[0],
size=self.parent.font_size
)
else:
......@@ -233,30 +243,31 @@ class PlottingAxes:
# 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
# variable for it.
# bottom
ax.text(
1.005, 0.25,
1.005, sample_no_pos[0],
sample_no_list[0],
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=self.parent.display_color['basic'],
color=sample_no_colors[0],
size=self.parent.font_size
)
# top
ax.text(
1.005, 0.75,
1.005, sample_no_pos[1],
sample_no_list[1],
horizontalalignment='left',
verticalalignment='center',
rotation='horizontal',
transform=ax.transAxes,
color=self.parent.display_color['basic'],
color=sample_no_colors[1],
size=self.parent.font_size
)
if linked_ax is not None:
ax.set_yticks([])
return
if y_list is None:
# draw center line
ax.plot([self.parent.min_x, self.parent.max_x],
......