Xarray Module¶
Introduction¶
Xarray is a python package to simplify working with labelled multi-dimension arrays in Python.
tfv uses Xarray to handle data extraction and management under-the-hood, and this xarray accessor module extends the functionality of native Xarray so that it can be used to directly handle TUFLOW FV data.
We now recommend that these functions are used to handle data access, analysis and plotting of TUFLOW FV results in Python, over the use of the original ‘low-level’ functions (e.g., provided in FvExtractor
). These methods directly call on the functions in the other modules, however simplify their use for typical analyses.
Usage¶
To enable the accessor methods, load up a TUFLOW FV domain (i.e., 2D or 3D spatial output netcdf) or profile timeseries netcdf in xarray.
General examples:
TfvDomain File (a spatial 2D or 3D TUFLOW FV netcdf)
ds = xr.open_dataset('tuflowfv_domain_result.nc')
Note: can swap withxr.open_mfdataset
for multiple TUFLOW FV files with matching geometry, or for parallelised access usingdask
).
Finally, callingds.tfv
will return aTfvDomain
object, that appears as a normal Xarray file, but has access to additional tuflow fv specific methods. For example,fv = ds.tfv
and then resulting methods can be used likefv.get_statistics(...)
TfvTimeseries File (a profile timeseries TUFLOW FV netcdf)
ds = xr.open_dataset('tuflowfv_profile_timeseries_result.nc')
Note: can swap withxr.open_mfdataset
for parallelised access usingdask
, however accessing multiple profile timeseries files usingopen_mfdataset
is NOT currently supported.
Callingds.tfv
will return aTfvTimeseries
object that has several methods to enable conveniently accessing the profile timeseries groups.
Accessor methods¶
- TfvDomain
TfvDomain
TfvDomain.get_cell_index()
TfvDomain.get_cell_inpolygon()
TfvDomain.get_curtain()
TfvDomain.get_longsection()
TfvDomain.get_profile()
TfvDomain.get_sheet()
TfvDomain.get_sheet_grid()
TfvDomain.get_statistics()
TfvDomain.get_timeseries()
TfvDomain.plot()
TfvDomain.plot_curtain()
TfvDomain.plot_curtain_interactive()
TfvDomain.plot_curtain_vector()
TfvDomain.plot_interactive()
TfvDomain.plot_vector()
TfvDomain.prep_interactive_slider()
convert_grid_to_tfv()
- TfvTimeseries