From 565879045111a98272b0d77fc39bad015834189e Mon Sep 17 00:00:00 2001 From: Kelvin Date: Wed, 30 Oct 2024 12:26:37 -0700 Subject: [PATCH] fixed syntax error --- ale/base/base.py | 2 +- ale/drivers/apollo_drivers.py | 218 +++++++++++++++++++++++++++++++++- 2 files changed, 218 insertions(+), 2 deletions(-) diff --git a/ale/base/base.py b/ale/base/base.py index 5e840d74a..929a6eabd 100644 --- a/ale/base/base.py +++ b/ale/base/base.py @@ -94,7 +94,7 @@ def get_property(prop_name): for prop in properties: data[prop] = get_property(prop) if prop == "line_scan_rate": - end = time.time() + end = time.time() start = time.time() with ThreadPool() as pool: diff --git a/ale/drivers/apollo_drivers.py b/ale/drivers/apollo_drivers.py index 3dd3fb85a..0411a5114 100644 --- a/ale/drivers/apollo_drivers.py +++ b/ale/drivers/apollo_drivers.py @@ -135,4 +135,220 @@ def detector_center_sample(self): list : The center of the CCD formatted as line, sample """ - return float(self.naif_keywords['INS{}_BORESIGHT'.format(self.ikid)][1]) + return float(spice.gdpool('INS{}_BORESIGHT'.format(self.ikid), 0, 3)[1]) + + +class ApolloPanIsisLabelIsisSpiceDriver(LineScanner, IsisLabel, IsisSpice, NoDistortion, Driver): + + @property + def instrument_id(self): + """ + The name of the instrument. + + Returns + ------- + str + The short text name for the instrument + """ + id_lookup = { + "APOLLO_PAN": "APOLLO PANORAMIC CAMERA" + } + + return id_lookup[super().instrument_id] + + + @property + def instrument_name(self): + """ + The name of the instrument. + + Returns + ------- + str + The short text name for the instrument + """ + return "APOLLO PANORAMIC CAMERA" + + @property + def sensor_model_version(self): + """ + The ISIS Sensor model number for ApolloPanCamera in ISIS. + + Returns + ------- + : int + ISIS sensor model version + """ + return 1 + + + @property + def focal2pixel_lines(self): + """ + The line component of the affine transformation + from focal plane coordinates to centered ccd pixels. + + This information is not contained in the label, so it is + hard-coded to match apollo kernels. + + Returns + ------- + list : + The coefficients of the affine transformation + formatted as constant, x, y + """ + return (0.0, 0.0, 200.0) + + @property + def focal2pixel_samples(self): + """ + The sample component of the affine transformation + from focal plane coordinates to centered ccd pixels + + This information is not contained in the label, so it is + hard-coded to match apollo kernels. + + Returns + ------- + list : + The coefficients of the affine transformation + formatted as constant, x, y + """ + return (0.0, 200.0, 0.0) + + @property + def pixel2focal_x(self): + """ + Returns detector to focal plane x. + + This information is not contained in the label, so it is + hard-coded to match apollo kernels. + + Returns + ------- + : list + detector to focal plane x + """ + return (0.0, 0.005, 0.0) + + + @property + def pixel2focal_y(self): + """ + Returns detector to focal plane y. + + This information is not contained in the label, so it is + hard-coded to match apollo kernels. + + Returns + ------- + : list + detector to focal plane y + """ + return (0.0, 0.0, 0.0) + + + @property + def focal_length(self): + """ + The focal length of the instrument + Hard-coded to return the same value as Isis::ApolloPanoramicCamera.cpp + + Returns + ------- + float : + The focal length in millimeters + """ + return 610.0 + + + @property + def ephemeris_start_time(self): + """ + The image start time in ephemeris time + The only time information written to the label by apollopaninit is UTC time, + so this pulls from tables. + + Returns + ------- + float : + The image start ephemeris time + """ + isis_bytes = read_table_data(self.label['Table'], self._file) + return parse_table(self.label['Table'], isis_bytes)['ET'][0] + + + @property + def target_body_radii(self): + + """ + The triaxial radii of the target body + This information is not added to the label by apollopaninit, so it + is pulled from kernels. + + Returns + ------- + list : + The body radii in kilometers. For most bodies, + this is formatted as semimajor, semimajor, + semiminor + """ + return (1737.4, 1737.4, 1737.4) + + + @property + def detector_center_line(self): + """ + The center line of the CCD in detector pixels + This information is not recorded in the label by apollopaninit, so this is + hard-coded to match the apollo kernels. + + Returns + ------- + list : + The center line of the CCD + """ + if self.spacecraft_name == "APOLLO16": + return 11503.5 + else: + return 11450.5 + + + @property + def detector_center_sample(self): + """ + The center sample of the CCD in detector pixels + This information is not recorded in the label by apollopaninit, so this is + hard-coded to match the apollo kernels. + + Returns + ------- + list : + The center sample of the CCD + """ + if self.spacecraft_name == "APOLLO16": + return 115537.5 + else: + return 11450.5 + + + @property + def naif_keywords(self): + """ + Apollopaninit doesn't create naif keywords section, so populate it manually here. + Only includes the NAIF keywords that are necessary for the ALE formatter. + ------- + : dict + Dictionary of NAIF keywords that are normally attached to the label + """ + return {"BODY301_RADII": self.target_body_radii, + "BODY_FRAME_CODE": self.target_frame_id, + f"INS{self.ikid}_CONSTANT_TIME_OFFSET": 0, + f"INS{self.ikid}_ADDITIONAL_PREROLL": 0, + f"INS{self.ikid}_ADDITIVE_LINE_ERROR": 0, + f"INS{self.ikid}_MULTIPLI_LINE_ERROR": 0, + f"INS{self.ikid}_TRANSX": self.pixel2focal_x, + f"INS{self.ikid}_TRANSY": self.pixel2focal_y, + f"INS{self.ikid}_ITRANSS": self.focal2pixel_samples, + f"INS{self.ikid}_ITRANSL": self.focal2pixel_lines, + "BODY_CODE": 301}