Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelvinrr committed Oct 30, 2024
1 parent 021833b commit 86e45ab
Show file tree
Hide file tree
Showing 60 changed files with 4,458 additions and 16,403 deletions.
6 changes: 6 additions & 0 deletions ale/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from ale.base.base import Driver

spiceql_mission_map = {
"APOLLO_METRIC" : "apollo",
"CHANDRAYAAN-1_M3": "m3",
"CHANDRAYAAN-1_MRFFR": "mrffr",
"M3": "m3",
"CASSINI_ISS_NAC": "cassini",
"CASSINI_ISS_WAC": "cassini",
"CASSINI_VIMS_V" : "cassini",
"DAWN_FC2_FILTER_1": "fc2",
"DAWN_FC2_FILTER_2": "fc2",
"DAWN_FC2_FILTER_3": "fc2",
Expand Down Expand Up @@ -49,6 +52,7 @@
"ORX_OCAMS_MAPCAM": "",
"ORX_OCAMS_POLYCAM": "",
"ORX_OCAMS_SAMCAM": "",
"ROS_VIRTIS-M_IR" : "rosetta",
"LISM_MI-VIS1": "kaguya",
"LISM_MI-VIS2": "kaguya",
"LISM_MI-VIS3": "kaguya",
Expand Down Expand Up @@ -83,6 +87,8 @@
"VG1_ISSWA": "",
"VG2_ISSNA": "",
"VG2_ISSWA": "",
"VISUAL_IMAGING_SUBSYSTEM_CAMERA_A" : "viking1",
"VISUAL_IMAGING_SUBSYSTEM_CAMERA_B" : "viking1",
"ULTRAVIOLET/VISIBLE CAMERA": "uvvis",
"Near Infrared Camera": "nir",
"High Resolution Camera": "clementine1",
Expand Down
13 changes: 6 additions & 7 deletions ale/base/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import sys

import tempfile
import os
Expand Down Expand Up @@ -48,9 +49,9 @@ def to_dict(self, properties=None):
def get_property(prop_name):
try:
return getattr(self, prop_name)
except Exception as e:
print(prop_name, e)
return None
except (Exception) as e:
print(f"Failed to get property {prop_name} with type {type(e)}: {e}", file=sys.stderr)
return None

if properties is None:
properties = []
Expand Down Expand Up @@ -88,14 +89,13 @@ def get_property(prop_name):
for result, property_name in zip(jobs, spice_props):
data[property_name] = result
end = time.time()
print(f"TOTAL SPICE TIME: {end - start}")

start = time.time()
for prop in properties:
data[prop] = get_property(prop)
if prop == "line_scan_rate":
end = time.time()
print(f"TOTAL OTHER TIME: {end - start}")


start = time.time()
with ThreadPool() as pool:
jobs = pool.starmap_async(get_property, [(name,) for name in ephemeris_props])
Expand All @@ -104,7 +104,6 @@ def get_property(prop_name):
for result, property_name in zip(jobs, ephemeris_props):
data[property_name] = result
end = time.time()
print(f"TOTAL EPHEM TIME: {end - start}")
return data

@property
Expand Down
2 changes: 1 addition & 1 deletion ale/base/data_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dateutil import parser

import pvl
import spiceypy as spice

from ale.rotation import ConstantRotation, TimeDependentRotation
from ale.transformation import FrameChain

Expand Down
21 changes: 13 additions & 8 deletions ale/base/data_naif.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import spiceypy as spice

import warnings
from multiprocessing.pool import ThreadPool


import numpy as np
import pyspiceql
import scipy.constants
from scipy.spatial.transform import Rotation as R
import spiceypy as spice

import ale
from ale.base import spiceql_mission_map
Expand All @@ -29,7 +31,6 @@ def __enter__(self):
"""
if self.kernels:
[pyspiceql.KernelPool.getInstance().load(k) for k in self.kernels]
[spice.furnsh(k) for k in self.kernels]
return self

def __exit__(self, exc_type, exc_val, exc_tb):
Expand All @@ -40,7 +41,6 @@ def __exit__(self, exc_type, exc_val, exc_tb):
"""
if self.kernels:
[pyspiceql.KernelPool.getInstance().unload(k) for k in self.kernels]
[spice.unload(k) for k in self.kernels]

@property
def kernels(self):
Expand Down Expand Up @@ -737,13 +737,18 @@ def naif_keywords(self):

self._naif_keywords['BODY_FRAME_CODE'] = self.target_frame_id
self._naif_keywords['BODY_CODE'] = self.target_id
mission_keywords = self.spiceql_call("findMissionKeywords", {"key": f"*{self.ikid}*", "mission": self.spiceql_mission})
target_keywords = self.spiceql_call("findTargetKeywords", {"key": f"*{self.target_id}*", "mission": self.spiceql_mission})

self._naif_keywords = {**self._naif_keywords,
**self.spiceql_call("findMissionKeywords", {"key": f"*{self.ikid}*", "mission": self.spiceql_mission}),
**self.spiceql_call("findTargetKeywords", {"key": f"*{self.target_id}*", "mission": self.spiceql_mission})}
if mission_keywords:
self._naif_keywords = self.naif_keywords | mission_keywords
if target_keywords:
self._naif_keywords = self._naif_keywords | target_keywords

try:
self._naif_keywords = {**self._naif_keywords, **self.spiceql_call("findMissionKeywords", {"key": f"*{self.fikid}*", "mission": self.spiceql_mission})}
frame_keywords = self.spiceql_call("findMissionKeywords", {"key": f"*{self.fikid}*", "mission": self.spiceql_mission})
if frame_keywords:
self._naif_keywords = self._naif_keywords | frame_keywords
except AttributeError as error:
pass

Expand Down Expand Up @@ -801,6 +806,6 @@ def spiceql_call(self, function_name = "", function_args = {}):
data_dir = ""

if function_name in memo_funcs and data_dir == "" and self.use_web == False:
function_name = f"NonMemo_{function_name}"
function_name = f"{function_name}"
return spiceql_access.spiceql_call(function_name, function_args, self.use_web)

11 changes: 6 additions & 5 deletions ale/base/type_distortion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import spiceypy as spice

class LegendreDistortion():
"""
Expand Down Expand Up @@ -194,10 +193,12 @@ def usgscsm_distortion_model(self):
# center (point of symmetry of distortion)
perspective_key = 'INS{}_PERSPECTIVE_FACTORS'.format(self.ikid)
center_key = 'INS{}_POINT_OF_SYMMETRY'.format(self.ikid)
perspective_x = float(spice.gdpool(perspective_key, 0, 1)[0])
perspective_y = float(spice.gdpool(perspective_key, 0, 2)[1])
center_point_x = float(spice.gdpool(center_key, 0, 1)[0])
center_point_y = float(spice.gdpool(center_key, 0, 2)[1])


perspective_x = float(self.naif_keywords[perspective_key][0])
perspective_y = float(self.naif_keywords[perspective_key][1])
center_point_x = float(self.naif_keywords[center_key][0])
center_point_y = float(self.naif_keywords[center_key][1])

# Get the distortion coefficients
# CameraDistortionMap::SetDistortion(naifIkCode);
Expand Down
2 changes: 1 addition & 1 deletion ale/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'ale' : to_isd}

def sort_drivers(drivers=[]):
return list(sorted(drivers, key=lambda x:IsisSpice in x.__bases__, reverse=False))
return list(sorted(set(drivers), key=lambda x:IsisSpice in x.__bases__, reverse=False))

class AleJsonEncoder(json.JSONEncoder):
def default(self, obj):
Expand Down
Loading

0 comments on commit 86e45ab

Please sign in to comment.