Skip to content

Commit

Permalink
Bufixes for MSL sensor intrinsics (#589)
Browse files Browse the repository at this point in the history
* Bufixes for MSL sensor intrinsics

* Fix msl tests

* Add to changelog the ray direction MSL fix
  • Loading branch information
oleg-alexandrov authored Jan 16, 2024
1 parent ec88933 commit 775ff21
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ release.
### Fixed
- Fixed LRO MiniRF drivers naif keywords focal to pixel and pixel to focal translations to be correct. [#569](https://github.com/DOI-USGS/ale/pull/569)
- Bugfix for position and orientation for MSL cameras (driver MslMastcamPds3NaifSpiceDriver). Validated that Nav and Mast LBL files (for both left and right sensor) produce correctly positioned and oriented CSM cameras, that are self-consistent and consistent with a prior DEM for the site. [#580](https://github.com/DOI-USGS/ale/pull/580)
- Bug fix for ray direction for MSL. [#589](https://github.com/DOI-USGS/ale/pull/589)

### Changed
- Removed the affine6p library and replaced affine6p's affine transformation with a numpy solution [#579](https://github.com/DOI-USGS/ale/pull/579)
Expand Down
2 changes: 1 addition & 1 deletion ale/base/type_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,4 +612,4 @@ def pixel_size(self):
: float
Pixel size of a cahvor model instrument
"""
return -self.focal_length/self.compute_h_s()
return self.focal_length/self.compute_h_s()
12 changes: 6 additions & 6 deletions ale/drivers/msl_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def focal2pixel_lines(self):
: list<double>
focal plane to detector lines
"""
return [0, 0, -1/self.pixel_size]
return [0, 0, 1/self.pixel_size]

@property
def focal2pixel_samples(self):
Expand All @@ -138,7 +138,7 @@ def focal2pixel_samples(self):
: list<double>
focal plane to detector samples
"""
return [0, -1/self.pixel_size, 0]
return [0, 1/self.pixel_size, 0]

@property
def sensor_model_version(self):
Expand Down Expand Up @@ -181,10 +181,10 @@ def focal_length(self):
if self.is_navcam:
# Focal length in pixel as computed for a cahvor model.
# See is_navcam() for an explanation.
return -(self.compute_h_s() + self.compute_v_s())/2.0
return (self.compute_h_s() + self.compute_v_s())/2.0

# For mast cam
return -super().focal_length
# For mast cam
return super().focal_length

@property
def pixel_size(self):
Expand All @@ -200,5 +200,5 @@ def pixel_size(self):
# See is_navcam() for an explanation.
return 1.0

# For mast cam
# For mast cam
return super().pixel_size
8 changes: 4 additions & 4 deletions tests/pytests/data/isds/msl_isd.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
"detector_sample_summing": 1,
"detector_line_summing": 1,
"focal_length_model": {
"focal_length": -34.0
"focal_length": 34.0
},
"detector_center": {
"line": 576.4026068104001,
Expand All @@ -235,11 +235,11 @@
"focal2pixel_lines": [
0,
0,
-136.49886775101947
136.49886775101947
],
"focal2pixel_samples": [
0,
-136.49886775101947,
136.49886775101947,
0
],
"optical_distortion": {
Expand Down Expand Up @@ -301,4 +301,4 @@
],
"reference_frame": 1
}
}
}
8 changes: 4 additions & 4 deletions tests/pytests/data/isds/msl_nadir_isd.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"detector_sample_summing": 1,
"detector_line_summing": 1,
"focal_length_model": {
"focal_length": -34.0
"focal_length": 34.0
},
"detector_center": {
"line": 576.4026068104001,
Expand All @@ -226,11 +226,11 @@
"focal2pixel_lines": [
0,
0,
-136.49886775101947
136.49886775101947
],
"focal2pixel_samples": [
0,
-136.49886775101947,
136.49886775101947,
0
],
"optical_distortion": {
Expand Down Expand Up @@ -292,4 +292,4 @@
],
"reference_frame": 1
}
}
}
2 changes: 1 addition & 1 deletion tests/pytests/test_cahvor_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ def test_cahvor_detector_center_sample(self, cahvor_camera_dict):

@patch("ale.base.type_sensor.Cahvor.cahvor_camera_dict", new_callable=PropertyMock, return_value=cahvor_camera_dict())
def test_cahvor_pixel_size(self, cahvor_camera_dict):
assert self.driver.pixel_size == -0.007248034226138798
assert self.driver.pixel_size == 0.007248034226138798
4 changes: 2 additions & 2 deletions tests/pytests/test_msl_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ def test_sensor_frame_id(self):
def test_focal2pixel_lines(self):
with patch('ale.drivers.msl_drivers.spice.bods2c', new_callable=PropertyMock, return_value=-76220) as bods2c, \
patch('ale.drivers.msl_drivers.spice.gdpool', new_callable=PropertyMock, return_value=[100]) as gdpool:
np.testing.assert_allclose(self.driver.focal2pixel_lines, [0, 0, -137.96844341513602])
np.testing.assert_allclose(self.driver.focal2pixel_lines, [0, 0, 137.96844341513602])
bods2c.assert_called_with('MSL_MASTCAM_RIGHT')
gdpool.assert_called_with('INS-76220_FOCAL_LENGTH', 0, 1)

def test_focal2pixel_samples(self):
with patch('ale.drivers.msl_drivers.spice.bods2c', new_callable=PropertyMock, return_value=-76220) as bods2c, \
patch('ale.drivers.msl_drivers.spice.gdpool', new_callable=PropertyMock, return_value=[100]) as gdpool:
np.testing.assert_allclose(self.driver.focal2pixel_samples, [0, -137.96844341513602, 0])
np.testing.assert_allclose(self.driver.focal2pixel_samples, [0, 137.96844341513602, 0])
bods2c.assert_called_with('MSL_MASTCAM_RIGHT')
gdpool.assert_called_with('INS-76220_FOCAL_LENGTH', 0, 1)

0 comments on commit 775ff21

Please sign in to comment.