<jupyter_start><jupyter_text>Comparing a USGSCSM and ISIS camera for Dawn FC<jupyter_code>import os 
import tempfile
import pvl
os.environ["ISISROOT"] = "/usgs/pkgs/isis3"

import pysis
from pysis import isis

import knoten
from knoten import vis

import json

import ale
from ale import util
from ale.drivers.dawn_drivers import DawnFcPds3NaifSpiceDriver
from ale.formatters.usgscsm_formatter import to_usgscsm

from IPython.display import Image

import plotly
plotly.offline.init_notebook_mode(connected=True)<jupyter_output><empty_output><jupyter_text>Make a CSM sensor model<jupyter_code>imageLink = 'https://pdsimage.wr.usgs.gov/Missions/Dawn/Ceres/DWNCSFC2_1A/DATA/IMG/20150604_SURVEY/20150617_CYCLE5/FC21A0038582_15170161546F6F.IMG'
!wget -N -P data/ {imageLink}
fileName = 'data/' + os.path.split(imageLink)[1]

camera = knoten.csm.create_csm(fileName)<jupyter_output>--2019-08-02 16:03:52--  https://pdsimage.wr.usgs.gov/Missions/Dawn/Ceres/DWNCSFC2_1A/DATA/IMG/20150604_SURVEY/20150617_CYCLE5/FC21A0038582_15170161546F6F.IMG
Resolving pdsimage.wr.usgs.gov (pdsimage.wr.usgs.gov)... 172.16.58.3
Connecting to pdsimage.wr.usgs.gov (pdsimage.wr.usgs.gov)|172.16.58.3|:443... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘data/FC21A0038582_15170161546F6F.IMG’ not modified on server. Omitting download.<jupyter_text>Ingest the image, run spiceinit, and create an isd<jupyter_code># Set the output location of the resulting .cub
cub_loc = os.path.splitext(fileName)[0] + '.cub'

try: 
    isis.dawnfc2isis(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)

# Create temp metakernel using the same kernels from the spincinit'd cube,
# update the config to point to temp directory, and create driver
# using the temp metakernel
img_label = pvl.load(cub_loc)
year = img_label['IsisCube']['Instrument']['StartTime'].year

with tempfile.NamedTemporaryFile("r+") as metakernel:
    metakernel_path = os.path.split(metakernel.name)[0]
    metakernel.name = metakernel_path + '/dawn_{}.tm'.format(year)
    util.write_metakernel_from_cube(cub_loc, metakernel.name)

    ale.config['dawn'] = metakernel_path
    with DawnFcPds3NaifSpiceDriver(fileName) as driver:
        usgscsmString = to_usgscsm(driver)
        usgscsm_dict = json.loads(usgscsmString)

        csm_isd = os.path.splitext(fileName)[0] + '.json'
        json.dump(usgscsm_dict, open(csm_isd, 'w'))<jupyter_output><empty_output><jupyter_text>Compute and display differences between USGSCSM and ISIS<jupyter_code>csmisis_diff_lv_plot, csmisis_diff_ephem_plot, external_orientation_data = vis.external_orientation_diff(csm_isd, cub_loc, 10, 50, 600, 600)
csmisis_diff_lv_plot_bytes = csmisis_diff_lv_plot.to_image(format="png")
csmisis_diff_ephem_plot_bytes = csmisis_diff_ephem_plot.to_image(format="png")
Image(csmisis_diff_lv_plot_bytes)
Image(csmisis_diff_ephem_plot_bytes)
external_orientation_data[['diffx', 'diffy', 'diffz', 'diffu', 'diffv', 'diffw']].describe()
isis2csm_plot, csm2isis_plot, isiscsm_plotlatlon, isiscsm_plotbf, isis2csm_data, csm2isis_data, isiscsm_latlondata, isiscsm_bfdata = vis.reprojection_diff(csm_isd, cub_loc, 10, 50, 500, 500)
Image(isis2csm_plot.to_image())
isis2csm_data[['diff line', 'diff sample']].describe()
Image(csm2isis_plot.to_image())
csm2isis_data[['diff line', 'diff sample']].describe()
Image(isiscsm_plotlatlon.to_image())
Image(isiscsm_plotbf.to_image())
isiscsm_bfdata[['diffx', 'diffy', 'diffz']].describe()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11609864228318094, 'fraction_numerical': 0.04793571626489332, 'mean_word_length': 6.616033755274262, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '139581', 'license': 'Unlicense', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1435, 'n_words': 241, 'path': 'examples/dawn_fc_isis_cmp.ipynb', 'repo_name': 'Kelvinrr/knoten', 'size': '3609'}