Skip to content

Instantly share code, notes, and snippets.

@jlaura
Created March 10, 2019 19:35
Show Gist options
  • Save jlaura/8ccd680a10f9afd1bde35e5015cc6139 to your computer and use it in GitHub Desktop.
Save jlaura/8ccd680a10f9afd1bde35e5015cc6139 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import csmapi\n",
"import ctypes\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<CDLL '/data/big/github/usgscsm/build/libusgscsm.so', handle 55588bdf0050 at 0x7f372c6ae160>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ctypes.CDLL('/data/big/github/usgscsm/build/libusgscsm.so')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"pl = csmapi.Plugin.getList()[0]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def checkstate(isdpath):\n",
" isd = csmapi.Isd(isdpath)\n",
" if pl.canModelBeConstructedFromISD(isd, 'USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL'):\n",
" model = pl.constructModelFromISD(isd, 'USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL')\n",
"\n",
" # State from the model\n",
" state = model.getModelState()\n",
" # State from another model constructed using the first state\n",
" model2 = pl.constructModelFromState(state)\n",
" state2 = model2.getModelState()\n",
" # State from the ISD converted through the plugin\n",
" state3 = pl.convertISDToModelState(isd, 'USGS_ASTRO_LINE_SCANNER_SENSOR_MODEL') \n",
"\n",
" jstate = json.loads(state) \n",
" jstate2 = json.loads(state2)\n",
" jstate3 = json.loads(state3)\n",
"\n",
" for k, v in jstate.items():\n",
" assert jstate3.get(k, None) == jstate2.get(k, None) == v\n",
"\n",
" return True"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"checkstate('/home/jlaura/Downloads/J03_046060_1986_XN_18N282W.json')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"checkstate('/home/jlaura/Downloads/J03_045994_1986_XN_18N282W.json')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment