Latest release 1.0.11 now available on PyPi and Conda-forge

[[ visible ? '▲ HIDE' : '▼ SHOW BANNER' ]]

|||

tfv 1.0.11 documentation

Quick search

  • API Reference
  • Examples Gallery
    • Tutorial 1. TUFLOW FV Post-Processing Using Xarray
    • Tutorial 2. Introductory Matplotlib Plot Composition
    • Tutorial 3: Working With Gridded Boundary Condition Data
    • Tutorial 4. Introduction to the Particle Tracking Module Tools
    • Gallery 1: Timeseries Plots
    • Gallery 2: Profile Plots
    • Gallery 3: Sheet Plots
    • Gallery 4: Curtain Plots
    • Gallery 5: Combined Plots
    • Gallery 6: Particle Tracking Plots
    • Gallery 7: Miscellaneous

Gallery 4: Curtain Plots¶

Curtain plots allow you to review 3D results along a long section or cross section.

This notebook is used in combination with the TUFLOW FV Python Toolbox (tfv) package.

from pathlib import Path # We'll also make use of the `pathlib` module to assist with managing file-paths, although this is entirely optional! 
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import tfv.xarray
import xarray as xr  # We utilise xarray to do all the heavy lifting 

Open TUFLOW FV Model Result¶

model_folder = Path(r'..\..\data')
model_file = 'HYD_002.nc'

fv = xr.open_dataset(model_folder / model_file, decode_times=False).tfv
#fv  # Uncomment if you would like to review the Dataset

Single Curtain Plot¶

from matplotlib.gridspec import GridSpec
sns.set(style='white', font_scale=0.9)

polyline = np.loadtxt(model_folder / 'polyline.csv', skiprows=1, delimiter=',')

time = '2011-05-02 12:00'
vardict = {
    'TEMP': dict(cmap='inferno', clim=(10, 22)),
    'SAL': dict(cmap='ocean', clim=(0, 36)),
    'V': dict(cmap='jet', clim=(0, 1)),
}

var = 'SAL'

# Create figure
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4), gridspec_kw={'width_ratios': [1, 3]}, constrained_layout=True)

cspec = vardict[var]
fv.plot(var, time, ax=ax1, colorbar=False, **cspec)
ax1.plot(polyline[:, 0], polyline[:, 1], lw=1, color='black', ls='--')
ax1.set_aspect('equal')
ax1.set_title(f'Depth Avg. {var}')

fv.plot_curtain(polyline, var, time, ax=ax2, ec='none', **cspec)
ax2.set_title(f'{var} Curtain Profile')

plt.show()
../../../_images/2664523489a380f6c8ef7c15c948b16010ba0bdb499edce75e028aa2f9366702.png

Multiple Curtain Plots¶

# Create figure
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(12, 8), constrained_layout=True)


var = 'SAL'
cspec = vardict[var]
fv.plot_curtain(polyline, var, time, ax=ax1, ec='none', **cspec)
ax1.set_title(f'{var} Curtain Profile')

var = 'TEMP'
cspec = vardict[var]
fv.plot_curtain(polyline, var, time, ax=ax2, ec='none', **cspec)
ax2.set_title(f'{var} Curtain Profile')

var = 'V'
cspec = vardict[var]
fv.plot_curtain(polyline, var, time, ax=ax3, ec='none', **cspec)
ax3.set_title(f'{var} Curtain Profile')

plt.show()
../../../_images/d197e841b55beba165a61a1124a1d997b52b12ba03de5c72af6d2cf5ab78c565.png

Plot Interactive Curtain¶

%matplotlib widget

Output hidden because it doesn’t render nicely on tutorial page

fv.plot_curtain_interactive(polyline, 'SAL', cmap='turbo', clim=(10,35), edgecolor='face')
plt.ylim(-10, 2)

To turn off interactive plotting (which can often make your sessions run faster, a good idea when you don’t need it), use %matplotlib inline

plt.close('all')
%matplotlib inline

This concludes the examples on curtain plotting.

<Page contents

>Page contents:

  • Gallery 4: Curtain Plots
    • Open TUFLOW FV Model Result
    • Single Curtain Plot
    • Multiple Curtain Plots
    • Plot Interactive Curtain
<Gallery 3: Sheet Plots
Gallery 5: Combined Plots>
© Copyright 2024 BMT. Created using Sphinx 8.2.3.

Styled using the Piccolo Theme