Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/instrument_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ cassini_iss
:members:
:show-inheritance:
:inherited-members:

galileo_ssi
-----------
.. automodule:: instrument_models.galileo_ssi
.. autoclass:: GalileoSSI
:members:
:show-inheritance:
:inherited-members:
90 changes: 90 additions & 0 deletions instrument_models/galileo_ssi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from astropy import units as astro_units

from .instrument import InstrumentBase


class GalileoSSI(InstrumentBase):
"""Model to get the filter wavelength from Galileo Solid State Imaging
(SSI) experiment imagery

See `SSI Raw Experiment Data Record (REDR) for Phase 2'
<https://pds-imaging.jpl.nasa.gov/data/go-j_jsa-ssi-2-redr-v1.0/go_0023/document/redrsis.pdf>`_
and
see 'Calibration And Performance Of The Galileo Solid-state Imaging
System In Jupiter Orbit`
<http://authors.library.caltech.edu/70894/1/1178_1.pdf>`_
for table of filter name, number, and corresponding wavelengths.
We use the effective (solar radiance) wavelength.

Attributes
----------
SSI_filters : :obj:`dict`
Dictionary of the Galileo Solid State Imaging (SSI) experiment
filter names and wavelengths

Key is the filter name and filter number and the value is the
wavelength in nm

unit : :obj:`str`
The default unit is ``nm``
"""

SSI_filters = {
'CLEAR, 0': 624.7,
'GREEN, 1': 559.0,
'RED, 2': 663.6,
'VIOLET, 3': 413.7,
'IR-7560, 4': 756.8,
'IR-9680, 5': 989.7,
'IR-7270, 6': 731.1,
'IR-8890, 7': 887.6,
}

unit = 'nm'

@property
def filter_name(self):
""":obj:`str` : The image's filter names joined by a comma and space

For example, in the label the filtername appears as ``("CLEAR","0")``
and so :attr:`filter_name` returns ``'CLEAR, 0'``
"""

filter_name = ', '.join(self.label['FILTER_NAME'])
return filter_name

@property
def is_SSI(self):
""":obj:`bool` : ``True`` if image is SSI"""
SSI_key = 'SOLID STATE IMAGING SYSTEM'
is_SSI = self.label['INSTRUMENT_NAME'] == SSI_key
return is_SSI

def get_wavelength(self, unit='nm'):
"""Get the image's filter wavelength

Parameters
----------
unit : :obj:`str` [``nm``]
The desired wavelength of the unit

Returns
-------
wavelength : :obj:`float`
The image's filter wavelength rounded to 1 decimal.
"""

if self.is_SSI:
filters = self.SSI_filters
else:
filters = None

if filters is not None:
wavelength = filters.get(self.filter_name)
wavelength = wavelength if wavelength is not None else float('nan')
else:
wavelength = float('nan')

wavelength = wavelength * astro_units.Unit(self.unit)
wavelength = wavelength.to(astro_units.Unit(unit))
return round(wavelength.value, 1)
27 changes: 27 additions & 0 deletions instrument_models/get_wavelength.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .pancam import Pancam
from .mastcam import Mastcam
from .cassini_iss import CassiniISS
from .galileo_ssi import GalileoSSI

instrument_name_key = 'INSTRUMENT_NAME'

Expand Down Expand Up @@ -89,6 +90,27 @@ def is_cassini_ISS(label):
return is_cassini_ISS


@is_instrument
def is_galileo_SSI(label):
"""Determine if label is for a Galileo Solid State Imaging experiment image

Parameters
----------
label : :class:`pvl.PVLModule`
Image's label

Returns
-------
is_galileo_SSI : :obj:`bool`
``True`` if label is from a Galileo SSI image, ``False`` otherwise
"""

is_galileo_SSI = 'SOLID STATE IMAGING SYSTEM' in label.get(
instrument_name_key
)
return is_galileo_SSI


def get_wavelength(label, unit):
"""Get the filter wavelength from the label of an image

Expand Down Expand Up @@ -120,6 +142,9 @@ def get_wavelength(label, unit):

instrument_models.cassini_iss.CassiniISS.get_wavelength : Get Cassini ISS
wavelength

instrument_models.galileo_ssi.GalileoSSI.get_wavelength : Get Galileo SSI
wavelength
"""

if is_pancam(label):
Expand All @@ -128,6 +153,8 @@ def get_wavelength(label, unit):
instrument = Mastcam(label)
elif is_cassini_ISS(label):
instrument = CassiniISS(label)
elif is_galileo_SSI(label):
instrument = GalileoSSI(label)
else:
instrument = None

Expand Down
4 changes: 3 additions & 1 deletion supported_instruments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
* MSL
* Mastcam
* Cassini
* Imaging Science Subsystem (ISS)
* Imaging Science Subsystem (ISS)
* Galileo
* Solid State Imaging (SSI) experiment
15 changes: 13 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
test_dir, '1p134482118erp0902p2600r8m1.img')
FILE_6 = os.path.join(
test_dir, '0047MH0000110010100214C00_DRCL.IMG')
FILE_7 = os.path.join(
test_dir, '6413r.img')
FILE_1_NAME = os.path.basename(FILE_1)
FILE_2_NAME = os.path.basename(FILE_2)
FILE_3_NAME = os.path.basename(FILE_3)
FILE_4_NAME = os.path.basename(FILE_4)
FILE_5_NAME = os.path.basename(FILE_5)
FILE_6_NAME = os.path.basename(FILE_6)
FILE_7_NAME = os.path.basename(FILE_7)

TEST_FILES = [FILE_1, FILE_2, FILE_3, FILE_4, FILE_5]
TEST_FILES = [FILE_1, FILE_2, FILE_3, FILE_4, FILE_5, FILE_6, FILE_7]
TEST_FILE_NAMES = [
FILE_1_NAME, FILE_2_NAME, FILE_3_NAME, FILE_4_NAME, FILE_5_NAME
FILE_1_NAME, FILE_2_NAME, FILE_3_NAME, FILE_4_NAME, FILE_5_NAME, FILE_6_NAME, FILE_7_NAME
]

SAMPLE_ROI = os.path.join(
Expand Down Expand Up @@ -80,6 +83,14 @@
}
)

SSI_label = pvl.PVLModule(
{
'INSTRUMENT_NAME': 'SOLID STATE IMAGING EXPERIMENT',
'FILTER_NAME': ["CLEAR", "0"],

}
)

EMPTY_LABEL = pvl.PVLModule(
{
'INSTRUMENT_NAME': 'EMPTY',
Expand Down
28 changes: 28 additions & 0 deletions tests/test_galileo_ssi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest

from instrument_models.galileo_ssi import GalileoSSI

import numpy as np

from . import SSI_label, EMPTY_LABEL


class TestGalileoSSI(object):

SSI = GalileoSSI(SSI_label)
EMPTY = GalileoSSI(EMPTY_LABEL)

def test_filter_name(self):
assert self.SSI.filter_name == 'CLEAR, 0'

@pytest.mark.parametrize(
'unit, wavelength',
[
('nm', 624.700),
('um', 0.625),
('AA', 6247.000)
]
)
def test_get_wavelength(self, unit, wavelength):
assert self.SSI.get_wavelength(unit) == wavelength
assert np.isnan(self.EMPTY.get_wavelength(unit))
5 changes: 4 additions & 1 deletion tests/test_get_wavelength.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import FILE_2, mastcam_label1, NA_label, WA_label
from . import FILE_2, mastcam_label1, NA_label, WA_label, SSI_label

import pvl
import math
Expand Down Expand Up @@ -49,6 +49,9 @@ def test_is_mastcam(label, expected):
(WA_label, 'nm', 752.354),
(WA_label, 'um', 0.752),
(WA_label, 'AA', 7523.540),
(SSI_label, 'nm', 624.700),
(SSI_label, 'um', 0.625),
(SSI_label, 'AA', 6247.000),
(mock_label, 'nm', float('nan')),
(mock_label, 'um', float('nan')),
(mock_label, 'AA', float('nan')),
Expand Down