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 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.

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/6f8ce43884b15a965674dd3c0ff328d2e9693d8616936bd3771d68deaddcc8f9.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: Sheet Plots>
© Copyright 2024 BMT. Created using Sphinx 8.2.3.

Styled using the Piccolo Theme