pytuflow.NCMesh#
- class NCMesh(fpath, driver='v1.1')#
Bases:
MeshClass for handling TUFLOW FV style output files.
The
NCMeshclass supports both QGIS and Python drivers. The drivers are also split between geometry handling and data extraction.If using Python libraries, the
NCMeshclass is initialised without loading the mesh geometry data. This makes the class cheap to initialise and allows querying of available data types and times without requiring mesh loading. The mesh geometry data is only loaded when required for spatial data extraction.QGIS libraries can be used for geometry handling and Python libraries can be used for data extraction, this also allows for the cheap initialisation of the class. If QGIS libraries are used for both geometry and data extraction, the mesh geometry data is loaded at initialisation.
- Parameters:
fpath (PathLike) – Path to the NetCDF file.
driver (str, optional) –
The driver to use for reading the NCMesh file. Options are:
"v1.0": Use PyTUFLOW v1.0 NCMesh reader (legacy). This uses old QGIS geometry and extraction methods."v1.1": Use PyTUFLOW v1.1 NCMesh reader (default). Uses Python geometry handling if available, otherwise usesQGISgeometry. For data extraction, the order of preference ish5py,netcdf4, thenQGIS."qgis geometry [data extractor]": Use QGIS libraries for geometry ("qgis geometry") and the optional use of QGIS for data extraction as well ("qgis geometry data extractor"). If only"qgis geometry"is provided, the data extraction can also use Python libraries if available e.g."qgis geometry netcdf4"or"qgis geometry h5py". Using NetCDF4 or h5py for data extraction allows for cheap initialisation of the class."netcdf4": Use NetCDF4 library for extracting data. Can be used with"qgis geometry"otherwiseuses Python libraries for geometry handling.
"h5py": Use h5py library for extracting data. Can be used with"qgis geometry"otherwise uses Python libraries for geometry handling.
Examples
>>> from pytuflow import NCMesh >>> nc = NCMesh('./path/to/nc')
Get all the data types available in the NetCDF file:
>>> nc.data_types() ['bed level', 'velocity', 'water level', 'salinity', 'temperature']
Get all the times available in the NetCDF file:
>>> nc.times() [0.0, 0.5, ..., 3.0]
Get the water level time-series data for a given point defined in a shapefile:
>>> nc.time_series('path/to/shapefile.shp', 'water level') time pnt1/water level 0.000000 NaN 0.083333 NaN 0.166667 NaN 0.250000 NaN 0.333333 NaN 0.416667 NaN 0.500000 NaN 0.583333 NaN 0.666667 41.561204 0.750000 41.838923 ... ... 2.666667 41.278006 2.750000 41.239387 2.833334 41.201996 2.916667 41.166462 3.000000 41.128152
Get the depth-averaged velocity time-series using the Sigma method:
>>> nc.time_series('path/to/shapefile.shp', 'velocity', averaging_method='sigma&0.1&0.9') time pnt1/velocity 0.000000 0.353553 0.016667 0.353553 0.033333 0.353553 0.050000 0.353553 0.066667 0.353553 0.083333 0.353553
Get water level section data using a shapefile:
>>> nc.section('path/to/shapefile.shp', 'water level', 1.0) line1 offset water level 0 0.000000 0.1 1 0.605553 0.1 2 0.605553 0.2 3 1.614808 0.2 4 1.614808 0.3 5 2.220360 0.3
Get a velocity curtain plot using a shapefile:
>>> nc.curtain('path/to/shapefile.shp', 'velocity', 0.5) line1 x y velocity 0 0.000000 0.0 0.282843 1 0.605553 0.0 0.282843 2 0.605553 0.5 0.282843 3 0.000000 0.5 0.282843 4 0.000000 0.5 0.424264 5 0.605553 0.5 0.424264 6 0.605553 1.0 0.424264 7 0.000000 1.0 0.424264 8 0.605553 0.0 0.565685 9 1.614808 0.0 0.565685 10 1.614808 0.5 0.565685 11 0.605553 0.5 0.565685 12 0.605553 0.5 0.707107 13 1.614808 0.5 0.707107 14 1.614808 1.0 0.707107 15 0.605553 1.0 0.707107 16 1.614808 0.0 0.848528 17 2.220360 0.0 0.848528 18 2.220360 0.5 0.848528 19 1.614808 0.5 0.848528 20 1.614808 0.5 0.989949 21 2.220360 0.5 0.989949 22 2.220360 1.0 0.989949 23 1.614808 1.0 0.989949
Get a velocity (vertical) profile plot using a point shapefile:
>>> nc.profile('path/to/shapefile.shp', 'velocity', 0.5) pnt1 elevation velocity 0 0.0 0.282843 1 0.5 0.282843 2 0.5 0.424264 3 1.0 0.424264
- __init__(fpath, driver='v1.1')#
- Parameters:
fpath (Path | str)
driver (str)
Methods
Extracts curtain data for the given locations and data types.
Extracts the data value for the given point locations and data types at the specified time.
Return the available data types for the given filter.
Returns the maximum values for the given data types.
Returns the minimum values for the given data types.
Extracts vertical profile data for the given locations and data types.
Extracts section data for the given locations and data types.
Returns the value for every cell/vertex at the specified time.
Extracts time-series data for the given locations and data types.
Returns a list of times for the given filter.
Exports the mesh to an Alembic file for visualisation in compatible software.
Exports the mesh to a glTF 2.0 file for visualisation in compatible software.
Attributes
Returns whether the mesh is in spherical coordinates.
The result name
Does the result have an inherent reference time.
The reference time for the output