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:

  1. TfvDomain File (a spatial 2D or 3D TUFLOW FV netcdf)
    ds = xr.open_dataset('tuflowfv_domain_result.nc')

    Calling ds.tfv will return a TfvDomain object, that appears as a normal Xarray file, but has access to TUFLOW FV specific methods. For example, fv = ds.tfv and then resulting methods can be used like fv.get_statistics(...)


  2. TfvTimeseries File (a profile timeseries TUFLOW FV netcdf)
    ds = xr.open_dataset('tuflowfv_profile_timeseries_result.nc')

    Calling ds.tfv will return a TfvTimeseries object that has several methods to enable conveniently accessing the profile timeseries groups.


  3. TfvParticle File (a particle tracking module TUFLOW FV netcdf)
    ds = xr.open_dataset('tuflowfv_ptm_result.nc')

    Calling ds.tfv will return a TfvParticle object that has methods to support plotting and gridded PTM results.

Accessor methods