mirror of
https://github.com/JHUAPL/kaipy.git
synced 2026-01-08 22:07:57 -05:00
Tests for transform along with fixes to allow arrays
This commit is contained in:
@@ -52,7 +52,7 @@ def SMtoGSM(x, y, z, ut):
|
||||
invec.ticks = Ticktock(ut)
|
||||
outvec = invec.convert(toSys, toType)
|
||||
|
||||
return outvec.x[0], outvec.y[0], outvec.z[0]
|
||||
return outvec.x, outvec.y, outvec.z
|
||||
|
||||
|
||||
def GSMtoSM(x, y, z, ut):
|
||||
@@ -82,7 +82,7 @@ def GSMtoSM(x, y, z, ut):
|
||||
invec.ticks = Ticktock(ut)
|
||||
outvec = invec.convert(toSys, toType)
|
||||
|
||||
return outvec.x[0], outvec.y[0], outvec.z[0]
|
||||
return outvec.x, outvec.y, outvec.z
|
||||
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ def GSEtoGSM(x, y, z, ut):
|
||||
invec.ticks = Ticktock(ut)
|
||||
outvec = invec.convert(toSys, toType)
|
||||
|
||||
return outvec.x[0], outvec.y[0], outvec.z[0]
|
||||
return outvec.x, outvec.y, outvec.z
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,3 +26,47 @@ def test_GSEtoGSM():
|
||||
assert np.isclose(x_gsm, 1.0, atol=1e-3)
|
||||
assert np.isclose(y_gsm, 0.540, atol=1e-3)
|
||||
assert np.isclose(z_gsm, 3.565, atol=1e-3)
|
||||
|
||||
def test_GSEtoGSM():
|
||||
x, y, z = 1, 2, 3
|
||||
ut = datetime.datetime(2009, 1, 27, 0, 0, 0)
|
||||
x_gsm, y_gsm, z_gsm = GSEtoGSM(x, y, z, ut)
|
||||
assert np.isclose(x_gsm, 1.0, atol=1e-3)
|
||||
assert np.isclose(y_gsm, 0.540, atol=1e-3)
|
||||
assert np.isclose(z_gsm, 3.565, atol=1e-3)
|
||||
|
||||
def test_GSEtoGSM_zero():
|
||||
x, y, z = 0, 0, 0
|
||||
ut = datetime.datetime(2009, 1, 27, 0, 0, 0)
|
||||
x_gsm, y_gsm, z_gsm = GSEtoGSM(x, y, z, ut)
|
||||
assert np.isclose(x_gsm, 0.0, atol=1e-3)
|
||||
assert np.isclose(y_gsm, 0.0, atol=1e-3)
|
||||
assert np.isclose(z_gsm, 0.0, atol=1e-3)
|
||||
|
||||
def test_GSEtoGSM_negative():
|
||||
x, y, z = -1, -2, -3
|
||||
ut = datetime.datetime(2009, 1, 27, 0, 0, 0)
|
||||
x_gsm, y_gsm, z_gsm = GSEtoGSM(x, y, z, ut)
|
||||
assert np.isclose(x_gsm, -1.0, atol=1e-3)
|
||||
assert np.isclose(y_gsm, -0.540, atol=1e-3)
|
||||
assert np.isclose(z_gsm, -3.565, atol=1e-3)
|
||||
|
||||
def test_GSEtoGSM_large():
|
||||
x, y, z = 1e6, 2e6, 3e6
|
||||
ut = datetime.datetime(2009, 1, 27, 0, 0, 0)
|
||||
x_gsm, y_gsm, z_gsm = GSEtoGSM(x, y, z, ut)
|
||||
assert np.isclose(x_gsm, 1e6, atol=1e-3)
|
||||
assert np.isclose(y_gsm, 540626.9291896636, atol=1e-3)
|
||||
assert np.isclose(z_gsm, 3564789.2677457044, atol=1e-3)
|
||||
|
||||
def test_GSEtoGSM_array():
|
||||
x = np.array([1, 2, 3])
|
||||
y = np.array([4, 5, 6])
|
||||
z = np.array([7, 8, 9])
|
||||
ut = np.array([datetime.datetime(2009, 1, 27, 0, 0, 0),
|
||||
datetime.datetime(2009, 1, 27, 1, 0, 0),
|
||||
datetime.datetime(2009, 1, 27, 2, 0, 0)])
|
||||
x_gsm, y_gsm, z_gsm = GSEtoGSM(x, y, z, ut)
|
||||
assert np.allclose(x_gsm, [1, 2, 3], atol=1e-3)
|
||||
assert np.allclose(y_gsm, [0.657, 1.285, 2.0822], atol=1e-3)
|
||||
assert np.allclose(z_gsm, [8.035, 9.3461, 10.614], atol=1e-3)
|
||||
Reference in New Issue
Block a user