digger.utils.gauge2ts
¶
Module Contents¶
Functions¶
This function takes a .gauge (or similarly formatted) output file from D-Claw and splits the output from a given level into time (t) and eta numpy arrays. Optionally, the dataset can be resampled with a constant, user- defined sample rate for subsequent processing by spectral_analysis or wavelet_analysis. |
API¶
- digger.utils.gauge2ts.gauge2ts(gaugefile, resample=True, samprate=2, plot=False, plotname='timeseries', plotform='png', dpi=210, outdir=None)¶
This function takes a .gauge (or similarly formatted) output file from D-Claw and splits the output from a given level into time (t) and eta numpy arrays. Optionally, the dataset can be resampled with a constant, user- defined sample rate for subsequent processing by spectral_analysis or wavelet_analysis.
Takes an input D-Claw gauge file and separates it into time (t) and eta numpy arrays. This is accomplished by filtering the gauge file to include only the user-specified gauges and AMR level outputs (assumption being that wave motion is always captured at the highest AMR level).
Spectral analysis typically requires uniform sampling frequency. Because D-Claw simulations use AMR and therefore do not sample the output uniformly, this utility can resample the data by linear interpolation, and does so by default. The data are first padded with zeros to the beginning of the simulation (since wave arrival is not instantaneous) and then resampled beginning with the first non-zero value, first to a 0.01 second sample rate, and then to a user-defined second sample rate. The double- resampling serves the purpose of more accurately capturing the initial wave arrival, and the zero padding enables the wave arrival time to be adjusted to the nearest sample interval. For example, if the first non-zero wave height occurs at 1.61 seconds, resampling and zero padding will ensure that the surface altitude at 1.60 seconds is still 0 while the surface altitude at 1.65 seconds corresponds linearly to the higher-resolution values output by the model.
The zero padding is trimmed before t and eta are output so that additional processing (e.g., detrending) can be performed on the time series as needed without impacting the pre-arrival conditions.
- Inputs:
- gaugefile:
gauge file output by D-Claw
- resample:
boolean, whether to resample data (default: True)
- samprate:
sample rate in Hz to use for resampling (default: 2)
- plot:
boolean, whether to plot the gage time series (default: False)
- plotname:
name for output plot (without extension), required if plot=True
- plotform:
format for output plot, required if plot=True
- dpi:
dots per inch resolution of the output plot
- outdir:
directory for output plot, if desired (default: None); if left as default, figure will output to current working directory
- Outputs:
- t:
numpy 1-D array containing sampling times (seconds) from first non-zero wave amplitude to the end of the dataset
- eta:
numpy 1-D array containing wave amplitudes (meters) for each instance of t