|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "1011976b-d400-46b6-a91c-1f72a6ef9c77", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "# required import\n", |
| 11 | + "import os\n", |
| 12 | + "import geopandas as gpd\n", |
| 13 | + "import pandas as pd\n", |
| 14 | + "import matplotlib.pyplot as plt\n", |
| 15 | + "import matplotlib.font_manager as fm\n", |
| 16 | + "import matplotlib as mpl\n", |
| 17 | + "import numpy as np\n", |
| 18 | + "from matplotlib_scalebar.scalebar import ScaleBar\n", |
| 19 | + "\n", |
| 20 | + "# helper scripts to read in spatial results using pandas and geopandas\n", |
| 21 | + "import read_voi\n", |
| 22 | + "\n", |
| 23 | + "os.chdir('../..')\n" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "id": "cb743616-7f43-41af-9f99-b8f054d0544b", |
| 29 | + "metadata": {}, |
| 30 | + "source": [ |
| 31 | + "## Import Results Using Pandas and Geopandas" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "code", |
| 36 | + "execution_count": null, |
| 37 | + "id": "e984864f-99f9-4949-b9c6-2447c96e16a9", |
| 38 | + "metadata": {}, |
| 39 | + "outputs": [], |
| 40 | + "source": [ |
| 41 | + "par_results = 'results/test/parallel/' # change 2nd directory to test or reference\n", |
| 42 | + "ser_results = 'results/test/serial/'" |
| 43 | + ] |
| 44 | + }, |
| 45 | + { |
| 46 | + "cell_type": "code", |
| 47 | + "execution_count": null, |
| 48 | + "id": "f88a0b89-deae-467c-a1e2-015352951fa9", |
| 49 | + "metadata": {}, |
| 50 | + "outputs": [], |
| 51 | + "source": [ |
| 52 | + "# read in integrated spatial model results using pandas\n", |
| 53 | + "int_df_par = read_voi.merge_parallel_spatial_files(f'{par_results}bigsp',35072)\n", |
| 54 | + "int_df_ser = pd.read_csv(f'{ser_results}bigsp.35072_00i')\n", |
| 55 | + "\n", |
| 56 | + "# read in voronoi from serial, they should be identical between but reading in both for demonstrative purposes\n", |
| 57 | + "voi_ser,_ = read_voi.read_voi_file(f'{ser_results}bigsp_voi',join=int_df_ser)\n", |
| 58 | + "voi_par = read_voi.merge_parallel_voi(f'{par_results}bigsp_voi',join=int_df_par['35072'])" |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "markdown", |
| 63 | + "id": "e3b04c08-821b-45fd-af2f-4b4eecdf705f", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "## Plot Spatial Maps of Mean Evapotranspiration Rates Averaged Over The Length of Simulation" |
| 67 | + ] |
| 68 | + }, |
| 69 | + { |
| 70 | + "cell_type": "markdown", |
| 71 | + "id": "cf01bf53-b2ca-4f62-98cc-af1cbad0617a", |
| 72 | + "metadata": {}, |
| 73 | + "source": [ |
| 74 | + "### Parallel" |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "cell_type": "code", |
| 79 | + "execution_count": null, |
| 80 | + "id": "d8f26c70-c5bb-4116-a07f-406eb6543e38", |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [], |
| 83 | + "source": [ |
| 84 | + "cm = 1/2.54 # centimeters in inches\n", |
| 85 | + "fig,ax = plt.subplots(figsize=[18*cm,18*cm],layout='constrained')\n", |
| 86 | + "low = np.percentile(voi_par['AvET'], 2.5)\n", |
| 87 | + "high = np.percentile(voi_par['AvET'], 97.5)\n", |
| 88 | + "voi_par.plot(ax=ax,column='AvET',cmap='YlOrBr',legend=True,vmin=low,vmax=high,legend_kwds={'label': r'ET in mm/hr','orientation': 'horizontal',\"shrink\":.5})\n", |
| 89 | + "ax.add_artist(ScaleBar(1,location='lower left'))\n", |
| 90 | + "plt.title('Parallel, Big Spring, Arizona, USA: Map of Mean Evapotranspiration Rate')\n", |
| 91 | + "plt.axis('off')" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "markdown", |
| 96 | + "id": "6e71d0c1-477d-4def-ab2c-d31c3670c526", |
| 97 | + "metadata": {}, |
| 98 | + "source": [ |
| 99 | + "### Serial" |
| 100 | + ] |
| 101 | + }, |
| 102 | + { |
| 103 | + "cell_type": "code", |
| 104 | + "execution_count": null, |
| 105 | + "id": "4cdba6e1-04d6-4d48-bfc7-9d043bdcb404", |
| 106 | + "metadata": {}, |
| 107 | + "outputs": [], |
| 108 | + "source": [ |
| 109 | + "fig,ax = plt.subplots(figsize=[18*cm,18*cm],layout='constrained')\n", |
| 110 | + "low = np.percentile(voi_ser['AvET'], 2.5)\n", |
| 111 | + "high = np.percentile(voi_ser['AvET'], 97.5)\n", |
| 112 | + "voi_ser.plot(ax=ax,column='AvET',cmap='YlOrBr',legend=True,vmin=low,vmax=high,legend_kwds={'label': r'ET in mm/hr','orientation': 'horizontal',\"shrink\":.5})\n", |
| 113 | + "ax.add_artist(ScaleBar(1,location='lower left'))\n", |
| 114 | + "plt.title('Serial, Big Spring, Arizona, USA: Map of Mean Evapotranspiration Rate')\n", |
| 115 | + "plt.axis('off')" |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "markdown", |
| 120 | + "id": "4aa52490-5c34-49b4-9f8f-8e963461f007", |
| 121 | + "metadata": {}, |
| 122 | + "source": [ |
| 123 | + "## Plot Parallel Partitioning\n", |
| 124 | + "The figure below shows how individual voronoi cells are assigned or partitioned to a given core. " |
| 125 | + ] |
| 126 | + }, |
| 127 | + { |
| 128 | + "cell_type": "code", |
| 129 | + "execution_count": null, |
| 130 | + "id": "82a6ac3a-cbe8-4bdd-8799-c57ca516e2c0", |
| 131 | + "metadata": {}, |
| 132 | + "outputs": [], |
| 133 | + "source": [ |
| 134 | + "fig,ax = plt.subplots(figsize=[18*cm,18*cm],layout='constrained')\n", |
| 135 | + "voi_par.plot(ax=ax,column='processor',cmap='Set2',legend=True,legend_kwds={'label': 'Core #','orientation': 'horizontal',\"shrink\":.5})\n", |
| 136 | + "ax.add_artist(ScaleBar(1,location='lower left'))\n", |
| 137 | + "plt.title('Big Spring, Arizona, USA: Partition map')\n", |
| 138 | + "plt.axis('off')" |
| 139 | + ] |
| 140 | + } |
| 141 | + ], |
| 142 | + "metadata": { |
| 143 | + "kernelspec": { |
| 144 | + "display_name": "Python 3 (ipykernel)", |
| 145 | + "language": "python", |
| 146 | + "name": "python3" |
| 147 | + }, |
| 148 | + "language_info": { |
| 149 | + "codemirror_mode": { |
| 150 | + "name": "ipython", |
| 151 | + "version": 3 |
| 152 | + }, |
| 153 | + "file_extension": ".py", |
| 154 | + "mimetype": "text/x-python", |
| 155 | + "name": "python", |
| 156 | + "nbconvert_exporter": "python", |
| 157 | + "pygments_lexer": "ipython3", |
| 158 | + "version": "3.12.2" |
| 159 | + } |
| 160 | + }, |
| 161 | + "nbformat": 4, |
| 162 | + "nbformat_minor": 5 |
| 163 | +} |
0 commit comments