diff --git a/ale/drivers/co_drivers.py b/ale/drivers/co_drivers.py index 106f38c16b6347caf0854beb4ab8944500ca6a53..2f79d8bbc9c5f2a250e179d85d7326219d5d1ce7 100644 --- a/ale/drivers/co_drivers.py +++ b/ale/drivers/co_drivers.py @@ -17,98 +17,104 @@ from ale.rotation import ConstantRotation from ale.transformation import FrameChain from scipy.spatial.transform import Rotation +id_lookup = { + "ISSNA" : "CASSINI_ISS_NAC", + "ISSWA" : "CASSINI_ISS_WAC" +} + +name_lookup = { + "ISSNA" : "Imaging Science Subsystem Narrow Angle Camera", + "ISSWA" : "Imaging Science Subsystem Wide Angle Camera" +} + +nac_filter_to_focal_length = { + ("P0","BL2"):2002.19, + ("P0","CB1"):2002.30, + ("P0","GRN"):2002.38, + ("P0","IR1"):2002.35, + ("P0","MT1"):2002.40, + ("P0","UV3"):2002.71, + ("P60","BL2"):2002.13, + ("P60","CB1"):2002.18, + ("P60","GRN"):2002.28, + ("P60","IR1"):2002.36, + ("P60","MT1"):2002.34, + ("P60","UV3"):2002.51, + ("RED","GRN"):2002.61, + ("RED","IR1"):2002.48, + ("UV1","CL2"):2003.03, + ("UV2","CL2"):2002.91, + ("UV2","UV3"):2002.90, + ("RED","CL2"):2002.69, + ("CL1","IR3"):2002.65, + ("CL1","BL2"):2002.37, + ("CL1","CB1"):2002.66, + ("CL1","CB2"):2002.66, + ("CL1","CB3"):2002.68, + ("CL1","MT1"):2002.88, + ("CL1","MT2"):2002.91, + ("CL1","MT3"):2002.87, + ("CL1","UV3"):2003.09, + ("HAL","CL2"):2002.94, + ("IR2","CL2"):2002.71, + ("IR2","IR1"):2002.56, + ("IR2","IR3"):2002.55, + ("IR4","CL2"):2002.89, + ("IR4","IR3"):2002.81, + ("BL1","CL2"):2002.79, + ("CL1","CL2"):2002.88, + ("CL1","GRN"):2002.75, + ("CL1","IR1"):2002.74, + ("IRP0","CB2"):2002.48, + ("IRP0","CB3"):2002.74, + ("IRP0","IR1"):2002.60, + ("IRP0","IR3"):2002.48, + ("IRP0","MT2"):2002.72, + ("IRP0","MT3"):2002.72, + ("P120","BL2"):2002.11, + ("P120","CB1"):002.28, + ("P120","GRN"):2002.38, + ("P120","IR1"):2002.39, + ("P120","MT1"):2002.54, + ("P120","UV3"):2002.71 +} + +wac_filter_to_focal_length = { + ("B2","CL2"):200.85, + ("B2","IRP90"):200.83, + ("B2","IRP0"):200.82, + ("B3","CL2"):201.22, + ("B3","IRP90"):201.12, + ("B3","IRP0"):201.11, + ("L1","BL1"):200.86, + ("L1","CL2"):200.77, + ("L1","GRN"):200.71, + ("L1","HAL"):200.74, + ("L1","IR1"):200.80, + ("L1","RED"):200.74, + ("L1","VIO"):201.09, + ("R2","CL2"):200.97, + ("R2","IR"):200.95, + ("R2","IRP90"):200.95, + ("R3","CL2"):201.04, + ("R3","IRP90"):201.03, + ("R3","IRP0"):201.04, + ("R4","CL2"):201.22, + ("R4","IRP90"):201.16, + ("R4","IRP0"):201.15, + ("T2","CL2"):200.82, + ("T2","IRP0"):200.81, + ("T2","IRP90"):200.82, + ("T3","CL2"):201.04, + ("T3","IRP0"):201.06, + ("T3","IRP90"):201.07 +} class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDistortion, Driver): """ Cassini mixin class for defining Spice calls. """ - id_lookup = { - "ISSNA" : "CASSINI_ISS_NAC", - "ISSWA" : "CASSINI_ISS_WAC" - } - - nac_filter_to_focal_length = { - ("P0","BL2"):2002.19, - ("P0","CB1"):2002.30, - ("P0","GRN"):2002.38, - ("P0","IR1"):2002.35, - ("P0","MT1"):2002.40, - ("P0","UV3"):2002.71, - ("P60","BL2"):2002.13, - ("P60","CB1"):2002.18, - ("P60","GRN"):2002.28, - ("P60","IR1"):2002.36, - ("P60","MT1"):2002.34, - ("P60","UV3"):2002.51, - ("RED","GRN"):2002.61, - ("RED","IR1"):2002.48, - ("UV1","CL2"):2003.03, - ("UV2","CL2"):2002.91, - ("UV2","UV3"):2002.90, - ("RED","CL2"):2002.69, - ("CL1","IR3"):2002.65, - ("CL1","BL2"):2002.37, - ("CL1","CB1"):2002.66, - ("CL1","CB2"):2002.66, - ("CL1","CB3"):2002.68, - ("CL1","MT1"):2002.88, - ("CL1","MT2"):2002.91, - ("CL1","MT3"):2002.87, - ("CL1","UV3"):2003.09, - ("HAL","CL2"):2002.94, - ("IR2","CL2"):2002.71, - ("IR2","IR1"):2002.56, - ("IR2","IR3"):2002.55, - ("IR4","CL2"):2002.89, - ("IR4","IR3"):2002.81, - ("BL1","CL2"):2002.79, - ("CL1","CL2"):2002.88, - ("CL1","GRN"):2002.75, - ("CL1","IR1"):2002.74, - ("IRP0","CB2"):2002.48, - ("IRP0","CB3"):2002.74, - ("IRP0","IR1"):2002.60, - ("IRP0","IR3"):2002.48, - ("IRP0","MT2"):2002.72, - ("IRP0","MT3"):2002.72, - ("P120","BL2"):2002.11, - ("P120","CB1"):002.28, - ("P120","GRN"):2002.38, - ("P120","IR1"):2002.39, - ("P120","MT1"):2002.54, - ("P120","UV3"):2002.71 - } - - wac_filter_to_focal_length = { - ("B2","CL2"):200.85, - ("B2","IRP90"):200.83, - ("B2","IRP0"):200.82, - ("B3","CL2"):201.22, - ("B3","IRP90"):201.12, - ("B3","IRP0"):201.11, - ("L1","BL1"):200.86, - ("L1","CL2"):200.77, - ("L1","GRN"):200.71, - ("L1","HAL"):200.74, - ("L1","IR1"):200.80, - ("L1","RED"):200.74, - ("L1","VIO"):201.09, - ("R2","CL2"):200.97, - ("R2","IR"):200.95, - ("R2","IRP90"):200.95, - ("R3","CL2"):201.04, - ("R3","IRP90"):201.03, - ("R3","IRP0"):201.04, - ("R4","CL2"):201.22, - ("R4","IRP90"):201.16, - ("R4","IRP0"):201.15, - ("T2","CL2"):200.82, - ("T2","IRP0"):200.81, - ("T2","IRP90"):200.82, - ("T3","CL2"):201.04, - ("T3","IRP0"):201.06, - ("T3","IRP90"):201.07 - } + @property def instrument_id(self): @@ -124,7 +130,7 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis : str instrument id """ - return self.id_lookup[super().instrument_id] + return id_lookup[super().instrument_id] @property def focal_epsilon(self): @@ -259,10 +265,10 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis filters = tuple(self.label['FILTER_NAME']) if self.instrument_id == "CASSINI_ISS_NAC": - return self.nac_filter_to_focal_length.get(filters, default_focal_len) + return nac_filter_to_focal_length.get(filters, default_focal_len) elif self.instrument_id == "CASSINI_ISS_WAC": - return self.wac_filter_to_focal_length.get(filters, default_focal_len) + return wac_filter_to_focal_length.get(filters, default_focal_len) @property def _original_naif_sensor_frame_id(self): @@ -329,6 +335,19 @@ class CassiniIssPds3LabelNaifSpiceDriver(Framer, Pds3Label, NaifSpice, RadialDis return self._frame_chain class CassiniIssIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion, Driver): + + @property + def instrument_id(self): + """ + Returns the ID of the instrument + + Returns + ------- + : str + ID of the sensor + """ + return id_lookup[super().instrument_id] + @property def sensor_name(self): """ @@ -339,4 +358,19 @@ class CassiniIssIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistort : str Name of the sensor """ - return self.label['IsisCube']['Instrument']['SpacecraftName'] + return name_lookup[super().instrument_id] + + @property + def center_ephemeris_time(self): + """ + Returns the middle exposure time for the image in ephemeris seconds. + + This is overriden because the ISIS ISSNAC and ISSWAC sensor models use the + label utc times so the converted times are not available in the + NaifKeywords. Instead we get it from the tables. + + Returns + ------- + : float + """ + return self.inst_position_table['SpkTableStartTime'] diff --git a/ale/drivers/viking_drivers.py b/ale/drivers/viking_drivers.py index 254d1dc98bb60a8ac56b0bbcf4b9d3de88293317..0bf1f85851cd485085455899a9903285d17120cf 100644 --- a/ale/drivers/viking_drivers.py +++ b/ale/drivers/viking_drivers.py @@ -8,8 +8,54 @@ from ale.base.type_sensor import Framer from ale.base.type_distortion import NoDistortion from ale.base.base import Driver +sensor_name_lookup = { + "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A" : "Visual Imaging Subsystem Camera A", + "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B" : "Visual Imaging Subsystem Camera B" +} + +spacecraft_name_lookup = { + 'VIKING_ORBITER_1': 'VIKING ORBITER 1', + 'VIKING_ORBITER_2': 'VIKING ORBITER 2' +} + +alt_id_lookup = { + 'VIKING ORBITER 1': -27999, + 'VIKING ORBITER 2':-30999 +} + class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver): + + + @property + def instrument_id(self): + """ + Overriden to check that the instrument ID is correct + + Returns + ------- + : str + The name of the sensor + """ + instrument_id = super().instrument_id + + if(instrument_id not in sensor_name_lookup): + raise Exception (f'Instrument ID [{instrument_id}] is wrong.') + + return instrument_id + + @property + def sensor_name(self): + """ + Returns the name of the instrument + + Returns + ------- + : str + Name of the sensor + """ + return sensor_name_lookup[super().instrument_id] + @property def spacecraft_name(self): """ @@ -20,12 +66,7 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver): : str Name of the spacecraft. """ - name_lookup = { - 'VIKING_ORBITER_1': 'VIKING ORBITER 1', - 'VIKING_ORBITER_2': 'VIKING ORBITER 2' - } - - return name_lookup[super().spacecraft_name] + return spacecraft_name_lookup[super().spacecraft_name] @property def alt_ikid(self): @@ -41,11 +82,6 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver): Alternate Naif Integer ID code for the instrument """ - alt_id_lookup = { - 'VIKING ORBITER 1': -27999, - 'VIKING ORBITER 2':-30999 - } - return alt_id_lookup[self.spacecraft_name] @property @@ -84,6 +120,24 @@ class VikingIsisLabelNaifSpiceDriver(Framer, IsisLabel, NaifSpice, Driver): return ephemeris_start_time + offset1 + offset2 class VikingIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion, Driver): + + @property + def instrument_id(self): + """ + Overriden to check that the instrument ID is correct + + Returns + ------- + : str + The name of the sensor + """ + instrument_id = super().instrument_id + + if(instrument_id not in sensor_name_lookup): + raise Exception (f'Instrument ID [{instrument_id}] is wrong.') + + return instrument_id + @property def sensor_name(self): """ @@ -94,4 +148,16 @@ class VikingIsisLabelIsisSpiceDriver(Framer, IsisLabel, IsisSpice, NoDistortion, : str Name of the sensor """ - return self.label['IsisCube']['Instrument']['SpacecraftName'] + return sensor_name_lookup[super().instrument_id] + + @property + def spacecraft_name(self): + """ + Overridden to work with spice calls. + + Returns + ------- + : str + Name of the spacecraft. + """ + return spacecraft_name_lookup[super().spacecraft_name] diff --git a/tests/pytests/conftest.py b/tests/pytests/conftest.py index c49b36bec02c3bb76ccce8afb5b4c5731de3d4a0..9c336380bda1c244f50fe1d4743800014e33d57d 100644 --- a/tests/pytests/conftest.py +++ b/tests/pytests/conftest.py @@ -4,9 +4,12 @@ import re import warnings import numpy as np import json +import pvl import ale +from ale.base.data_isis import read_table_data + from glob import glob class SimpleSpice(): @@ -95,6 +98,21 @@ def get_image_label(image, label_type='pds3'): return label_file[0] +def get_table_data(image, table_name): + if not isinstance(image, str): + try: + image = str(image) + except: + raise KeyError('Cannot coerce requested image name to string') + + table_file = glob(os.path.join(data_root, '*',f'{image}_{table_name}.tbl')) + if not table_file: + raise Exception(f'Could not find {table_name} table file for {image}') + + table_label = pvl.load(table_file[0]) + return read_table_data(table_label["Table"], table_file[0]) + + def get_isd(instrument): if not isinstance(instrument, str): raise KeyError('instrument name is not a string') diff --git a/tests/pytests/data/N1702360370_1/N1702360370_1_BodyRotation.tbl b/tests/pytests/data/N1702360370_1/N1702360370_1_BodyRotation.tbl new file mode 100644 index 0000000000000000000000000000000000000000..43614599a326ad43aafb0aa0792cd6af724279ae Binary files /dev/null and b/tests/pytests/data/N1702360370_1/N1702360370_1_BodyRotation.tbl differ diff --git a/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPointing.tbl b/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPointing.tbl new file mode 100644 index 0000000000000000000000000000000000000000..897b42504d368aed3e03cfb697b3088174cb713d Binary files /dev/null and b/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPointing.tbl differ diff --git a/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPosition.tbl b/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPosition.tbl new file mode 100644 index 0000000000000000000000000000000000000000..6bc6c4928cd0996f1274f54466a0bcd3514b92d7 Binary files /dev/null and b/tests/pytests/data/N1702360370_1/N1702360370_1_InstrumentPosition.tbl differ diff --git a/tests/pytests/data/N1702360370_1/N1702360370_1_SunPosition.tbl b/tests/pytests/data/N1702360370_1/N1702360370_1_SunPosition.tbl new file mode 100644 index 0000000000000000000000000000000000000000..c4b4783e9dda2379ab2fe147ec3e3343e1e5ed4a Binary files /dev/null and b/tests/pytests/data/N1702360370_1/N1702360370_1_SunPosition.tbl differ diff --git a/tests/pytests/data/N1702360370_1/N1702360370_1_isis3.lbl b/tests/pytests/data/N1702360370_1/N1702360370_1_isis3.lbl new file mode 100644 index 0000000000000000000000000000000000000000..58a25aa21a114f613dad39c22ec93a7f7d13e2f3 --- /dev/null +++ b/tests/pytests/data/N1702360370_1/N1702360370_1_isis3.lbl @@ -0,0 +1,388 @@ +Object = IsisCube + Object = Core + StartByte = 65537 + Format = Tile + TileSamples = 1024 + TileLines = 1024 + + Group = Dimensions + Samples = 1024 + Lines = 1024 + Bands = 1 + End_Group + + Group = Pixels + Type = SignedWord + ByteOrder = Lsb + Base = 0.0 + Multiplier = 1.0 + End_Group + End_Object + + Group = Instrument + SpacecraftName = Cassini-Huygens + InstrumentId = ISSNA + TargetName = Enceladus + StartTime = 2011-346T05:02:19.773 + StopTime = 2011-346T05:02:24.373 + ExposureDuration = 4600.0 <Milliseconds> + AntibloomingStateFlag = Off + + # BiasStripMean value converted back to 12 bit. + BiasStripMean = 21.550879 + CompressionRatio = 2.203063 + CompressionType = Lossless + DataConversionType = Table + DelayedReadoutFlag = No + FlightSoftwareVersionId = 1.4 + GainModeId = 29 <ElectronsPerDN> + GainState = 2 + ImageTime = 2011-346T05:02:24.373 + InstrumentDataRate = 182.783997 <KilobitsPerSecond> + OpticsTemperature = (0.627499, 1.905708 <DegreesCelcius>) + ReadoutCycleIndex = 6 + ShutterModeId = NacOnly + ShutterStateId = Enabled + SummingMode = 1 + InstrumentModeId = Full + SpacecraftClockCount = 1/1702360365.220 + ReadoutOrder = 0 + End_Group + + Group = Archive + DataSetId = CO-S-ISSNA/ISSWA-2-EDR-V1.0 + ImageNumber = 1702360370 + ObservationId = ISS_158EN_ENCEL001_PRIME + ProductId = 1_N1702360370.120 + End_Group + + Group = BandBin + FilterName = CL1/UV3 + OriginalBand = 1 + Center = 342.868 + Width = 68.904 + End_Group + + Group = Kernels + NaifFrameCode = -82360 + LeapSecond = $base/kernels/lsk/naif0012.tls + TargetAttitudeShape = ($base/kernels/pck/pck00009.tpc, + $cassini/kernels/pck/cpck15Dec2017.tpc) + TargetPosition = (Table, $base/kernels/spk/de430.bsp, + $base/kernels/spk/sat425.bsp) + InstrumentPointing = (Table, $cassini/kernels/ck/11344_11349ra.bc, + $cassini/kernels/fk/cas_v40.tf) + Instrument = Null + SpacecraftClock = $cassini/kernels/sclk/cas00172.tsc + InstrumentPosition = (Table, + $cassini/kernels/spk/200128RU_SCPSE_11337_113- + 57.bsp) + InstrumentAddendum = $cassini/kernels/iak/IssNAAddendum004.ti + ShapeModel = Null + InstrumentPositionQuality = Reconstructed + InstrumentPointingQuality = Reconstructed + CameraVersion = 1 + Source = isis + End_Group +End_Object + +Object = Label + Bytes = 65536 +End_Object + +Object = Table + Name = "ISS Prefix Pixels" + StartByte = 2163131 + Bytes = 24576 + Records = 1024 + ByteOrder = Lsb + Association = Lines + + Group = Field + Name = OverclockPixels + Type = Double + Size = 3 + End_Group +End_Object + +Object = Table + Name = InstrumentPointing + StartByte = 2192270 + Bytes = 64 + Records = 1 + ByteOrder = Lsb + TimeDependentFrames = (-82000, 1) + ConstantFrames = (14082360, -82360, -82000) + ConstantRotation = (-0.0014870197280319, -1.71828725624524e-04, + 0.99999887962298, -0.99999872852119, + -5.75703736655754e-04, -0.0014871184258906, + 5.75958621314492e-04, -0.99999981952003, + -1.70972424334032e-04) + CkTableStartTime = 376938208.25635 + CkTableEndTime = 376938208.25635 + CkTableOriginalSize = 1 + FrameTypeCode = 3 + Description = "Created by spiceinit" + Kernels = ($cassini/kernels/ck/11344_11349ra.bc, + $cassini/kernels/fk/cas_v40.tf) + + Group = Field + Name = J2000Q0 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q1 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q2 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q3 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV1 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV2 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV3 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = ET + Type = Double + Size = 1 + End_Group +End_Object + +Object = Table + Name = InstrumentPosition + StartByte = 2192334 + Bytes = 56 + Records = 1 + ByteOrder = Lsb + CacheType = Linear + SpkTableStartTime = 376938208.25635 + SpkTableEndTime = 376938208.25635 + SpkTableOriginalSize = 1.0 + Description = "Created by spiceinit" + Kernels = $cassini/kernels/spk/200128RU_SCPSE_11337_11357.bsp + + Group = Field + Name = J2000X + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Y + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Z + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000XV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000YV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000ZV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = ET + Type = Double + Size = 1 + End_Group +End_Object + +Object = Table + Name = BodyRotation + StartByte = 2192390 + Bytes = 64 + Records = 1 + ByteOrder = Lsb + TimeDependentFrames = (10040, 1) + CkTableStartTime = 376938208.25635 + CkTableEndTime = 376938208.25635 + CkTableOriginalSize = 1 + FrameTypeCode = 2 + PoleRa = (40.66, -0.036, 0.0) + PoleDec = (83.52, -0.004, 0.0) + PrimeMeridian = (6.32, 262.7318996, 0.0) + Description = "Created by spiceinit" + Kernels = ($base/kernels/spk/de430.bsp, + $base/kernels/spk/sat425.bsp, + $base/kernels/pck/pck00009.tpc, + $cassini/kernels/pck/cpck15Dec2017.tpc) + SolarLongitude = 18.419628138988 + + Group = Field + Name = J2000Q0 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q1 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q2 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Q3 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV1 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV2 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = AV3 + Type = Double + Size = 1 + End_Group + + Group = Field + Name = ET + Type = Double + Size = 1 + End_Group +End_Object + +Object = Table + Name = SunPosition + StartByte = 2192454 + Bytes = 56 + Records = 1 + ByteOrder = Lsb + CacheType = Linear + SpkTableStartTime = 376938208.25635 + SpkTableEndTime = 376938208.25635 + SpkTableOriginalSize = 1.0 + Description = "Created by spiceinit" + Kernels = ($base/kernels/spk/de430.bsp, + $base/kernels/spk/sat425.bsp) + + Group = Field + Name = J2000X + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Y + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000Z + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000XV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000YV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = J2000ZV + Type = Double + Size = 1 + End_Group + + Group = Field + Name = ET + Type = Double + Size = 1 + End_Group +End_Object + +Object = History + Name = IsisCube + StartByte = 2192510 + Bytes = 1334 +End_Object + +Object = OriginalLabel + Name = IsisCube + StartByte = 2187707 + Bytes = 4563 +End_Object + +Object = NaifKeywords + BODY_CODE = 602 + BODY602_RADII = (256.6, 251.4, 248.3) + BODY_FRAME_CODE = 10040 + INS-82360_CL1_UV3_FOCAL_LENGTH = 2003.09 + INS-82360_PIXEL_PITCH = 0.012 + INS_-82360_FRAME_ID = 14082360 + INS-82360_TRANSX = (0.0, 0.012, 0.0) + INS-82360_TRANSY = (0.0, 0.0, 0.012) + INS-82360_ITRANSS = (0.0, 83.333333333333, 0.0) + INS-82360_ITRANSL = (0.0, 0.0, 83.333333333333) + INS-82360_BORESIGHT_LINE = 512.5 + INS-82360_BORESIGHT_SAMPLE = 512.5 + INS-82360_K1 = 8.0e-06 +End_Object +End diff --git a/tests/pytests/data/isds/cassiniiss_isis_isd.json b/tests/pytests/data/isds/cassiniiss_isis_isd.json new file mode 100644 index 0000000000000000000000000000000000000000..d45e51c2f51c985421460392b4d5af77561bff40 --- /dev/null +++ b/tests/pytests/data/isds/cassiniiss_isis_isd.json @@ -0,0 +1,201 @@ +{ + "isis_camera_version": 1, + "image_lines": 1024, + "image_samples": 1024, + "name_platform": "Cassini-Huygens", + "name_sensor": "Imaging Science Subsystem Narrow Angle Camera", + "reference_height": { + "maxheight": 1000, + "minheight": -1000, + "unit": "m" + }, + "name_model": "USGS_ASTRO_FRAME_SENSOR_MODEL", + "center_ephemeris_time": 376938208.25635, + "radii": { + "semimajor": 256.6, + "semiminor": 248.3, + "unit": "km" + }, + "body_rotation": { + "time_dependent_frames": [ + 10040, + 1 + ], + "ck_table_start_time": 376938208.25635386, + "ck_table_end_time": 376938208.25635386, + "ck_table_original_size": 1, + "ephemeris_times": [ + 376938208.25635386 + ], + "quaternions": [ + [ + 0.4972617451295224, + -0.018842274857752542, + -0.05328962355712633, + -0.8657574380448987 + ] + ], + "angular_velocities": [ + [ + 4.544323197605576e-06, + 3.902625629848406e-06, + 5.2734222166983134e-05 + ] + ], + "reference_frame": 1 + }, + "instrument_pointing": { + "time_dependent_frames": [ + -82000, + 1 + ], + "ck_table_start_time": 376938208.25635386, + "ck_table_end_time": 376938208.25635386, + "ck_table_original_size": 1, + "ephemeris_times": [ + 376938208.25635386 + ], + "quaternions": [ + [ + 0.7145950771077332, + -0.21489011402790192, + -0.4418416741274442, + 0.4979478383030953 + ] + ], + "angular_velocities": [ + [ + -0.000757278786092557, + -0.0003503954137480032, + -0.000106338121706134 + ] + ], + "reference_frame": 1, + "constant_frames": [ + 14082360, + -82000 + ], + "constant_rotation": [ + -0.0014870197280309472, + -0.00017182872562249152, + 0.9999988796229811, + -0.9999987285211891, + -0.0005757037366557749, + -0.0014871184258896664, + 0.0005759586213145429, + -0.999999819520032, + -0.00017097242433200543 + ] + }, + "naif_keywords": { + "BODY_CODE": 602, + "BODY602_RADII": [ + 256.6, + 251.4, + 248.3 + ], + "BODY_FRAME_CODE": 10040, + "INS-82360_CL1_UV3_FOCAL_LENGTH": 2003.09, + "INS-82360_PIXEL_PITCH": 0.012, + "INS_-82360_FRAME_ID": 14082360, + "INS-82360_TRANSX": [ + 0.0, + 0.012, + 0.0 + ], + "INS-82360_TRANSY": [ + 0.0, + 0.0, + 0.012 + ], + "INS-82360_ITRANSS": [ + 0.0, + 83.333333333333, + 0.0 + ], + "INS-82360_ITRANSL": [ + 0.0, + 0.0, + 83.333333333333 + ], + "INS-82360_BORESIGHT_LINE": 512.5, + "INS-82360_BORESIGHT_SAMPLE": 512.5, + "INS-82360_K1": 8e-06 + }, + "detector_sample_summing": 1, + "detector_line_summing": 1, + "focal_length_model": { + "focal_length": null + }, + "detector_center": { + "line": 512.5, + "sample": 512.5 + }, + "starting_detector_line": 0, + "starting_detector_sample": 0, + "focal2pixel_lines": [ + 0.0, + 0.0, + 83.333333333333 + ], + "focal2pixel_samples": [ + 0.0, + 83.333333333333, + 0.0 + ], + "optical_distortion": { + "radial": { + "coefficients": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + "instrument_position": { + "spk_table_start_time": 376938208.25635386, + "spk_table_end_time": 376938208.25635386, + "spk_table_original_size": 1, + "ephemeris_times": [ + 376938208.25635386 + ], + "positions": [ + [ + 21962.31325652874, + 10152.071521618314, + -3286.8494024992624 + ] + ], + "velocities": [ + [ + 5.4555677148391, + -3.302818436967495, + -0.20369613220714297 + ] + ], + "reference_frame": 1 + }, + "sun_position": { + "spk_table_start_time": 376938208.25635386, + "spk_table_end_time": 376938208.25635386, + "spk_table_original_size": 1, + "ephemeris_times": [ + 376938208.25635386 + ], + "positions": [ + [ + 1342712164.8315928, + 521645737.4508392, + 157522069.42042258 + ] + ], + "velocities": [ + [ + -15.573465467758476, + 5.743806619852782, + 4.859438874986023 + ] + ], + "reference_frame": 1 + } +} \ No newline at end of file diff --git a/tests/pytests/test_cassini_drivers.py b/tests/pytests/test_cassini_drivers.py index 6600c4b027efe8852f3086dcf0eb04844678d047..ec19c3bf99190e0971376d030d8741e379749892 100644 --- a/tests/pytests/test_cassini_drivers.py +++ b/tests/pytests/test_cassini_drivers.py @@ -1,16 +1,16 @@ import pytest import ale import os +import pvl import numpy as np from ale.drivers import co_drivers import unittest from unittest.mock import PropertyMock, patch import json -from conftest import get_image_label, get_image_kernels, get_isd, convert_kernels, compare_dicts +from conftest import get_image_label, get_image_kernels, get_isd, convert_kernels, compare_dicts, get_table_data from ale.drivers.co_drivers import CassiniIssPds3LabelNaifSpiceDriver -from conftest import get_image_kernels, convert_kernels, get_image_label @pytest.fixture() def test_kernels(scope="module", autouse=True): @@ -20,7 +20,7 @@ def test_kernels(scope="module", autouse=True): for kern in binary_kernels: os.remove(kern) -def test_load(test_kernels): +def test_load_pds(test_kernels): label_file = get_image_label("N1702360370_1") compare_dict = get_isd("cassiniiss") @@ -29,6 +29,19 @@ def test_load(test_kernels): print(json.dumps(isd_obj, indent=2)) assert compare_dicts(isd_obj, compare_dict) == [] +def test_load_isis(): + label_file = get_image_label("N1702360370_1", label_type="isis3") + compare_dict = get_isd("cassiniiss_isis") + + def read_detatched_table(table_label, cube): + return get_table_data("N1702360370_1", table_label["Name"]) + + with patch('ale.base.data_isis.read_table_data', side_effect=read_detatched_table): + isd_str = ale.loads(label_file) + isd_obj = json.loads(isd_str) + print(json.dumps(isd_obj, indent=2)) + assert compare_dicts(isd_obj, compare_dict) == [] + # ========= Test cassini pds3label and naifspice driver ========= class test_cassini_pds3_naif(unittest.TestCase):