Skip to content
Snippets Groups Projects
Unverified Commit a710d5c4 authored by Jacob Cain's avatar Jacob Cain Committed by GitHub
Browse files

linked to info on CSM/USGSCSM (#119)

* linked to info on CSM/USGSCSM

* no checkmarks

* yes checkmarks
parent f1330a4b
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:a117baed-ab98-4499-832c-8c73a8606cc0 tags: %% Cell type:markdown id:a117baed-ab98-4499-832c-8c73a8606cc0 tags:
# Tutorial: Instantiating a CSM Camera Model from Image # Tutorial: Instantiating a CSM Camera Model from Image
%% Cell type:markdown id:3602c014-53bc-4330-a9b0-0848d4927458 tags: %% Cell type:markdown id:3602c014-53bc-4330-a9b0-0848d4927458 tags:
Lessons learned in this tutorial: Goals in this tutorial:
* How to generate Image Support Data (ISD) for an image
* instantiate a CSM camera model - [x] Generate Image Support Data (ISD) for an image
* Perform a simple ground to image call - [x] Instantiate a CSM camera model
- [x] Perform a simple ground to image call
-----
!!! info "CSM - The Community Sensor Model"
For more info on CSM, see
[Sensor Models](https://astrogeology.usgs.gov/docs/concepts/sensor-models/sensor-models/).
Also see
[Sensor Model Software: USGSCSM](https://astrogeology.usgs.gov/docs/concepts/sensor-models/sensor-model-software/#usgs-community-sensor-model-usgscsm)
for the USGS's implementation of CSM in its software.
### 1. Prerequisites, Install Knoten ### 1. Prerequisites, Install Knoten
The `knoten` installation may take a little longer than usual due to the many dependencies (including ALE) involved. The `knoten` installation may take a little longer than usual due to the many dependencies (including ALE) involved.
%% Cell type:markdown id:ffeccab3-0d5d-4609-9c7f-871bdb69f17a tags: %% Cell type:markdown id:ffeccab3-0d5d-4609-9c7f-871bdb69f17a tags:
``` ```
conda install -c conda-forge knoten=0.2.1 conda install -c conda-forge knoten=0.2.1
``` ```
%% Cell type:markdown id:faed4a43-cd06-45c7-bfa1-793978d41486 tags: %% Cell type:markdown id:faed4a43-cd06-45c7-bfa1-793978d41486 tags:
### 2. Generate an ISD from a Cube ### 2. Generate an ISD from a Cube
We will use MRO data located in the `data/image_to_ground` folder containing a cube and necessary kernels for ISD (Image Support Data) generation. We will use MRO data located in the `data/image_to_ground` folder containing a cube and necessary kernels for ISD (Image Support Data) generation.
*Note*: If your cube already has attached spice data, do you not have to specify kernels in the `props` param and can pass in an empty dict `{}` instead. *Note*: If your cube already has attached spice data, do you not have to specify kernels in the `props` param and can pass in an empty dict `{}` instead.
%% Cell type:code id:7f58cb34-d27f-456d-bfb5-f9075ca575b3 tags: %% Cell type:code id:7f58cb34-d27f-456d-bfb5-f9075ca575b3 tags:
``` python ``` python
import ale import ale
import json import json
import knoten import knoten
import os import os
# Set local data directory and paths # Set local data directory and paths
data_dir = '../data/image_to_ground' data_dir = '../data/image_to_ground'
cube_file = os.path.join(data_dir, 'B10_013341_1010_XN_79S172W.cub') cube_file = os.path.join(data_dir, 'B10_013341_1010_XN_79S172W.cub')
isd_file = os.path.join(data_dir, 'isd_file.json') isd_file = os.path.join(data_dir, 'isd_file.json')
# Set local kernel paths # Set local kernel paths
props = { props = {
'kernels': [ 'kernels': [
os.path.join(data_dir, 'B10_013341_1010_XN_79S172W_0.bsp'), os.path.join(data_dir, 'B10_013341_1010_XN_79S172W_0.bsp'),
os.path.join(data_dir, 'B10_013341_1010_XN_79S172W_1.bsp'), os.path.join(data_dir, 'B10_013341_1010_XN_79S172W_1.bsp'),
os.path.join(data_dir, 'mro_ctx_v11.ti'), os.path.join(data_dir, 'mro_ctx_v11.ti'),
os.path.join(data_dir, 'mro_sc_psp_090526_090601_0_sliced_-74000.bc'), os.path.join(data_dir, 'mro_sc_psp_090526_090601_0_sliced_-74000.bc'),
os.path.join(data_dir, 'mro_sc_psp_090526_090601_1_sliced_-74000.bc'), os.path.join(data_dir, 'mro_sc_psp_090526_090601_1_sliced_-74000.bc'),
os.path.join(data_dir, 'mro_sclkscet_00082_65536.tsc'), os.path.join(data_dir, 'mro_sclkscet_00082_65536.tsc'),
os.path.join(data_dir, 'mro_v16.tf'), os.path.join(data_dir, 'mro_v16.tf'),
os.path.join(data_dir, 'naif0012.tls'), os.path.join(data_dir, 'naif0012.tls'),
os.path.join(data_dir, 'pck00008.tpc') os.path.join(data_dir, 'pck00008.tpc')
] ]
} }
# Generate the ISD string from the cube's label # Generate the ISD string from the cube's label
isd_str = ale.loads( isd_str = ale.loads(
label=cube_file, label=cube_file,
formatter="ale", formatter="ale",
props=props, props=props,
indent=2, indent=2,
verbose=False, verbose=False,
only_isis_spice=False, only_isis_spice=False,
only_naif_spice=False only_naif_spice=False
) )
# Write the ISD string to file 'isd_file.json' # Write the ISD string to file 'isd_file.json'
with open(isd_file, "w") as file: with open(isd_file, "w") as file:
file.write(isd_str) file.write(isd_str)
``` ```
%% Cell type:markdown id:4ed327aa-bffc-4316-b42f-496d9e07465e tags: %% Cell type:markdown id:4ed327aa-bffc-4316-b42f-496d9e07465e tags:
### 3. Create a Community Sensor Model ### 3. Create a Community Sensor Model
We will use Knoten's implementation of CSM as the library supports line scanner types of sensor models in the usgscsm library. We will use Knoten's implementation of CSM as the library supports line scanner types of sensor models in the usgscsm library.
%% Cell type:code id:0c4dbf84-2986-495b-9e4a-da4c77059e7e tags: %% Cell type:code id:0c4dbf84-2986-495b-9e4a-da4c77059e7e tags:
``` python ``` python
sensor_model = knoten.csm.create_csm(isd_file, verbose=False) sensor_model = knoten.csm.create_csm(isd_file, verbose=False)
``` ```
%% Cell type:markdown id:d6973fe3-9d4a-4408-9310-50334a52ff58 tags: %% Cell type:markdown id:d6973fe3-9d4a-4408-9310-50334a52ff58 tags:
### 4. Convert image coordinates into ground coordinates ### 4. Convert image coordinates into ground coordinates
%% Cell type:code id:d8f2b155-9803-4a6b-a967-bca1ef35860f tags: %% Cell type:code id:d8f2b155-9803-4a6b-a967-bca1ef35860f tags:
``` python ``` python
# Create an image coordinate at line = 206 and sample = 206 # Create an image coordinate at line = 206 and sample = 206
image_coord = knoten.csmapi.ImageCoord(206, 206) image_coord = knoten.csmapi.ImageCoord(206, 206)
# Convert the image coordinates to ground coordinates with desired precision of 0.0 # Convert the image coordinates to ground coordinates with desired precision of 0.0
ground_coord = sensor_model.imageToGround(image_coord, 0.0) ground_coord = sensor_model.imageToGround(image_coord, 0.0)
# Output the ground coordinates # Output the ground coordinates
ground_coord.x, ground_coord.y, ground_coord.z ground_coord.x, ground_coord.y, ground_coord.z
``` ```
%% Output %% Output
(-572485.2147483829, -79884.88742005036, -3326939.6184008163) (-572485.2147483829, -79884.88742005036, -3326939.6184008163)
%% Cell type:markdown id:bf87c5a5-b26c-4168-9324-ce5b0004cc7c tags: %% Cell type:markdown id:bf87c5a5-b26c-4168-9324-ce5b0004cc7c tags:
### 5. Convert ground coordinates into image coordinates ### 5. Convert ground coordinates into image coordinates
%% Cell type:code id:0edc0b6d-cdbe-46a8-9fdc-4ebdc4570f1a tags: %% Cell type:code id:0edc0b6d-cdbe-46a8-9fdc-4ebdc4570f1a tags:
``` python ``` python
# Convert the image coordinates to ground coordinates with desired precision of 0.0 # Convert the image coordinates to ground coordinates with desired precision of 0.0
image_coord = sensor_model.groundToImage(ground_coord, 0.0) image_coord = sensor_model.groundToImage(ground_coord, 0.0)
# Output the image coordinates # Output the image coordinates
image_coord.line, image_coord.samp image_coord.line, image_coord.samp
``` ```
%% Output %% Output
(205.99991086761267, 206.00000010379927) (205.99991086761267, 206.00000010379927)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment