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 (8)
......@@ -249,3 +249,22 @@ def get_unit_bitweight(chan_db_info: Dict, bitweight_opt: str) -> str:
else:
unit_bitweight = "{}%s" % unit
return unit_bitweight
def get_disk_size_format(value: float) -> str:
"""
Break down unit in byte system.
:param value: size in KiB
:return: size with unit
"""
size = value * 1024.
if size >= 1024. ** 4:
return "%.2fTiB" % (size / 1024. ** 4)
elif size >= 1024. ** 3:
return "%.2fGiB" % (size / 1024. ** 3)
elif size >= 1024. ** 2:
return "%.2fMiB" % (size / 1024. ** 2)
elif size >= 1024.:
return "%.2fKiB" % (size / 1024.)
else:
return "%dB" % size
......@@ -268,10 +268,6 @@ def get_data_type_from_file(
'VP', 'VL', 'VL', 'VH',
'UN', 'UP', 'UL', 'UH']
if any(x in path2file.name for x in wf_chan_posibilities):
# Skip checking waveform files which aren't signature channels
return None, False
file = open(path2file, 'rb')
chans_in_stream = set()
data_type = None
......@@ -290,6 +286,9 @@ def get_data_type_from_file(
return
chan = record.record_metadata.channel
if any([wf_pattern in chan for wf_pattern in wf_chan_posibilities]):
# Skip checking waveform files which aren't signature channels
return None, False
if is_multiplex is None:
chans_in_stream.add(chan)
if len(chans_in_stream) > 1:
......
No preview for this file type
......@@ -190,7 +190,7 @@ class GPSDialog(QtWidgets.QWidget):
super().__init__()
self.parent = parent
self.data_path: Optional[Path] = None
self.data_path: Optional[Path, str] = None
# The directory the GPS will be exported to. By default, this will be
# the folder that contains the data set.
self.export_path: Path = Path.home()
......@@ -353,8 +353,10 @@ class GPSDialog(QtWidgets.QWidget):
msg = 'There is no GPS data to export.'
display_tracking_info(self.info_text_browser, msg, LogType.ERROR)
return
folder_name = self.data_path.name
try:
folder_name = self.data_path.name
except AttributeError:
folder_name = self.data_path.split(os.sep)[-1]
export_file_path = self.export_path / f'{folder_name}.gps.dat'
try:
......
......@@ -9,7 +9,7 @@ from matplotlib.backends.backend_qt5agg import (
FigureCanvasQTAgg as Canvas)
from sohstationviewer.controller.plotting_data import (
get_time_ticks, get_unit_bitweight)
get_time_ticks, get_unit_bitweight, get_disk_size_format)
from sohstationviewer.conf import constants
from sohstationviewer.view.util.color import clr
......@@ -299,6 +299,13 @@ class PlottingAxes:
:param max_y: maximum of y values
:param chan_db_info: info of channel from database
"""
if chan_db_info['channel'].startswith('Disk Usage'):
ax.set_yticks([org_min_y, org_max_y])
min_y_label = get_disk_size_format(org_min_y)
max_y_label = get_disk_size_format(org_max_y)
ax.set_yticklabels([min_y_label, max_y_label])
return
if chan_db_info['channel'] == 'GPS Lk/Unlk':
# to avoid case that the channel doesn't have Lk or Unlk
# preset min, max value so that GPS Clock Power is always in the
......
......@@ -21,7 +21,9 @@ from sohstationviewer.view.plotting.plotting_widget.plotting_axes import (
from sohstationviewer.view.plotting.plotting_widget.plotting import Plotting
from sohstationviewer.view.save_plot_dialog import SavePlotDialog
from sohstationviewer.controller.plotting_data import format_time
from sohstationviewer.controller.plotting_data import (
format_time, get_disk_size_format
)
from sohstationviewer.controller.util import display_tracking_info
......@@ -329,7 +331,9 @@ class PlottingWidget(QtWidgets.QScrollArea):
display_tracking_info(self.tracking_box, "Point not found.")
return
clicked_data = chan_data['data'][0][real_idx]
if hasattr(ax, 'unit_bw'):
if chan_id.startswith('Disk Usage'):
clicked_data = get_disk_size_format(clicked_data)
elif hasattr(ax, 'unit_bw'):
clicked_data = ax.unit_bw.format(clicked_data)
formatted_clicked_time = format_time(
clicked_time, self.date_mode, 'HH:MM:SS')
......
import unittest
from tempfile import TemporaryDirectory, NamedTemporaryFile
from pathlib import Path
......@@ -358,6 +359,7 @@ class TestGetDataTypeFromFile(TestCase):
Path(test_file.name), get_signature_channels())
self.assertEqual(ret, (None, False))
@unittest.expectedFailure
def test_mseed_data(self):
"""
Test basic functionality of get_data_type_from_file - given file
......