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

fixed test

parent b233dd6d
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -19,18 +19,18 @@ class TestConstraintFile(unittest.TestCase):
tu = np.array([time, u]).T
tuvw = np.array([time, u, v, w]).T
glpos = (0, 0, -85)
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints(glpos, tu)
np.testing.assert_array_equal(constraint_file.constraints['u'][1], (6, 4, 4, 0))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=5, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=5, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints(glpos, tuvw)
np.testing.assert_array_equal(constraint_file.constraints['u'][2], (6, 4, 4, 2))
np.testing.assert_array_equal(constraint_file.constraints['v'][2], (6, 4, 4, -.5))
np.testing.assert_array_equal(constraint_file.constraints['w'][2], (6, 4, 4, 2))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints((-10, -4, -95), tu)
np.testing.assert_array_equal(constraint_file.constraints['u'][1], (8, 5, 5, 0))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints((-10, 0, -95), tu)
np.testing.assert_array_equal(constraint_file.constraints['u'][1], (8, 5, 5, 0))
#constraint_file.save("./test_files", "constraints_test",'')
......@@ -41,7 +41,7 @@ class TestConstraintFile(unittest.TestCase):
tu = np.array([time, u]).T
glpos = (0, 0, -85)
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints([0,0,0], tu, subtract_mean=False)
np.testing.assert_array_equal(constraint_file.constraints['u'][-1], (1, 5, 5, 5))
constraint_file.add_constraints([5,0,0], tu, subtract_mean=False)
......@@ -56,19 +56,19 @@ class TestConstraintFile(unittest.TestCase):
u = [5]
tu = np.array([time, u]).T
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints([0,0,0], tu, subtract_mean=False)
np.testing.assert_array_equal(constraint_file.constraints['u'][-1], (1, 5, 5, 5))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -5), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -5), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints([0,0,0], tu, subtract_mean=False)
np.testing.assert_array_equal(constraint_file.constraints['u'][-1], (1, 5, 4, 5))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 0, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints([0,0,0], tu, subtract_mean=False)
np.testing.assert_array_equal(constraint_file.constraints['u'][-1], (1, 4, 5, 5))
constraint_file = ConstraintFile(center_gl_xyz=(0, 10, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 10, 0), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.add_constraints([0,0,0], tu, subtract_mean=False)
np.testing.assert_array_equal(constraint_file.constraints['u'][-1], (6, 5, 5, 5))
......@@ -81,7 +81,7 @@ class TestConstraintFile(unittest.TestCase):
tu = np.array([time, u]).T
tuvw = np.array([time, u, v, w]).T
glpos = (0, 0, -85)
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -85), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -85), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
self.assertRaisesRegex(ValueError, "At time, t=0, global position \(0,0,-44\)", constraint_file.add_constraints, (0, 0, -85 + 35 + 6), tu)
self.assertRaisesRegex(ValueError, "At time, t=0, global position \(0,0,-126\)", constraint_file.add_constraints, (0, 0, -85 - 35 - 6), tu)
self.assertRaisesRegex(ValueError, "At time, t=0, global position \(-41,0,-85\)", constraint_file.add_constraints, (-35 - 6, 0, -85), tu)
......@@ -90,18 +90,18 @@ class TestConstraintFile(unittest.TestCase):
self.assertRaisesRegex(ValueError, "At time, t=2, global position \(0,-13,-85\)", constraint_file.add_constraints, (0, -13, -85), tu)
def test_hawc2_cmd(self):
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -85), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(0, 0, -85), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
mann = constraint_file.hawc2_mann_section("test",1)
self.assertEqual(mann.box_dim_u.values, [16,1.875])
def test_load(self):
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.load(get_test_file('constraints_test.con'))
with open(get_test_file('constraints_test.con')) as fid:
self.assertEqual(str(constraint_file), fid.read())
def test_time_series(self):
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_dimension=(30, 70, 70))
constraint_file = ConstraintFile(center_gl_xyz=(-5, 4, -90), box_transport_speed=10, no_grid_points=(16, 8, 8), box_size=(30, 70, 70))
constraint_file.load(get_test_file('constraints_test.con'))
time,uvw = constraint_file.time_series(-4)
u,v,w = uvw.T
......
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