pytuflow.CATCHJson#
- class CATCHJson(fpath, driver='v1.1')#
Bases:
MapOutputClass for handling TUFLOW CATCH JSON output files.
The
CATCHJsonclass will only load header information from the output file on initialisation, this makes the class cheap to initialise. The class can be initialised and the methodstimes()anddata_types()can be used without requiring QGIS libraries. However, extracting spatial data requires QGIS libraries to be available and QGIS to be initialised. The class will automatically load the full mesh the first time a spatial method is called which can cause the first time a spatial method is called to be slow.- Parameters:
fpath (PathLike) – Path to the NetCDF file.
driver (str, optional) –
The driver to use for reading the XMDF file. Options are:
"v1.0": Use PyTUFLOW v1.0 XMDF reader (legacy). This uses old QGIS geometry and extraction methods. This option is exclusive and can’t be used with other options."v1.1": Use PyTUFLOW v1.1 XMDF reader (default). Usesvtkgeometry if available, otherwise usesQGISgeometry. In order of preference, usesh5py,netcdf4, orQGISengine for extracting data. This option is exclusive and can’t be used with other options."qgis [geometry] | [engine]": Use QGIS libraries for geometry ("qgis geometry") and/or use QGIS librariesfor extracting data (
"qgis engine"). Both can be passed together as"qgis geometry engine". This option can be used in conjunctionwith other extracting data options e.g."qgis geometry netcdf4". The QGIS engine must be used with QGIS geometry.
"netcdf4": Use NetCDF4 library for extracting data. Exclusive with other extraction options."h5py": Use h5py library for extracting data. Exclusive with other extraction options.
Examples
>>> from pytuflow import CATCHJson >>> res = CATCHJson('./path/to/json')
Get all the data types available in the JSON file:
>>> res.data_types() ['bed level', 'velocity', 'water level', 'salinity', 'temperature']
Extract the time-series at all the points contained in a shapefile:
>>> res.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
>>> res.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:
>>> res.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:
>>> res.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:
>>> res.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.
Extracts time-series data for the given locations and data types.
Returns a list of times for the given filter.
Attributes
The result name
Does the result have an inherent reference time.
The reference time for the output