|||

tfv 1.0.7 documentation

Quick search

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

Gallery 2: Profile Plots¶

This page provides example on how to plot 3D TUFLOW FV results as a function of depth (a 3D vertical profile). This notebook is used in combination with the TUFLOW FV Python Toolbox (tfv) package. To follow along on your own computer, please download the demonstration notebooks from the TUFLOW Downloads Page. Look for the TUFLOW FV Python Toolbox download. Installation instructions are provided on our TUFLOW FV Python Toolbox Wiki Page.

import xarray as xr  # We utilise xarray to do all the heavy lifting 
import numpy as np
import tfv.xarray
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

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

Define Locations for Extraction¶

locs = {
    'P1' : (159.0758, -31.3638),
    'P2' : (159.0845,  -31.3727),
    'P3' : (159.0906,  -31.3814),
    'P4' : (159.1001,  -31.3948),
    'P5' : (159.1154,  -31.4032),
    'P6' : (159.1266,  -31.4105),
    'P7' : (159.1202,  -31.4165),
    'P8' : (159.1178,  -31.4236),
    'P9' : (159.1277,  -31.4402)
}

loc = 'P1'

Extract Profile Data Directly from TUFLOW FV Xarray Accessor Object¶

prof = fv.get_profile(locs[loc],variables=['V','TEMP','SAL'])
#prof.head() # Uncomment to review the data array 

Plot Profile¶

time = '2011-05-02 12:00'
prof.sel(Time=time).plot.scatter(x='SAL',y='Z', color='black', lw=1)

# Show layerfaces
zfaces = prof['layerface_Z'].sel(Time=time)
plt.yticks(zfaces)
plt.grid(axis='y')
plt.show()
../../../_images/baf33c1e31c89262d7f64bdbfc547eb4dd42f7dc86b4633fe701e94a43613906.png

This concludes the examples on profile plotting.

<Page contents

>Page contents:

  • Gallery 2: Profile Plots
    • Open TUFLOW FV Model Result
    • Define Locations for Extraction
    • Extract Profile Data Directly from TUFLOW FV Xarray Accessor Object
    • Plot Profile
<Gallery 1: Timeseries Plots
Gallery 3: Working with Sheets>
© Copyright 2023 BMT. Created using Sphinx 7.2.6.

Styled using the Piccolo Theme