.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\visualize\flowvel_streamlines.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_examples_visualize_flowvel_streamlines.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_visualize_flowvel_streamlines.py: Flow velocities and streamlines =============================== In this section we will plot flow velocities and streamlines for some model results. .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import xarray as xr .. GENERATED FROM PYTHON SOURCE LINES 14-15 We'll start with the usual imports .. GENERATED FROM PYTHON SOURCE LINES 15-18 .. code-block:: Python import imod .. GENERATED FROM PYTHON SOURCE LINES 20-21 Load and unpack the data .. GENERATED FROM PYTHON SOURCE LINES 21-31 .. code-block:: Python ds_fluxes = imod.data.fluxes() ds_fluxes = ds_fluxes.isel(time=-1) ds_fluxes lower = ds_fluxes["bdgflf"] right = ds_fluxes["bdgfrf"] front = ds_fluxes["bdgfff"] heads = ds_fluxes["head"] .. GENERATED FROM PYTHON SOURCE LINES 32-39 Calculating flow velocity ------------------------- The imod-python function imod.evaluate.flow_velocity() computes flow velocities in m/d based on the budget results (bdgflf - flow lower face, bdgfrf - flow right face and bdgfff - flow front face). To apply this function, we first need to define a top_bot array. .. GENERATED FROM PYTHON SOURCE LINES 39-45 .. code-block:: Python top_bot = xr.full_like(lower, 1.0) top_bot["top"] = top_bot["z"] - 0.5 * top_bot["dz"] top_bot["bot"] = top_bot["z"] + 0.5 * top_bot["dz"] top_bot .. raw:: html <div class="output_subarea output_html rendered_html output_result"> <div><svg style="position: absolute; width: 0; height: 0; overflow: hidden"> <defs> <symbol id="icon-database" viewBox="0 0 32 32"> <path d="M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z"></path> <path d="M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z"></path> <path d="M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z"></path> </symbol> <symbol id="icon-file-text2" viewBox="0 0 32 32"> <path d="M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z"></path> <path d="M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path> <path d="M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path> <path d="M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path> </symbol> </defs> </svg> <style>/* CSS stylesheet for displaying xarray objects in jupyterlab. * */ :root { --xr-font-color0: var( --jp-content-font-color0, var(--pst-color-text-base rgba(0, 0, 0, 1)) ); --xr-font-color2: var( --jp-content-font-color2, var(--pst-color-text-base, rgba(0, 0, 0, 0.54)) ); --xr-font-color3: var( --jp-content-font-color3, var(--pst-color-text-base, rgba(0, 0, 0, 0.38)) ); --xr-border-color: var( --jp-border-color2, hsl(from var(--pst-color-on-background, white) h s calc(l - 10)) ); --xr-disabled-color: var( --jp-layout-color3, hsl(from var(--pst-color-on-background, white) h s calc(l - 40)) ); --xr-background-color: var( --jp-layout-color0, var(--pst-color-on-background, white) ); --xr-background-color-row-even: var( --jp-layout-color1, hsl(from var(--pst-color-on-background, white) h s calc(l - 5)) ); --xr-background-color-row-odd: var( --jp-layout-color2, hsl(from var(--pst-color-on-background, white) h s calc(l - 15)) ); } html[theme="dark"], html[data-theme="dark"], body[data-theme="dark"], body.vscode-dark { --xr-font-color0: var( --jp-content-font-color0, var(--pst-color-text-base, rgba(255, 255, 255, 1)) ); --xr-font-color2: var( --jp-content-font-color2, var(--pst-color-text-base, rgba(255, 255, 255, 0.54)) ); --xr-font-color3: var( --jp-content-font-color3, var(--pst-color-text-base, rgba(255, 255, 255, 0.38)) ); --xr-border-color: var( --jp-border-color2, hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10)) ); --xr-disabled-color: var( --jp-layout-color3, hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40)) ); --xr-background-color: var( --jp-layout-color0, var(--pst-color-on-background, #111111) ); --xr-background-color-row-even: var( --jp-layout-color1, hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5)) ); --xr-background-color-row-odd: var( --jp-layout-color2, hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15)) ); } .xr-wrap { display: block !important; min-width: 300px; max-width: 700px; } .xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; } .xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); } .xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; } .xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; } .xr-obj-type { color: var(--xr-font-color2); } .xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 0 20px 0 20px; } .xr-section-item { display: contents; } .xr-section-item input { display: inline-block; opacity: 0; height: 0; } .xr-section-item input + label { color: var(--xr-disabled-color); border: 2px solid transparent !important; } .xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); } .xr-section-item input:focus + label { border: 2px solid var(--xr-font-color0) !important; } .xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); } .xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; } .xr-section-summary > span { display: inline-block; padding-left: 0.5em; } .xr-section-summary-in:disabled + label { color: var(--xr-font-color2); } .xr-section-summary-in + label:before { display: inline-block; content: "►"; font-size: 11px; width: 15px; text-align: center; } .xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); } .xr-section-summary-in:checked + label:before { content: "▼"; } .xr-section-summary-in:checked + label > span { display: none; } .xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; } .xr-section-inline-details { grid-column: 2 / -1; } .xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; } .xr-section-summary-in:checked ~ .xr-section-details { display: contents; } .xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; } .xr-array-wrap > label { grid-column: 1; vertical-align: top; } .xr-preview { color: var(--xr-font-color3); } .xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; } .xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; } .xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; } .xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; } .xr-dim-list li { display: inline-block; padding: 0; margin: 0; } .xr-dim-list:before { content: "("; } .xr-dim-list:after { content: ")"; } .xr-dim-list li:not(:last-child):after { content: ","; padding-right: 5px; } .xr-has-index { font-weight: bold; } .xr-var-list, .xr-var-item { display: contents; } .xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); border-color: var(--xr-background-color-row-odd); margin-bottom: 0; padding-top: 2px; } .xr-var-item > .xr-var-name:hover span { padding-right: 5px; } .xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); border-color: var(--xr-background-color-row-even); } .xr-var-name { grid-column: 1; } .xr-var-dims { grid-column: 2; } .xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); } .xr-var-preview { grid-column: 4; } .xr-index-preview { grid-column: 2 / 5; color: var(--xr-font-color2); } .xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; } .xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; } .xr-var-attrs, .xr-var-data, .xr-index-data { display: none; border-top: 2px dotted var(--xr-background-color); padding-bottom: 20px !important; padding-top: 10px !important; } .xr-var-attrs-in + label, .xr-var-data-in + label, .xr-index-data-in + label { padding: 0 1px; } .xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data, .xr-index-data-in:checked ~ .xr-index-data { display: block; } .xr-var-data > table { float: right; } .xr-var-data > pre, .xr-index-data > pre, .xr-var-data > table > tbody > tr { background-color: transparent !important; } .xr-var-name span, .xr-var-data, .xr-index-name div, .xr-index-data, .xr-attrs { padding-left: 25px !important; } .xr-attrs, .xr-var-attrs, .xr-var-data, .xr-index-data { grid-column: 1 / -1; } dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; } .xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; } .xr-attrs dt { font-weight: normal; grid-column: 1; } .xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; } .xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; } .xr-icon-database, .xr-icon-file-text2, .xr-no-icon { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } .xr-var-attrs-in:checked + label > .xr-icon-file-text2, .xr-var-data-in:checked + label > .xr-icon-database, .xr-index-data-in:checked + label > .xr-icon-database { color: var(--xr-font-color0); filter: drop-shadow(1px 1px 5px var(--xr-font-color2)); stroke-width: 0.8px; } </style><pre class='xr-text-repr-fallback'><xarray.DataArray 'bdgflf' (layer: 49, y: 218, x: 248)> Size: 11MB array([[[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., ... [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]], shape=(49, 218, 248), dtype=float32) Coordinates: * x (x) float64 2kB 9.095e+04 9.105e+04 ... 1.156e+05 1.156e+05 * y (y) float64 2kB 4.676e+05 4.674e+05 ... 4.46e+05 4.458e+05 dx float64 8B 100.0 dy float64 8B -100.0 time datetime64[ns] 8B 1979-12-31 * layer (layer) int32 196B 1 2 3 4 5 6 7 8 9 ... 41 42 43 44 45 46 47 48 49 dz (layer) float64 392B -2.0 -2.0 -2.0 -2.0 ... -10.0 -10.0 -10.0 z (layer) float64 392B 9.0 7.0 5.0 3.0 ... -225.0 -235.0 -245.0 top (layer) float64 392B 10.0 8.0 6.0 4.0 ... -220.0 -230.0 -240.0 bot (layer) float64 392B 8.0 6.0 4.0 2.0 ... -230.0 -240.0 -250.0</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'bdgflf'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>layer</span>: 49</li><li><span class='xr-has-index'>y</span>: 218</li><li><span class='xr-has-index'>x</span>: 248</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-be990648-d8e8-44dc-8604-9d6aec548eaf' class='xr-array-in' type='checkbox' checked><label for='section-be990648-d8e8-44dc-8604-9d6aec548eaf' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 ... 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0</span></div><div class='xr-array-data'><pre>array([[[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., ... [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]], [[1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], ..., [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.], [1., 1., 1., ..., 1., 1., 1.]]], shape=(49, 218, 248), dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-41b8e842-3cb3-4e5a-9456-445726ecd86e' class='xr-section-summary-in' type='checkbox' checked><label for='section-41b8e842-3cb3-4e5a-9456-445726ecd86e' class='xr-section-summary' >Coordinates: <span>(10)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>x</span></div><div class='xr-var-dims'>(x)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>9.095e+04 9.105e+04 ... 1.156e+05</div><input id='attrs-07f408a9-f6a1-4099-912e-b17d6929dccd' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-07f408a9-f6a1-4099-912e-b17d6929dccd' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-70bc347b-3ef9-4cdc-98db-6ecdc36fdc44' class='xr-var-data-in' type='checkbox'><label for='data-70bc347b-3ef9-4cdc-98db-6ecdc36fdc44' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 90950., 91050., 91150., ..., 115450., 115550., 115650.], shape=(248,))</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>y</span></div><div class='xr-var-dims'>(y)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>4.676e+05 4.674e+05 ... 4.458e+05</div><input id='attrs-55eb5b44-40e1-4a04-94ea-b66b2fb13894' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-55eb5b44-40e1-4a04-94ea-b66b2fb13894' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-30e9207e-7f38-47b5-91f6-df426b489dcf' class='xr-var-data-in' type='checkbox'><label for='data-30e9207e-7f38-47b5-91f6-df426b489dcf' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([467550., 467450., 467350., ..., 446050., 445950., 445850.], shape=(218,))</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dx</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>100.0</div><input id='attrs-5940c355-a613-4ad6-b04d-3ca6dcf2a912' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-5940c355-a613-4ad6-b04d-3ca6dcf2a912' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d5fa7736-eb1e-46ec-841e-59ef07be27fd' class='xr-var-data-in' type='checkbox'><label for='data-d5fa7736-eb1e-46ec-841e-59ef07be27fd' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(100.)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dy</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-100.0</div><input id='attrs-dc981bd2-62d1-4516-8763-edf67dbae225' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-dc981bd2-62d1-4516-8763-edf67dbae225' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7b9e016f-c265-4133-bf95-98f4b8ee76b3' class='xr-var-data-in' type='checkbox'><label for='data-7b9e016f-c265-4133-bf95-98f4b8ee76b3' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(-100.)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>time</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>1979-12-31</div><input id='attrs-22d995bc-80b2-4368-a7b0-ad93c18df661' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-22d995bc-80b2-4368-a7b0-ad93c18df661' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-5105bc7e-b391-4395-9718-d87d4571d0ec' class='xr-var-data-in' type='checkbox'><label for='data-5105bc7e-b391-4395-9718-d87d4571d0ec' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array('1979-12-31T00:00:00.000000000', dtype='datetime64[ns]')</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>layer</span></div><div class='xr-var-dims'>(layer)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1 2 3 4 5 6 7 ... 44 45 46 47 48 49</div><input id='attrs-eaaf89bf-1538-4625-821e-77e08552488a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-eaaf89bf-1538-4625-821e-77e08552488a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-6071ccac-94c8-42e6-b043-cccac946cf4c' class='xr-var-data-in' type='checkbox'><label for='data-6071ccac-94c8-42e6-b043-cccac946cf4c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>dz</span></div><div class='xr-var-dims'>(layer)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-2.0 -2.0 -2.0 ... -10.0 -10.0</div><input id='attrs-a2dc49b8-5ea0-46a9-8cb9-ed4914eabfd4' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-a2dc49b8-5ea0-46a9-8cb9-ed4914eabfd4' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0828cee7-f984-4b8a-8788-18a4f82d3dd6' class='xr-var-data-in' type='checkbox'><label for='data-0828cee7-f984-4b8a-8788-18a4f82d3dd6' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -2., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -5., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10., -10.])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>z</span></div><div class='xr-var-dims'>(layer)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>9.0 7.0 5.0 ... -235.0 -245.0</div><input id='attrs-a1fa5d71-9e03-414b-9f0f-2b7d0ea411bc' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-a1fa5d71-9e03-414b-9f0f-2b7d0ea411bc' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-7dc98a3d-b3bf-4b1d-afc8-d8f618edadfd' class='xr-var-data-in' type='checkbox'><label for='data-7dc98a3d-b3bf-4b1d-afc8-d8f618edadfd' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 9. , 7. , 5. , 3. , 1. , -1. , -3. , -5. , -7. , -9. , -11. , -13. , -15. , -17. , -19. , -22.5, -27.5, -32.5, -37.5, -42.5, -47.5, -52.5, -57.5, -62.5, -67.5, -72.5, -77.5, -82.5, -87.5, -92.5, -97.5, -102.5, -107.5, -112.5, -117.5, -122.5, -127.5, -135. , -145. , -155. , -165. , -175. , -185. , -195. , -205. , -215. , -225. , -235. , -245. ])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>top</span></div><div class='xr-var-dims'>(layer)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>10.0 8.0 6.0 ... -230.0 -240.0</div><input id='attrs-333fcd52-cd18-44b0-a3a5-32e409e8a68a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-333fcd52-cd18-44b0-a3a5-32e409e8a68a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a17f2f1a-8760-4678-8689-3ce1c9a28a13' class='xr-var-data-in' type='checkbox'><label for='data-a17f2f1a-8760-4678-8689-3ce1c9a28a13' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 10., 8., 6., 4., 2., 0., -2., -4., -6., -8., -10., -12., -14., -16., -18., -20., -25., -30., -35., -40., -45., -50., -55., -60., -65., -70., -75., -80., -85., -90., -95., -100., -105., -110., -115., -120., -125., -130., -140., -150., -160., -170., -180., -190., -200., -210., -220., -230., -240.])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>bot</span></div><div class='xr-var-dims'>(layer)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>8.0 6.0 4.0 ... -240.0 -250.0</div><input id='attrs-bd1a51f6-4bab-48d8-8170-84d9c13a21fc' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bd1a51f6-4bab-48d8-8170-84d9c13a21fc' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-72f6ab14-af8f-4454-aa93-dfc8a972380c' class='xr-var-data-in' type='checkbox'><label for='data-72f6ab14-af8f-4454-aa93-dfc8a972380c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 8., 6., 4., 2., 0., -2., -4., -6., -8., -10., -12., -14., -16., -18., -20., -25., -30., -35., -40., -45., -50., -55., -60., -65., -70., -75., -80., -85., -90., -95., -100., -105., -110., -115., -120., -125., -130., -140., -150., -160., -170., -180., -190., -200., -210., -220., -230., -240., -250.])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-242f6410-394d-4560-bd45-5a76a4b17dd3' class='xr-section-summary-in' type='checkbox' ><label for='section-242f6410-394d-4560-bd45-5a76a4b17dd3' class='xr-section-summary' >Indexes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>x</div></div><div class='xr-index-preview'>PandasIndex</div><input type='checkbox' disabled/><label></label><input id='index-0fd04e56-def3-46be-85b0-493d92bdb11a' class='xr-index-data-in' type='checkbox'/><label for='index-0fd04e56-def3-46be-85b0-493d92bdb11a' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([ 90950.0, 91050.0, 91150.0, 91250.0, 91350.0, 91450.0, 91550.0, 91650.0, 91750.0, 91850.0, ... 114750.0, 114850.0, 114950.0, 115050.0, 115150.0, 115250.0, 115350.0, 115450.0, 115550.0, 115650.0], dtype='float64', name='x', length=248))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>y</div></div><div class='xr-index-preview'>PandasIndex</div><input type='checkbox' disabled/><label></label><input id='index-7574a2d2-9a4b-4109-a9e5-2dfb39754d9c' class='xr-index-data-in' type='checkbox'/><label for='index-7574a2d2-9a4b-4109-a9e5-2dfb39754d9c' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([467550.0, 467450.0, 467350.0, 467250.0, 467150.0, 467050.0, 466950.0, 466850.0, 466750.0, 466650.0, ... 446750.0, 446650.0, 446550.0, 446450.0, 446350.0, 446250.0, 446150.0, 446050.0, 445950.0, 445850.0], dtype='float64', name='y', length=218))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>layer</div></div><div class='xr-index-preview'>PandasIndex</div><input type='checkbox' disabled/><label></label><input id='index-42e1d27c-2998-4bdb-9dd0-2a0afc19785c' class='xr-index-data-in' type='checkbox'/><label for='index-42e1d27c-2998-4bdb-9dd0-2a0afc19785c' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], dtype='int32', name='layer'))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-c289aa77-9212-4bfe-9cbd-662d678face6' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-c289aa77-9212-4bfe-9cbd-662d678face6' class='xr-section-summary' title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div> </div> <br /> <br /> .. GENERATED FROM PYTHON SOURCE LINES 46-48 Next we'll calculate the velocities and plot a cross-section of the vertical velocity at for y = 450050 .. GENERATED FROM PYTHON SOURCE LINES 48-57 .. code-block:: Python fig, ax = plt.subplots() vx, vy, vz = imod.evaluate.flow_velocity( front=front, lower=lower, right=right, top_bot=top_bot, porosity=0.3 ) vz.sel(y=450050.0, method="nearest").plot(cmap="RdYlBu", yincrease=False) plt.title("Vz") .. image-sg:: /examples/visualize/images/sphx_glr_flowvel_streamlines_001.png :alt: Vz :srcset: /examples/visualize/images/sphx_glr_flowvel_streamlines_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'Vz') .. GENERATED FROM PYTHON SOURCE LINES 58-64 Quiver plot ----------- It is also possible to make quiver plots for a cross section defined by two pairs of coordinates. We will first define arrays indicating the start and end location of the cross section to be evaluated. .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python start = np.array([97132.710, 457177.928]) end = np.array([103736.517, 457215.557]) .. GENERATED FROM PYTHON SOURCE LINES 69-70 Using the function ``imod.evaluate.quiver_line()`` considering the starting and ending points .. GENERATED FROM PYTHON SOURCE LINES 70-73 .. code-block:: Python u, v = imod.evaluate.quiver_line(right, front, lower, start, end) .. GENERATED FROM PYTHON SOURCE LINES 74-75 Adding top and bottom information to the previously obtained arrays .. GENERATED FROM PYTHON SOURCE LINES 75-81 .. code-block:: Python u["top"] = u["z"] + 0.5 * u["dz"] u["bottom"] = u["z"] - 0.5 * u["dz"] v["top"] = v["z"] + 0.5 * v["dz"] v["bottom"] = v["z"] - 0.5 * v["dz"] .. GENERATED FROM PYTHON SOURCE LINES 82-84 Defining a cross section that shows the heads for the same location where the start and end points were defined, to use as a background image for the plot .. GENERATED FROM PYTHON SOURCE LINES 84-89 .. code-block:: Python cross_section = imod.select.cross_section_line(heads, start, end) cross_section["top"] = cross_section["z"] - 0.5 * cross_section["dz"] cross_section["bottom"] = cross_section["z"] + 0.5 * cross_section["dz"] .. GENERATED FROM PYTHON SOURCE LINES 90-91 Ploting the cross section .. GENERATED FROM PYTHON SOURCE LINES 91-100 .. code-block:: Python colors = "magma" levels = np.arange(-8, 0.0, 0.5) skip = (slice(None, None, 2), slice(None, None, 2)) fig, ax = plt.subplots() fig, ax = imod.visualize.cross_section( cross_section, colors=colors, levels=levels, ax=ax, fig=fig ) imod.visualize.quiver(u[skip], v[skip], ax, kwargs_quiver={"color": "k"}) .. image-sg:: /examples/visualize/images/sphx_glr_flowvel_streamlines_002.png :alt: flowvel streamlines :srcset: /examples/visualize/images/sphx_glr_flowvel_streamlines_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none <matplotlib.quiver.Quiver object at 0x0000016F3F9FA090> .. GENERATED FROM PYTHON SOURCE LINES 101-106 Streamline function ------------------- This function shows the streamlines for a line cross section through a 3D flow field. We will use the previously created arrays that indicate the start and end location of the cross section and apply them in the function imod.evaluate.streamfunction_line() .. GENERATED FROM PYTHON SOURCE LINES 106-109 .. code-block:: Python streamfunction = imod.evaluate.streamfunction_line(right, front, start, end) .. GENERATED FROM PYTHON SOURCE LINES 110-116 The previous array contains the streamfunction projected on the cross-section defined by provided linestring, with new dimension “s” along the cross-section. The cellsizes along “s” are given in the “ds” coordinate. The streamline function can be plotted using imod.visualize.streamfunction(), but first we need to define the 'top' and 'bottom' of the layers in the array Note: By default the steamlines are plotted in white. .. GENERATED FROM PYTHON SOURCE LINES 116-126 .. code-block:: Python streamfunction["bottom"] = streamfunction["z"] + streamfunction["dz"] streamfunction["top"] = streamfunction["z"] fig, ax = plt.subplots() fig, ax = imod.visualize.cross_section( cross_section, colors=colors, levels=levels, ax=ax, fig=fig ) imod.visualize.streamfunction(streamfunction, ax=ax, n_streamlines=10) .. image-sg:: /examples/visualize/images/sphx_glr_flowvel_streamlines_003.png :alt: flowvel streamlines :srcset: /examples/visualize/images/sphx_glr_flowvel_streamlines_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none <matplotlib.contour.QuadContourSet object at 0x0000016F3FE98F50> .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.814 seconds) .. _sphx_glr_download_examples_visualize_flowvel_streamlines.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: flowvel_streamlines.ipynb <flowvel_streamlines.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: flowvel_streamlines.py <flowvel_streamlines.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: flowvel_streamlines.zip <flowvel_streamlines.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_