Skip to content
Snippets Groups Projects
Commit 6685fc32 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

bugfix in fix_rotor_position + test

parent 8c9f27f4
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -98,14 +98,16 @@ def find_fix_dt(rotor_position, sample_frq, rotor_speed, plt=None):
rpm_pos = differentiation(fix_rotor_position(rotor_position, sample_frq, rotor_speed, i))%180 / 360 * sample_frq * 60
return np.sum((rpm_pos - rotor_speed)**2)
best = 0
for r in [np.arange(7,46,12), np.arange(-6,7,3),np.arange(-2,3)]:
x_lst = r + best
best = 27
for step in [9,3,1]:
x_lst = np.arange(-2,3)*step + best
res = [err(x) for x in x_lst]
if plt is not None:
plt.plot(x_lst, res,'.-')
best = x_lst[np.argmin(res)]
if plt is not None:
plt.show()
return best
\ No newline at end of file
......@@ -27,7 +27,6 @@ class TestFix(unittest.TestCase):
err_sum = np.sum((rpm_pos - ds.Rot_cor)**2)
self.assertLess(err_sum,40)
self.assertLess(np.sqrt(np.mean((((ds.azi-rp_fit)+180)%360-180)**2)),2)
if 0:
import matplotlib.pyplot as plt
t = ds.Time-ds.Time[0]
......@@ -35,10 +34,15 @@ class TestFix(unittest.TestCase):
plt.plot(t, ds.Rot_cor)
plt.plot(t, differentiation(rp_fit)%180 / 360 * sample_frq * 60, label='fit')
plt.ylim(10,16)
plt.show()
def test_find_fix_dt(self):
ds = gtsdf.Dataset(tfp+'azi.hdf5')
sample_frq = 25
self.assertEqual(find_fix_dt(ds.azi, sample_frq, ds.Rot_cor), 4)
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testRotorPositionFix']
unittest.main()
\ No newline at end of file
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