preprocess_test.py 1.16 KB
Newer Older
Lukas Eller's avatar
Lukas Eller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
import unittest
from context import measprocess as mpc

import os
import pickle

def extract_scan(path):
    filepath = os.path.join(path, 'ofdmscan.p0')
    with open(filepath, "rb") as fh:
        data = pickle.load(fh)
        return data[0][7][1]['rec'][0], data[0][7][1]['ot']['Band'], data[0][7]['ot']['Ch']

def extract_gps(path):
    filepath = os.path.join(path, 'gps.p0')
    with open(filepath, "rb") as fh:
        data = pickle.load(fh)
        return data[0]['ot']

class TestSum(unittest.TestCase):
    def test_synchronize(self):
        path = [
            f"tests/example_files/",
            'scanner'
        ]

        meas, band, channel  = extract_scan(
            os.path.join(*path)
        )

        meas['band'] = band
        meas['channel'] = channel

        gps = extract_gps(
            os.path.join(*path)
        )

        merged = mpc.preprocess.synchronize_df(meas, gps, 'Datetime', 'fk_gps', ['Lon.', 'Lat.', 'Quality'])

        print(merged)

        #self.assertEqual(sum([1, 2, 3]), 6, "Should be 6")

    #def test_sum_tuple(self):
    #    self.assertEqual(sum((1, 2, 2)), 6, "Should be 6")

if __name__ == '__main__':
    unittest.main()