forked from namalkanti/bloch-simulator-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradientAreaTest.py
40 lines (30 loc) · 850 Bytes
/
GradientAreaTest.py
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
import os.path
import unittest
import numpy as np
import scipy as sp
import scipy.io as sio
from bloch.min_time_gradient import minimum_time_gradient
from BlochTest import get_data_with_key
TEST_DIR = "test_data"
TEST_FILE = "gradient"
class GradientAreaTest(unittest.TestCase):
"""
Test class for the gradient time function.
"""
def test_waveforms(self):
"""
Tests waveforms against matlab code results.
"""
expected_gy = get_data_with_key(TEST_DIR, TEST_FILE, "gy")
Np = 32
fov = 7
smax = 15000
gmax = 4
gamma = 4257
dt = 4e-6
kmax = 1/(fov/Np)/2
area = kmax / gamma
gy = minimum_time_gradient(area, gmax, smax, dt)
self.assertTrue(np.allclose(expected_gy, gy))
if __name__ == "__main__":
unittest.main()