Skip to content

Instantly share code, notes, and snippets.

@thareUSGS
Created December 21, 2019 06:02
Show Gist options
  • Save thareUSGS/a968c9cbe90e5b12160cb19d96e7c33d to your computer and use it in GitHub Desktop.
Save thareUSGS/a968c9cbe90e5b12160cb19d96e7c33d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"setup\n",
"\n",
"conda installed (python3), ISIS3.9.x installed, Spice located and defined in ~/.bashrc\n",
"export ALESPICEROOT=/scratch/spice\n",
"\n",
"wget https://raw.githubusercontent.com/USGS-Astrogeology/ale/master/environment.yml\n",
"conda env create -f environment.yml\n",
"conda install -c conda-forge pysis\n",
"\n",
"\n",
"if new version needed, first run\n",
"conda remove --force-remove ale\n",
"rm directory where git clone \"ale\" was created\n",
"\n",
"git clone https://github.com/USGS-Astrogeology/ale.git\n",
"\n",
"cd ale\n",
"python setup.py develop\n",
"\n",
"run this notebook using\n",
"jupyter notebook lroc.ipynb\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os \n",
"\n",
"os.environ[\"ISISROOT\"] = \"/usgs/cpkgs/anaconda3_linux/envs/isis3.7.0\"\n",
"\n",
"import pysis\n",
"from pysis import isis\n",
"from pysis.exceptions import ProcessError\n",
"\n",
"import ale\n",
"from ale import util\n",
"from ale.drivers.lro_drivers import LroLrocPds3LabelNaifSpiceDriver\n",
"from ale.formatters.usgscsm_formatter import to_usgscsm\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"#fileName = 'M1121188383RE.IMG'\n",
"fileName = 'M1121202582LE.IMG'"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Set the output location of the resulting .cub\n",
"cub_loc = os.path.splitext(fileName)[0] + '.cub'\n",
"\n",
"try: \n",
" isis.lronac2isis(from_=fileName, to=cub_loc)\n",
"except ProcessError as e:\n",
" print(e.stderr)\n",
"\n",
"try:\n",
" isis.spiceinit(from_=cub_loc, shape='ellipsoid')\n",
"except ProcessError as e:\n",
" print(e.stderr)\n",
"\n",
"kernels = ale.util.generate_kernels_from_cube(cub_loc, expand=True)\n",
"\n",
"usgscsm_str = ale.loads(fileName, props={'kernels': kernels}, formatter=\"usgscsm\", verbose=False)\n",
"\n",
"csm_isd = os.path.splitext(fileName)[0] + '.json'\n",
"with open(csm_isd, 'w') as isd_file:\n",
" isd_file.write(usgscsm_str)"
]
},
{
"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.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment