diff --git a/sohstationviewer/controller/plotting_data.py b/sohstationviewer/controller/plotting_data.py index 59b068f99e9625b09b8dbc114e6a0facfa45f40f..186ebe1d2a33c4ffb1e7968281c61b77085a4822 100755 --- a/sohstationviewer/controller/plotting_data.py +++ b/sohstationviewer/controller/plotting_data.py @@ -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 diff --git a/sohstationviewer/controller/processing.py b/sohstationviewer/controller/processing.py index c9b22797739dbb163b368178cc7c884c0b3ec55f..3c21322720572945854afb852b5f644701efd2f6 100644 --- a/sohstationviewer/controller/processing.py +++ b/sohstationviewer/controller/processing.py @@ -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: diff --git a/sohstationviewer/database/soh.db b/sohstationviewer/database/soh.db index d0219d170e3a12a64c06c25261d07c3deb57df3d..25e32e1e83fc6cbf61973e0680a30ee82a958fcf 100755 Binary files a/sohstationviewer/database/soh.db and b/sohstationviewer/database/soh.db differ diff --git a/sohstationviewer/view/plotting/gps_plot/gps_dialog.py b/sohstationviewer/view/plotting/gps_plot/gps_dialog.py index 006f426f19f1228470e08e8048f9b1487243d9c2..ed3acd86ff9395dcb4a26779a636f39e78e7b1f1 100644 --- a/sohstationviewer/view/plotting/gps_plot/gps_dialog.py +++ b/sohstationviewer/view/plotting/gps_plot/gps_dialog.py @@ -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: diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py index a5ced409fbc624585f4014e7a9c6fac4910270e2..7cc06ddde70d2b107b6d31d2795b557bffe6baa6 100644 --- a/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting_axes.py @@ -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 diff --git a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py index 509fb61877b287dffa265e1992cbf999d587610f..fc266795d2105547dba6f150a23242e4085b60f9 100755 --- a/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py +++ b/sohstationviewer/view/plotting/plotting_widget/plotting_widget.py @@ -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') diff --git a/tests/controller/test_processing.py b/tests/controller/test_processing.py index a607aab9e702df84d73c27df6273eba4dec6129f..f7de7141398081e01524fa8df138bfaba7f4fee1 100644 --- a/tests/controller/test_processing.py +++ b/tests/controller/test_processing.py @@ -1,3 +1,4 @@ +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