pytuflow.NCGrid#
- class NCGrid(fpath)#
Bases:
Grid
Class for reading netCDF grid outputs (NC) from TUFLOW, though any CF-compliant netCDF file should work.
The
NCGrid
class will only load header information from the NC file on initialisation, this makes the class cheap to initialise.The netCDF4 library is required to use this class.
- Parameters:
fpath (PathLike) – Path to the netCDF file.
- Raises:
ResultTypeError – Raises
pytuflow.results.ResultTypeError
if the file does not look like aNCGrid
file, or if the file is empty or locked by another program.
Examples
>>> from pytuflow import NCGrid >>> nc = NCGrid('./path/to/nc')
Get all the data types available in the netCDF file:
>>> nc.data_types() ['water level', 'depth', 'velocity', 'z0', 'max water level', 'max depth', 'max velocity', 'max z0', 'tmax water level']
Get only the temporal data types:
>>> nc.data_types('temporal') ['water level', 'depth', 'velocity', 'z0']
Get only the vector data types:
>>> nc.data_types('vector') ['velocity', 'max velocity']
Get all the available times in the netCDF file:
>>> nc.times() [0.0, 0.08333, 0.1667, 0.25, 0.3333, 0.4167, 0.5]
Get the water level time-series data for a given point defined in a shapefile:
>>> nc.time_series('/path/to/point.shp', 'water level') time water level/pnt1 0.00000 NaN 0.08333 NaN 0.16670 NaN 0.25000 NaN 0.33330 44.125675 0.41670 44.642513 0.50000 45.672554 0.58330 46.877666
Get a water level section from a line defined in a shapefile at time 0.5 hrs:
>>> nc.section('/path/to/line.shp', 'water level', 0.5) offset water level/Line 1 0 0.000000 45.994362 1 1.495967 45.994362 2 1.495967 45.636654 3 4.159921 45.636654 4 4.159921 45.592628 5 6.804385 45.592628 6 6.804385 45.624744 7 6.823876 45.624744 8 6.823876 45.583813 9 9.487831 45.583813 10 9.487831 45.560959
- __init__(fpath)#
- Parameters:
fpath (Path | str)
Methods
Not supported for
NCGrid
results.Return the available data types for the given filter.
Not supported for
NCGrid
results.Extracts section data for the given locations and data types.
Extracts time-series data for the given locations and data types.
Returns a list of times for the given filter.
Attributes
The units of time in the netCDF file.
The result name
The reference time for the output