Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amystamile-usgs committed Dec 12, 2023
1 parent 4e3b411 commit f542b4e
Show file tree
Hide file tree
Showing 16 changed files with 23,825 additions and 26 deletions.
66 changes: 54 additions & 12 deletions ale/drivers/dawn_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ def ikid(self):

@property
def sensor_frame_id(self):
"""
Returns the FRAME_DAWN_VIR_{VIS/IR}_ZERO Naif ID code if there are no associated articulation kernels.
Otherwise the original Naif ID code is returned.
Returns
-------
: int
Naif ID code for the sensor frame
"""
if self.has_articulation_kernel:
lookup_table = {
'VIS': -203211,
Expand Down Expand Up @@ -580,33 +588,67 @@ def ephemeris_times(self):

@property
def ephemeris_start_time(self):
try:
# first line's middle et - 1/2 exposure duration = cube start time
return self.ephemeris_times[0] - (self.line_exposure_duration / 2)
except:
return spice.scs2e(self.spacecraft_id, self.label['IsisCube']['Instrument']['SpacecraftClockStartCount'])
"""
Returns the starting ephemeris time of the image using the first et time from
the housekeeping table minus the line exposure duration / 2.
Returns
-------
: double
Starting ephemeris time of the image
"""
return self.ephemeris_times[0] - (self.line_exposure_duration / 2)


@property
def ephemeris_stop_time(self):
try:
# last line's middle et + 1/2 exposure duration = cube end time
return self.ephemeris_times[-1] + (self.line_exposure_duration / 2)
except:
return spice.scs2e(self.spacecraft_id, self.label['IsisCube']['Instrument']['SpacecraftClockStopCount'])
"""
Returns the ephemeris stop time of the image using the last et time from
the housekeeping table plus the line exposure duration / 2.
Returns
-------
: double
Ephemeris stop time of the image
"""
return self.ephemeris_times[-1] + (self.line_exposure_duration / 2)

@property
def is_calibrated(self):
"""
Checks if image is calibrated.
Returns
-------
: bool
"""
return self.label['IsisCube']['Archive']['ProcessingLevelId'] > 2

@property
def has_articulation_kernel(self):
regex = re.compile('.*dawn_vir_[0-9]{9}_[0-9]{1}.BC')
return any([re.match(regex, i) for i in self.kernels])
"""
Checks if articulation kernel exists in pool of kernels.
Returns
-------
: bool
"""
try:
regex = re.compile('.*dawn_vir_[0-9]{9}_[0-9]{1}.BC')
return any([re.match(regex, i) for i in self.kernels])
except ValueError:
return False

@property
def inst_pointing_rotation(self):
"""
Returns a time dependent instrument pointing rotation for -203221 and -203223 sensor frame ids.
Returns
-------
: TimeDependentRotation
Instrument pointing rotation
"""
time_dep_quats = np.zeros((len(self.ephemeris_times), 4))
avs = []

Expand Down
8 changes: 4 additions & 4 deletions notebooks/write_DawnVirIsisLabelNaifSpiceDriver.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"metadata": {},
"outputs": [],
"source": [
"fileName = '/Users/astamile/testData/ale/dawnVIR/VIR_IR_1A_1_362681634_1_isis3.cub'\n",
"fileName = 'VIR_IR_1A_1_362681634_1_isis3.cub'\n",
"\n",
"import os\n",
"os.environ[\"ISISDATA\"] = \"/Users/astamile/testData/ale/dawnVIR/kernels\"\n",
"os.environ[\"ISISTESTDATA\"] = \"/Users/astamile/isisdata/isis_testData\"\n",
"os.environ[\"ISISROOT\"] = \"/Users/astamile/ISIS3/build\"\n",
"os.environ[\"ISISDATA\"] = \"isisdata/isis_data\"\"\n",
"os.environ[\"ISISTESTDATA\"] = \"/isisdata/isis_testData\"\n",
"os.environ[\"ISISROOT\"] = \"/ISIS3/build\"\n",
"\n",
"import ale \n",
"from ale.drivers.dawn_drivers import DawnVirIsisNaifSpiceDriver\n",
Expand Down
Loading

0 comments on commit f542b4e

Please sign in to comment.