Skip to content
Snippets Groups Projects
Commit 69379878 authored by Kristin's avatar Kristin
Browse files

:Merge branch 'master' of github.com:USGS-Astrogeology/knoten

parents 6ce49d6e 8492359a
No related branches found
No related tags found
No related merge requests found
...@@ -3,15 +3,20 @@ channels: ...@@ -3,15 +3,20 @@ channels:
- conda-forge - conda-forge
- usgs-astrogeology - usgs-astrogeology
dependencies: dependencies:
- python >= 3
- coveralls - coveralls
- csmapi - csmapi
- gdal - gdal
- jinja2 - jinja2
- jupyter
- matplotlib
- numpy - numpy
- pytest - plio
- pvl
- pyproj - pyproj
- pysis
- pytest
- python>=3
- requests - requests
- scipy - scipy
- matplotlib
- shapely - shapely
- usgscsm
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Comparing a USGSCSM and ISIS camera for Cassini ISS # Comparing a USGSCSM and ISIS camera for Cassini ISS
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import pvl import pvl
import numpy as np import numpy as np
import os import os
import pandas as pd import pandas as pd
import knoten import knoten
import csmapi import csmapi
os.environ['ISISROOT'] = '/usgs/pkgs/isis3.8.0_RC1/install' os.environ['ISISROOT'] = '/usgs/pkgs/isis3.8.0_RC1/install'
from pysis import isis from pysis import isis
from pysis.exceptions import ProcessError from pysis.exceptions import ProcessError
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Make a CSM sensor model ## Make a CSM sensor model
Requires N1702360370_1.LBL and N1702360370_1.IMG in data directory Requires N1702360370_1.LBL and N1702360370_1.IMG in data directory
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
fileName = 'data/N1702360370_1.LBL' fileName = 'data/N1702360370_1.LBL'
camera = knoten.csm.create_csm(fileName) camera = knoten.csm.create_csm(fileName)
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Ingest the image and spiceinit ## Ingest the image and spiceinit
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Set the output location of the resulting .cub # Set the output location of the resulting .cub
cub_loc = os.path.splitext(fileName)[0] + '.cub' cub_loc = os.path.splitext(fileName)[0] + '.cub'
try: try:
isis.ciss2isis(from_=fileName, to=cub_loc) isis.ciss2isis(from_=fileName, to=cub_loc)
except ProcessError as e: except ProcessError as e:
print(e.stderr) print(e.stderr)
try: try:
isis.spiceinit(from_=cub_loc, shape='ellipsoid') isis.spiceinit(from_=cub_loc, shape='ellipsoid')
except ProcessError as e: except ProcessError as e:
print(e.stderr) print(e.stderr)
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Define a function that compares ISIS and USGSCSM pixels ## Define a function that compares ISIS and USGSCSM pixels
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def check_pixel(camera, cub, line, sample): def check_pixel(camera, cub, line, sample):
"""Compares ISIS and USGSCSM pixel. """Compares ISIS and USGSCSM pixel.
Takes an image coordinate, projects it to a ground point using ISIS, then projects 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 the result back into an image coordinate using USGSCSM and computes the difference
between image coordinates. between image coordinates.
""" """
output = isis.campt(from_=cub, line=line, sample=sample) output = isis.campt(from_=cub, line=line, sample=sample)
pvl_output = pvl.loads(output) pvl_output = pvl.loads(output)
bodyfixed = pvl_output['GroundPoint']['BodyFixedCoordinate'] bodyfixed = pvl_output['GroundPoint']['BodyFixedCoordinate']
bodyfixed = np.asarray(bodyfixed.value) * 1000 bodyfixed = np.asarray(bodyfixed.value) * 1000
image_coord = camera.groundToImage(csmapi.EcefCoord(*bodyfixed)) 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 # (.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 line_diff = line - image_coord.line - .5
sample_diff = sample - image_coord.samp - .5 sample_diff = sample - image_coord.samp - .5
return line_diff, sample_diff return line_diff, sample_diff
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Get the total number of lines / samples ## Get the total number of lines / samples
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
isis_label = pvl.load(cub_loc) isis_label = pvl.load(cub_loc)
n_samples = isis_label['IsisCube']['Core']['Dimensions']['Samples'] n_samples = isis_label['IsisCube']['Core']['Dimensions']['Samples']
n_lines = isis_label['IsisCube']['Core']['Dimensions']['Lines'] n_lines = isis_label['IsisCube']['Core']['Dimensions']['Lines']
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Compare top left, top right, bottom left, bottom right, and center pixels using check_pixel ## Compare top left, top right, bottom left, bottom right, and center pixels using check_pixel
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
pixels_dict = {'line' : [1,1,n_lines, n_lines, n_lines/2], pixels_dict = {'line' : [1,1,n_lines, n_lines, n_lines/2],
'sample' : [1, n_samples, 1, n_samples, n_samples/2]} 'sample' : [1, n_samples, 1, n_samples, n_samples/2]}
pixels_df = pd.DataFrame.from_dict(pixels_dict) pixels_df = pd.DataFrame.from_dict(pixels_dict)
pixels_df['line_diff'] = np.NaN pixels_df['line_diff'] = np.NaN
pixels_df['sample_diff'] = np.NaN pixels_df['sample_diff'] = np.NaN
for idx, row in pixels_df.iterrows(): 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.iloc[idx]['line_diff'], pixels_df.iloc[idx]['sample_diff'] = check_pixel(camera, cub_loc, row['line'], row['sample'])
pixels_df pixels_df
``` ```
%% Output %% Output
line sample line_diff sample_diff line sample line_diff sample_diff
0 1.0 1.0 -1020.486363 -1024.409488 0 1.0 1.0 0.153039 0.906085
1 1.0 1024.0 -1020.472731 1022.315882 1 1.0 1024.0 0.142231 0.326977
2 1024.0 1.0 1026.247265 -1024.418200 2 1024.0 1.0 -0.425122 0.915083
3 1024.0 1024.0 1026.260599 1022.307325 3 1024.0 1024.0 -0.435769 0.335980
4 512.0 512.0 1.888677 -2.053929 4 512.0 512.0 -0.142021 0.620648
......
{"radii": {"semimajor": 482.1, "semiminor": 445.94, "unit": "km"}, "sensor_position": {"positions": [[258050.2687983894, 14326.958947727007, -4862493.832226484]], "velocities": [[-104.7145626143671, -85.03261098015915, -5.786975988636929]], "unit": "m"}, "sun_position": {"positions": [[360880681.08749247, 246471123.80357987, 30565891.31704259, 47397.508212291505]], "velocities": [[47397.508212291505, -69397.53747853675, 0.19335721325156585]], "unit": "m"}, "sensor_orientation": {"quaternions": [[0.001892487545803033, 0.021367862646678643, -0.2778085145572912, -0.9603969294912772]]}, "detector_sample_summing": 1, "detector_line_summing": 1, "focal_length_model": {"focal_length": 150.08}, "detector_center": {"line": 511.5, "sample": 511.5}, "starting_detector_line": 1, "starting_detector_sample": 1, "focal2pixel_lines": [0.0, 0.0, 71.40816909454442], "focal2pixel_samples": [0.0, 71.40816909454442, 0.0], "optical_distortion": {"dawnfc": {"coefficients": [9.2e-06]}}, "image_lines": 1024, "image_samples": 1024, "name_platform": "DAWN", "name_sensor": "FRAMING CAMERA 2", "reference_height": {"maxheight": 1000, "minheight": -1000, "unit": "m"}, "name_model": "USGS_ASTRO_FRAME_SENSOR_MODEL", "center_ephemeris_time": 488002614.62253857}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment