pytuflow.CATCHJson

pytuflow.CATCHJson#

class CATCHJson(fpath)#

Bases: MapOutput

Class for handling TUFLOW CATCH JSON output files.

The CATCHJson class 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 methods times() and data_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.

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)#
Parameters:

fpath (Path | str)

Methods

curtain

Extracts curtain data for the given locations and data types.

data_types

Return the available data types for the given filter.

profile

Extracts vertical profile data for the given locations and data types.

section

Extracts section data for the given locations and data types.

time_series

Extracts time-series data for the given locations and data types.

times

Returns a list of times for the given filter.

Attributes

ATTRIBUTE_TYPES

DOMAIN_TYPES

GEOMETRY_TYPES

ID_COLUMNS

name

The result name

reference_time

The reference time for the output