From ab589f4c1468075b31940258145bfacc65e7bf19 Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jmapel@usgs.gov> Date: Sun, 22 May 2022 23:27:48 -0700 Subject: [PATCH] Cleaning out absolute paths (#461) * Removed paths in utils * Removed old pre load/loads notebooks --- .../write_DawnFcPds3NaifSpiceDriver.ipynb | 170 ------------------ ...rite_IdealLsIsisLabelIsisSpiceDriver.ipynb | 131 -------------- ...rite_LroLrocPds3LabelNaifSpiceDriver.ipynb | 141 --------------- ...write_MroCtxPds3LabelNaifSpiceDriver.ipynb | 168 ----------------- 4 files changed, 610 deletions(-) delete mode 100644 notebooks/write_DawnFcPds3NaifSpiceDriver.ipynb delete mode 100644 notebooks/write_IdealLsIsisLabelIsisSpiceDriver.ipynb delete mode 100644 notebooks/write_LroLrocPds3LabelNaifSpiceDriver.ipynb delete mode 100644 notebooks/write_MroCtxPds3LabelNaifSpiceDriver.ipynb diff --git a/notebooks/write_DawnFcPds3NaifSpiceDriver.ipynb b/notebooks/write_DawnFcPds3NaifSpiceDriver.ipynb deleted file mode 100644 index 4d99686..0000000 --- a/notebooks/write_DawnFcPds3NaifSpiceDriver.ipynb +++ /dev/null @@ -1,170 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Writing out a USGSCSM ISD from a PDS3 Dawn Framing Camera image" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import json\n", - "\n", - "import ale\n", - "from ale.drivers.dawn_drivers import DawnFcPds3NaifSpiceDriver\n", - "from ale.formatters.usgscsm_formatter import to_usgscsm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Instantiating an ALE driver\n", - "\n", - "ALE drivers are objects that define how to acquire common ISD keys from an input image format, in this case we are reading in a PDS3 image using NAIF SPICE kernels for exterior orientation data. If the driver utilizes NAIF SPICE kernels, it is implemented as a [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) and will furnish metakernels when entering the context (i.e. when entering the `with` block) and free the metakernels on exit. This maintains the integrity of spicelib's internal data structures. These driver objects are short-lived and are input to a formatter function that consumes the API to create a serializable file format. `ale.formatters` contains available formatter functions. \n", - "\n", - "The default config file is located at `ale/config.yml` and is copied into your home directory at `.ale/config.yml` on first use of the library. The config file can be modified using a text editor. `ale.config` is loaded into memory as a dictionary. It is used to find metakernels for different missions. For example, there is an entry for Dawn that points to `/usgs/cpkgs/isis3/data/dawn/kernels/mk/` by default. If you want to use your own metakernels, you will need to udpate this path. For example, if the metakernels are located in `/data/dawn/mk/` the Dawn entry should be updated with this path. If you are using the default metakernels, then you do not need to update the path.\n", - "\n", - "ALE has a two step process for writing out an ISD: 1. Instantiate your driver (in this case `DawnFcPds3LabelNaifSpiceDriver`) within a context and 2. pass the driver object into a formatter (in this case, `to_usgscsm`). \n", - "\n", - "Requirements:\n", - " * A PDS3 Dawn image\n", - " * NAIF metakernels installed\n", - " * Config file path for Dawn (ale.config.dawn) pointing to Dawn NAIF metakernel directory \n", - " * A conda environment with ALE installed into it usisng the `conda install` command or created using the environment.yml file at the base of ALE." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cassini: /usgs/cpkgs/isis3/data/cassini/kernels/mk/\n", - "dawn: /data/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk\n", - "kaguya: /data/spice/SELENE/kernels/mk/\n", - "lro: /scratch/jlaura/spice/lro-l-spice-6-v1.0/lrosp_1000/extras/mk/\n", - "mdis: /data/spice/mess-e_v_h-spice-6-v1.0/messsp_1000/extras/mk\n", - "mro: /data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk\n", - "spice_root: /data/spice/\n", - "\n", - "Dawn spice directory: /data/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk\n" - ] - } - ], - "source": [ - "# printing config displays the yaml formatted string\n", - "print(ale.config)\n", - "\n", - "# config object is a dictionary so it has the same access patterns\n", - "print('Dawn spice directory:', ale.config['dawn'])\n", - "\n", - "# updating config for new Dawn path in this notebook \n", - "# Note: this will not change the path in `.ale/config.yml`. This change only lives in the notebook.\n", - "# ale.config['dawn'] = '/scratch/jlaura/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk/'" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "# change to desired PDS3 image path\n", - "file_name = 'FC21A0039691_15231053805F1E.IMG'\n", - "\n", - "# metakernels are furnsh-ed when entering the context (with block) with a driver instance\n", - "# most driver constructors simply accept an image path \n", - "with DawnFcPds3NaifSpiceDriver(file_name) as driver:\n", - " # pass driver instance into formatter function\n", - " usgscsmString = to_usgscsm(driver)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Write ISD to disk \n", - "\n", - "ALE formatter functions generally return bytes or a string that can be written out to disk. ALE's USGSCSM formatter function returns a JSON encoded string that can be written out using any JSON library. \n", - "\n", - "USGSCSM requires the ISD to be colocated with the image file with a `.json` extension in place of the image extension." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_keys(['radii', 'sensor_position', 'sun_position', 'sensor_orientation', 'detector_sample_summing', 'detector_line_summing', 'focal_length_model', 'detector_center', 'starting_detector_line', 'starting_detector_sample', 'focal2pixel_lines', 'focal2pixel_samples', 'optical_distortion', 'image_lines', 'image_samples', 'name_platform', 'name_sensor', 'reference_height', 'name_model', 'center_ephemeris_time'])" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Load the json string into a dict\n", - "usgscsm_dict = json.loads(usgscsmString)\n", - "\n", - "# Write the dict out to the associated file\n", - "json_file = os.path.splitext(file_name)[0] + '.json'\n", - "\n", - "# Save off the json and read it back in to check if\n", - "# the json exists and was formatted correctly\n", - "with open(json_file, 'w') as fp:\n", - " json.dump(usgscsm_dict, fp)\n", - " \n", - "with open(json_file, 'r') as fp:\n", - " usgscsm_dict = json.load(fp)\n", - " \n", - "usgscsm_dict.keys()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "ale_env", - "language": "python", - "name": "ale_env" - }, - "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.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/notebooks/write_IdealLsIsisLabelIsisSpiceDriver.ipynb b/notebooks/write_IdealLsIsisLabelIsisSpiceDriver.ipynb deleted file mode 100644 index 4b5a979..0000000 --- a/notebooks/write_IdealLsIsisLabelIsisSpiceDriver.ipynb +++ /dev/null @@ -1,131 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Writing out a USGSCSM ISD from an ISIS ideal camera image" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import json\n", - "\n", - "import ale\n", - "from ale.drivers.isis_ideal_drivers import IdealLsIsisLabelIsisSpiceDriver\n", - "from ale.formatters.usgscsm_formatter import to_usgscsm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Instantiating an ALE driver\n", - "\n", - "ALE drivers are objects that define how to acquire common ISD keys from an input image format, in this case we are reading in an ISIS ideal line scan image using updated, attached exterior orientation data. These driver objects are short-lived and are input to a formatter function that consumes the API to create a serializable file format. `ale.formatters` contains available formatter functions.\n", - "\n", - "ALE has a two step process for writing out an ISD: 1. Instantiate your driver (in this case `IdealLsIsisLabelIsisSpiceDriver`) within a context and 2. pass the driver object into a formatter (in this case, `to_usgscsm`). \n", - "\n", - "Requirements:\n", - " * An ISIS ideal line scan image (e.g. a deijjtered HiRISE image, an undistorted HRSC image, or any linescan image processed through [noproj](https://isis.astrogeology.usgs.gov/Application/presentation/Tabbed/noproj/noproj.html))\n", - " * A conda environment with ALE installed into it usisng the `conda install` command or created using the environment.yml file at the base of ALE." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# change to desired PDS3 image path\n", - "file_name = '/Users/jmapel/ale/ESP_016076_2175_REDmos_hijitreged.balance.noproj.8bit.cub'\n", - "\n", - "from ale.transformation import FrameChain, create_rotations\n", - "# metakernels are furnished when entering the context (with block) with a driver instance\n", - "# most driver constructors simply accept an image path \n", - "with IdealLsIsisLabelIsisSpiceDriver(file_name) as driver:\n", - " usgscsmString = to_usgscsm(driver)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Write ISD to disk \n", - "\n", - "ALE formatter functions generally return bytes or a string that can be written out to disk. ALE's USGSCSM formatter function returns a JSON encoded string that can be written out using any JSON library. \n", - "\n", - "USGSCSM requires the ISD to be colocated with the image file with a `.json` extension in place of the image extension." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_keys(['radii', 'sensor_position', 'sun_position', 'sensor_orientation', 'detector_sample_summing', 'detector_line_summing', 'focal_length_model', 'detector_center', 'starting_detector_line', 'starting_detector_sample', 'focal2pixel_lines', 'focal2pixel_samples', 'optical_distortion', 'image_lines', 'image_samples', 'name_platform', 'name_sensor', 'reference_height', 'name_model', 'interpolation_method', 'line_scan_rate', 'starting_ephemeris_time', 'center_ephemeris_time', 't0_ephemeris', 'dt_ephemeris', 't0_quaternion', 'dt_quaternion'])" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Load the json string into a dict\n", - "usgscsm_dict = json.loads(usgscsmString)\n", - "\n", - "# Write the dict out to the associated file\n", - "json_file = os.path.splitext(file_name)[0] + '.json'\n", - "\n", - "# Save off the json and read it back in to check if\n", - "# the json exists and was formatted correctly\n", - "with open(json_file, 'w') as fp:\n", - " json.dump(usgscsm_dict, fp)\n", - " \n", - "with open(json_file, 'r') as fp:\n", - " usgscsm_dict = json.load(fp)\n", - " \n", - "usgscsm_dict.keys()" - ] - }, - { - "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 -} diff --git a/notebooks/write_LroLrocPds3LabelNaifSpiceDriver.ipynb b/notebooks/write_LroLrocPds3LabelNaifSpiceDriver.ipynb deleted file mode 100644 index db4dd0d..0000000 --- a/notebooks/write_LroLrocPds3LabelNaifSpiceDriver.ipynb +++ /dev/null @@ -1,141 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Writing out a USGSCSM ISD from a PDS3 LRO LROC NAC image" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import ale\n", - "from ale.drivers.lro_drivers import LroLrocPds3LabelNaifSpiceDriver\n", - "from ale.formatters.usgscsm_formatter import to_usgscsm\n", - "import json\n", - "import os" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Instantiating an ALE driver\n", - "\n", - "ALE drivers are objects that define how to acquire common ISD keys from an input image format, in this case we are reading in a PDS3 image using NAIF SPICE kernels for exterior orientation data. If the driver utilizes NAIF SPICE kernels, it is implemented as a [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) and will furnish metakernels when entering the context (i.e. when entering the `with` block) and free the metakernels on exit. This maintains the integrity of spicelib's internal data structures. These driver objects are short-lived and are input to a formatter function that consumes the API to create a serializable file format. `ale.formatters` contains available formatter functions. \n", - "\n", - "The default config file is located at `ale/config.yml` and is copied into your home directory at `.ale/config.yml` on first use of the library. The config file can be modified using a text editor. `ale.config` is loaded into memory as a dictionary. It is used to find metakernels for different missions. For example, there is an entry for LRO that points to `/usgs/cpkgs/isis3/data/lro/kernels/mk/` by default. If you want to use your own metakernels, you will need to udpate this path. For example, if the metakernels are located in `/data/lrolrocnac/mk/` the LRO entry should be updated with this path. If you are using the default metakernels, then you do not need to update the path.\n", - "\n", - "ALE has a two step process for writing out an ISD: 1. Instantiate your driver (in this case `LroLrocPds3LabelNaifSpiceDriver`) within a context and 2. pass the driver object into a formatter (in this case, `to_usgscsm`). \n", - "\n", - "Requirements:\n", - " * A PDS3 LRO LROC NAC image\n", - " * NAIF metakernels installed\n", - " * Config file path for LRO (ale.config.lro) pointing to LRO NAIF metakernel directory \n", - " * A conda environment with ALE installed into it usisng the `conda install` command or created using the environment.yml file at the base of ALE." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cassini: /usgs/cpkgs/isis3/data/cassini/kernels/mk/\n", - "dawn: /data/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk\n", - "kaguya: /data/spice/SELENE/kernels/mk/\n", - "lro: /scratch/jlaura/spice/lro-l-spice-6-v1.0/lrosp_1000/extras/mk/\n", - "mdis: /data/spice/mess-e_v_h-spice-6-v1.0/messsp_1000/extras/mk\n", - "mro: /data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk\n", - "spice_root: /data/spice/\n", - "\n", - "LRO spice directory: /scratch/jlaura/spice/lro-l-spice-6-v1.0/lrosp_1000/extras/mk/\n" - ] - } - ], - "source": [ - "# printing config displays the yaml formatted string\n", - "print(ale.config)\n", - "\n", - "# config object is a dictionary so it has the same access patterns \n", - "print('LRO spice directory:', ale.config['lro'])\n", - "\n", - "# updating config for new LRO path in this notebook \n", - "# Note: this will not change the path in `.ale/config.yml`. This change only lives in the notebook.\n", - "# ale.config['lro'] = '/data/lrolrocnac/mk/'" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "# change to desired PDS3 image path \n", - "fileName = 'M1142142198RE.IMG'\n", - "\n", - "# metakernels are furnsh-ed when entering the context (with block) with a driver instance\n", - "# most driver constructors simply accept an image path \n", - "with LroLrocPds3LabelNaifSpiceDriver(fileName) as driver:\n", - " # pass driver instance into formatter function\n", - " usgscsmString = to_usgscsm(driver)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Write ISD to disk \n", - "\n", - "ALE formatter functions generally return bytes or a string that can be written out to disk. ALE's USGSCSM formatter function returns a JSON encoded string that can be written out using any JSON library. \n", - "\n", - "USGSCSM requires the ISD to be colocated with the image file with a `.json` extension in place of the image extension.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# load the json encoded string ISD\n", - "usgscsm_dict = json.loads(usgscsmString)\n", - "\n", - "# strip the image file extension and append .json \n", - "jsonFile = os.path.splitext(fileName)[0] + '.json'\n", - "\n", - "# write to disk \n", - "with open(jsonFile, 'w') as fp:\n", - " json.dump(usgscsm_dict, fp)" - ] - } - ], - "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.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/notebooks/write_MroCtxPds3LabelNaifSpiceDriver.ipynb b/notebooks/write_MroCtxPds3LabelNaifSpiceDriver.ipynb deleted file mode 100644 index 9f5dd81..0000000 --- a/notebooks/write_MroCtxPds3LabelNaifSpiceDriver.ipynb +++ /dev/null @@ -1,168 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Writing out a USGSCSM ISD from a PDS3 LRO LROC NAC image" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import json\n", - "\n", - "import ale\n", - "from ale.drivers.mro_drivers import MroCtxPds3LabelNaifSpiceDriver\n", - "from ale.formatters.usgscsm_formatter import to_usgscsm" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Instantiating an ALE driver\n", - "\n", - "ALE drivers are objects that define how to acquire common ISD keys from an input image format, in this case we are reading in a PDS3 image using NAIF SPICE kernels for exterior orientation data. If the driver utilizes NAIF SPICE kernels, it is implemented as a [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) and will furnish metakernels when entering the context (i.e. when entering the `with` block) and free the metakernels on exit. This maintains the integrity of spicelib's internal data structures. These driver objects are short-lived and are input to a formatter function that consumes the API to create a serializable file format. `ale.formatters` contains available formatter functions. \n", - "\n", - "The default config file is located at `ale/config.yml` and is copied into your home directory at `.ale/config.yml` on first use of the library. The config file can be modified using a text editor. `ale.config` is loaded into memory as a dictionary. It is used to find metakernels for different missions. For example, there is an entry for MRO that points to `/usgs/cpkgs/isis3/data/mro/kernels/mk/` by default. If you want to use your own metakernels, you will need to udpate this path. For example, if the metakernels are located in `/data/ctxmro/mk/` the MRO entry should be updated with this path. If you are using the default metakernels, then you do not need to update the path.\n", - "\n", - "ALE has a two step process for writing out an ISD: 1. Instantiate your driver (in this case `MroCtxPds3LabelNaifSpiceDriver`) within a context and 2. pass the driver object into a formatter (in this case, `to_usgscsm`). \n", - "\n", - "Requirements:\n", - " * A PDS3 CTX MRO image\n", - " * NAIF metakernels installed\n", - " * Config file path for MRO (ale.config.mro) pointing to MRO NAIF metakernel directory \n", - " * A conda environment with ALE installed into it usisng the `conda install` command or created using the environment.yml file at the base of ALE." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cassini: /usgs/cpkgs/isis3/data/cassini/kernels/mk/\n", - "dawn: /data/spice/dawn-m_a-spice-6-v1.0/dawnsp_1000/extras/mk\n", - "kaguya: /data/spice/SELENE/kernels/mk/\n", - "lro: /scratch/jlaura/spice/lro-l-spice-6-v1.0/lrosp_1000/extras/mk/\n", - "mdis: /data/spice/mess-e_v_h-spice-6-v1.0/messsp_1000/extras/mk\n", - "mro: /data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk\n", - "spice_root: /data/spice/\n", - "\n", - "MRO spice directory: /data/spice/mro-m-spice-6-v1.0/mrosp_1000/extras/mk\n" - ] - } - ], - "source": [ - "# printing config displays the yaml formatted string\n", - "print(ale.config)\n", - "\n", - "# config object is a dictionary so it has the same access patterns\n", - "print('MRO spice directory:', ale.config['mro'])\n", - "\n", - "# updating config for new LRO path in this notebook \n", - "# Note: this will not change the path in `.ale/config.yml`. This change only lives in the notebook.\n", - "# ale.config['lro'] = '/data/lrolrocnac/mk/'" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "# change to desired PDS3 image path\n", - "file_name = '/home/acpaquette/F03_037064_1857_XN_05N218W.IMG'\n", - "\n", - "# metakernels are furnsh-ed when entering the context (with block) with a driver instance\n", - "# most driver constructors simply accept an image path \n", - "with MroCtxPds3LabelNaifSpiceDriver(file_name) as driver:\n", - " # pass driver instance into formatter function\n", - " usgscsmString = to_usgscsm(driver)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Write ISD to disk \n", - "\n", - "ALE formatter functions generally return bytes or a string that can be written out to disk. ALE's USGSCSM formatter function returns a JSON encoded string that can be written out using any JSON library. \n", - "\n", - "USGSCSM requires the ISD to be colocated with the image file with a `.json` extension in place of the image extension." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_keys(['radii', 'sensor_position', 'sun_position', 'sensor_orientation', 'detector_sample_summing', 'detector_line_summing', 'focal_length_model', 'detector_center', 'starting_detector_line', 'starting_detector_sample', 'focal2pixel_lines', 'focal2pixel_samples', 'optical_distortion', 'image_lines', 'image_samples', 'name_platform', 'name_sensor', 'reference_height', 'name_model', 'interpolation_method', 'line_scan_rate', 'starting_ephemeris_time', 'center_ephemeris_time', 't0_ephemeris', 'dt_ephemeris', 't0_quaternion', 'dt_quaternion'])" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Load the json string into a dict\n", - "usgscsm_dict = json.loads(usgscsmString)\n", - "\n", - "# Write the dict out to the associated file\n", - "json_file = os.path.splitext(file_name)[0] + '.json'\n", - "\n", - "# Save off the json and read it back in to check if\n", - "# the json exists and was formatted correctly\n", - "with open(json_file, 'w') as fp:\n", - " json.dump(usgscsm_dict, fp)\n", - " \n", - "with open(json_file, 'r') as fp:\n", - " usgscsm_dict = json.load(fp)\n", - " \n", - "usgscsm_dict.keys()" - ] - }, - { - "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.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} -- GitLab