Skip to content
Snippets Groups Projects
Commit 38b8cf7e authored by Summer Stapleton's avatar Summer Stapleton Committed by Jesse Mapel
Browse files

Implementation of _naif_keywords in NaifSpice() along with tests for it and...

Implementation of _naif_keywords in NaifSpice() along with tests for it and properties I had to add for it. (#161)
parent 4239af27
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,14 @@ class NaifSpice():
def spacecraft_id(self):
return spice.bods2c(self.spacecraft_name)
@property
def target_id(self):
return spice.bods2c(self.target_name)
@property
def body_frame_code(self):
return spice.gipool('BODY_FRAME_CODE', 0, 1)
@property
def focal2pixel_lines(self):
return list(spice.gdpool('INS{}_ITRANSL'.format(self.ikid), 0, 3))
......@@ -80,6 +88,21 @@ class NaifSpice():
def _focal_length(self):
return float(spice.gdpool('INS{}_FOCAL_LENGTH'.format(self.ikid), 0, 1)[0])
@property
def pixel_size(self):
return spice.gdpool('INS{}_PIXEL_SIZE'.format(self.ikid), 0, 1)[0] * 0.001
@property
def _radii(self):
"""
Returns
-------
: list<double>
Radius of all three axis of the target body
"""
rad = spice.bodvrd(self.target_name, 'RADII', 3)
return rad[1]
@property
def _semimajor(self):
"""
......@@ -194,3 +217,18 @@ class NaifSpice():
@property
def detector_center_line(self):
return float(spice.gdpool('INS{}_BORESIGHT_LINE'.format(self.ikid), 0, 1)[0])
@property
def _naif_keywords(self):
naif_keywords = dict()
naif_keywords['BODY{}_RADII'.format(self.target_id)] = self._radii
naif_keywords['BODY_FRAME_CODE'] = self.body_frame_code
naif_keywords['INS{}_PIXEL_SIZE'.format(self.ikid)] = self.pixel_size
naif_keywords['INS{}_ITRANSL'.format(self.ikid)] = self.focal2pixel_lines
naif_keywords['INS{}_ITRANSS'.format(self.ikid)] = self.focal2pixel_samples
naif_keywords['INS{}_FOCAL_LENGTH'.format(self.ikid)] = self._focal_length
naif_keywords['INS{}_BORESIGHT_SAMPLE'.format(self.ikid)] = self.detector_center_sample
naif_keywords['INS{}_BORESIGHT_LINE'.format(self.ikid)] = self.detector_center_line
return naif_keywords
......@@ -7,6 +7,8 @@ class SimpleSpice():
return -12345
def gdpool(self, key, x, length):
return np.ones(length)
def gipool(self, key, x, length):
return np.arange(length)
def bodvrd(self, key, x, length):
return (3, np.ones(length,))
def spkpos(self, *args):
......
import pytest
import numpy as np
from ale.base import data_naif
# 'Mock' the spice module where it is imported
from conftest import SimpleSpice
simplespice = SimpleSpice()
data_naif.spice = simplespice
@pytest.fixture
def test_naif_data():
naif_data = data_naif.NaifSpice()
naif_data.instrument_id = "INSTRUMENT"
naif_data.target_name = "TARGET"
return naif_data
def test_target_id(test_naif_data):
assert test_naif_data.target_id == -12345
def test_pixel_size(test_naif_data):
assert test_naif_data.pixel_size == (0.001)
def test_radii(test_naif_data):
np.testing.assert_equal(test_naif_data._radii, np.ones(3))
def test_naif_keywords(test_naif_data):
np.testing.assert_equal(test_naif_data._naif_keywords['BODY-12345_RADII'], np.ones(3))
np.testing.assert_equal(test_naif_data._naif_keywords['BODY_FRAME_CODE'], np.arange(1))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_PIXEL_SIZE'], (0.001))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_ITRANSL'], np.ones(3))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_ITRANSS'], np.ones(3))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_FOCAL_LENGTH'], np.ones(1))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_BORESIGHT_LINE'], np.ones(1))
np.testing.assert_equal(test_naif_data._naif_keywords['INS-12345_BORESIGHT_SAMPLE'], np.ones(1))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment