Exploring Lagrangian Data

While the main aim of the lagrangian-filtering library is the filtering of the Lagrangian-transformed data, it can be useful to work with the transformed data in an exploratory capacity. Suppose we have a new dataset on which we’d like to perform the filtering. Two choices need to be made straight away: what is the high-pass cutoff frequency, and what is a sensible advection timestep? Certainly prior experience and an idea of the source model parameters like Coriolis parameter and timestep are useful, however directly interrogating the data may lead to better results.

Under the hood (see also the algorithm description), the Lagrangian transformation can be performed in isolation with advection_step(). For example, to compute the mean Lagrangian velocity, which could then be used to compute a spectrum for determining an ideal cutoff frequency:

f = LagrangeFilter(...)
data = f.advection_step(time)
mean_u = np.mean(data["var_U"][1], axis=1)

Using analysis functions

As an alternative to using ad-hoc explorations as above, there are predefined functions available to give more robust and efficient ways to interrogate your data. For example, a mean kinetic energy spectrum over all particles could be computed at a specified time using power_spectrum():

from filtering import analysis
f = LagrangeFilter(..., sample_variables["U", "V"], ...)
spectra = analysis.power_spectrum(f, time)
ke_spectrum = spectra["var_U"] + spectra["var_V"]