Skip to content
Snippets Groups Projects
Commit 42a1d2b3 authored by Kien Le's avatar Kien Le
Browse files

Add tests for readSOHTrace

Add additional test for readSOHTrace

Set up test directory

stuff
parent 6db5d972
No related branches found
No related tags found
1 merge request!27Draft: Add tests for functions in handling_data.py
from pathlib import Path
from math import isclose
from unittest import TestCase
from obspy.core import Stream, read as read_ms
import numpy as np
from sohstationviewer.model.handling_data import (
readSOHMSeed,
readSOHTrace
)
TEST_DATA_DIR = Path(__file__).parent.parent.joinpath('test_data')
class TestHandlingData(TestCase):
@classmethod
def setUpClass(cls) -> None:
q330_dir = TEST_DATA_DIR.joinpath('Q330-sample/day_vols_AX08')
# This file is chosen because it has time info.
cls.q330_file = q330_dir.joinpath('AX08.XA..VKI.2021.186')
cls.mseed_stream = read_ms(cls.q330_file)
cls.trace = cls.mseed_stream[0]
cls.processed_trace = {
'chanID': '',
'samplerate': '',
'startTmEpoch': '',
'endTmEpoch': '',
'times': '',
'data': '',
}
# @expectedFailure
# def test_read_sohmseed(self):
# self.fail()
def test_read_soh_trace_processed_trace_have_all_needed_info(self):
processed_trace = readSOHTrace(self.trace)
with self.subTest('test_processed_trace_have_all_needed_info'):
expected_key_list = [
'chanID',
'samplerate',
'startTmEpoch',
'endTmEpoch',
'times',
'data'
]
self.assertTrue(
all(key in processed_trace for key in expected_key_list)
)
def test_read_soh_trace_times_calculated_correctly(self):
processed_trace = readSOHTrace(self.trace)
if isclose(processed_trace['startTmEpoch'], 0, abs_tol=0.0001):
self.assertAlmostEqual(processed_trace['times'][0], 0)
else:
self.assertNotAlmostEqual(processed_trace['times'][0], 0)
# @skip
# def test_read_mptrace(self):
# self.fail()
#
# @skip
# def test_read_waveform_trace(self):
# self.fail()
#
# @skip
# def test_read_waveform_mseed(self):
# self.fail()
#
# @skip
# def test_read_waveform_reftek(self):
# self.fail()
#
# @skip
# def test_read_ascii(self):
# self.fail()
#
# @skip
# def test_read_text(self):
# self.fail()
#
# @skip
# def test_save_data2file(self):
# self.fail()
#
# @skip
# def test_check_chan(self):
# self.fail()
#
# @skip
# def test_check_sohchan(self):
# self.fail()
#
# @skip
# def test_check_wfchan(self):
# self.fail()
#
# @skip
# def test_sort_data(self):
# self.fail()
#
# @skip
# def test_squash_gaps(self):
# self.fail()
#
# @skip
# def test_downsample(self):
# self.fail()
#
# @skip
# def test_constant_rate(self):
# self.fail()
#
# @skip
# def test_chunk_minmax(self):
# self.fail()
#
# @skip
# def test_trim_downsample_sohchan(self):
# self.fail()
#
# @skip
# def test_trim_downsample_wfchan(self):
# self.fail()
#
# @skip
# def test_get_each_day5min_list(self):
# self.fail()
#
# @skip
# def test_get_trim_tpsdata(self):
# self.fail()
#
# @skip
# def test_find_tpstm(self):
# self.fail()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment