Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 72.20 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Surface adjusted distance project\n",
  8. "\n",
  9. "Start by loading up some packages. "
  10. ]
  11. },
  12. {
  13. "cell_type": "code",
  14. "execution_count": 1,
  15. "metadata": {
  16. "collapsed": false
  17. },
  18. "outputs": [
  19. {
  20. "name": "stdout",
  21. "output_type": "stream",
  22. "text": [
  23. "3.4.5 (default, Jun 27 2016, 13:21:51) \n",
  24. "[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]\n"
  25. ]
  26. }
  27. ],
  28. "source": [
  29. "import sys\n",
  30. "print (sys.version)\n",
  31. "sys.path.append(\"/home/majo3748/.local/lib/python3.4/site-packages\")\n",
  32. "sys.path.append(\"/projects/majo3748/TerrainMetrics_conda2\")\n",
  33. "import time\n",
  34. "import itertools\n",
  35. "import cProfile, pstats\n",
  36. "import os.path\n",
  37. "import numpy as np\n",
  38. "import pandas as pd\n",
  39. "from ipyparallel import Client\n",
  40. "import surfaceAdjusted"
  41. ]
  42. },
  43. {
  44. "cell_type": "markdown",
  45. "metadata": {},
  46. "source": [
  47. "Verify that the cluster is up and running"
  48. ]
  49. },
  50. {
  51. "cell_type": "code",
  52. "execution_count": 2,
  53. "metadata": {
  54. "collapsed": false
  55. },
  56. "outputs": [
  57. {
  58. "name": "stdout",
  59. "output_type": "stream",
  60. "text": [
  61. "[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"
  62. ]
  63. }
  64. ],
  65. "source": [
  66. "# check cluster status\n",
  67. "rc = Client(profile=\"janus-cpu\")\n",
  68. "print(rc.ids)"
  69. ]
  70. },
  71. {
  72. "cell_type": "code",
  73. "execution_count": 3,
  74. "metadata": {
  75. "collapsed": false
  76. },
  77. "outputs": [
  78. {
  79. "name": "stdout",
  80. "output_type": "stream",
  81. "text": [
  82. "<LoadBalancedView None>\n"
  83. ]
  84. }
  85. ],
  86. "source": [
  87. "lview = rc.load_balanced_view()\n",
  88. "lview.block = True\n",
  89. "print(lview)"
  90. ]
  91. },
  92. {
  93. "cell_type": "code",
  94. "execution_count": 4,
  95. "metadata": {
  96. "collapsed": false
  97. },
  98. "outputs": [
  99. {
  100. "data": {
  101. "text/plain": [
  102. "[0,\n",
  103. " 1,\n",
  104. " 1024,\n",
  105. " 59049,\n",
  106. " 1048576,\n",
  107. " 9765625,\n",
  108. " 60466176,\n",
  109. " 282475249,\n",
  110. " 1073741824,\n",
  111. " 3486784401,\n",
  112. " 10000000000,\n",
  113. " 25937424601,\n",
  114. " 61917364224,\n",
  115. " 137858491849,\n",
  116. " 289254654976,\n",
  117. " 576650390625,\n",
  118. " 1099511627776,\n",
  119. " 2015993900449,\n",
  120. " 3570467226624,\n",
  121. " 6131066257801,\n",
  122. " 10240000000000,\n",
  123. " 16679880978201,\n",
  124. " 26559922791424,\n",
  125. " 41426511213649,\n",
  126. " 63403380965376,\n",
  127. " 95367431640625,\n",
  128. " 141167095653376,\n",
  129. " 205891132094649,\n",
  130. " 296196766695424,\n",
  131. " 420707233300201,\n",
  132. " 590490000000000,\n",
  133. " 819628286980801]"
  134. ]
  135. },
  136. "execution_count": 4,
  137. "metadata": {},
  138. "output_type": "execute_result"
  139. }
  140. ],
  141. "source": [
  142. "#test it \n",
  143. "lview.map(lambda x:x**10, range(32))\n"
  144. ]
  145. },
  146. {
  147. "cell_type": "markdown",
  148. "metadata": {},
  149. "source": [
  150. "Now use `%` to import packages on each of the processors."
  151. ]
  152. },
  153. {
  154. "cell_type": "code",
  155. "execution_count": 5,
  156. "metadata": {
  157. "collapsed": false
  158. },
  159. "outputs": [],
  160. "source": [
  161. "%px import sys\n",
  162. "%px sys.path.append(\"/home/majo3748/.local/lib/python3.4/site-packages\")\n",
  163. "%px sys.path.append(\"/projects/majo3748/TerrainMetrics_conda2\")\n",
  164. "\n",
  165. "# load surfaceAdjusted module on each worker\n",
  166. "%px import surfaceAdjusted"
  167. ]
  168. },
  169. {
  170. "cell_type": "markdown",
  171. "metadata": {},
  172. "source": [
  173. "## Determining the cases \n",
  174. "\n",
  175. "We need to generate a data frame containing a row for each distance calculation we want to do. \n",
  176. "The following code blocks assign the cases of interest, and generate all relevant combinations, producing a data frame at the end."
  177. ]
  178. },
  179. {
  180. "cell_type": "code",
  181. "execution_count": 6,
  182. "metadata": {
  183. "collapsed": false
  184. },
  185. "outputs": [],
  186. "source": [
  187. "resolution_L = [3,10,30,100,1000]\n",
  188. "\n",
  189. "# NN interpolation does not work, leave commented out\n",
  190. "methods = ['p2p', 'clos', 'wavg', 'biLin', 'biQua', 'biQub', 'TIN']#, 'NN']\n",
  191. "\n",
  192. "# for testing, just use one state\n",
  193. "study_areas = [\"Colorado\"] #[\"Colorado\", \"Nebraska\", \"Louisiana\", \"Washington\", \"NC\", \"Texas\"]\n",
  194. "\n",
  195. "# the duplicated end of this path is NOT a typo\n",
  196. "data_dir = r\"/work/earthlab/EarthLab_shared/data_harm/Modified_2/Modified_2/\""
  197. ]
  198. },
  199. {
  200. "cell_type": "code",
  201. "execution_count": 7,
  202. "metadata": {
  203. "collapsed": false
  204. },
  205. "outputs": [],
  206. "source": [
  207. "def expandgrid(*itrs):\n",
  208. " \"\"\"\n",
  209. " Generate all possible combinations of elements in multiple lists\n",
  210. " \n",
  211. " Args:\n",
  212. " - lists separated by commas\n",
  213. " \n",
  214. " Example:\n",
  215. " >>> expandgrid([0, 1], [2, 3, 4])\n",
  216. " >>> [[0, 0, 0, 1, 1, 1], [2, 3, 4, 2, 3, 4]]\n",
  217. " \n",
  218. " Returns: \n",
  219. " - a list of lists, with one element in each inner list for each \n",
  220. " combination of elements in the input lists\n",
  221. " \"\"\"\n",
  222. " product = list(itertools.product(*itrs))\n",
  223. " return [[x[i] for x in product] for i in range(len(itrs))]"
  224. ]
  225. },
  226. {
  227. "cell_type": "code",
  228. "execution_count": 8,
  229. "metadata": {
  230. "collapsed": false,
  231. "scrolled": true
  232. },
  233. "outputs": [
  234. {
  235. "data": {
  236. "text/html": [
  237. "<div>\n",
  238. "<table border=\"1\" class=\"dataframe\">\n",
  239. " <thead>\n",
  240. " <tr style=\"text-align: right;\">\n",
  241. " <th></th>\n",
  242. " <th>transect</th>\n",
  243. " <th>method</th>\n",
  244. " <th>resolution</th>\n",
  245. " <th>path</th>\n",
  246. " <th>area</th>\n",
  247. " </tr>\n",
  248. " </thead>\n",
  249. " <tbody>\n",
  250. " <tr>\n",
  251. " <th>count</th>\n",
  252. " <td>29000</td>\n",
  253. " <td>29000</td>\n",
  254. " <td>29000</td>\n",
  255. " <td>29000</td>\n",
  256. " <td>29000</td>\n",
  257. " </tr>\n",
  258. " <tr>\n",
  259. " <th>unique</th>\n",
  260. " <td>1000</td>\n",
  261. " <td>7</td>\n",
  262. " <td>5</td>\n",
  263. " <td>1</td>\n",
  264. " <td>1</td>\n",
  265. " </tr>\n",
  266. " <tr>\n",
  267. " <th>top</th>\n",
  268. " <td>999</td>\n",
  269. " <td>clos</td>\n",
  270. " <td>1000</td>\n",
  271. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  272. " <td>Colorado</td>\n",
  273. " </tr>\n",
  274. " <tr>\n",
  275. " <th>freq</th>\n",
  276. " <td>29</td>\n",
  277. " <td>5000</td>\n",
  278. " <td>7000</td>\n",
  279. " <td>29000</td>\n",
  280. " <td>29000</td>\n",
  281. " </tr>\n",
  282. " </tbody>\n",
  283. "</table>\n",
  284. "</div>"
  285. ],
  286. "text/plain": [
  287. " transect method resolution \\\n",
  288. "count 29000 29000 29000 \n",
  289. "unique 1000 7 5 \n",
  290. "top 999 clos 1000 \n",
  291. "freq 29 5000 7000 \n",
  292. "\n",
  293. " path area \n",
  294. "count 29000 29000 \n",
  295. "unique 1 1 \n",
  296. "top /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  297. "freq 29000 29000 "
  298. ]
  299. },
  300. "execution_count": 8,
  301. "metadata": {},
  302. "output_type": "execute_result"
  303. }
  304. ],
  305. "source": [
  306. "# Determine all of the cases to compute (area X resolution X transect X method combinations)\n",
  307. "cases_list = []\n",
  308. "for area in study_areas:\n",
  309. " area_start_time = time.time()\n",
  310. " area_path = data_dir + area + '/'\n",
  311. " area_transects = np.genfromtxt(area_path + \"/simulation/\" + 'tran_sim_pts.csv', delimiter=\",\")\n",
  312. " #area_transects = np.genfromtxt(area_path + 'transect_pts.csv', delimiter=\",\")\n",
  313. "\n",
  314. " \n",
  315. " for resolution in resolution_L:\n",
  316. " \n",
  317. " n_transects = int(area_transects.shape[0] / 2)\n",
  318. " transect_indices = [i for i in range(n_transects)]\n",
  319. "\n",
  320. " if resolution == 3:\n",
  321. " # subset 3m resolution to \"clos\" method only\n",
  322. " cases = expandgrid(transect_indices, [\"clos\"], [resolution], [area_path], [area])\n",
  323. " else:\n",
  324. " # determine all possible combinations of transects and methods\n",
  325. " cases = expandgrid(transect_indices, methods, [resolution], [area_path], [area])\n",
  326. " \n",
  327. " n_cases = len(cases[0])\n",
  328. " \n",
  329. " df = pd.DataFrame(cases).transpose()\n",
  330. " df.columns = [\"transect\", \"method\", \"resolution\", \"path\", \"area\"]\n",
  331. " cases_list.append(df)\n",
  332. "\n",
  333. "cases_df = pd.concat(cases_list)\n",
  334. "cases_df.describe()"
  335. ]
  336. },
  337. {
  338. "cell_type": "markdown",
  339. "metadata": {},
  340. "source": [
  341. "For testing purposes, we'll just use a few of the transects."
  342. ]
  343. },
  344. {
  345. "cell_type": "code",
  346. "execution_count": 10,
  347. "metadata": {
  348. "collapsed": false
  349. },
  350. "outputs": [
  351. {
  352. "data": {
  353. "text/html": [
  354. "<div>\n",
  355. "<table border=\"1\" class=\"dataframe\">\n",
  356. " <thead>\n",
  357. " <tr style=\"text-align: right;\">\n",
  358. " <th></th>\n",
  359. " <th>transect</th>\n",
  360. " <th>method</th>\n",
  361. " <th>resolution</th>\n",
  362. " <th>path</th>\n",
  363. " <th>area</th>\n",
  364. " </tr>\n",
  365. " </thead>\n",
  366. " <tbody>\n",
  367. " <tr>\n",
  368. " <th>0</th>\n",
  369. " <td>0</td>\n",
  370. " <td>clos</td>\n",
  371. " <td>3</td>\n",
  372. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  373. " <td>Colorado</td>\n",
  374. " </tr>\n",
  375. " <tr>\n",
  376. " <th>1</th>\n",
  377. " <td>1</td>\n",
  378. " <td>clos</td>\n",
  379. " <td>3</td>\n",
  380. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  381. " <td>Colorado</td>\n",
  382. " </tr>\n",
  383. " <tr>\n",
  384. " <th>0</th>\n",
  385. " <td>0</td>\n",
  386. " <td>p2p</td>\n",
  387. " <td>10</td>\n",
  388. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  389. " <td>Colorado</td>\n",
  390. " </tr>\n",
  391. " <tr>\n",
  392. " <th>1</th>\n",
  393. " <td>0</td>\n",
  394. " <td>clos</td>\n",
  395. " <td>10</td>\n",
  396. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  397. " <td>Colorado</td>\n",
  398. " </tr>\n",
  399. " <tr>\n",
  400. " <th>2</th>\n",
  401. " <td>0</td>\n",
  402. " <td>wavg</td>\n",
  403. " <td>10</td>\n",
  404. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  405. " <td>Colorado</td>\n",
  406. " </tr>\n",
  407. " <tr>\n",
  408. " <th>3</th>\n",
  409. " <td>0</td>\n",
  410. " <td>biLin</td>\n",
  411. " <td>10</td>\n",
  412. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  413. " <td>Colorado</td>\n",
  414. " </tr>\n",
  415. " <tr>\n",
  416. " <th>4</th>\n",
  417. " <td>0</td>\n",
  418. " <td>biQua</td>\n",
  419. " <td>10</td>\n",
  420. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  421. " <td>Colorado</td>\n",
  422. " </tr>\n",
  423. " <tr>\n",
  424. " <th>5</th>\n",
  425. " <td>0</td>\n",
  426. " <td>biQub</td>\n",
  427. " <td>10</td>\n",
  428. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  429. " <td>Colorado</td>\n",
  430. " </tr>\n",
  431. " <tr>\n",
  432. " <th>6</th>\n",
  433. " <td>0</td>\n",
  434. " <td>TIN</td>\n",
  435. " <td>10</td>\n",
  436. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  437. " <td>Colorado</td>\n",
  438. " </tr>\n",
  439. " <tr>\n",
  440. " <th>7</th>\n",
  441. " <td>1</td>\n",
  442. " <td>p2p</td>\n",
  443. " <td>10</td>\n",
  444. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  445. " <td>Colorado</td>\n",
  446. " </tr>\n",
  447. " <tr>\n",
  448. " <th>8</th>\n",
  449. " <td>1</td>\n",
  450. " <td>clos</td>\n",
  451. " <td>10</td>\n",
  452. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  453. " <td>Colorado</td>\n",
  454. " </tr>\n",
  455. " <tr>\n",
  456. " <th>9</th>\n",
  457. " <td>1</td>\n",
  458. " <td>wavg</td>\n",
  459. " <td>10</td>\n",
  460. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  461. " <td>Colorado</td>\n",
  462. " </tr>\n",
  463. " <tr>\n",
  464. " <th>10</th>\n",
  465. " <td>1</td>\n",
  466. " <td>biLin</td>\n",
  467. " <td>10</td>\n",
  468. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  469. " <td>Colorado</td>\n",
  470. " </tr>\n",
  471. " <tr>\n",
  472. " <th>11</th>\n",
  473. " <td>1</td>\n",
  474. " <td>biQua</td>\n",
  475. " <td>10</td>\n",
  476. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  477. " <td>Colorado</td>\n",
  478. " </tr>\n",
  479. " <tr>\n",
  480. " <th>12</th>\n",
  481. " <td>1</td>\n",
  482. " <td>biQub</td>\n",
  483. " <td>10</td>\n",
  484. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  485. " <td>Colorado</td>\n",
  486. " </tr>\n",
  487. " <tr>\n",
  488. " <th>13</th>\n",
  489. " <td>1</td>\n",
  490. " <td>TIN</td>\n",
  491. " <td>10</td>\n",
  492. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  493. " <td>Colorado</td>\n",
  494. " </tr>\n",
  495. " <tr>\n",
  496. " <th>0</th>\n",
  497. " <td>0</td>\n",
  498. " <td>p2p</td>\n",
  499. " <td>30</td>\n",
  500. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  501. " <td>Colorado</td>\n",
  502. " </tr>\n",
  503. " <tr>\n",
  504. " <th>1</th>\n",
  505. " <td>0</td>\n",
  506. " <td>clos</td>\n",
  507. " <td>30</td>\n",
  508. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  509. " <td>Colorado</td>\n",
  510. " </tr>\n",
  511. " <tr>\n",
  512. " <th>2</th>\n",
  513. " <td>0</td>\n",
  514. " <td>wavg</td>\n",
  515. " <td>30</td>\n",
  516. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  517. " <td>Colorado</td>\n",
  518. " </tr>\n",
  519. " <tr>\n",
  520. " <th>3</th>\n",
  521. " <td>0</td>\n",
  522. " <td>biLin</td>\n",
  523. " <td>30</td>\n",
  524. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  525. " <td>Colorado</td>\n",
  526. " </tr>\n",
  527. " <tr>\n",
  528. " <th>4</th>\n",
  529. " <td>0</td>\n",
  530. " <td>biQua</td>\n",
  531. " <td>30</td>\n",
  532. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  533. " <td>Colorado</td>\n",
  534. " </tr>\n",
  535. " <tr>\n",
  536. " <th>5</th>\n",
  537. " <td>0</td>\n",
  538. " <td>biQub</td>\n",
  539. " <td>30</td>\n",
  540. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  541. " <td>Colorado</td>\n",
  542. " </tr>\n",
  543. " <tr>\n",
  544. " <th>6</th>\n",
  545. " <td>0</td>\n",
  546. " <td>TIN</td>\n",
  547. " <td>30</td>\n",
  548. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  549. " <td>Colorado</td>\n",
  550. " </tr>\n",
  551. " <tr>\n",
  552. " <th>7</th>\n",
  553. " <td>1</td>\n",
  554. " <td>p2p</td>\n",
  555. " <td>30</td>\n",
  556. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  557. " <td>Colorado</td>\n",
  558. " </tr>\n",
  559. " <tr>\n",
  560. " <th>8</th>\n",
  561. " <td>1</td>\n",
  562. " <td>clos</td>\n",
  563. " <td>30</td>\n",
  564. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  565. " <td>Colorado</td>\n",
  566. " </tr>\n",
  567. " <tr>\n",
  568. " <th>9</th>\n",
  569. " <td>1</td>\n",
  570. " <td>wavg</td>\n",
  571. " <td>30</td>\n",
  572. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  573. " <td>Colorado</td>\n",
  574. " </tr>\n",
  575. " <tr>\n",
  576. " <th>10</th>\n",
  577. " <td>1</td>\n",
  578. " <td>biLin</td>\n",
  579. " <td>30</td>\n",
  580. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  581. " <td>Colorado</td>\n",
  582. " </tr>\n",
  583. " <tr>\n",
  584. " <th>11</th>\n",
  585. " <td>1</td>\n",
  586. " <td>biQua</td>\n",
  587. " <td>30</td>\n",
  588. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  589. " <td>Colorado</td>\n",
  590. " </tr>\n",
  591. " <tr>\n",
  592. " <th>12</th>\n",
  593. " <td>1</td>\n",
  594. " <td>biQub</td>\n",
  595. " <td>30</td>\n",
  596. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  597. " <td>Colorado</td>\n",
  598. " </tr>\n",
  599. " <tr>\n",
  600. " <th>13</th>\n",
  601. " <td>1</td>\n",
  602. " <td>TIN</td>\n",
  603. " <td>30</td>\n",
  604. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  605. " <td>Colorado</td>\n",
  606. " </tr>\n",
  607. " <tr>\n",
  608. " <th>0</th>\n",
  609. " <td>0</td>\n",
  610. " <td>p2p</td>\n",
  611. " <td>100</td>\n",
  612. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  613. " <td>Colorado</td>\n",
  614. " </tr>\n",
  615. " <tr>\n",
  616. " <th>1</th>\n",
  617. " <td>0</td>\n",
  618. " <td>clos</td>\n",
  619. " <td>100</td>\n",
  620. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  621. " <td>Colorado</td>\n",
  622. " </tr>\n",
  623. " <tr>\n",
  624. " <th>2</th>\n",
  625. " <td>0</td>\n",
  626. " <td>wavg</td>\n",
  627. " <td>100</td>\n",
  628. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  629. " <td>Colorado</td>\n",
  630. " </tr>\n",
  631. " <tr>\n",
  632. " <th>3</th>\n",
  633. " <td>0</td>\n",
  634. " <td>biLin</td>\n",
  635. " <td>100</td>\n",
  636. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  637. " <td>Colorado</td>\n",
  638. " </tr>\n",
  639. " <tr>\n",
  640. " <th>4</th>\n",
  641. " <td>0</td>\n",
  642. " <td>biQua</td>\n",
  643. " <td>100</td>\n",
  644. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  645. " <td>Colorado</td>\n",
  646. " </tr>\n",
  647. " <tr>\n",
  648. " <th>5</th>\n",
  649. " <td>0</td>\n",
  650. " <td>biQub</td>\n",
  651. " <td>100</td>\n",
  652. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  653. " <td>Colorado</td>\n",
  654. " </tr>\n",
  655. " <tr>\n",
  656. " <th>6</th>\n",
  657. " <td>0</td>\n",
  658. " <td>TIN</td>\n",
  659. " <td>100</td>\n",
  660. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  661. " <td>Colorado</td>\n",
  662. " </tr>\n",
  663. " <tr>\n",
  664. " <th>7</th>\n",
  665. " <td>1</td>\n",
  666. " <td>p2p</td>\n",
  667. " <td>100</td>\n",
  668. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  669. " <td>Colorado</td>\n",
  670. " </tr>\n",
  671. " <tr>\n",
  672. " <th>8</th>\n",
  673. " <td>1</td>\n",
  674. " <td>clos</td>\n",
  675. " <td>100</td>\n",
  676. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  677. " <td>Colorado</td>\n",
  678. " </tr>\n",
  679. " <tr>\n",
  680. " <th>9</th>\n",
  681. " <td>1</td>\n",
  682. " <td>wavg</td>\n",
  683. " <td>100</td>\n",
  684. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  685. " <td>Colorado</td>\n",
  686. " </tr>\n",
  687. " <tr>\n",
  688. " <th>10</th>\n",
  689. " <td>1</td>\n",
  690. " <td>biLin</td>\n",
  691. " <td>100</td>\n",
  692. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  693. " <td>Colorado</td>\n",
  694. " </tr>\n",
  695. " <tr>\n",
  696. " <th>11</th>\n",
  697. " <td>1</td>\n",
  698. " <td>biQua</td>\n",
  699. " <td>100</td>\n",
  700. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  701. " <td>Colorado</td>\n",
  702. " </tr>\n",
  703. " <tr>\n",
  704. " <th>12</th>\n",
  705. " <td>1</td>\n",
  706. " <td>biQub</td>\n",
  707. " <td>100</td>\n",
  708. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  709. " <td>Colorado</td>\n",
  710. " </tr>\n",
  711. " <tr>\n",
  712. " <th>13</th>\n",
  713. " <td>1</td>\n",
  714. " <td>TIN</td>\n",
  715. " <td>100</td>\n",
  716. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  717. " <td>Colorado</td>\n",
  718. " </tr>\n",
  719. " <tr>\n",
  720. " <th>0</th>\n",
  721. " <td>0</td>\n",
  722. " <td>p2p</td>\n",
  723. " <td>1000</td>\n",
  724. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  725. " <td>Colorado</td>\n",
  726. " </tr>\n",
  727. " <tr>\n",
  728. " <th>1</th>\n",
  729. " <td>0</td>\n",
  730. " <td>clos</td>\n",
  731. " <td>1000</td>\n",
  732. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  733. " <td>Colorado</td>\n",
  734. " </tr>\n",
  735. " <tr>\n",
  736. " <th>2</th>\n",
  737. " <td>0</td>\n",
  738. " <td>wavg</td>\n",
  739. " <td>1000</td>\n",
  740. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  741. " <td>Colorado</td>\n",
  742. " </tr>\n",
  743. " <tr>\n",
  744. " <th>3</th>\n",
  745. " <td>0</td>\n",
  746. " <td>biLin</td>\n",
  747. " <td>1000</td>\n",
  748. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  749. " <td>Colorado</td>\n",
  750. " </tr>\n",
  751. " <tr>\n",
  752. " <th>4</th>\n",
  753. " <td>0</td>\n",
  754. " <td>biQua</td>\n",
  755. " <td>1000</td>\n",
  756. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  757. " <td>Colorado</td>\n",
  758. " </tr>\n",
  759. " <tr>\n",
  760. " <th>5</th>\n",
  761. " <td>0</td>\n",
  762. " <td>biQub</td>\n",
  763. " <td>1000</td>\n",
  764. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  765. " <td>Colorado</td>\n",
  766. " </tr>\n",
  767. " <tr>\n",
  768. " <th>6</th>\n",
  769. " <td>0</td>\n",
  770. " <td>TIN</td>\n",
  771. " <td>1000</td>\n",
  772. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  773. " <td>Colorado</td>\n",
  774. " </tr>\n",
  775. " <tr>\n",
  776. " <th>7</th>\n",
  777. " <td>1</td>\n",
  778. " <td>p2p</td>\n",
  779. " <td>1000</td>\n",
  780. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  781. " <td>Colorado</td>\n",
  782. " </tr>\n",
  783. " <tr>\n",
  784. " <th>8</th>\n",
  785. " <td>1</td>\n",
  786. " <td>clos</td>\n",
  787. " <td>1000</td>\n",
  788. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  789. " <td>Colorado</td>\n",
  790. " </tr>\n",
  791. " <tr>\n",
  792. " <th>9</th>\n",
  793. " <td>1</td>\n",
  794. " <td>wavg</td>\n",
  795. " <td>1000</td>\n",
  796. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  797. " <td>Colorado</td>\n",
  798. " </tr>\n",
  799. " <tr>\n",
  800. " <th>10</th>\n",
  801. " <td>1</td>\n",
  802. " <td>biLin</td>\n",
  803. " <td>1000</td>\n",
  804. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  805. " <td>Colorado</td>\n",
  806. " </tr>\n",
  807. " <tr>\n",
  808. " <th>11</th>\n",
  809. " <td>1</td>\n",
  810. " <td>biQua</td>\n",
  811. " <td>1000</td>\n",
  812. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  813. " <td>Colorado</td>\n",
  814. " </tr>\n",
  815. " <tr>\n",
  816. " <th>12</th>\n",
  817. " <td>1</td>\n",
  818. " <td>biQub</td>\n",
  819. " <td>1000</td>\n",
  820. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  821. " <td>Colorado</td>\n",
  822. " </tr>\n",
  823. " <tr>\n",
  824. " <th>13</th>\n",
  825. " <td>1</td>\n",
  826. " <td>TIN</td>\n",
  827. " <td>1000</td>\n",
  828. " <td>/work/earthlab/EarthLab_shared/data_harm/Modif...</td>\n",
  829. " <td>Colorado</td>\n",
  830. " </tr>\n",
  831. " </tbody>\n",
  832. "</table>\n",
  833. "</div>"
  834. ],
  835. "text/plain": [
  836. " transect method resolution \\\n",
  837. "0 0 clos 3 \n",
  838. "1 1 clos 3 \n",
  839. "0 0 p2p 10 \n",
  840. "1 0 clos 10 \n",
  841. "2 0 wavg 10 \n",
  842. "3 0 biLin 10 \n",
  843. "4 0 biQua 10 \n",
  844. "5 0 biQub 10 \n",
  845. "6 0 TIN 10 \n",
  846. "7 1 p2p 10 \n",
  847. "8 1 clos 10 \n",
  848. "9 1 wavg 10 \n",
  849. "10 1 biLin 10 \n",
  850. "11 1 biQua 10 \n",
  851. "12 1 biQub 10 \n",
  852. "13 1 TIN 10 \n",
  853. "0 0 p2p 30 \n",
  854. "1 0 clos 30 \n",
  855. "2 0 wavg 30 \n",
  856. "3 0 biLin 30 \n",
  857. "4 0 biQua 30 \n",
  858. "5 0 biQub 30 \n",
  859. "6 0 TIN 30 \n",
  860. "7 1 p2p 30 \n",
  861. "8 1 clos 30 \n",
  862. "9 1 wavg 30 \n",
  863. "10 1 biLin 30 \n",
  864. "11 1 biQua 30 \n",
  865. "12 1 biQub 30 \n",
  866. "13 1 TIN 30 \n",
  867. "0 0 p2p 100 \n",
  868. "1 0 clos 100 \n",
  869. "2 0 wavg 100 \n",
  870. "3 0 biLin 100 \n",
  871. "4 0 biQua 100 \n",
  872. "5 0 biQub 100 \n",
  873. "6 0 TIN 100 \n",
  874. "7 1 p2p 100 \n",
  875. "8 1 clos 100 \n",
  876. "9 1 wavg 100 \n",
  877. "10 1 biLin 100 \n",
  878. "11 1 biQua 100 \n",
  879. "12 1 biQub 100 \n",
  880. "13 1 TIN 100 \n",
  881. "0 0 p2p 1000 \n",
  882. "1 0 clos 1000 \n",
  883. "2 0 wavg 1000 \n",
  884. "3 0 biLin 1000 \n",
  885. "4 0 biQua 1000 \n",
  886. "5 0 biQub 1000 \n",
  887. "6 0 TIN 1000 \n",
  888. "7 1 p2p 1000 \n",
  889. "8 1 clos 1000 \n",
  890. "9 1 wavg 1000 \n",
  891. "10 1 biLin 1000 \n",
  892. "11 1 biQua 1000 \n",
  893. "12 1 biQub 1000 \n",
  894. "13 1 TIN 1000 \n",
  895. "\n",
  896. " path area \n",
  897. "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  898. "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  899. "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  900. "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  901. "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  902. "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  903. "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  904. "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  905. "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  906. "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  907. "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  908. "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  909. "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  910. "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  911. "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  912. "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  913. "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  914. "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  915. "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  916. "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  917. "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  918. "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  919. "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  920. "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  921. "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  922. "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  923. "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  924. "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  925. "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  926. "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  927. "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  928. "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  929. "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  930. "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  931. "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  932. "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  933. "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  934. "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  935. "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  936. "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  937. "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  938. "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  939. "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  940. "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  941. "0 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  942. "1 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  943. "2 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  944. "3 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  945. "4 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  946. "5 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  947. "6 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  948. "7 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  949. "8 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  950. "9 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  951. "10 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  952. "11 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  953. "12 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado \n",
  954. "13 /work/earthlab/EarthLab_shared/data_harm/Modif... Colorado "
  955. ]
  956. },
  957. "execution_count": 10,
  958. "metadata": {},
  959. "output_type": "execute_result"
  960. }
  961. ],
  962. "source": [
  963. "# subset transects\n",
  964. "n_transects = 2\n",
  965. "cases_df = cases_df.loc[lambda df: df.transect < n_transects, :]\n",
  966. "cases_df"
  967. ]
  968. },
  969. {
  970. "cell_type": "markdown",
  971. "metadata": {
  972. "collapsed": false
  973. },
  974. "source": [
  975. "The next line maps our distance function to all of the cases with automatic load balancing. "
  976. ]
  977. },
  978. {
  979. "cell_type": "code",
  980. "execution_count": 11,
  981. "metadata": {
  982. "collapsed": false,
  983. "scrolled": true
  984. },
  985. "outputs": [
  986. {
  987. "name": "stdout",
  988. "output_type": "stream",
  989. "text": [
  990. "Processing\n"
  991. ]
  992. },
  993. {
  994. "ename": "CompositeError",
  995. "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 ...",
  996. "output_type": "error",
  997. "traceback": [
  998. "[Engine Exception]",
  999. "\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",
  1000. "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
  1001. "\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",
  1002. "\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",
  1003. "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
  1004. "During handling of the above exception, another exception occurred:",
  1005. "\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",
  1006. "\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",
  1007. "\u001b[0;32m 248\u001b[0m )",
  1008. "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1009. "\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",
  1010. "\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",
  1011. "\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",
  1012. "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
  1013. "\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",
  1014. "\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",
  1015. "\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",
  1016. "\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",
  1017. "\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",
  1018. "\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",
  1019. "\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",
  1020. "\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",
  1021. "\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",
  1022. "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1023. "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1024. "\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",
  1025. "\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",
  1026. "\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",
  1027. "\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",
  1028. "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1029. "\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",
  1030. "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
  1031. "",
  1032. "[Engine Exception]",
  1033. "\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",
  1034. "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
  1035. "\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",
  1036. "\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",
  1037. "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
  1038. "During handling of the above exception, another exception occurred:",
  1039. "\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",
  1040. "\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",
  1041. "\u001b[0;32m 248\u001b[0m )",
  1042. "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1043. "\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",
  1044. "\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",
  1045. "\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",
  1046. "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
  1047. "\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",
  1048. "\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",
  1049. "\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",
  1050. "\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",
  1051. "\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",
  1052. "\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",
  1053. "\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",
  1054. "\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",
  1055. "\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",
  1056. "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1057. "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1058. "\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",
  1059. "\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",
  1060. "\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",
  1061. "\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",
  1062. "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1063. "\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",
  1064. "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
  1065. "",
  1066. "[Engine Exception]",
  1067. "\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",
  1068. "\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",
  1069. "\u001b[1;32m--> 205\u001b[1;33m \"\"\" ",
  1070. "\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",
  1071. "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
  1072. "During handling of the above exception, another exception occurred:",
  1073. "\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",
  1074. "\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",
  1075. "\u001b[0;32m 248\u001b[0m )",
  1076. "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1077. "\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",
  1078. "\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",
  1079. "\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",
  1080. "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
  1081. "\u001b[0;32m 48\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1082. "\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",
  1083. "\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",
  1084. "\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",
  1085. "\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",
  1086. "\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",
  1087. "\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",
  1088. "\u001b[0;32m 205\u001b[0m \"\"\" ",
  1089. "\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",
  1090. "\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",
  1091. "\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",
  1092. "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
  1093. "",
  1094. "[Engine Exception]",
  1095. "\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",
  1096. "\u001b[0;32m 41\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m",
  1097. "\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",
  1098. "\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",
  1099. "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
  1100. "During handling of the above exception, another exception occurred:",
  1101. "\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",
  1102. "\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",
  1103. "\u001b[0;32m 248\u001b[0m )",
  1104. "\u001b[0;32m 249\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1105. "\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",
  1106. "\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",
  1107. "\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",
  1108. "\u001b[1;32m/projects/majo3748/TerrainMetrics_conda2/surfaceAdjusted.py\u001b[0m in \u001b[0;36mdistance\u001b[1;34m(transect, method, res, path)\u001b[0m",
  1109. "\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",
  1110. "\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",
  1111. "\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",
  1112. "\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",
  1113. "\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",
  1114. "\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",
  1115. "\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",
  1116. "\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",
  1117. "\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",
  1118. "\u001b[0m\u001b[0;32m 254\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1119. "\u001b[0;32m 255\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1120. "\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",
  1121. "\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",
  1122. "\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",
  1123. "\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",
  1124. "\u001b[0m\u001b[0;32m 44\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m",
  1125. "\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",
  1126. "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed",
  1127. "",
  1128. "... 46 more exceptions ..."
  1129. ]
  1130. }
  1131. ],
  1132. "source": [
  1133. "# in parallel\n",
  1134. "print(\"Processing\")\n",
  1135. "res = lview.map(surfaceAdjusted.distance, \n",
  1136. " cases_df['transect'].tolist(), \n",
  1137. " cases_df['method'].tolist(), \n",
  1138. " cases_df['resolution'].tolist(), \n",
  1139. " cases_df['path'].tolist())"
  1140. ]
  1141. },
  1142. {
  1143. "cell_type": "code",
  1144. "execution_count": null,
  1145. "metadata": {
  1146. "collapsed": false
  1147. },
  1148. "outputs": [],
  1149. "source": [
  1150. "# the next lines are for interactive progress tracking\n",
  1151. "#frac_done = 1.0 * res.progress / len(res)\n",
  1152. "#print(\"Progress: \" + str(100 * frac_done) + \"% done\")"
  1153. ]
  1154. },
  1155. {
  1156. "cell_type": "code",
  1157. "execution_count": 12,
  1158. "metadata": {
  1159. "collapsed": false
  1160. },
  1161. "outputs": [
  1162. {
  1163. "ename": "TypeError",
  1164. "evalue": "catching classes that do not inherit from BaseException is not allowed",
  1165. "output_type": "error",
  1166. "traceback": [
  1167. "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
  1168. "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
  1169. "\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",
  1170. "\u001b[1;31mIndexError\u001b[0m: index 0 is out of bounds for axis 0 with size 0",
  1171. "\nDuring handling of the above exception, another exception occurred:\n",
  1172. "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
  1173. "\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",
  1174. "\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",
  1175. "\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",
  1176. "\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",
  1177. "\u001b[1;31mTypeError\u001b[0m: catching classes that do not inherit from BaseException is not allowed"
  1178. ]
  1179. }
  1180. ],
  1181. "source": [
  1182. "# try just one case\n",
  1183. "surfaceAdjusted.distance(\n",
  1184. " cases_df['transect'].tolist()[0], \n",
  1185. " cases_df['method'].tolist()[0], \n",
  1186. " cases_df['resolution'].tolist()[0], \n",
  1187. " cases_df['path'].tolist()[0])"
  1188. ]
  1189. },
  1190. {
  1191. "cell_type": "code",
  1192. "execution_count": null,
  1193. "metadata": {
  1194. "collapsed": false,
  1195. "scrolled": true
  1196. },
  1197. "outputs": [],
  1198. "source": [
  1199. "#is_done = frac_done == 1.0\n",
  1200. "#if is_done:\n",
  1201. " # add result to data frame\n",
  1202. "# cases_df['distance'] = res.get()\n",
  1203. "#cases_df"
  1204. ]
  1205. },
  1206. {
  1207. "cell_type": "code",
  1208. "execution_count": null,
  1209. "metadata": {
  1210. "collapsed": false
  1211. },
  1212. "outputs": [],
  1213. "source": [
  1214. "# save the output to csv\n",
  1215. "# df.to_csv(\"output/results.csv\")"
  1216. ]
  1217. },
  1218. {
  1219. "cell_type": "code",
  1220. "execution_count": null,
  1221. "metadata": {
  1222. "collapsed": true
  1223. },
  1224. "outputs": [],
  1225. "source": []
  1226. }
  1227. ],
  1228. "metadata": {
  1229. "anaconda-cloud": {},
  1230. "kernelspec": {
  1231. "display_name": "Python 3",
  1232. "language": "python",
  1233. "name": "python3"
  1234. },
  1235. "language_info": {
  1236. "codemirror_mode": {
  1237. "name": "ipython",
  1238. "version": 3
  1239. },
  1240. "file_extension": ".py",
  1241. "mimetype": "text/x-python",
  1242. "name": "python",
  1243. "nbconvert_exporter": "python",
  1244. "pygments_lexer": "ipython3",
  1245. "version": "3.4.5"
  1246. }
  1247. },
  1248. "nbformat": 4,
  1249. "nbformat_minor": 0
  1250. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement