From b6ca7ab9d46c1b9650fcc3f1e0400c24415d4a0e Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Fri, 18 Oct 2019 10:30:29 -0700 Subject: [PATCH] Lro updates (#302) * Updated LRO sensor model * Updated LRO test data * Moved new target frame logic into data naif * Revert debug print --- ale/base/data_naif.py | 5 +- ale/drivers/lro_drivers.py | 18 +----- tests/pytests/test_data_naif.py | 2 +- tests/pytests/test_lro_drivers.py | 101 +++++------------------------- 4 files changed, 20 insertions(+), 106 deletions(-) diff --git a/ale/base/data_naif.py b/ale/base/data_naif.py index 549ff7e01..0243be510 100644 --- a/ale/base/data_naif.py +++ b/ale/base/data_naif.py @@ -278,7 +278,10 @@ def reference_frame(self): : str String name of the target reference frame """ - return 'IAU_{}'.format(self.target_name) + try: + return spice.cidfrm(spice.bodn2c(self.target_name))[1] + except: + return 'IAU_{}'.format(self.target_name) @property def sun_position(self): diff --git a/ale/drivers/lro_drivers.py b/ale/drivers/lro_drivers.py index 87abc4fff..635ac5325 100644 --- a/ale/drivers/lro_drivers.py +++ b/ale/drivers/lro_drivers.py @@ -222,6 +222,7 @@ def sampling_factor(self): """ return self.crosstrack_summing + class LroLrocIsisLabelNaifSpiceDriver(LineScanner, NaifSpice, IsisLabel, Driver): @property def instrument_id(self): @@ -403,20 +404,3 @@ def sampling_factor(self): Number of samples and lines combined from the original data to produce a single pixel in this image """ return self.label['IsisCube']['Instrument']['SpatialSumming'] - - @property - def target_frame_id(self): - """ - Returns the Naif ID code for the target body - Expects target_name to be defined. This must be a string containig the name - of the target body. - - Returns - ------- - : int - Naif ID code for the target body - """ - name_lookup = { - "MOON": "MOON_ME" - } - return int(spice.gdpool('FRAME_{}'.format(name_lookup[self.target_name]),0,1)) diff --git a/tests/pytests/test_data_naif.py b/tests/pytests/test_data_naif.py index 5bf7fab18..7b63804fd 100644 --- a/tests/pytests/test_data_naif.py +++ b/tests/pytests/test_data_naif.py @@ -69,7 +69,7 @@ def test_target_body_radii(self): np.testing.assert_array_equal(self.driver.target_body_radii, [3396.19, 3396.19, 3376.2 ]) def test_reference_frame(self): - assert self.driver.reference_frame == 'IAU_Mars' + assert self.driver.reference_frame.upper() == 'IAU_MARS' def test_ephemeris_start_time(self): assert self.driver.ephemeris_start_time == -631195148.8160816 diff --git a/tests/pytests/test_lro_drivers.py b/tests/pytests/test_lro_drivers.py index a88de3942..6f967dea1 100644 --- a/tests/pytests/test_lro_drivers.py +++ b/tests/pytests/test_lro_drivers.py @@ -163,30 +163,26 @@ 302228504.6989461, 302228504.7816205 ], - "Positions": [ - [ -1516.151401156933, -668.6288568627692, 902.0947198613901 ], - [ -1516.223409461061, -668.5964957526799, 901.9888699314455 ], - [ -1516.2954102001283, -668.5641313047068, 901.8830154985509 ], - [ -1516.3674033217933, -668.5317635424859, 901.7771566394573 ], - [ -1516.4393889295134, -668.4993924191643, 901.6712932021625 ], - [ -1516.511366970942, -668.4670179583775, 901.5654252634131 ] - ], - "Velocities": [ - [ -0.8710326332082557, 0.39140831001748183, -1.2802959403961716 ], - [ -0.870941131400504, 0.3914486847034966, -1.280350409495549 ], - [ -0.870849624629936, 0.39148905771548614, -1.280404872563503 ], - [ -0.8707581129628269, 0.3915294290241222, -1.2804593295603206 ], - [ -0.8706665962676469, 0.39156979868758957, -1.2805137805641233 ], - [ -0.8705750746107267, 0.3916101666764657, -1.2805682255353403 ] - ] + "Positions": [[-1516.1039882048947, -668.6745734893002, 902.1405183116759 ], + [ -1516.176000573894, -668.6422150991707, 902.0346703324196 ], + [ -1516.2480053780712, -668.6098533709328, 901.9288178499854 ], + [ -1516.320002565111, -668.5774883280569, 901.8229609411912 ], + [ -1516.3919922384162, -668.5451199240163, 901.7170994539005 ], + [ -1516.4639743456696, -668.5127481822817, 901.6112334649276 ]], + "Velocities": [[-0.8710817993164441, 0.3913754105818205, -1.2802723434988814 ], + [ -0.8709903003882029, 0.39141578800691706, -1.2803268153571778 ], + [ -0.8708987964969201, 0.3914561637581709, -1.2803812811841886 ], + [ -0.8708072877088842, 0.391496537806338, -1.2804357409401614 ], + [ -0.8707157738925385, 0.3915369102094339, -1.2804901947032974 ], + [ -0.8706242551142269, 0.39157728093812155, -1.2805446424339852 ]] }, "SunPosition": { "SpkTableStartTime": 302228504.5749346, "SpkTableEndTime": 302228504.5749346, "SpkTableOriginalSize": 1, "EphemerisTimes": [ 302228504.5749346 ], - "Positions": [ [ -91883378.263122, 111069433.8370443, 48184018.936351 ] ], - "Velocities": [ [ -23.97818344566901, -15.922784266924515, -6.938247041660347 ] ] + "Positions": [ [ -91885596.62561405, 111066639.06681778, 48186230.75049895 ] ], + "Velocities": [ [ -23.97582426247181, -15.920790540011309, -6.940052709040858 ] ] } } } @@ -210,70 +206,6 @@ def driver(request): label = get_image_label("M103595705LE", "pds3") return LroLrocPds3LabelNaifSpiceDriver(label) -@pytest.fixture() -def usgscsm_comparison_isd(): - return { - 'radii': { - 'semimajor': 1737.4, - 'semiminor': 1737.4, - 'unit': 'km'}, - 'sensor_position': { - 'positions': np.array([[-1207231.46307793, 995625.53174743, 1053981.26081487], - [-1207284.70256369, 995671.36239502, 1053869.44545937], - [-1207337.93600499, 995717.18809878, 1053757.62484255], - [-1207391.16336313, 995763.00882545, 1053645.79904556], - [-1207444.38471462, 995808.82464074, 1053533.96790769], - [-1207497.60002076, 995854.63551139, 1053422.13151007]]), - 'velocities': np.array([[ -644.00247387, 554.38114107, -1352.44702294], - [ -643.92936421, 554.32134372, -1352.51066509], - [ -643.85625085, 554.26154319, -1352.57430092], - [ -643.78313387, 554.20173949, -1352.63793037], - [ -643.71001314, 554.14193256, -1352.70155355], - [ -643.63688874, 554.08212243, -1352.76517038]]), - 'unit': 'm'}, - 'sun_position': { - 'positions': np.array([[3.21525248e+10, 1.48548292e+11, -5.42339533e+08]]), - 'velocities': np.array([[366615.76978428, -78679.46821947, -787.76505647]]), - 'unit': 'm'}, - 'sensor_orientation': { - 'quaternions': np.array([[ 0.83106252, -0.29729751, 0.44741172, 0.14412506], - [ 0.83104727, -0.29729165, 0.44744078, 0.14413484], - [ 0.83103181, -0.29728538, 0.44747013, 0.14414582], - [ 0.83101642, -0.29727968, 0.44749888, 0.14415708], - [ 0.83100113, -0.29727394, 0.44752759, 0.1441679 ], - [ 0.8309859 , -0.29726798, 0.44755647, 0.14417831]])}, - 'detector_sample_summing': 1, - 'detector_line_summing': 1, - 'focal_length_model': { - 'focal_length': 699.62}, - 'detector_center': { - 'line': 0.0, - 'sample': 2547.5}, - 'starting_detector_line': 0, - 'starting_detector_sample': 0, - 'focal2pixel_lines': [0.0, 142.857, 0.0], - 'focal2pixel_samples': [0.0, 0.0, 142.857], - 'optical_distortion': { - 'lrolrocnac': { - 'coefficients': [1.81e-05]}}, - 'image_lines': 400, - 'image_samples': 5064, - 'name_platform': 'LUNAR RECONNAISSANCE ORBITER', - 'name_sensor': 'LUNAR RECONNAISSANCE ORBITER CAMERA', - 'reference_height': { - 'maxheight': 1000, - 'minheight': -1000, - 'unit': 'm'}, - 'name_model': 'USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL', - 'interpolation_method': 'lagrange', - 'line_scan_rate': [[0.5, -0.20668596029281616, 0.0010334295999999998]], - 'starting_ephemeris_time': 302228504.36824864, - 'center_ephemeris_time': 302228504.5749346, - 't0_ephemeris': -0.20668596029281616, - 'dt_ephemeris': 0.08267437219619751, - 't0_quaternion': -0.20668596029281616, - 'dt_quaternion': 0.08267437219619751} - def test_short_mission_name(driver): assert driver.short_mission_name=='lro' @@ -391,8 +323,3 @@ def test_additional_preroll(self): def test_sampling_factor(self): assert self.driver.sampling_factor == 1 - - def test_target_frame_id(self): - with patch('ale.drivers.lro_drivers.spice.gdpool', return_value=-12345) as gdpool: - assert self.driver.target_frame_id == -12345 - gdpool.assert_called_with('FRAME_MOON_ME',0,1)