Skip to content

Commit

Permalink
Hayabusa amica (DOI-USGS#521)
Browse files Browse the repository at this point in the history
* add hayabusa drivers (part 1)

* amica tests (load test fails), partial NIRS driver

* moved Hayabusa NIRS driver to its own branch

* sorted pck kernels first, checked for >1 eph times

* corrected new horizons radii in tests

* IsisLable mixin handles clock times with qunatities

* Removed spacecraft_clock tests

---------

Co-authored-by: acpaquette <[email protected]>
  • Loading branch information
jrcain-usgs and acpaquette authored Mar 20, 2023
1 parent da5f968 commit 24f65a4
Show file tree
Hide file tree
Showing 21 changed files with 12,217 additions and 11 deletions.
44 changes: 44 additions & 0 deletions ale/drivers/hayabusa_drivers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from ale.base.data_naif import NaifSpice
from ale.base.label_isis import IsisLabel
from ale.base.type_sensor import Framer
from ale.base.type_distortion import RadialDistortion, NoDistortion
from ale.base.base import Driver

class HayabusaAmicaIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, RadialDistortion, Driver):

@property
def instrument_id(self):
"""
Returns the ID of the instrument
Returns
-------
: str
Name of the instrument
"""
lookup_table = {'AMICA': 'HAYABUSA_AMICA'}
return lookup_table[super().instrument_id]

@property
def sensor_model_version(self):
"""
The ISIS Sensor model number for HiRise in ISIS. This is likely just 1
Returns
-------
: int
ISIS sensor model version
"""
return 1

@property
def sensor_name(self):
"""
Returns the name of the instrument
Returns
-------
: str
Name of the sensor
"""
return self.instrument_id
2 changes: 1 addition & 1 deletion ale/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def from_spice(cls, sensor_frame, target_frame, center_ephemeris_time, ephemeris
if len(target_times) > 1:
target_times = np.asarray([ephemeris_times[0], ephemeris_times[-1]])

if exact_ck_times and not nadir:
if exact_ck_times and len(ephemeris_times) > 1 and not nadir:
try:
sensor_times = cls.extract_exact_ck_times(ephemeris_times[0], ephemeris_times[-1], sensor_frame)
except Exception as e:
Expand Down
2 changes: 2 additions & 0 deletions ale/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def load_table_data(key):
kernels = [expandvars(expandvars(k, isisprefs['DataDirectory'], case_sensitive=False)) for k in kernels]
# Ensure that the ISIS Addendum kernel is last in case it overrides
# some values from the default Instrument kernel
# Sorts planetary constants kernel first so it can be overridden by more specific kernels
kernels = sorted(kernels, key=lambda x: "Addendum" in x)
kernels = sorted(kernels, key=lambda x: "pck00" in x, reverse=True)
return kernels
elif (format_as == 'dict'):
# return created dict
Expand Down
8 changes: 8 additions & 0 deletions tests/pytests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,12 @@ def convert_kernels(kernels):
except:
warnings.warn(f"Unable to convert {path} to binary kernel")
updated_kernels.append(kernel)

# Sort Kernels
# Ensure that the ISIS Addendum kernel is last in case it overrides
# some values from the default Instrument kernel
# Sorts planetary constants kernel first so it can be overridden by more specific kernels
updated_kernels = sorted(updated_kernels, key=lambda x: "Addendum" in x)
updated_kernels = sorted(updated_kernels, key=lambda x: "pck00" in x, reverse=True)

return updated_kernels, binary_kernels
278 changes: 278 additions & 0 deletions tests/pytests/data/isds/hayabusaamica_isd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
"isis_camera_version": 1,
"image_lines": 1024,
"image_samples": 1024,
"name_platform": "HAYABUSA",
"name_sensor": "HAYABUSA_AMICA",
"reference_height": {
"maxheight": 1000,
"minheight": -1000,
"unit": "m"
},
"name_model": "USGS_ASTRO_FRAME_SENSOR_MODEL",
"center_ephemeris_time": 182502855.87767982,
"radii": {
"semimajor": 0.274,
"semiminor": 0.138,
"unit": "km"
},
"body_rotation": {
"time_dependent_frames": [
2025143,
1
],
"ck_table_start_time": 182502855.87767982,
"ck_table_end_time": 182502855.87767982,
"ck_table_original_size": 1,
"ephemeris_times": [
182502855.87767982
],
"quaternions": [
[
-0.08077042629450831,
-0.3978802006010579,
0.8955645826414776,
0.1820207749792905
]
],
"angular_velocities": [
[
-2.512589340256263e-08,
5.61469404198439e-05,
-0.00013244767067246732
]
],
"reference_frame": 1
},
"instrument_pointing": {
"time_dependent_frames": [
-130000,
1
],
"ck_table_start_time": 182502855.87767982,
"ck_table_end_time": 182502855.87767982,
"ck_table_original_size": 1,
"ephemeris_times": [
182502855.87767982
],
"quaternions": [
[
-0.35631878528559185,
0.6008590807630156,
0.37126158431750983,
0.6116944697537136
]
],
"angular_velocities": [
[
-3.8262173581753043e-07,
-7.423354754135573e-06,
-4.099140843147822e-05
]
],
"reference_frame": 1,
"constant_frames": [
-130102,
-130101,
-130000
],
"constant_rotation": [
0.006635481026673982,
0.9999756648566065,
0.002154085915888306,
0.9999768321090574,
-0.006632187003876368,
-0.0015327559101681021,
-0.0015184323097166528,
0.002164206583021168,
-0.9999965052804872
]
},
"naif_keywords": {
"BODY2025143_RADII": [
0.274,
0.156,
0.138
],
"BODY_FRAME_CODE": 2025143,
"BODY_CODE": 2025143,
"TKFRAME_-130102_AXES": [
1.0,
2.0,
3.0
],
"TKFRAME_-130102_SPEC": "ANGLES",
"TKFRAME_-130102_RELATIVE": "HAYABUSA_AMICA_IDEAL",
"INS-130102_FOCAL_LENGTH": 0.1208,
"FRAME_-130102_NAME": "HAYABUSA_AMICA",
"FRAME_-130102_CLASS_ID": -130102.0,
"INS-130102_PIXEL_LINES": 1024.0,
"INS-130102_CENTER": [
511.5,
511.5
],
"INS-130102_LT_SURFACE_CORRECT": "FALSE",
"INS-130102_F_NUMBER": 8.0,
"INS-130102_PIXEL_SIZE": 1.2e-05,
"INS-130102_SWAP_OBSERVER_TARGET": "TRUE",
"INS-130102_PIXEL_SAMPLES": 1024.0,
"FRAME_-130102_CLASS": 4.0,
"INS-130102_ITRANSL": [
0.0,
0.0,
-83.33333333
],
"INS-130102_LIGHTTIME_CORRECTION": "NONE",
"INS-130102_FOV_BOUNDARY_CORNERS": [
0.006144,
0.006144,
0.1204711614,
-0.006144,
0.006144,
0.1204711614,
-0.006144,
-0.006144,
0.1204711614,
0.006144
],
"INS-130102_ITRANSS": [
0.0,
83.33333333,
0.0
],
"INS-130102_BORESIGHT": [
0.0,
0.0,
1.0
],
"INS-130102_UPVECTOR": [
0.0,
-1.0,
0.0
],
"INS-130102_BORESIGHT_LINE": 511.5,
"INS-130102_BORESIGHT_SAMPLE": 511.5,
"TKFRAME_-130102_UNITS": "DEGREES",
"INS-130102_PIXEL_PITCH": 0.012,
"INS-130102_FOV_SHAPE": "POLYGON",
"INS-130102_TRANSX": [
0.0,
0.012,
0.0
],
"INS-130102_TRANSY": [
0.0,
0.0,
-0.012
],
"INS-130102_OD_K": [
0.0,
2.8e-05,
0.0
],
"INS-130102_FOV_FRAME": "HAYABUSA_AMICA",
"TKFRAME_-130102_ANGLES": [
-0.087,
-0.124,
-0.38
],
"FRAME_-130102_CENTER": -130.0,
"OBJECT_2025143_FRAME": "ITOKAWA_FIXED",
"FRAME_2025143_CLASS": 2.0,
"BODY2025143_PM": [
129.73,
712.1437611,
0.0
],
"BODY2025143_POLE_RA": [
90.02564,
0.0,
0.0
],
"FRAME_2025143_CLASS_ID": 2025143.0,
"BODY2025143_POLE_DEC": [
-67.02704,
0.0,
0.0
],
"FRAME_2025143_CENTER": 2025143.0,
"BODY2025143_LONG_AXIS": 0.0,
"FRAME_2025143_NAME": "ITOKAWA_FIXED"
},
"detector_sample_summing": 1,
"detector_line_summing": 1,
"focal_length_model": {
"focal_length": 0.1208
},
"detector_center": {
"line": 511.5,
"sample": 511.5
},
"focal2pixel_lines": [
0.0,
0.0,
-83.33333333
],
"focal2pixel_samples": [
0.0,
83.33333333,
0.0
],
"optical_distortion": {
"radial": {
"coefficients": [
0.0,
2.8e-05,
0.0
]
}
},
"starting_detector_line": 0,
"starting_detector_sample": 0,
"instrument_position": {
"spk_table_start_time": 182502855.87767982,
"spk_table_end_time": 182502855.87767982,
"spk_table_original_size": 1,
"ephemeris_times": [
182502855.87767982
],
"positions": [
[
8.86672985554185,
0.2413099824695155,
0.0807100049795115
]
],
"velocities": [
[
-1.7052270063544483e-07,
3.570752676118616e-07,
2.8761355905130292e-06
]
],
"reference_frame": 1
},
"sun_position": {
"spk_table_start_time": 182502855.87767982,
"spk_table_end_time": 182502855.87767982,
"spk_table_original_size": 1,
"ephemeris_times": [
182502855.87767982
],
"positions": [
[
154700502.11551195,
5443988.583930893,
-2054766.29920961
]
],
"velocities": [
[
-6.6574479060899465,
28.813387859292327,
13.032393923917786
]
],
"reference_frame": 1
}
}
10 changes: 5 additions & 5 deletions tests/pytests/data/isds/mvic_mpf_isd.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"name_model": "USGS_ASTRO_FRAME_SENSOR_MODEL",
"center_ephemeris_time": 486576443.42086315,
"radii": {
"semimajor": 1195.0,
"semiminor": 1195.0,
"semimajor": 1188.3,
"semiminor": 1188.3,
"unit": "km"
},
"body_rotation": {
Expand Down Expand Up @@ -1638,9 +1638,9 @@
},
"naif_keywords": {
"BODY999_RADII": [
1195.0,
1195.0,
1195.0
1188.3,
1188.3,
1188.3
],
"BODY_FRAME_CODE": 10019,
"BODY_CODE": 999,
Expand Down
Loading

0 comments on commit 24f65a4

Please sign in to comment.