Skip to content
Snippets Groups Projects
Commit 7d0aac3f authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Fixed AV multiplication and added MDIS ISIS test (#280)

parent 8b38f395
Branches
Tags
No related merge requests found
...@@ -110,7 +110,7 @@ class ConstantRotation: ...@@ -110,7 +110,7 @@ class ConstantRotation:
new_rot = self._rot * other._rot new_rot = self._rot * other._rot
return ConstantRotation(new_rot.as_quat(), other.source, self.dest) return ConstantRotation(new_rot.as_quat(), other.source, self.dest)
elif isinstance(other, TimeDependentRotation): elif isinstance(other, TimeDependentRotation):
return TimeDependentRotation((self._rot * other._rots).as_quat(), other.times, other.source, self.dest, av=self._rot.apply(other.av)) return TimeDependentRotation((self._rot * other._rots).as_quat(), other.times, other.source, self.dest, av=other.av)
else: else:
raise TypeError("Rotations can only be composed with other rotations.") raise TypeError("Rotations can only be composed with other rotations.")
...@@ -325,13 +325,18 @@ class TimeDependentRotation: ...@@ -325,13 +325,18 @@ class TimeDependentRotation:
if self.source != other.dest: if self.source != other.dest:
raise ValueError("Destination frame of first rotation {} is not the same as source frame of second rotation {}.".format(other.dest, self.source)) raise ValueError("Destination frame of first rotation {} is not the same as source frame of second rotation {}.".format(other.dest, self.source))
if isinstance(other, ConstantRotation): if isinstance(other, ConstantRotation):
return TimeDependentRotation((self._rots * other._rot).as_quat(), self.times, other.source, self.dest, av=self.av) if self.av is not None:
other_inverse = other._rot.inv()
new_av = np.asarray([other_inverse.apply(av) for av in self.av])
else:
new_av = None
return TimeDependentRotation((self._rots * other._rot).as_quat(), self.times, other.source, self.dest, av=new_av)
elif isinstance(other, TimeDependentRotation): elif isinstance(other, TimeDependentRotation):
merged_times = np.union1d(np.asarray(self.times), np.asarray(other.times)) merged_times = np.union1d(np.asarray(self.times), np.asarray(other.times))
reinterp_self = self.reinterpolate(merged_times) reinterp_self = self.reinterpolate(merged_times)
reinterp_other = other.reinterpolate(merged_times) reinterp_other = other.reinterpolate(merged_times)
new_quats = (reinterp_self._rots * reinterp_other._rots).as_quat() new_quats = (reinterp_self._rots * reinterp_other._rots).as_quat()
new_av = reinterp_self.av + reinterp_self._rots.apply(reinterp_other.av) new_av = reinterp_other._rots.inv().apply(reinterp_self.av) + reinterp_other.av
return TimeDependentRotation(new_quats, merged_times, other.source, self.dest, av=new_av) return TimeDependentRotation(new_quats, merged_times, other.source, self.dest, av=new_av)
else: else:
raise TypeError("Rotations can only be composed with other rotations.") raise TypeError("Rotations can only be composed with other rotations.")
......
...@@ -20,9 +20,114 @@ def test_kernels(): ...@@ -20,9 +20,114 @@ def test_kernels():
for kern in binary_kernels: for kern in binary_kernels:
os.remove(kern) os.remove(kern)
@pytest.fixture() image_dict = {
def usgscsm_compare_dict(): # MDIS NAC
return { 'EN1072174528M': {
'isis': {
'CameraVersion': 2,
'NaifKeywords': {
'BODY_CODE' : 199,
'BODY199_RADII' : [2439.4, 2439.4, 2439.4],
'BODY_FRAME_CODE' : 10011,
'INS-236820_SWAP_OBSERVER_TARGET' : 'TRUE',
'INS-236820_LIGHTTIME_CORRECTION' : 'LT+S',
'INS-236820_LT_SURFACE_CORRECT' : 'FALSE',
'INS-236820_REFERENCE_FRAME' : 'MSGR_SPACECRAFT',
'INS-236820_FRAME' : 'MSGR_MDIS_NAC',
'INS-236820_FOCAL_LENGTH' : 549.11781953727,
'INS-236820_PIXEL_PITCH' : 0.014,
'INS-236820_TRANSX' : [0.0, 0.014, 0.0],
'INS-236820_TRANSY' : [0.0, 0.0, 0.014],
'INS-236820_ITRANSS' : [0.0, 71.42857143, 0.0],
'INS-236820_ITRANSL' : [0.0, 0.0, 71.42857143],
'INS-236820_BORESIGHT_SAMPLE' : 512.5,
'INS-236820_BORESIGHT_LINE' : 512.5,
'INS-236820_OD_T_X' : [0.0, 1.0018542696238, 0.0, 0.0, -5.09444047494111e-04, 0.0, 1.00401047146886e-05, 0.0, 1.00401047146886e-05, 0.0],
'INS-236820_OD_T_Y' : [0.0, 0.0, 1.0, 9.06001059499675e-04, 0.0, 3.57484262662076e-04, 0.0, 1.00401047146886e-05, 0.0, 1.00401047146886e-05],
'INS-236820_FPUBIN_START_SAMPLE': 9.0,
'INS-236820_CK_TIME_TOLERANCE': 1.0,
'INS-236820_CK_REFERENCE_ID': 1.0,
'INS-236820_FOV_CLASS_SPEC': 'ANGLES',
'INS-236820_FOV_REF_VECTOR': [1.0,0.0,0.0],
'INS-236820_CK_FRAME_ID': -236000.0,
'INS-236820_FOV_SHAPE': 'RECTANGLE',
'INS-236820_FOV_ANGLE_UNITS': 'DEGREES',
'FRAME_-236820_CLASS': 4.0,
'INS-236820_BORESIGHT_LINE': 512.5,
'INS-236820_SWAP_OBSERVER_TARGET': 'TRUE',
'INS-236820_LIGHTTIME_CORRECTION': 'LT+S',
'INS-236820_FOV_FRAME': 'MSGR_MDIS_NAC',
'INS-236820_PIXEL_SAMPLES': 1024.0,
'INS-236820_REFERENCE_FRAME': 'MSGR_SPACECRAFT',
'INS-236820_FL_UNCERTAINTY': 0.5,
'INS-236820_ITRANSL': [0.0,0.0,71.42857143],
'INS-236820_ITRANSS': [0.0,71.42857143,0.0],
'INS-236820_FOV_CROSS_ANGLE': 0.7465,
'TKFRAME_-236820_SPEC': 'MATRIX',
'INS-236820_BORESIGHT_SAMPLE': 512.5,
'INS-236820_PIXEL_LINES': 1024.0,
'INS-236820_F/NUMBER': 22.0,
'INS-236820_IFOV': 25.44,
'INS-236820_SPK_TIME_BIAS': 0.0,
'INS-236820_CCD_CENTER': [512.5,512.5],
'FRAME_-236820_NAME': 'MSGR_MDIS_NAC',
'INS-236820_FRAME': 'MSGR_MDIS_NAC',
'INS-236820_PLATFORM_ID': -236000.0,
'INS-236820_LT_SURFACE_CORRECT': 'FALSE',
'INS-236820_TRANSX': [0.0,0.014,0.0],
'INS-236820_TRANSY': [0.0,0.0,0.014],
'INS-236820_FL_TEMP_COEFFS': [549.5120497341695,0.01018564339123439,0.0,0.0,0.0,0.0],
'FRAME_-236820_CENTER': -236.0,
'TKFRAME_-236820_RELATIVE': 'MSGR_MDIS_WAC',
'INS-236820_WAVELENGTH_RANGE': [700.0,800.0],
'INS-236820_CK_TIME_BIAS': 0.0,
'INS-236820_FOV_REF_ANGLE': 0.7465,
'TKFRAME_-236820_MATRIX': [-0.9998215487408793,-0.018816063038872958,0.001681203469647119,0.01881610195359367,-0.9998229614554359,7.33168257224375e-06,0.0016807678784302768,3.8964070113872887e-05,0.9999985867495713],
'INS-236820_FPUBIN_START_LINE': 1.0,
'FRAME_-236820_CLASS_ID': -236820.0,
'INS-236820_PIXEL_PITCH': 0.014,
'INS-236820_BORESIGHT': [0.0,0.0,1.0],
'BODY199_PM': [329.5988,6.1385108,0.0],
'BODY199_POLE_RA': [281.0103,-0.0328,0.0],
'BODY199_NUT_PREC_PM': [0.01067257,-0.00112309,-0.0001104,-2.539e-05,-5.71e-06],
'BODY199_LONG_AXIS': 0.0,
'BODY199_POLE_DEC': [61.4155,-0.0049,0.0],
'BODY199_NUT_PREC_RA': [0.0,0.0,0.0,0.0,0.0],
'BODY199_NUT_PREC_DEC': [0.0,0.0,0.0,0.0,0.0]
},
'InstrumentPointing': {
'TimeDependentFrames': [-236890, -236892, -236880, -236000, 1],
'ConstantFrames': [-236820, -236800, -236890],
'ConstantRotation': (0.001686595916635, 0.99996109494739, 0.0086581745086423, 6.3008625209968e-04, -0.0086592477671008, 0.99996230949942, 0.99999837919145, -0.0016810769512645, -6.44666390486019e-04),
'CkTableStartTime': 483122606.85252,
'CkTableEndTime': 483122606.85252,
'CkTableOriginalSize': 1,
'EphemerisTimes': [483122606.85252],
'Quaternions': [[-0.38021468196247,-0.021997068513824,0.88129521110671,0.27977075522175]],
'AngularVelocity' : [[3.70128511234226e-04,-0.0012069098299837,-6.64295531160265e-04]]},
'BodyRotation': {
'TimeDependentFrames': [10011, 1],
'CkTableStartTime': 483122606.85252,
'CkTableEndTime': 483122606.85252,
'CkTableOriginalSize': 1,
'EphemerisTimes': [483122606.85252],
'Quaternions': [[-0.58791736752687,0.18448696708541,-0.16404715837556,0.77032866866346]],
'AngularVelocity' : [[1.13272180361114e-07,-5.82448215686951e-07,1.08896661936564e-06]]},
'InstrumentPosition': {
'SpkTableStartTime': 483122606.85252,
'SpkTableEndTime': 483122606.85252,
'SpkTableOriginalSize': 1,
'EphemerisTimes': [483122606.85252],
'Positions': [[1844.0372753409,-966.47836059939,1322.8442926008]],
'Velocities': [[-2.6146204621248,-0.30506719264668,2.8563617189104]]},
'SunPosition': {
'SpkTableStartTime': 483122606.85252,
'SpkTableEndTime': 483122606.85252,
'SpkTableOriginalSize': 1,
'EphemerisTimes': [483122606.85252],
'Positions': [[11805115.780304,-39513889.220831,-22331586.824705]],
'Velocities': [[56.903276907758496, 11.401211521119633, 0.19123815749182813]]}},
'usgscsm': {
'radii': { 'radii': {
'semimajor': 2439.4, 'semimajor': 2439.4,
'semiminor': 2439.4, 'semiminor': 2439.4,
...@@ -61,16 +166,19 @@ def usgscsm_compare_dict(): ...@@ -61,16 +166,19 @@ def usgscsm_compare_dict():
'minheight': -1000, 'minheight': -1000,
'unit': 'm'}, 'unit': 'm'},
'name_model': 'USGS_ASTRO_FRAME_SENSOR_MODEL', 'name_model': 'USGS_ASTRO_FRAME_SENSOR_MODEL',
'center_ephemeris_time': 483122606.85252464} 'center_ephemeris_time': 483122606.85252464}}}
@pytest.mark.parametrize("label_type", ["pds3", "isis3"]) @pytest.mark.parametrize("label_type", ["pds3", "isis3"])
def test_load(test_kernels, usgscsm_compare_dict, label_type): @pytest.mark.parametrize("formatter", ['usgscsm', 'isis'])
label_file = get_image_label('EN1072174528M', label_type) @pytest.mark.parametrize("image", image_dict.keys())
def test_load(test_kernels, label_type, formatter, image):
label_file = get_image_label(image, label_type)
usgscsm_isd_str = ale.loads(label_file, props={'kernels': test_kernels}, formatter='usgscsm') usgscsm_isd_str = ale.loads(label_file, props={'kernels': test_kernels}, formatter=formatter)
usgscsm_isd_obj = json.loads(usgscsm_isd_str) usgscsm_isd_obj = json.loads(usgscsm_isd_str)
print(json.dumps(usgscsm_isd_obj, indent=2))
assert compare_dicts(usgscsm_isd_obj, usgscsm_compare_dict) == [] assert compare_dicts(usgscsm_isd_obj, image_dict[image][formatter]) == []
# ========= Test Pds3 Label and NAIF Spice driver ========= # ========= Test Pds3 Label and NAIF Spice driver =========
class test_pds3_naif(unittest.TestCase): class test_pds3_naif(unittest.TestCase):
......
...@@ -235,12 +235,12 @@ def isis_compare_dict(): ...@@ -235,12 +235,12 @@ def isis_compare_dict():
[0.42064763, 0.18624551, -0.2397057 , 0.85493237], [0.42064763, 0.18624551, -0.2397057 , 0.85493237],
[0.42065923, 0.18630667, -0.23967382, 0.85492228], [0.42065923, 0.18630667, -0.23967382, 0.85492228],
[0.42067144, 0.18636687, -0.23964185, 0.85491211]], [0.42067144, 0.18636687, -0.23964185, 0.85491211]],
'AngularVelocity': [[-5.797334508173795e-05, 0.0009339642673794059, -0.00011512424986625757], 'AngularVelocity': [[-0.0006409728984903079, 0.0005054077299115119, 0.0004718267948468069],
[-5.872001786769966e-05, 0.0009343455952639878, -0.00011371124132355403], [-0.0006410700774431097, 0.0005044862657976017, 0.0004731836236807216],
[-6.244619825703372e-05, 0.000935616649435616, -0.00010584418382022431], [-0.0006408186407087456, 0.0004992170698116158, 0.0004802237192760833],
[-5.965469273385757e-05, 0.0009306551165985512, -0.00010670063014175982], [-0.0006363961683672021, 0.0004989647975959612, 0.00047654664046286975],
[-6.001692495046523e-05, 0.0009318842753552843, -0.00010732755544866732], [-0.0006376443791903504, 0.0004996117504290811, 0.00047678850931380653],
[-5.9466333983691536e-05, 0.0009375199811173681, -0.00010690951512741344]]}, [-0.0006404093657132724, 0.0005028749658176146, 0.0004805228583087444]]},
'BodyRotation': {'TimeDependentFrames': [10014, 1], 'BodyRotation': {'TimeDependentFrames': [10014, 1],
'CkTableStartTime': 297088762.24158406, 'CkTableStartTime': 297088762.24158406,
'CkTableEndTime': 297088762.9923841, 'CkTableEndTime': 297088762.9923841,
......
...@@ -24,10 +24,9 @@ def test_constant_time_dependent_composition(): ...@@ -24,10 +24,9 @@ def test_constant_time_dependent_composition():
assert rot1_3.source == 1 assert rot1_3.source == 1
assert rot1_3.dest == 3 assert rot1_3.dest == 3
expected_quats = [[0.5, 0.5, -0.5, 0.5],[1.0/np.sqrt(2), 0, -1.0/np.sqrt(2), 0]] expected_quats = [[0.5, 0.5, -0.5, 0.5],[1.0/np.sqrt(2), 0, -1.0/np.sqrt(2), 0]]
expected_av = [[0, 0, -np.pi/2], [0, 0, -np.pi/2]]
np.testing.assert_equal(rot1_3.times, times) np.testing.assert_equal(rot1_3.times, times)
np.testing.assert_almost_equal(rot1_3.quats, expected_quats) np.testing.assert_almost_equal(rot1_3.quats, expected_quats)
np.testing.assert_almost_equal(rot1_3.av, expected_av) np.testing.assert_almost_equal(rot1_3.av, av)
def test_time_dependent_constant_composition(): def test_time_dependent_constant_composition():
rot1_2 = ConstantRotation([1.0/np.sqrt(2), 0, 0, 1.0/np.sqrt(2)], 1, 2) rot1_2 = ConstantRotation([1.0/np.sqrt(2), 0, 0, 1.0/np.sqrt(2)], 1, 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment