Example #1
0
    def test_export_reload_ascii(self):
        self.db.load(os.path.join(self.data_directory, 'model_test_data.dat'))
        name = "Wave-S[m]"
        fnout = os.path.join(self.data_directory, '_test_export.dat')
        try:
            # route screen dump from export to null
            was_stdout = sys.stdout
            f = open(os.devnull, 'w')
            sys.stdout = f
            # export, should not raise errors
            self.db.export(fnout, names=name)
        finally:
            sys.stdout = was_stdout
            f.close()
        # reload
        db2 = TsDB()
        db2.load(fnout)
        # compare ts
        ts1 = self.db.get(name=name)
        ts2 = db2.get(name=name)

        # clean exported files
        os.remove(fnout)

        # check arrays
        np.testing.assert_array_almost_equal(ts1.x, ts2.x, 6, "Export/reload did not yield same arrays")
Example #2
0
    def test_export_reload(self):
        self.db.load(os.path.join(self.data_directory, 'mooring.ts'))
        name = "Sway"
        fnout = os.path.join(self.data_directory, '_test_export.ts')
        try:
            # route screen dump from export to null
            was_stdout = sys.stdout
            f = open(os.devnull, 'w')
            sys.stdout = f
            # export, should not raise errors
            self.db.export(fnout, names=name)
        finally:
            # reset sys.stdout
            sys.stdout = was_stdout
            f.close()
        # reload
        db2 = TsDB()
        db2.load(fnout)
        # compare ts
        ts1 = self.db.get(name=name)
        ts2 = db2.get(name=name)
        # clean exported files
        try:
            os.remove(fnout)
            os.remove(os.path.splitext(fnout)[0] + ".key")
        except FileNotFoundError:
            pass

        # check arrays
        self.assertTrue(np.array_equal(ts1.x, ts2.x), "Export/reload did not yield same arrays")
Example #3
0
 def setUp(self):
     """
     Common setup for all tests
     """
     self.db = TsDB()
     # the data directory used in the test relative to this module
     # necessary to do it like this for the tests to work both locally and in virtual env for conda build
     self.tsfile = os.path.join(os.path.dirname(__file__), '..', 'data',
                                'mooring.ts')
     self.db.load(self.tsfile)
     self.ts = self.db.get(name="Mooring line 4")
     # add datetime reference to ts for later testing
     self.ts._dtg_ref = datetime.now()
Example #4
0
    def test_geta(self):
        tsfile = os.path.join(self.data_directory, 'simo_p.ts')
        self.db.load(tsfile)
        tsname = "Tension_2_qs"
        keys = self.db.list(names=tsname, display=False)
        _, data1 = self.db.geta(name=keys[0])

        # test 1: geta() when ts is already loaded
        _, data2 = self.db.geta(name=tsname)
        self.assertTrue(np.array_equal(data1, data2), "Did not get correct data time series using get() "
                                                      "(ts pre-loaded)")
        # test 2: geta() when ts is not already loaded
        db2 = TsDB()
        db2.load(tsfile)
        _, data3 = db2.geta(name=tsname)
        self.assertTrue(np.array_equal(data1, data3), "Did not get correct data time series using get() "
                                                      "(ts not pre-loaded)")
Example #5
0
 def setUp(self):
     self.db = TsDB()
     # the data directory used in the test relative to this module
     # necessary to do it like this for the tests to work both locally and in virtual env for conda build
     self.data_directory = os.path.join(os.path.dirname(__file__), '..', 'data')
Example #6
0
from qats.ts import TimeSeries, average_frequency
from qats.signal import find_maxima, smooth
from qats import TsDB
from scipy.optimize import curve_fit
from scipy.integrate import odeint
import time
# Input field: Write the names for the test to be tested.

start = time.perf_counter()

name = "test"  #"surge", "hsseave", "moored_heave", "pitch" or "moored_pitch"
sf = 75
#dt = 0.01
n_tests = 3  # Number of decay tests in model test base file. If more than 1, the script will produce plots for all
# individual tests but also print out a txt. file with averaged natural periods and coefficients.
db = TsDB()

if name == "surge":
    n_name = "*M207_COF X"
    f = ['Recorded Data_Y200.tdms']
    t_dur = 35  # Time-interval for each test in the decay-test.
elif name == "heave":
    n_name = "*M207_COF Z"
    f = ['Recorded Data_Y300.tdms']
    t_dur = 12  # Time-interval for each test in the decay-test.
elif name == "pitch":
    n_name = "*M207_COF Pitch"
    f = ['Recorded Data_Y301.tdms']
    t_dur = 25  # Time-interval for each test in the decay-test.
elif name == "moored_heave":
    n_name = "*M207_COF Z"