1. Introduction
In recent years, acoustic Doppler velocimeters (ADVs) have proven valuable tools for measuring turbulent statistics in various environments. With their fast sample rates, relatively accurate measurements, and ability to measure in shallow water, ADVs have led to improvements in our understanding of surf zone and shallow estuarine turbulence (e.g., Feddersen 2012; Jones and Monismith 2008). Key to this success has been the development of reliable data processing techniques for despiking ADV data and calculating wavenumber spectra from ADV velocity data in the presence of surface gravity waves (e.g., Goring and Nikora 2002; Shaw and Trowbridge 2001).
At the same time, physical oceanographers are becoming increasingly aware of the importance of infragravity (IG) oscillations (25–250 s periods) for coastal, shallow reef, and estuarine processes (e.g., Bertin et al. 2018; Becker et al. 2016). IG waves have long been known to contribute to swash and run up on beaches (e.g., Guza and Thornton 1982; Ruessink et al. 1998). More recently, researchers have shown that IG oscillations are important in sediment transport and estuarine mouth closure processes (e.g., Behrens et al. 2013; Bertin et al. 2019; Bertin and Olabarrieta 2016). Some studies have also shown that shallow estuarine mouths can act as lowpass frequency filters, leading to oscillations within estuaries dominated by IG frequencies with velocity amplitudes as large as tidal velocities (e.g., Williams and Stacey 2016; Harvey et al. 2022; McSweeney et al. 2020). To be explicit, we are using oscillation and wave as distinct terms here, with oscillation implying repeated back and forth motion with a definable frequency range and wave implying a more regular process with consistent statistics that follows wave theory.
With our new understanding that IG frequencies are dynamically important, it is increasingly important to understand how IG motions affect velocity and turbulence. It is particularly important to tease out how IG velocity oscillations interact with other sediment transport mechanisms and how they affect mixing within estuaries. To address turbulence in the presence of IG motions, ADVs appear to be the ideal tool, as IG waves are often most dominant in particularly shallow waters. However, many of the existing methods for analyzing ADV data in the presence of waves make assumptions that fail in the presence of IG motions. In particular, the irregular IG motions introduce nonstationary turbulence with unpredictable changes in velocity variance that interfere with despiking algorithms, and the nonlinear behavior of the oscillations lead to changes in spectral slope when using standard frozen turbulence assumptions. To be clear, we use the term oscillations instead of waves because the data presented here are nonlinear and asymmetric, frequently with broken fronts. Such oscillations match observations from other experiments in shallow estuaries (e.g., Williams and Stacey 2016; McSweeney et al. 2020) and are most accurately described as IG frequency bores. Therefore, we will use this terminology for the rest of the paper. Harvey et al. (2022) and Fig. 2e have raw ADV time series that provide visualizations for these oscillations.
This manuscript closely examines and adapts existing techniques for despiking ADV data and measuring turbulent dissipation in the presence of large IG frequency bores in a shallow estuary. We identify where current algorithms fail and suggest alterations in order to deal with the unique challenges presented by dominant IG oscillations. We note that the effects we correct for are not unique to IG frequency bores, meaning that many of the techniques presented here have the potential to be applied to a wider range of situations. In addition, our modifications to inertial subrange fitting methods are improvements even in the absence of nonlinear dynamics. We provide tolerance calculations and an error analysis framework with the goal that future researchers may use these techniques to more easily evaluate turbulence using ADVs. This error analysis examines variables not traditionally considered in final turbulence calculations, allowing us to identify areas where ADV processing for turbulence calculations needs careful consideration and further work to produce reliable results.
2. Data
The data used for the analyses presented were obtained during a short field deployment at the beginning of 2020 aimed at understanding IG frequency bores within Los Peñasquitos Lagoon. Los Peñasquitos lagoon, shown in Fig. 1, is a lowinflow, barbuilt estuary in Southern California with a mouth that has been heavily modified due to the presence of a road. The shallow sill at the mouth is above sea level at low tide, while most of the lagoon interior is around 2 m deep or less. When submerged, the shallow sill acts as a lowpass frequency filter where larger sea and swell waves dissipate in the surfzone while IG oscillations propagate into the estuary (Harvey et al. 2022; Williams and Stacey 2016). The 1–2.5 m tides during our deployment drive a semidiurnal 0.3–1.5 m waterlevel change inside the lagoon, leading to water depths at station 5 (see Fig. 1) that range from 0.2 to 1.7 m.
As part of the deployment, two synced ADVs (Nortek Vectors) were mounted, along with other instruments, on a sawhorse frame that was secured with sand anchors into the bed at location 5 in Fig. 1c, 300 m upstream of the mouth. These two ADVs sampled the water 30 and 50 cm above the bottom. A third, bottom frame mounted, upward looking ADV was deployed 250 m farther upstream at location 7 in Fig. 1c, sampling 1 m above the bottom. Diagrams for both moorings are shown in Fig. 1c. All three ADVs started sampling at midnight on 2 February and collected data continuously at 16 Hz, with 5 s breaks every hour to write the data to memory. One of the synced ADVs stopped sampling the afternoon of 11 February due to memory limitations. The other two ADVs included synced optical backscatter measurements and low batteries led to shortened and irregular bursts starting the morning of 14 February, making later data unusable.
After recovery, the data for each ADV were converted to a netCDF4 file and processed for quality control. The pressure was corrected for atmospheric pressure changes using a nearby National Estuarine Research Reserve meteorological station and converted to depth using the Python gsw package (https://pypi.org/project/gsw/3.0.3/; McDougall and Barker 2011). Initial cleaning of the velocity data used a correlation cutoff of 70% and signaltonoise ratio (SNR) cutoff of 10 dB for any beam, based on initial data inspection as recommended by the manufacturer (Nortek 2018). Details on how to access these data and the code for the methods presented below can be found in the data availability statement.
3. Despiking
The first challenge when using ADV field measurements is despiking. Due to phase shift ambiguities caused by contamination from previous pulses reflecting off air bubbles and other reflective surfaces suspended in the water, spikes can appear in ADV velocity records (e.g., Goring and Nikora 2002). These spikes can contaminate otherwise valid data, leading to errors in later averaging or turbulence calculations.
a. Existing methods
Perhaps the most common method for eliminating these spikes is the Goring and Nikora (2002) method. This approach assumes that valid points collected by an ADV, after removing the lowfrequency signal, are clustered in a dense ellipsoid in phase space. Here, phase space is defined by using the measured velocity (u), first time derivative (du/dt), and second time derivative (d^{2}u/dt^{2}) to form 3 independent axes. The outer limits of the valid data ellipsoid are determined using the universal threshold,
Further modifications to the phase space method came from Parsheh et al. (2010), who noticed that particularly large spikes could introduce a bias in the derivative, making normal data points appear as spikes in phase space. The proposed fix used the MADbased threshold to perform an initial screening based only on velocity magnitude before continuing to the phase space method. In addition, Parsheh et al. (2010) suggested that replacing spikes with the last valid data point prevented the extended contamination of cleaned data from yet to be detected spikes found when using other interpolation methods.
Upon examination of our data, we find that the distributions for our velocities and derivatives are noticeably nonGaussian, with long tails that extend beyond the universal threshold and MAD threshold cutoffs (see Fig. 2a). As a result, the use of unmodified versions of the methods proposed by Goring and Nikora (2002), Wahl (2003), and Parsheh et al. (2010) misidentifies too many valid data points as spikes. These tails are likely a direct result of nonstationary turbulence leading to changes in the variance of our data over our burst length (30 min). In addition, this nonstationary effect appears to be related to the passage of IG frequency bores, which come in at largely irregular and unpredictable intervals and can be seen as the lowpass signal in Figs. 2e and 2f. This short term increase in turbulent energy with passing bores is very similar to what Simpson et al. (2004) observe in the presence of a tidal bore propagating up a shallow estuary. As a result, simply changing the burst length for our despiking algorithm was not an option.
Since Goring and Nikora (2002), several new methods of despiking have been proposed that we also find inappropriate for our situation. Cea et al. (2007) explore how correlations between different velocity components can be used to create a different 3D space for detecting spikes in a similar way to the phase space approach. However, the lack of temporal derivatives (e.g., du/dt) misses an essential element of spike detection for our situation. In data with varying velocity amplitudes, as in the presence of large IG frequency bores, some spikes have magnitudes that are no bigger than other points in the same burst of data. These spikes must then be identified by how much they stand out from their immediate neighbors, which is captured by a temporal derivative. In addition to Cea et al. (2007), Razaz and Kawanisi (2011) propose an improved waveletbased despiking algorithm that decomposes data into wavelet packets. Sharma et al. (2018) suggest a modified singular spectrum analysis approach that identifies key eigenvectors which describe the data and can be used for reconstructing a spikefree signal. However, inherent in both the Razaz and Kawanisi (2011) and Sharma et al. (2018) approaches is a reliance on stationary data that are broken by the presence of IG frequency bores. To adapt either of these approaches would be very dependent on the individual characteristics of the IG frequency bores in each deployment, preventing the creation of a widely usable algorithm.
For replacing detected spikes, Jesson et al. (2013) tested a variety of proposed methods in combination with many of the above despiking methods. Their results show that the optimal replacement method depends on the detection method used, and verified the conclusions of Parsheh et al. (2010) that the last valid data point method was optimal for the modified phase space method.
b. Expanding cutoff algorithm
Based on the variety of approaches above, we determine that the best approach is to use the Goring and Nikora (2002) algorithm with a modified cutoff to account for our nonGaussian data distribution. Because the Goring and Nikora (2002) universal threshold is too strict for our data, we modify the phase space approach with an expanding cutoff algorithm, similar to the one used by Islam and Zhu (2013). This approach uses the basic observation by Goring and Nikora (2002) that valid ADV data fall within a tight ellipse in phase space. However, rather than using a Gaussian distribution–based cutoff, we use the density of points in phase space to determine where the ellipse ends. Islam and Zhu (2013) use a bivariate kernel density function to create a density map of the data in each 2D phase space projection. The threshold is then determined by where the gradient in the density levels off (indicating an end to the dense cluster in phase space). However, Islam and Zhu (2013) found that the particular implementation of the bivariate kernel density function appears to heavily influence the mean velocity of their data. Because Islam and Zhu (2013) do not provide an explicit sensitivity analysis on the frequency spectrum of their data, the sensitivity of the mean currents suggests that this approach would not be a robust and easily adaptable algorithm for turbulence calculations; thus, here we use a modified expanding cutoff algorithm.
We begin by linearly interpolating any data already marked as bad and removing the 1/20 Hz lowpass filtered data so that we are only despiking the highfrequency signal (appendix A, steps 1 and 2). Then, for our modified cutoffs, we start with the universal threshold from Goring and Nikora (2002) as an initial estimate (appendix A, step 4). While these thresholds are inaccurate in magnitude, the relative magnitudes (and therefore the shape of the ellipsoid) are well represented by the standard deviation of the data, as can be seen in Figs. 2b–d. To determine the overall magnitude for a given 2D projection of phase space, we then increase the corresponding cutoff limits by 1% repeatedly, keeping the ellipse axis ratio constant throughout (appendix A, step 5). For each expansion, we then calculate an elliptical ring density of points as the number of data points that lie between the ellipses defined by the new cutoff and the previous increment divided by the corresponding area (appendix A, steps 6 and 7). The modified cutoff is then chosen as the point at which the elliptical ring density of points in the ring between sequential cutoffs decreases by more than 95% of the previous value (appendix A, steps 8 and 9) (see Figs. 2b–d). We do this expansion for each 2D projection of phase space independently. Figure 2 shows how these expanded cutoffs keep more valid data points than the original Goring and Nikora (2002) cutoffs, allowing us to produce a more complete despiked time series in the presence of nonstationarity.
Including these modified cutoffs, our full final despiking algorithm is as follows. We begin by linearly interpolating any NaNs in our data (appendix A, step 1) and then follow the Goring and Nikora (2002) algorithm exactly until the point of specifying cutoffs (appendix A, steps 2–4). We next use our expanding algorithm to define the modified cutoffs as described above (appendix A, steps 5–9). From here, we follow the modified phase space approach suggested by Parsheh et al. (2010) and Jesson et al. (2013) for replacing spikes. First, we check if there are any points that explicitly exceed the velocity threshold, marking those as spikes and replacing them with the last valid point (appendix A, step 10). We use the last valid point, because both Parsheh et al. (2010) and Jesson et al. (2013) show that this replacement method produces a more accurate spectrum than other interpolation methods when paired with the modified phase space approach introduced by Parsheh et al. (2010). If we identify spikes this way, we return to the beginning of the iteration process (appendix A, steps 11, 18, and 19), allowing us to remove particularly bad spikes that might lead to valid points being detected as spikes later on. If we do not identify spikes this way, we identify spikes using the full phase space ellipses, being careful to use the rotated ellipse for u–d^{2}u/dt^{2} space as in Goring and Nikora (2002), and again replace identified spikes with the last valid point (appendix A, steps 12–18). Finally, we iterate until no new data points are identified as spikes, add back the lowfrequency signal, and return any original NaN values that were interpolated at the beginning back to NaN (appendix A, step 20). This iteration occasionally gets stuck on repeatedly identifying the same points as spikes, so we impose a limit of 100 iterations to prevent an infinite loop. Similar to Goring and Nikora (2002), we despike each velocity component independently as shown in Figs. 2b–d. This phase space despiking algorithm with modified expanding cutoffs could be used on any dataset, but is particularly well suited when the data are nonGaussian due to nonstationary turbulence over the burst length. Examples include irregular waves and bores such as these, but also the passage of fronts.
4. Spectral estimation
Once the velocity has been effectively despiked, the next major challenge in measuring turbulent dissipation with an ADV is calculating a wavenumber power spectrum of the vertical velocity while properly accounting for the presence of oscillating velocities.
a. Existing methods
Since velocity measurements are often taken at one point in space over time, rather than over space at one point in time, initial spectra calculated are frequency spectra. Using Taylor’s frozen turbulence hypothesis, the mean current during the observation period can then be used to convert observed frequencies to observed wavenumbers (e.g., Rusello and Cowen 2011; Lumley and Terray 1983).
To reduce spectral noise, spectra are calculated over minutes long batches of data, where windowing and segmentation can be used to produce high degrees of freedom for reduced errors. Because the turbulence is assumed constant over the averaging time scale, a robust fit to the low noise spectrum will accurately determine the turbulent dissipation. However, in the presence of waves with periods smaller than the observation period, the advection of turbulence past the sensor by wave orbital velocities can bias energy spectra high for frequencies higher than the wave frequency. This is because using the mean velocity to convert frequency to wavenumber is no longer an accurate assumption (e.g., Lumley and Terray 1983; Rosman and Gerbi 2017).
Past attempts to adjust for this wave bias have employed spectralbased corrections. By assuming a random, linear wave field that leads to roughly Gaussian distributed wave velocities, an analytical solution for the correlation of measured turbulent velocities can be found. Using this correlation, one can calculate the expected difference between the measured spectrum and the ideal inertial subrange. Such corrections were first introduced by Lumley and Terray (1983), built on by Trowbridge and Elgar (2001) and Feddersen et al. (2007) among others, and have most recently been generalized to a wide range of cases by Rosman and Gerbi (2017).
b. Semiidealized model
We convert this spectrum to Fourier coefficients with random phases and perform an inverse Fourier transform to obtain an idealized spatial turbulent vertical velocity dataset for that chosen dissipation value. We then sample from these idealized data at a fixed location in space at 16 Hz, while advecting the data with our IG frequency bore containing measured horizontal velocities. The resulting semiidealized (idealized turbulence field with a fixed dissipation value advected by a realistic IG bore containing velocity field) temporal dataset then represents the vertical velocities that we would measure with our field instruments if the vertical velocities followed the initial idealized turbulent spectrum.
From these semiidealized data, we can test different approaches to reconstruct the initial idealized turbulent spectrum and the associated dissipation value. The following subsections describe the two main approaches that we test with this method.
c. Full Rosman and Gerbi correction
Figure 3 shows that when we use I given by Eq. (4), the resulting spectrum appears to have the correct amplitude, but the wrong slope when compared to the initial ideal spectrum. This implies that the nonlinear aspects of the IG frequency bores introduce a slope variation in the frequency spectrum not predicted by, and therefore not corrected by, the linear theory assumed by the above methods. Therefore, to avoid wave bias from IG frequency bores, we must find a different approach.
d. Segmented approach
Here, we adapt a method first introduced by George et al. (1994). By splitting the velocity data into short enough segments (as defined below), we ensure that the velocity varies linearly or not at all within any particular segment, thus enabling the use of Taylor’s frozen turbulence hypothesis. Then, the resulting spectra can be averaged in wavenumber space, resulting in an accurately reproduced wavenumber spectrum. We use this approach over a 30 min burst of data to produce a final 30 min averaged spectrum that is minimally impacted by the phasing of individual IG oscillations. While 30 min is long enough for our 30 s to 2 min long oscillations, the averaging interval will need to be adjusted for datasets with different dominant frequencies. Also, because the inertial subrange scales as ϵ^{2/3}, our final dissipation values will be composed of the 30 min average of instantaneous dissipation values raised to the twothirds power, then raised to the three halves power to maintain proper units, e.g.,
Before we can calculate spectra for these 10 s segments, we must now use the lowfrequency and highfrequency components of the horizontal velocity to filter out segments that break Taylor’s frozen turbulence hypothesis or those where the advection velocity significantly changes over the 10 s segment. First, for Taylor’s frozen turbulence hypothesis to hold, the turbulent fluctuations must be much smaller than the mean advection velocity (e.g., Bluteau et al. 2011; George et al. 1994). Following George et al. (1994), to satisfy this condition, we use the standard deviation of the rotated highfrequency velocity oscillations to characterize the turbulent fluctuations (appendix B, step 8). We then require the standard deviation of the highfrequency velocity component in the direction of the mean velocity to be less than 1/5 of the mean velocity magnitude (i.e.,
For the second condition, the advection velocity cannot change too much over the 10 s segment. To satisfy this, George et al. (1994) modified a criterion first suggested by Lin (1953) to only keep segments where the variation of the advection velocity was much less than the mean. This criterion would lead us to throw out most of our segments, However, we can relax this condition using the results of an idealized test with the model introduced in section 4b. Noting that the lowfrequency component of most of the 10 s segments is a roughly linearly changing advection velocity, we test the effects of a linear advection velocity on idealized data. Even though a linear advection velocity is not an oscillating velocity, we choose to test the correction used in Eq. (5) because it is designed for the highfrequency limit where the turbulent frequencies are much higher than the advection frequencies. Our lowfrequency signal is defined as anything below 1/5 Hz, so we use the standard deviation of the linear advection velocity when applying the wave correction constant to our test cases (e.g.,
Based on work by Feddersen (2010), we also eliminate segments that have too many unoriginal points. These unoriginal points can be due to interpolating NaNs or from replacing spikes as described above. Feddersen (2010) showed that if more than 1% of the data is unoriginal, the effects of individual spike replacement techniques start to become important. Therefore, we eliminate the 10 s segments with the largest number of unoriginal points until less than 1% of the total points in all remaining segments of the 30 min burst are unoriginal (appendix B, steps 10 and 11). It is important to note here that we do not place a limit on the number of consecutive unoriginal points or unoriginal points in a given segment. This is because including such cutoffs has little impact on the final calculated dissipation values beyond the conditions we already use, and we choose to limit the number of subjective cutoffs used. Further discussion on the sensitivity of different subjective cutoffs (e.g.,
Once we have eliminated bad segments, we detrend, apply a Hanning window, and calculate a power spectrum of the unfiltered vertical velocity for each segment (Thomson and Emery 2014b) (appendix B, step 12). We then use the local mean horizontal velocity with Taylor’s frozen turbulence hypothesis to convert each segment to wavenumber space independently and correct the spectrum magnitude using I as in Eq. (5) (appendix B, step 13). The resulting individual wavenumber spectra can be seen as the thin blue lines in Fig. 3.
In summary, our spectrum calculation starts by interpolating NaNs and splitting the horizontal velocities into a low and highfrequency portion (using a 1/5 Hz cutoff) before splitting both the filtered horizontal and unfiltered vertical velocity data into 10 s segments (appendix B, step 2). We then rotate both the low and highfrequency horizontal signals into the direction of the mean velocity for each 10 s segment independently (appendix B, steps 4–7). Next, we eliminate any segments where the standard deviation of the lowfrequency horizontal signal is greater than 1.025 times the mean speed or the standard deviation of the highfrequency horizontal signal is greater than 1/5 times the mean speed, all calculated in the mean velocity direction (appendix B, steps 8 and 9). We also eliminate segments with the most unoriginal points until less than 1% of the total points in all remaining segments are unoriginal. After eliminating, we take a spectrum of the unfiltered vertical velocity of all the remaining segments, convert the spectra to wavenumber space individually, including the wave correction factor (I) in Eq. (4), and trim the two lowest wavenumbers along with the wavenumbers above κ_{cutoff} to avoid aliasing. Finally, we bin the N resulting spectral estimates as evenly as possible into floor(N/N_{min}) groups by wavenumber and average each bin to obtain an averaged spectrum. It is important to note that because we assume an inertial subrange at several steps in our spectrum calculation, we only expect the final result to be accurate within the inertial subrange. Figure 3 illustrates the method’s success in the inertial subrange.
5. Dissipation calculations
To use Eq. (1) to calculate dissipation, we must fit a line to the logarithm of the wavenumber spectrum within the inertial subrange. This poses two distinct problems: 1) how to fit a line and 2) where to fit a line. The details of how to approach these two problems have varied slightly in the literature, with no consensus on what approach is best. The issues and modifications we explain in this section are not specific to nonlinear or intermittent dynamics such as IG frequency bores and are therefore helpful over a broad range of observational conditions.
a. How to fit
For fitting a line, a least squares error approach is commonly used (e.g., Feddersen 2010; Jones and Monismith 2008). However, the least squares error approach originates from the maximum likelihood estimation (MLE) method specific to data with Gaussian errors (e.g., Leo 1994). As Bluteau et al. (2011) point out, the errors on a spectrum follow a χ^{2} distribution, meaning that an MLE approach (rather than a least squares error) would be more appropriate as it accounts for the χ^{2} distribution. Unfortunately, the solution suggested by Bluteau et al. (2011) requires constant degrees of freedom over the entire spectrum (not guaranteed by our approach) and the use of computationally costly nonlinear minimization algorithms. Here, we choose to use a weighted least squares approach with some modifications to account for the effects of a χ^{2} distribution.
Considering our spectral calculation method, every 10 s segment estimate of a spectrum comes from taking the square magnitude of a calculated Fourier coefficient. The real and imaginary portion of each Fourier coefficient are sampled from a Gaussian distribution with a mean of 0. Therefore, the spectrum estimate is sampled from
To confirm that our approach is satisfactory, we generate a test inertial spectrum, add random χ^{2} noise, and calculate the dissipation from the spectrum. When repeating this many times, we find negligible differences between our approach and the full nonlinear approach of Bluteau et al. (2011), even for degrees of freedom as low as 10. We then proceed with confidence that our simplification to Gaussian uncertainties will not affect our final result.
b. Where to fit
When deciding what portion of the spectrum to fit as the inertial subrange, a variety of approaches have been suggested. Trowbridge and Elgar (2001) and Feddersen (2010) fit to a constant, prespecified frequency range, eliminating spectra that did not satisfy a misfit cutoff. Jones and Monismith (2008) and Bluteau et al. (2011) fit to all portions of the spectrum longer than a minimum frequency range, and select the fit that has the smallest misfit. Bluteau et al. (2011) use largescale flow properties and the Kolmogorov length scale to define bounds to restrict where the final fit could be located, employing an iterative procedure to account for the Kolmogorov length scale being a function of the dissipation itself.
To quantify the misfit, Jones and Monismith (2008) use the total squared error from the least squares fit of a −5/3 line to the spectrum. Feddersen (2010) uses two misfit tests. First, after performing a least squares fit of a line with unspecified slope, Feddersen (2010) uses the difference of the fitted slope from −5/3, normalized by the uncertainty of the fitted slope. Second, Feddersen (2010) uses the ratio of the horizontal and vertical spectra to test for isotropic turbulence. Bluteau et al. (2011) use the same condition as Jones and Monismith (2008), with an additional criterion based on the maximum absolute deviation of their fit and a χ^{2} distribution.
After performing several tests with the semiidealized model, we find a common problem with all of the methods suggested above. The statistical uncertainties from our fitting method consistently underestimate the error of our calculated dissipation values compared to the dissipation used to create the initial ideal spectrum. This is because slight changes in noise can change what portion of the spectrum is fit and dramatically change the final dissipation value. The first two rows of Fig. 4 show two bursts where the best and second best fits for two different measurements of best fit result in dramatically different dissipation values. The first row uses the total error as used by Jones and Monismith (2008) while the second uses the average error because we found that the total error preferentially selected shorter fits. We therefore conclude that specifying a specific portion of the spectrum as the best fit can introduce unnecessary uncertainty. To solve this problem, we instead calculate a kernel density estimate of the dissipation values from all possible valid fits to determine the most likely true dissipation value, as shown in Fig. 4 and described in the following paragraphs.
For the iterative procedure, we begin by guessing a high dissipation of ϵ_{test} = 10^{−3} to start with a very high upper bound (appendix C, step 1). After setting the bounds based on Eqs. (18) and (19), we take every possible continuous subsection of the spectrum within those bounds that contains at least 10 data points and wavenumbers that span at least a quarter of a decade (appendix C, step 2). For each of these subsections, we fit a line as described above, first calculating the slope and slope error (Leo 1994) to determine what subsections to eliminate (as described below), then fixing the slope at −5/3 to obtain the y intercept and calculate the resulting dissipation [Eqs. (13)–(17) and appendix C, steps 3–9].
We do not use the total error of the fit to eliminate subsections because we find that the spectrum noise varies between bursts, requiring arbitrary cutoffs greater than the statistical errors suggested by our degrees of freedom. We also do not use the comparison of the vertical to horizontal spectra because it would require removing noise from the horizontal data. The noise is primarily Doppler white noise from the instrument, which varies with flow conditions, and is much larger for the horizontal velocity components than the vertical (e.g., Voulgaris and Trowbridge 1998). The most common method for evaluating noise levels requires our spectra to flatten, and alternatives, such as those suggested by Durgesh et al. (2014), require stationary data. Neither of these are true for our data, so we choose to focus on the lower noise vertical velocity data. Similar to the misfit used by Feddersen (2010), we choose to ignore spectrum subsections where −5/3 lies outside the 95% confidence interval of the fitted slope (appendix C, step 7).
After eliminating invalid subsections, we treat the remaining dissipation values as samples from a probability distribution. Using the SciPy gaussian_kde function (Virtanen et al. 2020) and Scott’s rule for determining bandwidth (Scott 2015), we calculate a 1D Gaussian kerneldensity estimate (KDE) of the log_{10} of the dissipation values (appendix C, step 12). Scott’s rule sets a bandwidth, h = m^{−1/5}, based on the number of points used, m, that estimates the theoretical bandwidth that would produce a zero bias density estimate (Virtanen et al. 2020; Scott 2015). The KDE itself is a smoothed estimate of the continuous probability density function for the dissipation. Because it is continuous, we find the dissipation value corresponding to the peak probability of the KDE and select the calculated dissipation value closest to that peak. (appendix C, step 13). Three examples of a histogram and KDE can be seen in Fig. 4a, including the burst shown in Fig. 2, which can be seen in the last row.
This dissipation allows us to redefine our theoretical maximum wavenumber bound using Eq. (19) (appendix C, step 14). If any of the spectrum subsections used have more than one wavenumber outside of the new bounds, we then repeat the process until the subsections used to estimate the dissipation value satisfy the bounds set by that dissipation value (appendix C, step 15). We specify having more than one wavenumber outside of the bounds in order to allow fits slightly outside of theoretical bounds, similar to the approach taken by Bluteau et al. (2011). In addition, if an iteration leads to a higher dissipation value than the last, we force another iteration (appendix C, step 16) to include the new sections allowed by the relaxed upper bound (forcing a hard cutoff after five iterations with an increasing dissipation to avoid infinite loops).
6. Error analysis
Inherent in our dissipation calculation methods are several sources of error, both statistical and systematic. Tracking each individual source of error is difficult; however, here we present three different approaches to identify and quantify many of these errors and biases. This approach not only provides detailed error quantification; it also addresses the generalization of our methods by indicating which parameters may need adjustment under different environmental conditions and identifying overall areas for future improvement.
a. Semiidealized model–based errors
For testing our spectrum calculation and dissipation fitting methods, we can use our semiidealized model to reveal general patterns and determine an estimate of the total error.
Breaking out these test dissipation calculations by the ideal dissipation value used and the average advection speed, Fig. 5b further shows that our method introduces some systematic biases. Generally, higher advection speeds and higher dissipation values introduce a bias high. This bias also introduces the skewness of the distribution compared to the Gaussian in Fig. 5a. The source of these high biases is aliasing, which, because we convert each 10 s spectrum to wavenumber space with a different advection velocity, gets spread out across the entire spectrum. We do correct for aliasing in Eq. (7), but we only limit the aliasing bias to less than 25%. We do not limit the bias further because our tolerance test in Table 1 for the Nyquist threshold factor shows that using a stricter cutoff would lead to more noise. We also find that the strict cutoff would lead to 128 fewer final dissipation values. So, we instead note that a majority of these biases are within the 15.2% error and are accounted for in our data analysis except for particularly high dissipation values with high advection speeds. We also observe that while the bias high is consistent for very high dissipation values [
Results of tolerance tests. Average change refers to the average of (ϵ_{new} − ϵ_{original})/ϵ_{original}, allowing us to estimate any biases introduced by modifying the corresponding variable. Average absolute change refers to the same, but taking the absolute value before calculating the average. This allows us to identify potential changes, even if no average bias is introduced.
There is also a low bias at low dissipation values. Because of our shallow water, at particularly low dissipation values, the idealized inertial subrange practically does not exist. As a result, our fitting algorithm for the idealized spectrum is fitting to the rolloff portions of the spectrum when our dissipation values are low, which biases these low dissipation values lower. This bias is generally smaller than the bias high at high dissipation, so further corrections are not required. In addition, these low biases occur for particularly low dissipation values (on the order of 10^{−8} m^{2} s^{−3}), which are also rarely observed in our data.
b. Noisebased errors
Because of the ideal spectrum used, our semiidealized model fails to capture two important sources of error. First, nonturbulent physical processes and errors in our despiking methods can introduce increased noise into the spectrum over the ideal χ^{2} distribution. Second, white noise from the instrument can bias the entire spectrum high (e.g., Voulgaris and Trowbridge 1998).
To account for the former, our KDE dissipation fit approach provides a built in estimate of the variation introduced by spectrum noise. We take the halfwidth of the middle 95% of the final dissipation distribution used for estimating the KDE as an initial estimate of the uncertainty. This is effectively an estimate of the statistical uncertainty on our measurement. The average statistical uncertainty for our final dissipation estimates is around 7.8%, which is comparable the 15.2% methodological uncertainty, suggesting that these error estimates should be combined. However, these two uncertainties are not independent, because the semiidealized model is already using the KDE dissipation fit approach. Calculating the corresponding statistical uncertainty of the semiidealized model, we find an average contribution of 4.5% to the calculation of the methodological uncertainty, which is significant enough to make these uncertainty calculations dependent. Therefore, we record these two uncertainties separately and note that the summation in quadrature of the two as if they were independent provides an upper bound on the error while the maximum of the statistical or methodological uncertainty provides a lower bound on the error.
For the bias introduced by white noise, we first recall that we are using the vertical velocity component, which is the component with the lowest noise contribution for ADV’s (e.g., Voulgaris and Trowbridge 1998). While we cannot identify an accurate noise level for many our bursts, about 20% of our bursts from all three ADVs do exhibit a spectrum flattening, equivalent to spectrum noise of typically 10^{−9}, and occasionally 10^{−8} m^{2} s^{−3}. Subtracting this noise level from our spectra and recalculating dissipation values, we note that noticeable effects only occur for dissipation values close to the noise level and become negligible for dissipation values greater than 1.5 orders of magnitude larger than the noise value (dissipations around 10^{−7} m^{2} s^{−3}). For the lower dissipation values, the bias can be on the same order of magnitude or larger than the upper bound of our error range, which is on average 18.7% for all of our data.
Because the white noise might bias our spectrum high while the semiidealized model indicates a bias low at the same dissipation values, it is impossible to truly quantify the net bias affects on our low dissipation values. Ultimately the error on our low dissipation values [
In summary, the total errors due to methodology and noise place an absolute lower bound on the error of 15.2% and an average upper bound on the error of 18.7%. Because the statistical error is sometimes greater than the systematic error, the lower bound for any given dissipation measurement is the maximum of systematic and statistical error, which on average for our dataset is 17.5%. We also find an occasional burst with significant statistical error that slightly increases our average errors. Thus, the average error could be reduced if a maximum statistical error limit were imposed. Finally, particularly high dissipation values [
c. Sensitivity analysis
In addition to the sources of errors mentioned above, our methods also introduce several changeable variables whose impact on the final results need to be understood. For each of these variables, we test them by selecting a high and low value with which to redo our analysis to understand how our final results on all 3 ADVs change. A summary of these changes can be seen in Table 1.
For the expanding cutoff despiking algorithm (section 3b), we use 3 predetermined constants. First, we choose to filter out the lowpass signal with a cutoff frequency of 1/20 Hz. Second, we incrementally expand the phase space cutoffs by 1% of the universal threshold. Third, we choose the stopping point of the expansion where the density of points between sequential cutoffs decreases by more than 95% of the previous value.
For our segmented spectrum calculation algorithm (section 4d), we use 8 predetermined constants. For separating turbulent from advection velocities, we use a frequency cutoff of 1/5 Hz and segment the data into 10slong segments to avoid wave contamination. When eliminating segments, we require the mean current to be larger than 5 times the turbulent standard deviation and the advection standard deviation to be less than 1.025 times the mean current. We further require that less than 1% of the points used for calculating a spectrum be replaced spikes. We then eliminate the two lowest wavenumbers and any wavenumbers where we expect the spectral values to be less than 4 times the spectral value at the Nyquist frequency assuming a −5/3 slope. Finally, we bin average with bin sizes of at least 50 points.
For the KDEbased inertial subrange fitting (section 5), we further introduce six predetermined constants. For determining the bounds on the inertial subrange, we multiply the generation length scale by a factor of 1/2. When identifying possible spectrum subsections to fit an inertial subrange to, we require the subsection to contain at least 10 data points and have wavenumbers that span at least a factor of 2.5 (a quarter of a decade). For determining valid fits, we require −5/3 to be within the 95% confidence interval of the slope and that the maximum peak prominence of the data in the fit be smaller than 0.8. When determining the final dissipation value, we use Scott’s rule with no alterations to determine the bandwidth for calculating the KDE (Scott 2015).
Reviewing the results in Table 1 shows that the dissipation is not very sensitive to a majority of the variables when compared to the 15.2% uncertainties we have already identified. One notable exception is the expansion step size factor in the despiking algorithm. For this particular variable, we tested smaller incremental changes than shown in Table 1 and found that there is a roughly consistent linear relationship between the change in expansion step size factor and the average dissipation change. This consistent and relatively strong relationship between expansion step size and dissipation bias indicates that careful consideration must be given to initial despiking to properly evaluate final dissipation uncertainty. We chose our particular step size by closely examining plots similar to Figs. 2a–d for many of our bursts, which does not guarantee the selection is appropriate for other datasets. Such sensitivity also points to an area for potential future methodological improvements, which we elaborate on in the discussion.
A few other variables introduce large average absolute changes. Altering segment size when calculating spectra seems to generally increase uncertainty in dissipation value. This reflects the fact that too short of a segment reduces the resolution of the inertial subrange while too long of a segment introduces stronger IG frequency bore driven bias. Similarly, reducing the bin size during the spectrum calculation introduces large dissipation changes, likely because of the presence of stronger noise in the final spectrum values due to lower degrees of freedom. Finally, reducing the minimum range between the minimum and maximum wavenumbers of the spectrum subsections when fitting the inertial subrange introduces changes due to the fitting algorithm becoming much more sensitive to the highfrequency portion of the spectrum, which contains a large density of data points.
Two other variables with substantial sensitivities that might be of interest to readers are the turbulence variance cutoff and number of unoriginal points allowed. Both of these cutoffs were chosen to match cutoffs used in other methods. The turbulence variance cutoff is chosen to match that used by George et al. (1994), and shows sensitivity because relaxing this cutoff increases the number of segments with large variance included in calculating the spectrum. This increase in dissipation also likely includes segments where the frozen turbulence hypothesis is invalid, which is why we keep the George et al. (1994) cutoff. The number of unoriginal points allowed matches the fraction determined by Feddersen (2010) as the point past which the specific interpolation method used begins to matter. This sensitivity then tells us that our particular interpolation method would start to bias our dissipation high if we had more unoriginal points included in the spectrum calculation.
7. Discussion
In this section, we highlight a few key results that we believe should be considered in future work measuring turbulence using ADV data, including applicability of our methods to other types of datasets and important directions for future work.
For our despiking algorithm, we adapted the Islam and Zhu (2013) expanding cutoff phase space method to reduce the number of tunable parameters while still preventing the elimination of real data as spikes during time periods of intermittent variance. While our final algorithm is simplified relative to Islam and Zhu (2013), our tolerance tests show significant sensitivity to one parameter. Islam and Zhu (2013) also show significant sensitivity where the mean velocity changes by over 15% with their bandwidth tests. This is not equivalent to our sensitivity tests on the final dissipation value. For a more direct comparison, we find that our mean velocities change by less than 1% for all of our despiking sensitivity tests, albeit over a smaller parameter change. With this in mind, our despiking algorithm is a successful simplification of the Islam and Zhu (2013) method that results in a relatively robust algorithm for use in complex environmental conditions.
While our mean velocities are relatively stable, the sensitivity of our final dissipation values highlights the inherent subjectivity of despiking ADV data and how that subjectivity can introduce hidden biases in turbulence calculations. The subjectivity can be seen more clearly when looking at Fig. 2f, where our expanded cutoffs appear to eliminate some valid data for this particular data burst. So, while we find the presented algorithm to be the most reliable in the presence of large IG frequency bores, or any other process that leads to unpredictably intermittent velocity variance, we recommend extra caution when determining the uncertainties of turbulence calculations when using any despiking algorithm. Further, we look forward to future improvements in ADV despiking by other researchers. We believe that the expanding cutoff approach has inherent limitations and that another promising approach would be an adaptive algorithm that can identify varying length bursts of data with consistent variance over which to apply despiking rather than sticking with a predefined burst length.
The segmented spectrum calculation approach here is very specific to the presence of lowfrequency velocity oscillations. However, the result that our nonlinear velocity oscillations can change the shape of a frequency spectrum, even at high frequencies, suggests that careful consideration should be given to the calculation of the spectrum before converting to wavenumber space in situations with nonlinear processes. Therefore, we recommend that future surfzone turbulence measurements, or measurements in the presence of other nonlinear processes, carefully examine the assumptions of the spectrum calculation methods used and consider applying our segmented spectrum calculation in the case of nonlinear and nonstationary velocity oscillations.
Our method for fitting an inertial subrange to a wavenumber spectrum was not specific to the presence of IG frequency bores. As a result, it can apply to any situation where dissipation estimates from spectra are performed, and is likely the most widely applicable result of this paper. While the χ^{2} adjusted, weighted least squares approach helps better account for nonGaussian errors, we believe the more important improvement is the use of all possible fits to collectively determine the final dissipation value through a KDE estimation. This avoids any reliance on a single goodness of fit measurement, which could be more easily affected by random variations not captured by standard error analysis.
We also want to briefly mention that the presence of horizontal length scales in the inertial subrange that are longer that the water depth theoretically implies a level of anisotropy. To our knowledge, any field deployment observing turbulent dissipation generated by bottom boundary layers in shallow water would find similar levels of anisotropy. However, we are not aware of any existing work to understand the impacts that this has on inertial subrange derived dissipation values. Therefore, while we believe our measurements are accurate and comparable to past methods for measuring turbulent dissipation, we also believe that future work examining the impacts of anisotropic length scales on the inertial subrange would be valuable.
When we put all three methods together, we successfully produce representative dissipation values that are consistent between collocated instruments that are vertically separated by 20 cm, lower and upper, and can be seen in Fig. 6. These values display expected high values during strong tidal flows, and even show elevated levels in the presence of large IG wave oscillations. The typical 15.2% uncertainty gives us confidence in our results. We note the caveat that dissipation levels around 10^{−7} m^{2} s^{−3} and below possibly have higher errors; however, these make up a relatively small fraction of our data. Specifically, 1.4% of the dissipation values from the two collocated ADVs shown in Fig. 6 and 15.1% of all the dissipation values when including the third ADV. The percentage increases when we include the third ADV because it is located farther upstream in deeper water, where the turbulence is generally weaker.
Finally, our goal for this work was to measure turbulent dissipation in the presence of large IG frequency bores. However, by necessity, our calculations were performed in 30 min bursts, resulting in representative dissipation values that are the average of instantaneous dissipation values raised to the twothirds power, then raised to the threehalves power as in
8. Conclusions
Using data from a deployment in Los Peñasquitos Lagoon in February 2020, we develop several new algorithms to calculate reliable turbulent dissipation values in the presence of large IG frequency bores. We implement an expanded phase space cutoff to remove spikes from nonstationary data. Then we use a segmented spectrum approach to account for nonlinear bore biases in producing wavenumber spectra from a stationary instrument. Finally, we use a Gaussian KDE approach for fitting an inertial spectrum to avoid unnecessary errors arising from selecting a single portion of the spectrum to fit to for calculating dissipation values. The final 30 min representative dissipation values for two vertically separated, collocated ADVs, using these methods, can be seen in Fig. 6. The code and data presented in this paper have also been published to the University of California, San Diego, Library Digital Collections (Wheeler et al. 2023) and to GitHub.
The despiking and spectral estimation methods introduced here can be applied in other situations where nonlinear oscillations and nonstationary data limit the application of more standard approaches. The KDE dissipation calculation approach can be applied to any dataset where the inertial subrange must be located and fit to and provides a robust methodology to finding an optimal fit. The error analysis presented provides a rigorous approach to assessing dissipation calculations and highlights the need for further careful consideration of despiking when measuring turbulent dissipation with ADVs. Finally, successful observations of representative dissipation values under large IG frequency bores opens the door for future studies to understand turbulent processes and the potential importance of these bores in nearshore and estuarine systems.
Acknowledgments.
We thank members and volunteers of the Giddings and Merrifield labs and the Center for Coastal Studies field crew at UCSD for their help with data collection. We thank the Los Peñasquitos Lagoon Foundation (especially Mike Hastings), California State Parks (especially Cara Stafford, Darren Smith, and Reinhard Flick), and the Tijuana River National Estuarine Research Reserve (especially Jeff Crooks) for helping to facilitate this research and providing permits. We also thank Geno Pawlak, Pascal Polonik, and Yunyi Zhang at UCSD and Johanna Rosman at UNC for their valuable feedback during discussions about this project. Finally, we thank two anonymous reviewers whose comments substantially helped the presentation of this methodology. This material is based upon work supported by NOAA’s National Centers for Coastal Ocean Science (NCCOS) Competitive Research Program under Award NA18NOS4780172 to SIO and the National Science Foundation Graduate Research Fellowship Program under Grant DGE2038238. This work was also partially funded by California (CA) Department of Parks and Recreation Division of Boating and Waterways Oceanography Program under Contract C1670005 with SIO. This is CHRP Contribution Number 258. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.
Data availability statement.
The data for the two ADVs presented in Fig. 6, as well as the code for the algorithms and graphs presented here, are available through the UCSD Library Digital Collections at the DOI https://doi.org/10.6075/J0J67H27. A GitHub repository for the code used has also been created at https://github.com/dcwheeler/IGDissipationProcessingCode.
APPENDIX A
Expanding Cutoff Despiking Algorithm

Use linear interpolation to fill any NaNs in data (from correlation and SNRbased filtering or time periods where the instrument was out of water), and store the location of those NaNs.

Remove lowpass filtered signal to avoid contamination from large nonturbulent signals. In our case, we found that using a 1/20 Hz, fourthorder Butterworth filter effectively eliminated contamination from IG waves without introducing negative effects from filtering particularly large spikes.

Use central differences to calculate the first (u^{(1)}) and second (u^{(2)}) derivatives for locating each point in phase space as in Goring and Nikora (2002), their Eqs. (7) and (8), where in their notation the first and second derivatives are Δu and Δ^{2}u, respectively.

Calculate the universal threshold cutoffs c^{0} using the total number of data points n and the standard deviations σ for the corresponding derivative as in Goring and Nikora (2002), their Eq. (2):${c}_{{u}^{(k)}}^{0}=\sqrt{2\hspace{0.17em}\mathrm{ln}\hspace{0.17em}n}\times {\sigma}_{{u}^{(k)}},$where k is denoting the number of derivatives.

Define the ith expanded cutoff for each dimension as${c}_{{u}^{(k)}}^{i}=(1+0.01i)\times {c}_{{u}^{(k)}}^{0}.$

Starting with u–u^{(1)} space, as a first step before calculating the elliptical ring density, define the number of points within the ith expanded ellipse as${P}_{u\u2014{u}^{(1)}}^{i}={\displaystyle \sum _{j=1}^{n}\frac{{u}_{j}^{2}}{{c}_{u}^{i}{}^{2}}+\frac{{u}^{(1)}{}_{j}^{2}}{{c}_{{u}^{(1)}}^{i}{}^{2}}}\le 1,$where j is an index that iterates over all points.

Then, for the ith expanded ellipse, define the elliptical ring density of points in the ring between sequential cutoffs as${\rho}_{u{u}^{(1)}}^{i}=\frac{{P}_{u{u}^{(1)}}^{i}{P}_{u{u}^{(1)}}^{i1}}{\pi \times ({c}_{u}^{i}{c}_{{u}^{(1)}}^{i}{c}_{u}^{i1}{c}_{{u}^{(1)}}^{i1})}.$

To determine when to stop expanding the cutoff, first calculate the fractional change in elliptical ring density between sequential cutoffs as$\mathrm{\Delta}{\rho}_{u{u}^{(1)}}^{i}=\frac{{\rho}_{u\text{\u2013}{u}^{(1)}}^{i1}{\rho}_{u\text{\u2013}{u}^{(1)}}^{i}}{{\rho}_{u\text{\u2013}{u}^{(1)}}^{i1}}.$

Then, determine the last expanded cutoffs for u–u^{(1)} space,
${C}_{u\text{\u2013}{u}^{(1)}}^{u}$ and${C}_{u\text{\u2013}{u}^{(1)}}^{{u}^{(1)}}$ , as the cutoffs before the fractional ring density change exceeds 0.95:${C}_{u\text{\u2013}{u}^{(1)}}^{{u}^{(k)}}={c}_{{u}^{(k)}}^{i}\mathrm{\Delta}{\rho}_{u\text{\u2013}{u}^{(1)}}^{i+1}\ge 0.95.$ 
Mark any points where the velocity exceeds the final
${C}_{u\text{\u2013}{u}^{(1)}}^{u}$ cutoff as spikes. This is a first pass, as described by Parsheh et al. (2010), to avoid large spikes influencing the derivatives at nearby data points and causing valid data to look like more spikes. 
If spikes are found, skip to step 18 for replacing those spikes. If no spikes are found, proceed to step 12 to use the full phase space detection method.

Mark any points that are outside the ellipse with major and minor radii defined by
${C}_{u\text{\u2013}{u}^{(1)}}^{u}$ and${C}_{u\text{\u2013}{u}^{(1)}}^{{u}^{(1)}}$ as spikes. 
Repeat steps 6–9 and 12 for u^{(1)}–u^{(2)} space. Note, steps 10 and 11 are skipped because the initial, velocityonlybased spike detection is only done for the u–u^{(1)}based cutoffs.

Because of the correlation between the velocity and the second derivative, calculate the principal axis rotation angle θ between the velocity and second derivative as in Goring and Nikora (2002), their Eq. (9).

Rotate u–u^{(2)} space to α–β space with the principal axis rotation angle, where$z=(u+i\times {u}^{(2)})\times {e}^{i\theta},$$\alpha =\text{Real}(z),$and$\beta =\text{Imag}(z).$

Calculate the initial cutoffs for the rotated ellipse using the solutions to the equations found in Goring and Nikora (2002), their Eqs. (10) and (11), as${c}_{\alpha}=\sqrt{\frac{{({c}_{u}\mathrm{cos}\theta )}^{2}{({c}_{{u}^{(2)}}\mathrm{sin}\theta )}^{2}}{{\mathrm{cos}}^{4}\theta {\mathrm{sin}}^{4}\theta}},$and${c}_{\beta}=\sqrt{\frac{{({c}_{{u}^{(2)}})}^{2}{({c}_{\alpha}\mathrm{sin}\theta )}^{2}}{{\mathrm{cos}}^{2}\theta}}.$

Repeat step 5 for the
${c}_{\alpha}^{i}$ and${c}_{\beta}^{i}$ cutoffs, then repeat steps 6–9 and 12 for α–β space to complete the full phase space spike detection. 
Replace each spike with the value of the last valid point.

If spikes were identified, return to step 3 in order to repeat the phase space spike detection and spike replacement until no more spikes are detected. On rare occasions, this loop will continue for a very long time, so we recommend a maximum number of iterations allowed (we use 100).

Record the location of any spikes that were replaced through all iterations, add back the lowfrequency signal, return NaNs removed in step 1, and finish.
APPENDIX B
Segmented Spectrum Algorithm

Linearly interpolate any NaNs in the vertical and horizontal velocity data.

Separate the highfrequency turbulent velocities (u′) from all other lowerfrequency advection velocities (
$\tilde{u}$ ) with an appropriate filter. In our case, we use a 1/5 Hz, fourthorder Butterworth filter that separates lowfrequency advection velocities$\tilde{u}$ , which include IG and lowerfrequency oscillations, from the highfrequency turbulent velocities (${u}^{\prime}=u\tilde{u}$ ). These separated signals will be used for identifying bad segments and correcting the magnitude of the spectrum. 
Split the vertical velocity data along with both the low and highfrequency horizontal velocity data into short segments with N_{seg} data points each such that the velocity varies little over each segment. We found that 10 s worked well for our data, which, with our 16 Hz sampling rate, gives N_{seg} = 160.

Calculate the average lowfrequency horizontal advection velocities,
${U}_{\text{seg}}={\displaystyle {\sum}_{i=1}^{{N}_{\text{seg}}}{\tilde{u}}^{i}/{N}_{\text{seg}}}$ and${V}_{\text{seg}}={\displaystyle {\sum}_{i=1}^{{N}_{\text{seg}}}{\tilde{\upsilon}}^{i}/{N}_{\text{seg}}}$ , for each segment. 
Calculate the advection speed for each segment as
${c}_{\text{seg}}=\sqrt{{U}_{\text{seg}}^{2}+{V}_{\text{seg}}^{2}}$ . 
Calculate the advection direction for each segment as
${\theta}_{\text{seg}}={\mathrm{tan}}^{1}({V}_{\text{seg}}/{U}_{\text{seg}})$ . 
Rotate the low and highfrequency horizontal velocities of each segment into the mean advection direction, keeping the primary components as
$\tilde{\gamma}$ and γ′. 
Calculate the standard deviations of the low and highfrequency rotated primary velocities for each segment (
${\sigma}_{\text{seg}}^{\tilde{\gamma}}$ and${\sigma}_{\text{seg}}^{\gamma \prime}$ ). 
Eliminate any segments that fail to satisfy either of the relations${\sigma}_{\text{seg}}^{\tilde{\gamma}}\le 1.025{c}_{\text{seg}}$or${\sigma}_{\text{seg}}^{\gamma \prime}\le {c}_{\text{seg}}/5.$

Count the number of unoriginal data points in each segment,
${n}_{\text{seg}}^{\text{bad}}$ . 
Eliminate the segment with the largest
${n}_{\text{seg}}^{\text{bad}}$ until the total number of bad points is less than 1% of the total remaining points:$\sum _{i=1}^{k}{n}_{i}^{\text{bad}}}<0.01{N}_{\text{seg}}l,$where l is the number of segments left. 
For each remaining segment, detrend, multiply by a Hanning window, Fourier transform, and calculate a power spectrum of the vertical velocity in frequency space S_{ww}(ω), where ω is the radian frequency. Thomson and Emery (2014b) provides a good discussion for the effects of detrending and windowing on spectra.

Convert each remaining spectrum to wavenumber space and correct magnitude as${S}_{ww}(\kappa )=\frac{{S}_{ww}(\omega ){c}_{\text{seg}}}{I({\sigma}_{\text{seg}}^{\tilde{\gamma}}/{c}_{\text{seg}})}$and$\kappa =\frac{\omega}{{c}_{\text{seg}}},$where I is calculated according to Eq. (4).

Eliminate the two lowest wavenumber spectral values for each segment to avoid lowfrequency bias.

For each segment, eliminate any spectral values for wavenumbers that are higher than${\kappa}_{\text{cutoff}}={({\kappa}_{\text{max}}^{5/3}\times 4)}^{3/5},$where κ_{max} is the highest wavenumber estimated for that spectrum. This avoids significant aliasing from frequencies above the Nyquist frequency.

Sort each remaining spectral value from all remaining segments in increasing order by wavenumber.

Group sorted spectral values as evenly as possible into M = floor(N/50) bins, where N is the total number of spectral values left.

Calculate the mean spectral value for each bin. The degrees of freedom for these average estimates is then 2N_{bin}, where N_{bin} is the number of spectral values in the bin.

Calculate the corresponding wavenumbers of the averaged spectral values, assuming an inertial subrange, using Eq. (8).
APPENDIX C
KDE Dissipation Fit Algorithm

Calculate the minimum and maximum wavenumber cutoffs using Eqs. (18) and (19), assuming a dissipation of 10^{−3} m^{2} s^{−3}. This gives an initial estimate of where the inertial subrange can be.

Find all possible continuous subsections of the spectrum with wavenumbers (κ_{i}, i ∈ [1, N_{sec}]) inside the wavenumber cutoffs (κ_{min} < κ_{i} < κ_{max}), with at least 10 spectral values (N_{sec} ≥ 10), and for which the wavenumbers span at least a quarter of a decade (
${k}_{{N}_{\mathrm{sec}}}/{k}_{1}\ge 2.5$ ). Here, N_{sec} refers to the total number of spectral values in a given subsection and i refers to a specific spectral value in the subsection. 
For each subsection, convert spectrum to log space (x–y space) using Eqs. (13) and (14).

For each subsection, calculate the variance,
${\sigma}_{y}^{2}({d}_{\text{bin},i})=2/{d}_{\text{bin},i}$ , from the degrees of freedom d_{bin,}_{i} of each converted spectral value (${\widehat{y}}_{i}$ ). 
For each subsection, calculate a weighted least squares fitted slope (a_{sec}, where the subscript refers to the specific subsection) to x_{i} and
${\widehat{y}}_{i}$ , using the inverse of the variances from step 4 as the weights. We follow the approach used by Leo (1994). 
Calculate the error on the fitted slope (
${\sigma}_{{a}_{\mathrm{sec}}}$ ). Again, we follow Leo (1994). 
Discard any subsection where
$\left{a}_{\mathrm{sec}}+5/3\right/{\sigma}_{{a}_{\mathrm{sec}}}\ge 1.960$ , with 1.960 coming from the 97.5th percentile of the standard normal distribution. 
For each remaining subsection, assume a slope of−5/3, and use the weighted least squares approach to calculate the y intercept (b_{sec}).

Using those y intercepts, calculate dissipation values for each remaining subsection (ϵ_{sec}) following Eq. (17).

Calculate the largest peak or valley prominence, using the SciPy peak_prominences function (Virtanen et al. 2020), of the residual from Eq. (20) for each subsection.

Further discard any dissipation values from subsections where the maximum prominence is ≥0.8. The remaining dissipation values are now referred to as valid dissipation values.

Using the valid dissipation values (
${\u03f5}_{\text{sec}}^{\text{valid}}$ ), calculate a Gaussian KDE of${\mathrm{log}}_{10}{\u03f5}_{\text{sec}}^{\text{valid}}$ . 
Select the valid dissipation value that is closest to the peak of the Gaussian KDE as the calculated dissipation value (ϵ_{calc}).

Repeat step 1 using the new dissipation value and Eq. (19) to obtain a new maximum wavenumber cutoff.

If any of the subsections used to calculate the dissipation values used for the Gaussian KDE have more than one wavenumber outside of the new wavenumber cutoffs, select the subset of the valid dissipation values coming from subsections entirely within the new cutoffs and repeat steps 12–14 until none of the subsections used have more than one wavenumber outside of the final cutoffs. Note, we do not need to repeat any of the other steps, because we have already calculated all possible potential dissipation values with the original nonstrict cutoffs. The repeat of steps 12–14 merely changes the number of valid subsections included in the calculations due to the refined cutoff values.

If the final dissipation value is larger than the previous dissipation value calculated, again repeat steps 12–15 until the final dissipation value is smaller than the previous dissipation value calculated. Note that this step has the potential to loop infinitely, so we stop if this condition is used five times.
REFERENCES
Amador, A., S. N. Giddings, and G. Pawlak, 2022: ADCPbased estimates of lateral turbulent Reynolds stresses in wavy coastal environments. Limnol. Oceanogr. Methods, 20, 260–280, https://doi.org/10.1002/lom3.10485.
Becker, J. M., M. A. Merrifield, and H. Yoon, 2016: Infragravity waves on fringing reefs in the tropical Pacific: Dynamic setup. J. Geophys. Res. Oceans, 121, 3010–3028, https://doi.org/10.1002/2015JC011516.
Behrens, D. K., F. A. Bombardelli, J. L. Largier, and E. Twohy, 2013: Episodic closure of the tidal inlet at the mouth of the Russian River—A small barbuilt estuary in California. Geomorphology, 189, 66–80, https://doi.org/10.1016/j.geomorph.2013.01.017.
Bertin, X., and M. Olabarrieta, 2016: Relevance of infragravity waves in a wavedominated inlet. J. Geophys. Res. Oceans, 121, 5418–5435, https://doi.org/10.1002/2015JC011444.
Bertin, X., and Coauthors, 2018: Infragravity waves: From driving mechanisms to impacts. EarthSci. Rev., 177, 774–799, https://doi.org/10.1016/j.earscirev.2018.01.002.
Bertin, X., D. Mendes, K. Martins, A. B. Fortunato, and L. Lavaud, 2019: The closure of a shallow tidal inlet promoted by infragravity waves. Geophys. Res. Lett., 46, 6804–6810, https://doi.org/10.1029/2019GL083527.
Bluteau, C. E., N. L. Jones, and G. N. Ivey, 2011: Estimating turbulent kinetic energy dissipation using the inertial subrange method in environmental flows. Limnol. Oceanogr. Methods, 9, 302–321, https://doi.org/10.4319/lom.2011.9.302.
Burchard, H., and Coauthors, 2008: Observational and numerical modeling methods for quantifying coastal ocean turbulence and mixing. Prog. Oceanogr., 76, 399–442, https://doi.org/10.1016/j.pocean.2007.09.005.
Cea, L., J. Puertas, and L. Pena, 2007: Velocity measurements on highly turbulent free surface flow using ADV. Exp. Fluids, 42, 333–348, https://doi.org/10.1007/s0034800602373.
Durgesh, V., J. Thomson, M. C. Richmond, and B. L. Polagye, 2014: Noise correction of turbulent spectra obtained from acoustic Doppler velocimeters. Flow Meas. Instrum., 37, 29–41, https://doi.org/10.1016/j.flowmeasinst.2014.03.001.
Feddersen, F., 2010: Quality controlling surf zone acoustic Doppler velocimeter observations to estimate the turbulent dissipation rate. J. Atmos. Oceanic Technol., 27, 2039–2055, https://doi.org/10.1175/2010JTECHO783.1.
Feddersen, F., 2012: Observations of the surfzone turbulent dissipation rate. J. Phys. Oceanogr., 42, 386–399, https://doi.org/10.1175/JPOD11082.1.
Feddersen, F., J. H. Trowbridge, and A. Williams III, 2007: Vertical structure of dissipation in the nearshore. J. Phys. Oceanogr., 37, 1764–1777, https://doi.org/10.1175/JPO3098.1.
George, R., R. E. Flick, and R. T. Guza, 1994: Observations of turbulence in the surf zone. J. Geophys. Res., 99, 801–810, https://doi.org/10.1029/93JC02717.
Goring, D. G., and V. I. Nikora, 2002: Despiking acoustic Doppler velocimeter data. J. Hydraul. Eng., 128, 117–126, https://doi.org/10.1061/(ASCE)07339429(2002)128:1(117).
Guza, R. T., and E. B. Thornton, 1982: Swash oscillations on a natural beach. J. Geophys. Res., 87, 483–491, https://doi.org/10.1029/JC087iC01p00483.
Harvey, M. E., S. N. Giddings, G. Pawlak, and J. A. Crooks, 2022: Hydrodynamic variability of an intermittently closed estuary over interannual, seasonal, fortnightly and tidal timescales. Estuaries Coasts, 46, 84–108, https://doi.org/10.1007/s12237021010140.
Islam, M. R., and D. Z. Zhu, 2013: Kernel density–based algorithm for despiking ADV data. J. Hydraul. Eng., 139, 785–793, https://doi.org/10.1061/(ASCE)HY.19437900.0000734.
Jesson, M., M. Sterling, and J. Bridgeman, 2013: Despiking velocity timeseries—Optimisation through the combination of spike detection and replacement methods. Flow Meas. Instrum., 30, 45–51, https://doi.org/10.1016/j.flowmeasinst.2013.01.007.
Jones, N. L., and S. G. Monismith, 2008: The influence of whitecapping waves on the vertical structure of turbulence in a shallow estuarine embayment. J. Phys. Oceanogr., 38, 1563–1580, https://doi.org/10.1175/2007JPO3766.1.
Kirincich, A. R., S. J. Lentz, and G. P. Gerbi, 2010: Calculating Reynolds stresses from ADCP measurements in the presence of surface gravity waves using the cospectrafit method. J. Atmos. Oceanic Technol., 27, 889–907, https://doi.org/10.1175/2009JTECHO682.1.
Lee, P. M., 2012: Bayesian Statistics: An Introduction. 4th ed. John Wiley and Sons, 496 pp.
Leo, W. R., 1994: Statistics and the treatment of experimental data. Techniques for Nuclear and Particle Physics Experiments, SpringerVerlag, 81–113, https://doi.org/10.1007/9783642579202_4.
Lin, C. C., 1953: On Taylor’s hypothesis and the acceleration terms in the NavierStokes equation. Quart. Appl. Math., 10, 295–306, https://doi.org/10.1090/qam/51649.
Lumley, J. L., and E. A. Terray, 1983: Kinematics of turbulence convected by a random wave field. J. Phys. Oceanogr., 13, 2000–2007, https://doi.org/10.1175/15200485(1983)013<2000:KOTCBA>2.0.CO;2.
McDougall, T. J., and P. M. Barker, 2011: Getting started with TEOS10 and the Gibbs Seawater (GSW) Oceanographic Toolbox. SCOR/IAPSO Working Group 127 Rep., 28 pp.
McSweeney, S. L., J. C. Stout, and D. M. Kennedy, 2020: Variability in infragravity wave processes during estuary artificial entrance openings. Earth Surf. Processes Landforms, 45, 3414–3428, https://doi.org/10.1002/esp.4974.
Nortek, 2018: The comprehensive manual for velocimeters. Nortek Support Doc., 139 pp., https://support.nortekgroup.com/hc/enus/article_attachments/4551609336220/N3015030_Comprehensive_Manual__Velocimeters_0322compressed.pdf.
Parsheh, M., F. Sotiropoulos, and F. PortéAgel, 2010: Estimation of power spectra of acousticDoppler velocimetry data contaminated with intermittent spikes. J. Hydraul. Eng., 136, 368–378, https://doi.org/10.1061/(ASCE)HY.19437900.0000202.
Pope, S. B., 2000: The scales of turbulent motion. Turbulent Flows, Cambridge University Press, 182–263, https://doi.org/10.1017/CBO9780511840531.008.
Razaz, M., and K. Kawanisi, 2011: Signal postprocessing for acoustic velocimeters: Detecting and replacing spikes. Meas. Sci. Technol., 22, 125404, https://doi.org/10.1088/09570233/22/12/125404.
Rosman, J. H., and G. P. Gerbi, 2017: Interpreting fixedlocation observations of turbulence advected by waves: Insights from spectral models. J. Phys. Oceanogr., 47, 909–931, https://doi.org/10.1175/JPOD150249.1.
Ruessink, B. G., M. G. Kleinhans, and P. G. L. van den Beukel, 1998: Observations of swash under highly dissipative conditions. J. Geophys. Res., 103, 3111–3118, https://doi.org/10.1029/97JC02791.
Rusello, P. J., and E. A. Cowen, 2011: Turbulent dissipation estimates from pulse coherent Doppler instruments. 2011 IEEE/OES 10th Current, Waves and Turbulence Measurements, Monterey, CA, IEEE, 167–172, https://doi.org/10.1109/CWTM.2011.5759546.
Scott, D. W., 2015: Kernel density estimators. Multivariate Density Estimation: Theory, Practice, and Visualization, D. J. Balding et al., Eds., Wiley Series in Probability and Statistics, John Wiley and Sons, 137–216, https://doi.org/10.1002/9781118575574.ch6.
Sharma, A., A. K. Maddirala, and B. Kumar, 2018: Modified singular spectrum analysis for despiking acoustic Doppler velocimeter (ADV) data. Measurement, 117, 339–346, https://doi.org/10.1016/j.measurement.2017.12.025.
Shaw, W. J., and J. H. Trowbridge, 2001: The direct estimation of nearbottom turbulent fluxes in the presence of energetic wave motions. J. Atmos. Oceanic Technol., 18, 1540–1557, https://doi.org/10.1175/15200426(2001)018<1540:TDEONB>2.0.CO;2.
Simpson, J. H., N. R. Fisher, and P. Wiles, 2004: Reynolds stress and TKE production in an estuary with a tidal bore. Estuarine Coastal Shelf Sci., 60, 619–627, https://doi.org/10.1016/j.ecss.2004.03.006.
Stacey, M. T., S. G. Monismith, and J. R. Burau, 1999: Observations of turbulence in a partially stratified estuary. J. Phys. Oceanogr., 29, 1950–1970, https://doi.org/10.1175/15200485(1999)029<1950:OOTIAP>2.0.CO;2.
Thomson, R. E., and W. J. Emery, 2014a: Statistical methods and error handling. Data Analysis Methods in Physical Oceanography, 3rd ed. R. E. Thomson and W. J. Emery, Eds., Elsevier, 219–311, https://doi.org/10.1016/B9780123877826.00003X.
Thomson, R. E., and W. J. Emery, 2014b: Time series analysis methods. Data Analysis Methods in Physical Oceanography, 3rd ed. R. E. Thomson and W. J. Emery, Eds., Elsevier, 425–591, https://doi.org/10.1016/B9780123877826.000053.
Trowbridge, J., and S. Elgar, 2001: Turbulence measurements in the surf zone. J. Phys. Oceanogr., 31, 2403–2417, https://doi.org/10.1175/15200485(2001)031<2403:TMITSZ>2.0.CO;2.
Virtanen, P., and Coauthors, 2020: SciPy 1.0: Fundamental algorithms for scientific computing in Python. Nat. Methods, 17, 261–272, https://doi.org/10.1038/s4159201906862.
Voulgaris, G., and J. H. Trowbridge, 1998: Evaluation of the acoustic Doppler velocimeter (ADV) for turbulence measurements. J. Atmos. Oceanic Technol., 15, 272–289, https://doi.org/10.1175/15200426(1998)015<0272:EOTADV>2.0.CO;2.
Wahl, T. L., 2003: Discussion of “Despiking acoustic Doppler velocimeter data” by Derek G. Goring and Vladimir I. Nikora. J. Hydraul. Eng., 129, 484–487, https://doi.org/10.1061/(ASCE)07339429(2003)129:6(484).
Wheeler, D. C., S. N. Gidings, and J. McCullough, 2023: Data and code from measuring turbulent dissipation with acoustic Doppler velocimeters in the presence of large, intermittent, infragravity frequency bores. University of California, San Diego, Library Digital Collections, accessed 6 February 2023, https://doi.org/10.6075/J0J67H27.
Williams, M. E., and M. T. Stacey, 2016: Tidally discontinuous ocean forcing in barbuilt estuaries: The interaction of tides, infragravity motions, and frictional control. J. Geophys. Res. Oceans, 121, 571–585, https://doi.org/10.1002/2015JC011166.