Skip to content
Snippets Groups Projects
Socet2ISIS.ipynb 4.54 KiB
Newer Older
  • Learn to ignore specific revisions
  • {
     "cells": [
      {
       "cell_type": "code",
       "execution_count": 67,
       "metadata": {},
       "outputs": [
        {
         "data": {
          "text/plain": [
           "{'ATF_FILE': 'CTX_Athabasca_Middle_step0.atf',\n",
           " 'GP_FILE': 'CTX_Athabasca_Middle.gpf',\n",
           " 'IMAGE_IPF': ['P19_008344_1894_XN_09N203W.ipf',\n",
           "  'P20_008845_1894_XN_09N203W.ipf',\n",
           "  'P03_002371_1888_XI_08N204W.ipf',\n",
           "  'P01_001540_1889_XI_08N204W.ipf',\n",
           "  'P01_001606_1897_XI_09N203W.ipf',\n",
           "  'P03_002226_1895_XI_09N203W.ipf'],\n",
           " 'IMAGE_SUP': ['P19_008344_1894_XN_09N203W.sup',\n",
           "  'P20_008845_1894_XN_09N203W.sup',\n",
           "  'P03_002371_1888_XI_08N204W.sup',\n",
           "  'P01_001540_1889_XI_08N204W.sup',\n",
           "  'P01_001606_1897_XI_09N203W.sup',\n",
           "  'P03_002226_1895_XI_09N203W.sup'],\n",
           " 'PATH': '/home/tthatcher/Desktop/Projects/Plio/plio/notebooks',\n",
           " 'PROJECT': 'D:\\\\data\\\\CTX_Athabasca_Middle.prj'}"
          ]
         },
         "execution_count": 67,
         "metadata": {},
         "output_type": "execute_result"
        }
       ],
       "source": [
        "import os\n",
        "import numpy as np\n",
        "\n",
        "# Reads a .atf file and outputs all of the \n",
        "# .ipf, .gpf, .sup, .prj, and path to locate the \n",
        "# .apf file (should be the same as all others) \n",
        "def read_atf(atf_file):\n",
        "    with open(atf_file) as f:\n",
        "\n",
        "        files = []\n",
        "        ipf = []\n",
        "        sup = []\n",
        "        files_dict = []\n",
        "        \n",
        "        # Grabs every PRJ, GPF, SUP, and IPF image from the ATF file\n",
        "        for line in f:\n",
        "            if line[-4:-1] == 'prj' or line[-4:-1] == 'gpf' or line[-4:-1] == 'sup' or line[-4:-1] == 'ipf' or line[-4:-1] == 'atf':\n",
        "                files.append(line)\n",
        "        \n",
        "        files = np.array(files)\n",
        "        \n",
        "        # Creates appropriate arrays for certain files in the right format\n",
        "        for file in files:\n",
        "            file = file.strip()\n",
        "            file = file.split(' ')\n",
        "\n",
        "            # Grabs all the IPF files\n",
        "            if file[1].endswith('.ipf'):\n",
        "                ipf.append(file[1])\n",
        "\n",
        "            # Grabs all the SUP files\n",
        "            if file[1].endswith('.sup'):\n",
        "                sup.append(file[1])\n",
        "\n",
        "            files_dict.append(file)\n",
        "\n",
        "        # Creates a dict out of file lists for GPF, PRJ, IPF, and ATF\n",
        "        files_dict = (dict(files_dict))\n",
        "        \n",
        "        # Sets the value of IMAGE_IPF to all IPF images\n",
        "        files_dict['IMAGE_IPF'] = ipf\n",
        "        \n",
        "        # Sets the value of IMAGE_SUP to all SUP images\n",
        "        files_dict['IMAGE_SUP'] = sup\n",
        "        \n",
        "        # Sets the value of PATH to the path of the ATF file\n",
        "        files_dict['PATH'] = os.path.dirname(os.path.abspath(atf_file))\n",
        "        \n",
        "        return files_dict\n",
        "    \n",
        "read_atf('CTX_Athabasca_Middle_step0.atf')"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "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.4"
      }
     },
     "nbformat": 4,
     "nbformat_minor": 2
    }