Skip to content
Snippets Groups Projects
Commit 224a72c6 authored by Kristin's avatar Kristin Committed by Jesse Mapel
Browse files

Adds Cassini Comparison Notebook (#28)

* Added Cassini ISS notebook

* Update Cassini notebook based on comments and update environment.yml to add shapely

* Added cassini comparison notebook
parent 53e63f19
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Comparing a USGSCSM and ISIS camera for Cassini ISS
%% Cell type:code id: tags:
``` python
import pvl
import numpy as np
import os
import pandas as pd
import knoten
import csmapi
os.environ['ISISROOT'] = '/usgs/pkgs/isis3.8.0_RC1/install'
from pysis import isis
from pysis.exceptions import ProcessError
```
%% Cell type:markdown id: tags:
## Make a CSM sensor model
Requires N1702360370_1.LBL and N1702360370_1.IMG in data directory
%% Cell type:code id: tags:
``` python
fileName = 'data/N1702360370_1.LBL'
camera = knoten.csm.create_csm(fileName)
```
%% Cell type:markdown id: tags:
## Ingest the image and spiceinit
%% Cell type:code id: tags:
``` python
# Set the output location of the resulting .cub
cub_loc = os.path.splitext(fileName)[0] + '.cub'
try:
isis.ciss2isis(from_=fileName, to=cub_loc)
except ProcessError as e:
print(e.stderr)
try:
isis.spiceinit(from_=cub_loc, shape='ellipsoid')
except ProcessError as e:
print(e.stderr)
```
%% Cell type:markdown id: tags:
## Define a function that compares ISIS and USGSCSM pixels
%% Cell type:code id: tags:
``` python
def check_pixel(camera, cub, line, sample):
"""Compares ISIS and USGSCSM pixel.
Takes an image coordinate, projects it to a ground point using ISIS, then projects
the result back into an image coordinate using USGSCSM and computes the difference
between image coordinates.
"""
output = isis.campt(from_=cub, line=line, sample=sample)
pvl_output = pvl.loads(output)
bodyfixed = pvl_output['GroundPoint']['BodyFixedCoordinate']
bodyfixed = np.asarray(bodyfixed.value) * 1000
image_coord = camera.groundToImage(csmapi.EcefCoord(*bodyfixed))
# (.5,.5) in CSM == (1,1) in ISIS, so we have to subtract (.5,.5) from the ISIS pixels
line_diff = line - image_coord.line - .5
sample_diff = sample - image_coord.samp - .5
return line_diff, sample_diff
```
%% Cell type:markdown id: tags:
## Get the total number of lines / samples
%% Cell type:code id: tags:
``` python
isis_label = pvl.load(cub_loc)
n_samples = isis_label['IsisCube']['Core']['Dimensions']['Samples']
n_lines = isis_label['IsisCube']['Core']['Dimensions']['Lines']
```
%% Cell type:markdown id: tags:
## Compare top left, top right, bottom left, bottom right, and center pixels using check_pixel
%% Cell type:code id: tags:
``` python
pixels_dict = {'line' : [1,1,n_lines, n_lines, n_lines/2],
'sample' : [1, n_samples, 1, n_samples, n_samples/2]}
pixels_df = pd.DataFrame.from_dict(pixels_dict)
pixels_df['line_diff'] = np.NaN
pixels_df['sample_diff'] = np.NaN
for idx, row in pixels_df.iterrows():
pixels_df.iloc[idx]['line_diff'], pixels_df.iloc[idx]['sample_diff'] = check_pixel(camera, cub_loc, row['line'], row['sample'])
pixels_df
```
%% Output
line sample line_diff sample_diff
0 1.0 1.0 -1020.486363 -1024.409488
1 1.0 1024.0 -1020.472731 1022.315882
2 1024.0 1.0 1026.247265 -1024.418200
3 1024.0 1024.0 1026.260599 1022.307325
4 512.0 512.0 1.888677 -2.053929
File added
PDS_VERSION_ID = PDS3
/* FILE CHARACTERISTICS */
RECORD_TYPE = FIXED_LENGTH
RECORD_BYTES = 1048
FILE_RECORDS = 1028
/* POINTERS TO DATA OBJECTS */
^IMAGE_HEADER = ("N1702360370_1.IMG",1)
^TELEMETRY_TABLE = ("N1702360370_1.IMG",4)
^LINE_PREFIX_TABLE = ("N1702360370_1.IMG",5)
^IMAGE = ("N1702360370_1.IMG",5)
/* IDENTIFICATION DATA ELEMENTS */
ANTIBLOOMING_STATE_FLAG = "OFF"
BIAS_STRIP_MEAN = 8.850293
CALIBRATION_LAMP_STATE_FLAG = "N/A"
COMMAND_FILE_NAME = "trigger_3618_1.ioi"
COMMAND_SEQUENCE_NUMBER = 3618
DARK_STRIP_MEAN = 0.269221
DATA_CONVERSION_TYPE = "TABLE"
DATA_SET_ID = "CO-S-ISSNA/ISSWA-2-EDR-V1.0"
DELAYED_READOUT_FLAG = "NO"
DESCRIPTION = "Incomplete product finalized due to truncated lines."
DETECTOR_TEMPERATURE = -89.243546 <DEGC>
EARTH_RECEIVED_START_TIME = 2011-346T22:30:08.981
EARTH_RECEIVED_STOP_TIME = 2011-346T22:30:49.765
ELECTRONICS_BIAS = 112
EXPECTED_MAXIMUM = (62.996498,69.454498)
EXPECTED_PACKETS = 576
EXPOSURE_DURATION = 4600.000000
FILTER_NAME = ("CL1","UV3")
FILTER_TEMPERATURE = 0.248629
FLIGHT_SOFTWARE_VERSION_ID = "1.4"
GAIN_MODE_ID = "29 ELECTRONS PER DN"
IMAGE_MID_TIME = 2011-346T05:02:22.073
IMAGE_NUMBER = "1702360370"
IMAGE_OBSERVATION_TYPE = {"SCIENCE"}
IMAGE_TIME = 2011-346T05:02:24.373
INSTRUMENT_DATA_RATE = 182.783997
INSTRUMENT_HOST_NAME = "CASSINI ORBITER"
INSTRUMENT_ID = "ISSNA"
INSTRUMENT_MODE_ID = "FULL"
INSTRUMENT_NAME = "IMAGING SCIENCE SUBSYSTEM - NARROW ANGLE"
INST_CMPRS_PARAM = ("N/A","N/A","N/A","N/A")
INST_CMPRS_RATE = (5.333330,3.631307)
INST_CMPRS_RATIO = 2.203063
INST_CMPRS_TYPE = "LOSSLESS"
LIGHT_FLOOD_STATE_FLAG = "ON"
METHOD_DESC = "ISSPT2.7;Enceladus;ISS_158EN_ENCEL001_PRIME"
MISSING_LINES = 31
MISSING_PACKET_FLAG = "NO"
MISSION_NAME = "CASSINI-HUYGENS"
MISSION_PHASE_NAME = "EXTENDED-EXTENDED MISSION"
OBSERVATION_ID = "ISS_158EN_ENCEL001_PRIME"
OPTICS_TEMPERATURE = (0.627499,1.905708)
ORDER_NUMBER = 16
PARALLEL_CLOCK_VOLTAGE_INDEX = 9
PREPARE_CYCLE_INDEX = 4
PRODUCT_CREATION_TIME = 2011-346T15:34:07.000
PRODUCT_ID = "1_N1702360370.120"
PRODUCT_VERSION_TYPE = "FINAL"
READOUT_CYCLE_INDEX = 6
RECEIVED_PACKETS = 523
SENSOR_HEAD_ELEC_TEMPERATURE = 1.633024
SEQUENCE_ID = "S71"
SEQUENCE_NUMBER = 16
SEQUENCE_TITLE = "ISS_158EN_ENCEL001_PRIME"
SHUTTER_MODE_ID = "NACONLY"
SHUTTER_STATE_ID = "ENABLED"
SOFTWARE_VERSION_ID = "ISS 11.00 05-24-2006"
SPACECRAFT_CLOCK_CNT_PARTITION = 1
SPACECRAFT_CLOCK_START_COUNT = "1702360365.220"
SPACECRAFT_CLOCK_STOP_COUNT = "1702360370.120"
START_TIME = 2011-346T05:02:19.773
STOP_TIME = 2011-346T05:02:24.373
TARGET_DESC = "Enceladus"
TARGET_LIST = "N/A"
TARGET_NAME = "ENCELADUS"
TELEMETRY_FORMAT_ID = "S&ER3"
VALID_MAXIMUM = (4095,4095)
OBJECT = IMAGE_HEADER
INTERCHANGE_FORMAT = ASCII
HEADER_TYPE = VICAR2
BYTES = 3144
RECORDS = 1
^DESCRIPTION = "../../label/vicar2.txt"
END_OBJECT = IMAGE_HEADER
OBJECT = TELEMETRY_TABLE
INTERCHANGE_FORMAT = BINARY
ROWS = 1
COLUMNS = 2
ROW_BYTES = 1048
^STRUCTURE = "../../label/tlmtab.fmt"
OBJECT = COLUMN
NAME = NULL_PADDING
DATA_TYPE = MSB_UNSIGNED_INTEGER
START_BYTE = 61
BYTES = 987
END_OBJECT = COLUMN
END_OBJECT = TELEMETRY_TABLE
OBJECT = LINE_PREFIX_TABLE
INTERCHANGE_FORMAT = BINARY
ROWS = 1024
COLUMNS = 7
ROW_BYTES = 24
ROW_SUFFIX_BYTES = 1024
^LINE_PREFIX_STRUCTURE = "../../label/prefix3.fmt"
END_OBJECT = LINE_PREFIX_TABLE
OBJECT = IMAGE
LINES = 1024
LINE_SAMPLES = 1024
SAMPLE_BITS = 8
SAMPLE_TYPE = SUN_INTEGER
LINE_PREFIX_BYTES = 24
END_OBJECT = IMAGE
END
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment