Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Surface adjusted distance project\n",
- "\n",
- "Start by loading up some packages. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "3.4.5 (default, Jun 27 2016, 13:21:51) \n",
- "[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]\n"
- ]
- }
- ],
- "source": [
- "import sys\n",
- "print (sys.version)\n",
- "sys.path.append(\"/home/majo3748/.local/lib/python3.4/site-packages\")\n",
- "sys.path.append(\"/projects/majo3748/TerrainMetrics_conda2\")\n",
- "import time\n",
- "import itertools\n",
- "import cProfile, pstats\n",
- "import os.path\n",
- "import numpy as np\n",
- "import pandas as pd\n",
- "from ipyparallel import Client\n",
- "import surfaceAdjusted"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Verify that the cluster is up and running"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n"
- ]
- }
- ],
- "source": [
- "# check cluster status\n",
- "rc = Client(profile=\"janus-cpu\")\n",
- "print(rc.ids)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "<LoadBalancedView None>\n"
- ]
- }
- ],
- "source": [
- "lview = rc.load_balanced_view()\n",
- "lview.block = True\n",
- "print(lview)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "[0,\n",
- " 1,\n",
- " 1024,\n",
- " 59049,\n",
- " 1048576,\n",
- " 9765625,\n",
- " 60466176,\n",
- " 282475249,\n",
- " 1073741824,\n",
- " 3486784401,\n",
- " 10000000000,\n",
- " 25937424601,\n",
- " 61917364224,\n",
- " 137858491849,\n",
- " 289254654976,\n",
- " 576650390625,\n",
- " 1099511627776,\n",
- " 2015993900449,\n",
- " 3570467226624,\n",
- " 6131066257801,\n",
- " 10240000000000,\n",
- " 16679880978201,\n",
- " 26559922791424,\n",
- " 41426511213649,\n",
- " 63403380965376,\n",
- " 95367431640625,\n",
- " 141167095653376,\n",
- " 205891132094649,\n",
- " 296196766695424,\n",
- " 420707233300201,\n",
- " 590490000000000,\n",
- " 819628286980801]"
- ]
- },
- "execution_count": 4,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#test it \n",
- "lview.map(lambda x:x**10, range(32))\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Now use `%` to import packages on each of the processors."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "%px import sys\n",
- "%px sys.path.append(\"/home/majo3748/.local/lib/python3.4/site-packages\")\n",
- "%px sys.path.append(\"/projects/majo3748/TerrainMetrics_conda2\")\n",
- "\n",
- "# load surfaceAdjusted module on each worker\n",
- "%px import surfaceAdjusted"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Determining the cases \n",
- "\n",
- "We need to generate a data frame containing a row for each distance calculation we want to do. \n",
- "The following code blocks assign the cases of interest, and generate all relevant combinations, producing a data frame at the end."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "resolution_L = [3,10,30,100,1000]\n",
- "\n",
- "# NN interpolation does not work, leave commented out\n",
- "methods = ['p2p', 'clos', 'wavg', 'biLin', 'biQua', 'biQub', 'TIN']#, 'NN']\n",
- "\n",
- "# for testing, just use one state\n",
- "study_areas = [\"Colorado\"] #[\"Colorado\", \"Nebraska\", \"Louisiana\", \"Washington\", \"NC\", \"Texas\"]\n",
- "\n",
- "# the duplicated end of this path is NOT a typo\n",
- "data_dir = r\"/work/earthlab/EarthLab_shared/data_harm/Modified_2/Modified_2/\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "def expandgrid(*itrs):\n",
- " \"\"\"\n",
- " Generate all possible combinations of elements in multiple lists\n",
- " \n",
- " Args:\n",
- " - lists separated by commas\n",
- " \n",
- " Example:\n",
- " >>> expandgrid([0, 1], [2, 3, 4])\n",
- " >>> [[0, 0, 0, 1, 1, 1], [2, 3, 4, 2, 3, 4]]\n",
- " \n",
- " Returns: \n",
- " - a list of lists, with one element in each inner list for each \n",
- " combination of elements in the input lists\n",
- " \"\"\"\n",
- " product = list(itertools.product(*itrs))\n",
- " return [[x[i] for x in product] for i in range(len(itrs))]"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {
- "collapsed": false,
- "scrolled": true
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>transect</th>\n",
- " <th>method</th>\n",
- " <th>resolution</th>\n",
- " <th>path</th>\n",
- " <th>area</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>count</th>\n",
- " <td>29000</td>\n",
- " <td>29000</td>\n",
- " <td>29000</td>\n",
- " <td>29000</td>\n",
- " <td>29000</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>unique</th>\n",
- " <td>1000</td>\n",
- " <td>7</td>\n",
- " <td>5</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>top</th>\n",
- " <td>999</td>\n",
- " <td>clos</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>freq</th>\n",
- " <td>29</td>\n",
- " <td>5000</td>\n",
- " <td>7000</td>\n",
- " <td>29000</td>\n",
- " <td>29000</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " transect method resolution \\\n",
- "count 29000 29000 29000 \n",
- "unique 1000 7 5 \n",
- "top 999 clos 1000 \n",
- "freq 29 5000 7000 \n",
- "\n",
- " path area \n",
- "count 29000 29000 \n",
- "unique 1 1 \n",
- "top /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "freq 29000 29000 "
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Determine all of the cases to compute (area X resolution X transect X method combinations)\n",
- "cases_list = []\n",
- "for area in study_areas:\n",
- " area_start_time = time.time()\n",
- " area_path = data_dir + area + '/'\n",
- " area_transects = np.genfromtxt(area_path + \"/simulation/\" + 'tran_sim_pts.csv', delimiter=\",\")\n",
- " #area_transects = np.genfromtxt(area_path + 'transect_pts.csv', delimiter=\",\")\n",
- "\n",
- " \n",
- " for resolution in resolution_L:\n",
- " \n",
- " n_transects = int(area_transects.shape[0] / 2)\n",
- " transect_indices = [i for i in range(n_transects)]\n",
- "\n",
- " if resolution == 3:\n",
- " # subset 3m resolution to \"clos\" method only\n",
- " cases = expandgrid(transect_indices, [\"clos\"], [resolution], [area_path], [area])\n",
- " else:\n",
- " # determine all possible combinations of transects and methods\n",
- " cases = expandgrid(transect_indices, methods, [resolution], [area_path], [area])\n",
- " \n",
- " n_cases = len(cases[0])\n",
- " \n",
- " df = pd.DataFrame(cases).transpose()\n",
- " df.columns = [\"transect\", \"method\", \"resolution\", \"path\", \"area\"]\n",
- " cases_list.append(df)\n",
- "\n",
- "cases_df = pd.concat(cases_list)\n",
- "cases_df.describe()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "For testing purposes, we'll just use a few of the transects."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>transect</th>\n",
- " <th>method</th>\n",
- " <th>resolution</th>\n",
- " <th>path</th>\n",
- " <th>area</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>0</td>\n",
- " <td>clos</td>\n",
- " <td>3</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>1</td>\n",
- " <td>clos</td>\n",
- " <td>3</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>0</td>\n",
- " <td>p2p</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>0</td>\n",
- " <td>clos</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>0</td>\n",
- " <td>wavg</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>0</td>\n",
- " <td>biLin</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>0</td>\n",
- " <td>biQua</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>5</th>\n",
- " <td>0</td>\n",
- " <td>biQub</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>0</td>\n",
- " <td>TIN</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>7</th>\n",
- " <td>1</td>\n",
- " <td>p2p</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>8</th>\n",
- " <td>1</td>\n",
- " <td>clos</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>9</th>\n",
- " <td>1</td>\n",
- " <td>wavg</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>10</th>\n",
- " <td>1</td>\n",
- " <td>biLin</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>1</td>\n",
- " <td>biQua</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>12</th>\n",
- " <td>1</td>\n",
- " <td>biQub</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>13</th>\n",
- " <td>1</td>\n",
- " <td>TIN</td>\n",
- " <td>10</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>0</td>\n",
- " <td>p2p</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>0</td>\n",
- " <td>clos</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>0</td>\n",
- " <td>wavg</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>0</td>\n",
- " <td>biLin</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>0</td>\n",
- " <td>biQua</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>5</th>\n",
- " <td>0</td>\n",
- " <td>biQub</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>0</td>\n",
- " <td>TIN</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>7</th>\n",
- " <td>1</td>\n",
- " <td>p2p</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>8</th>\n",
- " <td>1</td>\n",
- " <td>clos</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>9</th>\n",
- " <td>1</td>\n",
- " <td>wavg</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>10</th>\n",
- " <td>1</td>\n",
- " <td>biLin</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>1</td>\n",
- " <td>biQua</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>12</th>\n",
- " <td>1</td>\n",
- " <td>biQub</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>13</th>\n",
- " <td>1</td>\n",
- " <td>TIN</td>\n",
- " <td>30</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>0</td>\n",
- " <td>p2p</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>0</td>\n",
- " <td>clos</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>0</td>\n",
- " <td>wavg</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>0</td>\n",
- " <td>biLin</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>0</td>\n",
- " <td>biQua</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>5</th>\n",
- " <td>0</td>\n",
- " <td>biQub</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>0</td>\n",
- " <td>TIN</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>7</th>\n",
- " <td>1</td>\n",
- " <td>p2p</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>8</th>\n",
- " <td>1</td>\n",
- " <td>clos</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>9</th>\n",
- " <td>1</td>\n",
- " <td>wavg</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>10</th>\n",
- " <td>1</td>\n",
- " <td>biLin</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>1</td>\n",
- " <td>biQua</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>12</th>\n",
- " <td>1</td>\n",
- " <td>biQub</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>13</th>\n",
- " <td>1</td>\n",
- " <td>TIN</td>\n",
- " <td>100</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>0</td>\n",
- " <td>p2p</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>0</td>\n",
- " <td>clos</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>0</td>\n",
- " <td>wavg</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>0</td>\n",
- " <td>biLin</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>0</td>\n",
- " <td>biQua</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>5</th>\n",
- " <td>0</td>\n",
- " <td>biQub</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>0</td>\n",
- " <td>TIN</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>7</th>\n",
- " <td>1</td>\n",
- " <td>p2p</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>8</th>\n",
- " <td>1</td>\n",
- " <td>clos</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>9</th>\n",
- " <td>1</td>\n",
- " <td>wavg</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>10</th>\n",
- " <td>1</td>\n",
- " <td>biLin</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>1</td>\n",
- " <td>biQua</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>12</th>\n",
- " <td>1</td>\n",
- " <td>biQub</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>13</th>\n",
- " <td>1</td>\n",
- " <td>TIN</td>\n",
- " <td>1000</td>\n",
- " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
- " <td>Colorado</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " transect method resolution \\\n",
- "0 0 clos 3 \n",
- "1 1 clos 3 \n",
- "0 0 p2p 10 \n",
- "1 0 clos 10 \n",
- "2 0 wavg 10 \n",
- "3 0 biLin 10 \n",
- "4 0 biQua 10 \n",
- "5 0 biQub 10 \n",
- "6 0 TIN 10 \n",
- "7 1 p2p 10 \n",
- "8 1 clos 10 \n",
- "9 1 wavg 10 \n",
- "10 1 biLin 10 \n",
- "11 1 biQua 10 \n",
- "12 1 biQub 10 \n",
- "13 1 TIN 10 \n",
- "0 0 p2p 30 \n",
- "1 0 clos 30 \n",
- "2 0 wavg 30 \n",
- "3 0 biLin 30 \n",
- "4 0 biQua 30 \n",
- "5 0 biQub 30 \n",
- "6 0 TIN 30 \n",
- "7 1 p2p 30 \n",
- "8 1 clos 30 \n",
- "9 1 wavg 30 \n",
- "10 1 biLin 30 \n",
- "11 1 biQua 30 \n",
- "12 1 biQub 30 \n",
- "13 1 TIN 30 \n",
- "0 0 p2p 100 \n",
- "1 0 clos 100 \n",
- "2 0 wavg 100 \n",
- "3 0 biLin 100 \n",
- "4 0 biQua 100 \n",
- "5 0 biQub 100 \n",
- "6 0 TIN 100 \n",
- "7 1 p2p 100 \n",
- "8 1 clos 100 \n",
- "9 1 wavg 100 \n",
- "10 1 biLin 100 \n",
- "11 1 biQua 100 \n",
- "12 1 biQub 100 \n",
- "13 1 TIN 100 \n",
- "0 0 p2p 1000 \n",
- "1 0 clos 1000 \n",
- "2 0 wavg 1000 \n",
- "3 0 biLin 1000 \n",
- "4 0 biQua 1000 \n",
- "5 0 biQub 1000 \n",
- "6 0 TIN 1000 \n",
- "7 1 p2p 1000 \n",
- "8 1 clos 1000 \n",
- "9 1 wavg 1000 \n",
- "10 1 biLin 1000 \n",
- "11 1 biQua 1000 \n",
- "12 1 biQub 1000 \n",
- "13 1 TIN 1000 \n",
- "\n",
- " path area \n",
- "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
- "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado "
- ]
- },
- "execution_count": 10,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# subset transects\n",
- "n_transects = 2\n",
- "cases_df = cases_df.loc[lambda df: df.transect < n_transects, :]\n",
- "cases_df"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "collapsed": false
- },
- "source": [
- "The next line maps our distance function to all of the cases with automatic load balancing. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {
- "collapsed": false,
- "scrolled": true
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Processing\n"
- ]
- },
- {
- "ename": "CompositeError",
- "evalue": "one or more exceptions from call to method: distance\n[Engine Exception]TypeError: catching classes that do not inherit from BaseException is not allowed\n[Engine Exception]TypeError: catching classes that do not inherit from BaseException is not allowed\n[Engine Exception]TypeError: catching classes that do not inherit from BaseException is not allowed\n[Engine Exception]TypeError: catching classes that do not inherit from BaseException is not allowed\n.... 46 more exceptions ...",
- "output_type": "error",
- "traceback": [
- "[Engine Exception]",
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 42\u001b[1;33m \u001b[0mZ\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdem_elv\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 43\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
- "During handling of the above exception, another exception occurred:",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)\u001b[1;32m<string>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m",
- "\u001b[1;32m/curc/tools/x86_64/rh6/software/python/3.4.3/intel/15.0.2/lib/python3.4/site-packages/ipyparallel/client/remotefunction.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(f, *sequences)\u001b[0m",
- "\u001b[0;32m 248\u001b[0m )",
- "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 250\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mblock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 251\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
- "\u001b[0;32m 58\u001b[0m \u001b[1;31m# compute elevation of each sample point\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 59\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 60\u001b[1;33m \u001b[0mnb_x\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_y\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_z\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_nb_vals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrows\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcols\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 61\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"clos\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 62\u001b[0m \u001b[0melev\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mget_nb_vals\u001b[1;34m(i, pnts, dem, top_left_cor, cellsize, rows, cols)\u001b[0m",
- "\u001b[0;32m 251\u001b[0m \u001b[0min_data_avg\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 253\u001b[1;33m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m<\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 42\u001b[0m \u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 43\u001b[1;33m \u001b[0mindx_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 45\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
- "",
- "[Engine Exception]",
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 42\u001b[1;33m \u001b[0mZ\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdem_elv\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 43\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
- "During handling of the above exception, another exception occurred:",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)\u001b[1;32m<string>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m",
- "\u001b[1;32m/curc/tools/x86_64/rh6/software/python/3.4.3/intel/15.0.2/lib/python3.4/site-packages/ipyparallel/client/remotefunction.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(f, *sequences)\u001b[0m",
- "\u001b[0;32m 248\u001b[0m )",
- "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 250\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mblock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 251\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
- "\u001b[0;32m 58\u001b[0m \u001b[1;31m# compute elevation of each sample point\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 59\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 60\u001b[1;33m \u001b[0mnb_x\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_y\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_z\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_nb_vals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrows\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcols\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 61\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"clos\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 62\u001b[0m \u001b[0melev\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mget_nb_vals\u001b[1;34m(i, pnts, dem, top_left_cor, cellsize, rows, cols)\u001b[0m",
- "\u001b[0;32m 251\u001b[0m \u001b[0min_data_avg\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 253\u001b[1;33m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m<\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 42\u001b[0m \u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 43\u001b[1;33m \u001b[0mindx_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 45\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
- "",
- "[Engine Exception]",
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mp2p_xyz\u001b[1;34m(start_point, end_point, top_left_cor, cellsize, dem)\u001b[0m",
- "\u001b[0;32m 204\u001b[0m \u001b[0mGenerates\u001b[0m \u001b[0mstart\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mend\u001b[0m \u001b[0mpoints\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0ma\u001b[0m \u001b[0mtransect\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 205\u001b[1;33m \"\"\" ",
- "\u001b[0m\u001b[0;32m 206\u001b[0m \u001b[0mtransect_array\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgenfromtxt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;34m'transect_pts.csv'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdelimiter\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\",\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
- "During handling of the above exception, another exception occurred:",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)\u001b[1;32m<string>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m",
- "\u001b[1;32m/curc/tools/x86_64/rh6/software/python/3.4.3/intel/15.0.2/lib/python3.4/site-packages/ipyparallel/client/remotefunction.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(f, *sequences)\u001b[0m",
- "\u001b[0;32m 248\u001b[0m )",
- "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 250\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mblock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 251\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
- "\u001b[0;32m 48\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 49\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"p2p\"\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# pixel to pixel distance\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 50\u001b[1;33m \u001b[0mpnts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0melev\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mp2p_xyz\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstart_point\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_point\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 51\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# must be one of clos, wavg, bilin, biqua, biqub, tin, or nn\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 52\u001b[0m \u001b[0mpnts\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmake_pnts\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstart_point\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_point\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mp2p_xyz\u001b[1;34m(start_point, end_point, top_left_cor, cellsize, dem)\u001b[0m",
- "\u001b[0;32m 204\u001b[0m \u001b[0mGenerates\u001b[0m \u001b[0mstart\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mend\u001b[0m \u001b[0mpoints\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0ma\u001b[0m \u001b[0mtransect\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 205\u001b[0m \"\"\" ",
- "\u001b[1;32m--> 206\u001b[1;33m \u001b[0mtransect_array\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgenfromtxt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;34m'transect_pts.csv'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdelimiter\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\",\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 207\u001b[0m \u001b[0mstart_point\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtransect_array\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mtransect\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 208\u001b[0m \u001b[0mend_point\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtransect_array\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mtransect\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
- "",
- "[Engine Exception]",
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 42\u001b[1;33m \u001b[0mZ\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdem_elv\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 43\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
- "During handling of the above exception, another exception occurred:",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)\u001b[1;32m<string>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m",
- "\u001b[1;32m/curc/tools/x86_64/rh6/software/python/3.4.3/intel/15.0.2/lib/python3.4/site-packages/ipyparallel/client/remotefunction.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(f, *sequences)\u001b[0m",
- "\u001b[0;32m 248\u001b[0m )",
- "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 250\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mblock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 251\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
- "\u001b[0;32m 58\u001b[0m \u001b[1;31m# compute elevation of each sample point\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 59\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 60\u001b[1;33m \u001b[0mnb_x\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_y\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_z\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_nb_vals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrows\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcols\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 61\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"clos\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 62\u001b[0m \u001b[0melev\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mget_nb_vals\u001b[1;34m(i, pnts, dem, top_left_cor, cellsize, rows, cols)\u001b[0m",
- "\u001b[0;32m 251\u001b[0m \u001b[0min_data_avg\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0min_data\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 252\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m--> 253\u001b[1;33m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mnb_z\u001b[0m\u001b[1;33m<\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m3.4e+10\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0min_data_avg\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m",
- "\u001b[0;32m 41\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m==\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 42\u001b[0m \u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;32m---> 43\u001b[1;33m \u001b[0mindx_dif_sum\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindx_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdem_inbox\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[0;32m 45\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mshape_dif_sum\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
- "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
- "",
- "... 46 more exceptions ..."
- ]
- }
- ],
- "source": [
- "# in parallel\n",
- "print(\"Processing\")\n",
- "res = lview.map(surfaceAdjusted.distance, \n",
- " cases_df['transect'].tolist(), \n",
- " cases_df['method'].tolist(), \n",
- " cases_df['resolution'].tolist(), \n",
- " cases_df['path'].tolist())"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "# the next lines are for interactive progress tracking\n",
- "#frac_done = 1.0 * res.progress / len(res)\n",
- "#print(\"Progress: \" + str(100 * frac_done) + \"% done\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "ename": "TypeError",
- "evalue": "catching classes that do not inherit from BaseException is not allowed",
- "output_type": "error",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m\n\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 42\u001b[1;33m \u001b[0mZ\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdem_elv\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 43\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
- "\nDuring handling of the above exception, another exception occurred:\n",
- "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-12-26b94b2d11ef>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mcases_df\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'method'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mcases_df\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'resolution'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m cases_df['path'].tolist()[0])\n\u001b[0m",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m\n\u001b[0;32m 58\u001b[0m \u001b[1;31m# compute elevation of each sample point\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 59\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 60\u001b[1;33m \u001b[0mnb_x\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_y\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnb_z\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_nb_vals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpnts\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcellsize\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mrows\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcols\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 61\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"clos\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 62\u001b[0m \u001b[0melev\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnb_z\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mget_nb_vals\u001b[1;34m(i, pnts, dem, top_left_cor, cellsize, rows, cols)\u001b[0m\n\u001b[0;32m 239\u001b[0m \u001b[0mdem\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 240\u001b[0m \u001b[0mtop_left_cor\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 241\u001b[1;33m cellsize)\n\u001b[0m\u001b[0;32m 242\u001b[0m \u001b[1;31m#Deal with sample points near boundary of the DEM\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 243\u001b[0m \u001b[0mpoint_within_dem\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mcell_X\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>=\u001b[0m\u001b[1;36m0\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mcell_Y\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m>=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mcell_X\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m<=\u001b[0m\u001b[0mcols\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mcell_Y\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m<=\u001b[0m\u001b[0mrows\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/misc.py\u001b[0m in \u001b[0;36mgetCellValue\u001b[1;34m(point, dem, top_left_cor, cellsize)\u001b[0m\n\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 42\u001b[0m \u001b[0mZ\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mdem_elv\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 43\u001b[1;33m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mz_indx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Oops! That was more than one indices in dem matching the query index (in getCellValue)\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 45\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed"
- ]
- }
- ],
- "source": [
- "# try just one case\n",
- "surfaceAdjusted.distance(\n",
- " cases_df['transect'].tolist()[0], \n",
- " cases_df['method'].tolist()[0], \n",
- " cases_df['resolution'].tolist()[0], \n",
- " cases_df['path'].tolist()[0])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "scrolled": true
- },
- "outputs": [],
- "source": [
- "#is_done = frac_done == 1.0\n",
- "#if is_done:\n",
- " # add result to data frame\n",
- "# cases_df['distance'] = res.get()\n",
- "#cases_df"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "# save the output to csv\n",
- "# df.to_csv(\"output/results.csv\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "anaconda-cloud": {},
- "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.4.5"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement