{
 "metadata": {
  "name": "phase_function_table"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import pandas as pd\n",
      "reload(pd)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 1,
       "text": [
        "<module 'pandas' from '/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/pandas-0.11.0.dev_3790f16-py2.7-macosx-10.5-x86_64.egg/pandas/__init__.pyc'>"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "df = pd.io.parsers.read_csv(\"/Users/maye/data/hirise/inca/grid_by_phase.txt\",skipinitialspace=True, na_values='-NaN')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "some of phase and reflectance values are missing?"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "df"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 4,
       "text": [
        "<class 'pandas.core.frame.DataFrame'>\n",
        "Int64Index: 1458000 entries, 0 to 1457999\n",
        "Data columns:\n",
        "incidence      1458000  non-null values\n",
        "emission       1458000  non-null values\n",
        "phase          1457994  non-null values\n",
        "reflectance    1457989  non-null values\n",
        "dtypes: float64(2), int64(2)"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "df[~df.phase.notnull()] # this searches for phases that are nan values"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th></th>\n",
        "      <th>incidence</th>\n",
        "      <th>emission</th>\n",
        "      <th>phase</th>\n",
        "      <th>reflectance</th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>81900  </th>\n",
        "      <td>  5</td>\n",
        "      <td>  5</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 0.278157</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>737100 </th>\n",
        "      <td> 45</td>\n",
        "      <td> 45</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 0.360779</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>933660 </th>\n",
        "      <td> 57</td>\n",
        "      <td> 57</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 0.441665</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1048320</th>\n",
        "      <td> 64</td>\n",
        "      <td> 64</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 0.522464</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1326780</th>\n",
        "      <td> 81</td>\n",
        "      <td> 81</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 1.275300</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1375920</th>\n",
        "      <td> 84</td>\n",
        "      <td> 84</td>\n",
        "      <td>NaN</td>\n",
        "      <td> 1.865133</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "</div>"
       ],
       "output_type": "pyout",
       "prompt_number": 9,
       "text": [
        "         incidence  emission  phase  reflectance\n",
        "81900            5         5    NaN     0.278157\n",
        "737100          45        45    NaN     0.360779\n",
        "933660          57        57    NaN     0.441665\n",
        "1048320         64        64    NaN     0.522464\n",
        "1326780         81        81    NaN     1.275300\n",
        "1375920         84        84    NaN     1.865133"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "df[-df.reflectance.notnull()] # this searches for reflectance values that are nan values"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "html": [
        "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
        "<table border=\"1\" class=\"dataframe\">\n",
        "  <thead>\n",
        "    <tr style=\"text-align: right;\">\n",
        "      <th></th>\n",
        "      <th>incidence</th>\n",
        "      <th>emission</th>\n",
        "      <th>phase</th>\n",
        "      <th>reflectance</th>\n",
        "    </tr>\n",
        "  </thead>\n",
        "  <tbody>\n",
        "    <tr>\n",
        "      <th>49140  </th>\n",
        "      <td>  3</td>\n",
        "      <td>  3</td>\n",
        "      <td> 0.000001</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>65520  </th>\n",
        "      <td>  4</td>\n",
        "      <td>  4</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>114660 </th>\n",
        "      <td>  7</td>\n",
        "      <td>  7</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>131040 </th>\n",
        "      <td>  8</td>\n",
        "      <td>  8</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>163800 </th>\n",
        "      <td> 10</td>\n",
        "      <td> 10</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>180180 </th>\n",
        "      <td> 11</td>\n",
        "      <td> 11</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>196560 </th>\n",
        "      <td> 12</td>\n",
        "      <td> 12</td>\n",
        "      <td> 0.000001</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1212120</th>\n",
        "      <td> 74</td>\n",
        "      <td> 74</td>\n",
        "      <td> 0.000001</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1359540</th>\n",
        "      <td> 83</td>\n",
        "      <td> 83</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1408680</th>\n",
        "      <td> 86</td>\n",
        "      <td> 86</td>\n",
        "      <td> 0.000000</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "    <tr>\n",
        "      <th>1425060</th>\n",
        "      <td> 87</td>\n",
        "      <td> 87</td>\n",
        "      <td> 0.000001</td>\n",
        "      <td>NaN</td>\n",
        "    </tr>\n",
        "  </tbody>\n",
        "</table>\n",
        "</div>"
       ],
       "output_type": "pyout",
       "prompt_number": 10,
       "text": [
        "         incidence  emission     phase  reflectance\n",
        "49140            3         3  0.000001          NaN\n",
        "65520            4         4  0.000000          NaN\n",
        "114660           7         7  0.000000          NaN\n",
        "131040           8         8  0.000000          NaN\n",
        "163800          10        10  0.000000          NaN\n",
        "180180          11        11  0.000000          NaN\n",
        "196560          12        12  0.000001          NaN\n",
        "1212120         74        74  0.000001          NaN\n",
        "1359540         83        83  0.000000          NaN\n",
        "1408680         86        86  0.000000          NaN\n",
        "1425060         87        87  0.000001          NaN"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "because the index in the most left column is zero based, the line number would be index+1"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "df.index"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 12,
       "text": [
        "Int64Index([0, 1, 2, ..., 1457997, 1457998, 1457999], dtype=int64)"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}