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')
Callingds.tfvwill return aTfvDomainobject, that appears as a normal Xarray file, but has access to TUFLOW FV specific methods. For example,fv = ds.tfvand 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')
Callingds.tfvwill return aTfvTimeseriesobject that has several methods to enable conveniently accessing the profile timeseries groups.
TfvParticle File (a particle tracking module TUFLOW FV netcdf)
ds = xr.open_dataset('tuflowfv_ptm_result.nc')
Callingds.tfvwill return aTfvParticleobject that has methods to support plotting and gridded PTM results.
Accessor methods¶
- TfvDomain
TfvDomainTfvDomain.get_cell_index()TfvDomain.get_cell_inpolygon()TfvDomain.get_contours()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_hovmoller()TfvDomain.plot_interactive()TfvDomain.plot_mesh()TfvDomain.plot_profile()TfvDomain.plot_profile_interactive()TfvDomain.plot_vector()TfvDomain.prep_interactive_slider()
convert_grid_to_tfv()
- TfvTimeseries
- TfvParticle