Skip to content

Instantly share code, notes, and snippets.

@jlaura
Created August 30, 2018 19:53
Show Gist options
  • Save jlaura/0e648125eee1e289ba5d064243e19cef to your computer and use it in GitHub Desktop.
Save jlaura/0e648125eee1e289ba5d064243e19cef to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"# requires:\n",
"libcsm\n",
"csmapi\n",
"usgscam\n",
"\n",
"all on usgs-astrogeology conda page."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import ctypes\n",
"from ctypes.util import find_library\n",
"\n",
"from csmapi import csmapi\n",
"import requests\n",
"\n",
"lib = ctypes.CDLL(find_library('usgscsm'))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pvl\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"label = pvl.load('<PATH_TO_IMAGE>')\n",
"data = {'label': pvl.dumps(label).decode()}"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"#isd = requests.post('http://pfeffer.wr.usgs.gov/v1/pds/', json=data).json()\n",
"isd = requests.post('http://pfeffer.wr.usgs.gov/v1/pds/', json=data)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"isd['IKCODE'] = -1"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"isd = csmapi.Isd.loads(isd)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"plugin = csmapi.Plugin.findPlugin('USGS_ASTRO_LINE_SCANNER_PLUGIN')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"model_name = 'USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL'"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"if plugin.canModelBeConstructedFromISD(isd, model_name):\n",
" model = plugin.constructModelFromISD(isd, model_name)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(713556.87001488, 3158256.0550970575, 1018839.1996246666)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ipt = csmapi.ImageCoord(1,1)\n",
"ecef = model.imageToGround(ipt, 0)\n",
"ecef.x, ecef.y, ecef.z"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1.002024106304816, 0.5204529592349643)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ic = model.groundToImage(ecef)\n",
"ic.samp, ic.line # 1/2 pixel off in line..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Camera Testing",
"language": "python",
"name": "ct"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment