DiffusionBased Smoothers for Spatial Filtering of Gridded Geophysical Data
Abstract
We describe a new way to apply a spatial filter to gridded data from models or observations, focusing on lowpass filters. The new method is analogous to smoothing via diffusion, and its implementation requires only a discrete Laplacian operator appropriate to the data. The new method can approximate arbitrary filter shapes, including Gaussian filters, and can be extended to spatially varying and anisotropic filters. The new diffusionbased smoother's properties are illustrated with examples from ocean model data and ocean observational products. An opensource Python package implementing this algorithm, called gcmfilters, is currently under development.
Key Points

A new way to apply a spatial lowpass filter to gridded data is developed

The new method can be applied in any geometry since it only requires a discrete Laplacian operator

The algorithm's flexibility is illustrated using a range of examples from simulation and observation data
Plain Language Summary
“The large scale part” and “the small scale part” of quantities like velocity, temperature, and pressure fluctuations are important for a range of questions in Earth system science. This study describes a precise way of defining these quantities, as well as an efficient method for diagnosing them from gridded data, especially the data produced by Earth system models.
1 Introduction
Spatial scale is an organizing concept in Earth system science: atmospheric synoptic scales and convective scales, and oceanic mesoscales and submesoscales, for example, are ubiquitous touchstones in atmospheric and oceanic dynamics. The pervasive idea of an energy spectrum is fundamentally based on the idea of partitioning energy (or variance) across a range of spatial scales. Despite this central importance, diagnosing dynamics at different spatial scales remains challenging. When analyzing remotesensing or simulation data, scientists instead often rely on time averaging as proxy for separating scales, which is more computationally convenient than spatial filtering. Temporal filtering is often of interest in its own right, but in situations where spatial filtering is called for this trade of spatial for temporal filtering can be justified by the fact that dynamics at different spatial scales are frequently also associated with different time scales.
We make a semantic distinction between spatial filtering and coarsegraining. In our use of the terms, coarsegraining is an operation that produces output at a lower resolution (i.e., smaller number of grid points) than the input, whereas spatial filtering produces output at the same resolution as the input. (Note that this terminology is not uniformly adopted in the literature; cf. Aluie et al. [2018)].) Berloff (2005), Porta Mana and Zanna (2014), Williams et al. (2016), Stanley, Grooms, et al. (2020), and Zanna and Bolton (2020) are all examples where coarsegraining was used in the context of ocean model subgridscale parameterization. The term “averaging” is sometimes used instead of filtering. They are essentially synonymous when the filter kernel is nonnegative, but a filter whose kernel has negative values cannot be described as an average, so we opt to use the more general term. A lowpass filter can be described as a smoother, which is the focus here, but the methods described here can be straightforwardly adapted to bandpass or highpass filters.
This study introduces a new way of designing and implementing spatial filters that rely only on a discrete Laplacian operator for the data. Because it relies on the discrete Laplacian to smooth a field through an iterative process reminiscent of diffusion, we refer to the new method as diffusionbased filters. The study is structured as follows. Section 2 describes the new filters along with their properties. Examples using model data and observations are provided in Section 19 to illustrate the various filter properties described in Section 2. Conclusions are offered in Section 25. Appendix A provides some details of the filter specification, and Appendix B discusses the commutation of the filter with derivatives.
2 Spatial Filtering of Gridded Data
2.1 Review
Spatial filtering of gridded data is a welldeveloped field, both for general applications and in the context of geophysical data. The focus here is on filtering in the context of fluid models, especially atmosphere and ocean models. To place our new method into context, we review existing filtering techniques, and distinguish between implicit and explicit filters.
Shapiro (1970) introduced a class of filters, widely used to improve the performance of early finitedifference weather models by removing energy near the gridscale and thereby preventing accumulation leading to blowup. Shapiro filters are essentially discrete spatial convolution filters optimized to remove the smallest scales that can be represented on a logically rectangular grid, while leaving the other scales as close to unchanged as possible. Sagaut and Grohens (1999) reviewed some of the more recent approaches to convolutionbased filtering for largeeddy simulation. Sadek and Aluie (2018) developed two discrete convolution kernels for the purpose of accurately extracting the energy spectrum using convolution filters rather than Fourier methods.
The new approach developed here results in high order explicit differential filters, meaning that they use a discrete Laplacian, but that they do not require solving a system of equations.
2.2 Spatial Filtering Basics
Most intuition about spatial filtering and spatial scales is built on the foundation of kernel convolution and Fourier analysis, in the context of Equation 1. The wellknown convolution theorem (e.g., Hunter & Nachtergaele, 2001, Theorem 11.35) states that the Fourier transform of is proportional to , where denotes the Fourier transform and the proportionality constant depends on the dimension and on the normalization convention chosen in the definition of the Fourier transform.
Fourier analysis enables us to understand the effect of spatial convolution filtering in terms of length scales. We consider the function to be a sum of many Fourier modes, each of which has a distinct spatial scale. The Fourier transform of the kernel, , then describes how each Fourier mode is modified by the spatial filtering operation. Filter kernels are usually symmetric about the origin, which makes realvalued, so that spatial filtering only changes the amplitude of the Fourier modes and not their phase. If for a particular Fourier mode then the corresponding length scale is left unchanged in , whereas if for a particular Fourier mode then the corresponding length scale is removed from . By modifying the amplitudes of the Fourier modes, spatial filtering controls the scale content of .
The background intuition for kernelbased spatial filters in this subsection is developed entirely for functions on Euclidean spaces. The definition of convolutionbased spatial filters is considerably more complicated on a sphere; see Aluie (2019) for details.
2.3 DiffusionBased Smoothers
2.3.1 Discrete Integral and Laplacian
The area integral can be expressed in terms of the inner product as , where is a vector whose entries are all 1.
This is automatically guaranteed for finitevolume discretizations of the Laplacian with noflux boundary conditions.
2.3.2 Connecting the Discrete Laplacian to Spatial Scales
On the left in the above expression represents the familiar Fourier wavenumber corresponding to a wavelength of , while on the right the eigenvalue has been written with similar notation to emphasize the similarity. Precisely because is a discretization of the Laplacian, the length should roughly correspond to the length scale of the eigenvector . We assume that the eigenvalues are ordered such that .
The assumption that the eigenvalue corresponds to a physical length scale for the eigenvector is crucial. It is not typically possible in realistic applications to derive the eigenvalues and eigenvectors in closed form to verify this assumption, nor is it practical to compute them numerically. The assumption is nevertheless expected to hold except possibly in nonsmooth geometries.
2.3.3 Polynomial Approximation of the Target Filter
For the large data sets produced by Earth system models computing the eigenvalues and eigenvectors of is prohibitively expensive, and even solving linear systems involving can be expensive. By contrast, simply applying is usually inexpensive. In practice this means that it is inexpensive to compute when is a polynomial. (The implicit differential filters of Germano (1986) and Guedot et al. (2015) correspond to letting be a polynomial.)
To construct a filter that acts like a convolutionbased spatial filter with a Gaussian kernel of standard deviation , one might choose a target filter of the form . It is worth emphasizing that the connection to convolution is only heuristic; near boundaries or in nonEuclidean geometry the target filter is not exactly the same as a convolutionbased spatial filter. In particular, the use of a Gaussian target filter will not produce exactly the same result as convolution with a Gaussian kernel. The precise interpretation of is based on Equation 14: the expansion coefficient is multiplied by .
The goal would then be to find a polynomial such that . In general this is not possible with an explicit filter because polynomials grow without bound as ; thankfully it is only necessary for the approximation to hold over the range of scales represented on the grid, specifically for where is the mostnegative eigenvalue of . If is not known, some reasonable proxy can be used to define the range of scales over which should act like a spatial filter. For example, on a quadrilateral grid one might use d where d is the length of the smallest grid cell edge and is the spatial dimension of the grid.
In Appendix A, we present a leastsquares approach for finding a polynomial such that approximates . The left column of Figure 2 shows three examples of target filters, along with their approximations using polynomials of degree and 21. The top row shows the boxcar target shown in Equation 4 with length scale (nondimensional), and the middle row shows the Gaussian target that corresponds to a Gaussian kernel with standard deviation (nondimensional). The bottom row shows a target that we here label “taper.”
The taper target is developed as an example of a filter that is more scaleselective than the Gaussian; it is a smooth approximation of a spectral cutoff filter. The taper target is a piecewise polynomial with a continuous first derivative. It is for above some cutoff , with (nondimensional) in Figure 2. For it takes the value where controls the width of the transition region; in Figure 2. For wavenumbers in the transition region the taper target is a cubic polynomial. As the width of the transition region goes to zero () the taper target approaches the spectral truncation filter, which is a step function at wavenumber . The left column of Figure 2 shows that the number of steps required to achieve an accurate approximation of the target filter depends on the shape of the target filter, with more scaleselective targets like the taper requiring more steps .
2.3.4 Definition of Filter Scale
We provide a single convention linking the “filter scale” for the boxcar, Gaussian, and taper targets as follows. The filter scale for a boxcar kernel is simply the width of the kernel (not the halfwidth). Per Equation 4, the boxcar filter exactly zeros out the wavenumber . Since the taper filter also zeros out wavenumber , it is natural to let define the ‘filter scale’ for both the boxcar and taper filters. The filter scale for a Gaussian is chosen so that the standard deviation of the Gaussian and boxcar kernels match for a given filter scale (cf. Sagaut & Grohens, 1999). This is achieved by defining the “filter scale” for a Gaussian to be times the standard deviation of the Gaussian kernel, that is, to extract the standard deviation from the filter scale use . This convention is developed based on convolution over a Euclidean space, but once developed it simply serves to link the definition of the filter scale across target filters, which can be used in nonEuclidean geometry, for example, on the sphere.
2.3.5 Filter Algorithm
These stages are called biharmonic stages because of the need to apply the discrete biharmonic operator .
In the absence of roundoff errors the Laplacian and biharmonic stages can be applied in any order, and once they are both complete contains the filtered field (though at any point in the middle of the iterations has no particular meaning). However, in practice, the order can have an impact on numerical stability. This issue is discussed in Section 12.
2.3.6 Scalar, Vector, and Tensor Laplacians on Curved Surfaces
The development thus far is based on a discrete approximation of a scalar Laplacian, or of the LaplaceBeltrami operator on a curved surface like the sphere. In Euclidean space, the Laplacian of a vector or a tensor is obtained by applying the scalar Laplacian to the elements of the vector or tensor. This is no longer the case on a curved surface like the sphere, as can be seen, for example, in the fact that the discretizations of viscosity and diffusion are different on the sphere. The algorithm described in the foregoing section can be directly extended to filtering vectors or tensors on curved surfaces by simply taking to be a discretization of the appropriate continuous operator, for example, the vector or tensor Laplacian on a sphere. In this case should be understood to include all components of the vector or tensor being filtered. For example, the grid values of zonal velocity could be arranged as the first half of while the grid values of meridional velocity could be arranged as the second half of .
2.3.7 Computational Cost
Typically the computational cost (in terms of floating point operations) of applying the discrete Laplacian is where is the number of grid points. The total number of discrete applications of the Laplacian is , so the cost to apply the filter is . The number of stages depends on the shape of the target filter and the ratio of the filter scale to the grid scale, called the filter factor . For both the Gaussian and taper filters the number of stages needed to achieve a fixed accuracy scales (empirically) linearly with , so the overall cost of applying the filter is .
This is directly comparable to a convolutiontype filter implemented using quadrature. In a convolutiontype filter, one is required to compute a quadrature at each of the grid points. The number of nonzero elements in the kernel, and thus the number of floatingpoint operations required to compute the quadrature, is linearly related to the ratio of the gridscale to the width of the kernel, that is, the filter factor. The cost of applying a convolutiontype filter is thus also : at each of grid points one must compute a quadrature that costs floating point operations. Naturally, the performance in practice depends heavily on the details of the implementation, the coding language, the machine architecture, and so on.
2.4 Floating Point Roundoff Errors
Any modes such that will have their coefficients amplified at this stage, and smaller scales will experience greater amplification. (The sign of the coefficients will also be changed; the real roots are generally positive.) In contrast, when none of the modes will experience amplification and the smallest scales will be damped.
As a function of this is a positive parabola that equals 1 at . When the real part of is negative all modes are amplified with increasing amplification at small scales. When the real part of is positive, modes with will be amplified, with increasing amplification at small scales.
Consider a filter that attempts to remove a wide range of scales, that is, one where the filter scale is much larger than the gridscale. To achieve this, the polynomial approximation algorithm from Appendix A selects a range of roots , with some of the roots corresponding to scales much larger than the grid scale . The stages with amplify the small scales while damping the large scales. Taken together, the stages end up producing smoothing over a wide range of scales, but if the iteration (21b) is stopped partway, there can be ranges of scales that are amplified rather than damped. In particular, if there are several stages in succession that cause amplification at the small scales (near the gridscale), it can lead to extreme amplification at small scales, including extreme amplification of any roundoff errors present in the small scales. This combination of many stages that amplify small scales, together with a large number of stages for roundoff errors to accumulate, can lead to inaccurate results or even blowup of the filtered field. To avoid this, we recommend choosing a specific order for the roots , such that stages that amplify small scales are always followed by stages that damp small scales.
To illustrate these ideas, we set up a simple toy problem with a onedimensional, periodic, equispaced grid of 256 points in a nondimensional domain of size , and a spectral discrete Laplacian. The eigenvectors of the discrete Laplacian are the discrete Fourier modes with wavenumbers , and the eigenvalues are exactly . The filter polynomial is constructed by directly specifying the roots , rather than by approximating some target filter . The roots are the integers from 43 to 170, squared, that is, there are stages with roots on both sides of the cutoff scale . This filter should thus exactly zero out all discrete wavenumbers with , while smoothly damping wavenumbers with . The field to be filtered is constructed to have discrete Fourier transform where are independent and uniformly distributed on . This initial condition is chosen so that the discrete Fourier transform of the final filtered field should, in the absence of roundoff errors, have absolute value equal to .
Figure 3 shows the amplitude of the Fourier modes of the field as it progresses through the stages of the filter. The left panel shows the result for a filter where are ordered from least to greatest, such that the first stages amplify the small scales while the last stages damp them. The small scales grow to amplitudes on the order of within the first 50 stages. The subsequent stages manage to damp these small scales back out, but the solution is so corrupted by the effect of roundoff errors that the final solution is completely inaccurate: the large scales have amplitudes on the order of .
The center panel of Figure 3 shows the effect of arranging in decreasing order, such that the last stages amplify the small scales while the first stages damp them. The filter behaves quite well until the final few stages, where the small scales are amplified to the order of . Evidently, the initial damping stages introduce small amplitude roundoff errors into the small scales which are then amplified in the final stages.
The right panel of Figure 3 shows the effect of arranging the so that the small scales are alternately amplified and then damped. In the early stages of the filter, there is a range of intermediate scales that begins to amplify, though they maintain modest amplitudes less than 100. These intermediate scales are eventually damped back out in the later stages, leading to a wellbehaved and accurate solution.
The stages in the right panel of Figure 3 are arranged in the following simple way. We first compute the impact of each stage on the smallest scale, given by setting in the absolute value of expression (23) and in expression (24). These values are then ordered, and the stage order is set by selecting the smallest value (strongest damping) first, followed by the largest value (strongest amplification), followed by the nextsmallest value, and so on.
2.4.1 Connection to Diffusion
The form of Equation 21b is reminiscent of time integration of the diffusion equation via an explicit Euler discretization with variable time steps, and in some sense the method can be thought of as smoothing through diffusion. To be explicit, if we assume a diffusivity of then the time step sizes are d. (The serves to distinguish this , which is dimensional, from the introduced in Section 15, which is nondimensional). There is no analogy for the biharmonic stages, or for negative , so the analogy only holds when all the are real and positive. The usual stability analysis for time integration of the diffusion equation corresponds to the case where all the time steps are of equal size, that is, all the must be real, positive, and equal. In this case the CourantFriedrichsLewy (CFL) condition corresponds to requiring that a single step does not amplify any component of the solution; if this condition is violated, then as the number of steps proceeds to infinity the solution will also grow to infinity, even in exact arithmetic. Per the discussion above, requiring no growth of any part of the solution in a single step corresponds to the condition . Written in terms of the time step this CFL condition takes the form d. Inserting the approximation d yields a more familiar form for the CFL condition for diffusion: d (recall that is the dimension of the physical domain).
The instability associated with violating the CFL condition for diffusion is not the same as the one described above, nor is it relevant for analyzing the stability of our filtering algorithm. That they are not the same can be seen from the fact that the instability analyzed above is entirely a result of roundoff errors, whereas the instability associated with violating a CFL condition occurs even in exact arithmetic. The CFL condition is not relevant for our algorithm because our algorithm is not solving the heat equation except in special cases, and even in those cases the size of the time step varies and the number of time steps is finite.
2.5 Impact of the Order of Accuracy of the Discrete Laplacian
This section gives a simple example to show that higherorder discretizations of the Laplacian should be better able to sharply distinguish between scales near the gridscale. Throughout this section, “small” length scales refer to scales near the gridscale. The fundamental idea of Section 4 is that the eigenvalues of the discrete Laplacian correspond to the spatial length scale of the eigenvector in the same way that this correspondence works for the continuous Fourier problem, that is, if is an eigenvalue of the discrete Laplacian then the length scale of the corresponding eigenvector is assumed to be . This connection between eigenvalues and length scales can be inaccurate at small length scales.
The fact that these are not equal to is tantamount to saying that the filter will incorrectly identify the length scales of the eigenfunctions. Figure 4 shows the ratio of the discrete eigenvalues (28) and (29) to the correct value . In both cases, the wavenumber implied by the eigenvalue is smaller than the true wavenumber , meaning that these Laplacians treat small scales as if they were largerscale than they really are. Both Laplacians have accurate eigenvalues at large scales, but the fourthorder Laplacian's eigenvalues are more accurate at small scales. A filter that uses the fourthorder Laplacian will thus be more accurate when the filter is attempting to separate scales near the limit of resolution. If one is attempting, for example, to get an accurate estimate of the energy spectrum at scales near the gridscale using the diffusionbased filter of Section 4 in combination with the method of Sadek and Aluie (2018) for estimating the spectrum, then it would be important to use a highorder discretization of the Laplacian. On the other hand, if the filter is attempting to remove the entire range of small scales where the secondorder Laplacian is inaccurate, then the secondorder Laplacian will work as well as higherorder Laplacians.
A user might attempt to filter two different data sets, each with a different resolution, to the same filter scale. The results will be similar provided that the filter scale is wellresolved in both data sets. If the filter scale is close to the gridscale of one of the data sets and the discrete Laplacian uses a loworder approximation, then the results could differ.
2.6 Spatially Varying Filter Properties
The filters developed in Section 4 are based on the isotropic Laplacian, and are therefore isotropic in the sense that they provide an equal amount of smoothing in every direction. The filter coefficients are the same over the whole domain, so the degree of smoothing is also constant over the domain. This can be generalized to anisotropic and spatially varying filters by letting be a discretization of where is a symmetric and positive definite tensor that varies in space (cf. Báez Vidal et al., 2016). (In this context is nondimensional, since the dimensions are carried by the polynomial roots .)
Consider first the isotropic case with constant , and assume that the filter polynomial has been designed as described in Section 4 under the assumption . If the filter polynomial is used with constant then the filter polynomial is replaced by . This is tantamount to rescaling the filter length scale by . For example, if the original filter with had a characteristic length scale of then the filter using has a characteristic length scale of .
Next consider the case of an isotropic Laplacian with spatially varying , and assume that varies slowly over the domain. The filter polynomial is designed to have length scale if . In regions where the filter will have a longer length scale , while in regions where the filter will have a smaller length scale. (If varies on length scales smaller than the filter scale then the behavior of the filter is hard to predict, so this situation should be avoided.)
Finally, consider the case of an anisotropic Laplacian with symmetric and positive definite that varies over the domain. At each point in the domain has two orthogonal eigenvectors corresponding to different directions, and the eigenvalues indicate the strength of smoothing in each direction. One natural application of the anisotropic Laplacian is to apply a filter whose length scale is tied to the local gridscale, which is especially relevant for Earth system models whose grid cell sizes vary in space. This can be achieved by aligning the eigenvectors of with the local orthogonal grid directions, and letting the respective eigenvalues determine the amount of filtering in each direction.
Consider, for example, a onedimensional nonuniform grid with maximum grid spacing , minimum grid spacing , and local grid spacing . To apply a filter that smooths locally to a scale times larger than the local grid, one could choose the filter scale to be and then set . Locally the filter scale is rescaled to as desired, but at the same time which will lead to undesirable behavior at the small scales. Instead, one can achieve the same effect by setting the filter scale to , and then setting . The local filter scale is again , but with over the whole domain.
We next describe a more ad hoc method of tying the local filter scale to the local grid scale. This method is not without drawbacks, but it is simpler and faster than the method based on an anisotropic and spatially varying Laplacian. We call this filter the simple fixed factor filter.

Weight the input data by cell sizes

Apply the filter assuming the cell sizes are equal

Divide the result by the cell sizes
The above sequence uses the facts that is symmetric, which implies , that any consistent discretization of the Laplacian with noflux boundary conditions will have , and that .
Applying the discrete Laplacian under the assumption that all cell sizes are equal is much simpler than using an anisotropic Laplacian, and the algorithm can thus be much faster. On the other hand, this ad hoc method no longer has the property that the constant vector is left unchanged by the filter. Note that the simple fixed factor filter is anisotropic whenever the grid spacing is anisotropic, and it is spatially varying whenever the grid spacing is nonuniform.
2.7 Variance Reduction
In order for this to be satisfied for any possible vector this requires for every up to the largest one represented on the model grid, that is, . The eigenvalues of the discrete Laplacian are usually not known exactly, so a sufficient condition for variance reduction would be that for every where . It is worth noting that this condition applies to and not to the target filter. Even if the target filter satisfies this condition, the polynomial might not satisfy it. (In all examples in the left column of Figure 2 both the target filter and the approximating polynomials do satisfy this condition.) It is also worth noting that failure to satisfy this condition does not guarantee that the filtered field has more total variance than the unfiltered field, but only that it might happen in some cases.
2.8 The Effective Kernel Implied by the DiffusionBased Filter
which implies that . We can thus compute the effective filter kernel that corresponds to at the grid cell by applying the filter to and then dividing the result by . The same arguments can be used to find the effective filter kernel associated with the spatially varying filters of Section 15.
which uses the fact that and the definition of (37), and assumes . Equation 39 directly implies that .
The result that follows by plugging in .
Note that if the filter kernel ever takes a negative value, then it is no longer guaranteed to preserve positivity in the sense that may have negative values even when all the values in are positive. Similarly if the filter kernel ever takes a negative value then it could produce a negative local variance . The spectral truncation filter is such an example having negative weights.
The right column of Figure 2 computes the filter kernels associated with the polynomial approximations of the boxcar, Gaussian, and taper filters in the left column of Figure 2. The standard equispaced, secondorder Laplacian (25) was used, with a nondimensional grid size of 1. The upper right panel illustrates that the kernel associated with the polynomial approximation of the boxcar filter does not converge to the actual boxcar kernel, though it is close. One reason for this discrepancy is the fact that the boxcar target (4) was formulated by reference to a continuous Fourier transform, which is not a onetoone match to the discrete version. Another reason is that the effective kernel depends on the discretization of the Laplacian; a higherorder discretization would result in a slightly different effective kernel. Despite these discrepancies, the effective kernel of the polynomial approximation to a Gaussian target still converges to a close approximation of the expected Gaussian kernel, as can be seen in the middle right panel of Figure 2.
3 Illustrative Examples
In this section, we present examples using model output and observational data to illustrate the various filter properties and capabilities. An opensource Python package implementing the diffusionbased filters described in Section 2, called gcmfilters, is currently under development and will be described elsewhere. This Python code includes implementations of the discrete scalar and vector Laplacians on a variety of spherical grids for different ocean general circulation models. All examples that show the filtering of twodimensional data use a secondorder discrete Laplacian (on a 5point stencil) with noflux boundary condition.
3.1 Effective Kernels
We begin with an example showing effective filter kernels (see Section 17) for various configurations of the filters, noting especially how the filter kernel adapts near boundaries. Figure 6 shows effective kernels centered at four locations in the Antarctic Circumpolar Current. The grid is a 2/3° nominal resolution tripole grid of the Modular Ocean Model version 6 (MOM6). The top row shows filters with a Gaussian target, while the bottom row shows filters with the taper target. It is clear that the taper target produces kernels with negative weights, while the Gaussian target does not. In the top left panel, we chose a filter scale of 100 km for the kernel centered at (W, S), and 1,000 km for the remaining three kernels. In the bottom left, we reduced the large filter scale from 1,000 to 300 km, because the Taper filter became numerically unstable at high latitudes for a filter scale of 1,000 km. The right column shows the anisotropic versions of the filters in the right column where the filter scale has been decreased by a factor of 3 in the meridional direction. It is interesting to note that the kernel in the upper left panel near the southern tip of South America does not curl around into the Argentine basin, as might be expected for a convolutiontype filter.
3.2 Spatially Varying Filter Scale
Figure 7 illustrates the ability of our filters to vary their length scales over the domain by using variable as described in Section 15. We filter the vertical component of relative vorticity at the surface from the submesoscaleresolving MITgcm simulation of the Scotia Sea with a resolution of described in Bachman et al. (2017). In the map of the unfiltered vorticity (top panel), large scales are evident in the Antarctic Circumpolar Current to the east of Drake Passage, where the first baroclinic deformation radius tends to be km and is generally smaller than the eddies themselves. Small scales are ubiquitous over the continental shelf off the eastern coast of Argentina, where the deformation radius is km and is much closer to the eddy scale. We demonstrate the spatially varying filter by choosing the length scale of the Gaussian filter so that the filter scale is proportional to the local first baroclinic deformation radius. In making this choice we expect that more features will be filtered out in the areas where the dynamics tend to be larger than the deformation scale, as shown in the map of the filtered vorticity (middle panel) and the difference, that is, the eddy vorticity field (lower panel).
3.3 NonCommutation of the Filter and Spatial Derivatives
Figure 8 illustrates the lack of commutation of the filters with spatial derivatives in the presence of boundaries. We compute a largescale part of the vertical component of relative vorticity in two ways, first by filtering the velocity using a vector Laplacian and then computing vorticity as , and second by computing the vertical vorticity directly from the velocity and then applying the filter to the result . The filter is isotropic, and uses a Gaussian target with a length scale of 300 km. The data are from a stateoftheart climate model, GFDLCM2.6 (Delworth et al., 2012; Griffies et al., 2015), obtained through the Pangeo cloud data library (Abernathey et al., 2021). The ocean component of GFDLCM2.6 utilizes the GFDLMOM5 numerical ocean code with a nominal resolution of 0.1°. The upper left panel shows the raw vorticity in the northwest Pacific, while the upper right and lower left panels show the filtered vorticity and the vorticity obtained from the filtered velocity, respectively. The lower right panel shows the difference between the two smoothed vorticities, and it is clear that the differences are extremely small over most of the domains. Significant differences arise only near the boundaries, as can be seen especially in the vicinity of the Philippines, which serves to illustrate the fact that the filter does not commute with derivatives near boundaries.
The ability to commute the filter with spatial derivatives can be restored by treating velocity values on land as zero, following Aluie et al. (2018). To illustrate the difference of this approach compared to using stressfree boundary conditions in the vector Laplacian, we compare in Figure 9 the filtered surface velocity that results from the two approaches. The left column shows the zonal component of velocity and the right column shows the meridional component. The top row shows the unfiltered velocity; the second row shows the velocity filtered using the stressfree condition on the discrete vector Laplacian; the third row shows the filtered velocity that results from setting velocity to zero over land; the fourth row is the second row minus the third row. Setting the velocity to zero over land allows the filter to commute with derivatives, but at the cost of reducing the strength of currents near land. For example, the Florida Current is much weaker in the third row than in the second row. It is thus clear that both methods have pros and cons near boundaries. The data used in Figure 9 are from a JRA55forced 2/3° MOM6 simulation; the filter has a length scale of 500 km and a Gaussian target.
3.4 Negative Weights and Eddy Kinetic Energy
This definition of EKE has the virtue that the total kinetic energy is exactly the sum of the mean and eddy kinetic energies. When the weights are nonnegative this definition of EKE will also be nonnegative, as discussed in Section 17. An alternative proof based only on having a convex kernel is given by Sadek and Aluie (2018). A proof specific to EKE can be found in Vreman et al. (1994).
Figure 10 illustrates the application of our filters to a single 5day average of AVISO estimates of absolute geostrophic velocity on a 0.25° grid obtained from Copernicus European Earth Observation program (https://marine.copernicus.eu) via Pangeo (Abernathey et al., 2021). The upper left panel shows the unfiltered surface kinetic energy defined as . To compute mean surface kinetic energy we use the simple fixed factor Laplacian with a filter scale four times the local gridscale, that is, a filter scale of 1°. The center panel in the upper row shows the mean kinetic energy defined as using a Gaussian target, while the upper right panel shows the mean kinetic energy obtained using the taper target. The lower panels show the surface EKE defined according to Equation 41. It is clear that the negative weights in the taper filter lead to locally negative values of surface EKE.
The alternative definition where can also produce negative values of EKE when the filter has negative weights. As a simple example consider the case where is nonzero at only one grid point. Then is proportional to the effective kernel centered at that point, and Figure 6 shows that the taper filter's effective kernel has negative weights.
3.5 Application to OneDimensional Observational Data
Our final example in Figure 11 illustrates the application of our filters to onedimensional data, specifically alongtrack altimeter observations of absolute dynamic topography used to estimate crosstrack geostrophic velocity. This example is included not only to highlight additional capabilities of this filtering framework, but also to encourage its use on insitu velocity or tracer measurements to permit scaleaware observationalmodel comparisons. We apply three filters (boxcar, Gaussian, and taper) to crosstrack geostrophic velocity estimates along a single track of the Jason2 altimeter located in the Western North Atlantic. Velocities are interpolated to 20 km spacing and then filtered to a 100 km filter scale. The upper panel shows a single cycle of crosstrack geostrophic velocity as a function of alongtrack distance moving north to south (gray lines show all cycles completed at 10day intervals over a 2year period). The single cycle (black) is then filtered using each of the three filter types with EKE shown in the lower panel. The three filters produce nearly indistinguishable largescale fields, but the EKE defined according to Equation 41, shown in the lower panel, displays notable differences. Specifically, the taper filter's negative weights lead to occasional negative values for EKE.
4 Conclusions
We have presented a new method for spatially filtering gridded data that only relies on the availability of a discrete Laplacian operator. The method involves repeated steps of form 21b, and is therefore analogous to smoothing via diffusion. (More details on this point are provided in Section 12.) The new filters provide an efficient way of implementing something close to a Gaussian kernel convolution; they also allow the scale selectiveness (i.e., the shape) of the filter to be tuned as desired. As they require only the ability to apply a discrete Laplacian operator, these filters can be used with a wide range of data types, including output from models on unstructured grids, and gridded observational data sets.
The only time the filter commutes with derivatives is when the domain has no boundaries and the filter scale is constant over the domain. If desired, ocean boundaries can be eliminated by treating velocity values on land as zero, following Aluie et al. (2018); however, to preserve the integral with this method, the integral has to be extended over land. The basic method can be generalized to allow for anisotropic, that is, directiondependent, as well as spatially varying filter scales. It is our hope that the new method and forthcoming software package will enable an increase in scaledependent analysis of Earth system data, particularly for the purposes of subgridscale parameterization, though by no means limited to such.
Acknowledgments
The authors are grateful to the editor, S. M. Griffies, and to H. Aluie and two anonymous reviewers for their efforts to improve the clarity and scope of the manuscript. The authors are grateful to J. Busecke for help with setting up the cmfilters Python package, and to H. Khatri for discovering the numerical instability described in Section 12. The authors thank A. Adcroft for helpful discussions on the design of spatially varying filters. I.G. and N.L. are supported by NSF OCE 1912332. R.A. is supported by NSF OCE 1912325. J.S. is supported by NSF OCE 1912302. S.B. and G.M. are supported by NSF OCE 1912420. A.G. and E.Y. are supported by NSF GEO 1912357 and NOAA CVP NA19OAR4310364.
Appendix A: Solving the Optimization Problem to Find the Filter Polynomial
Once a target filter has been specified, one must also choose the degree of the polynomial . As increases the filter approaches the target filter—the approximation converges provided that is absolutely continuous (Trefethen, 2013, Theorem 7.2). As increases the computational cost of the filter grows because applying the filter requires applying the discrete Laplacian times. It is therefore desirable to choose some tradeoff between cost and accuracy. The Python packageg gcmfilters (gcmfilters, 2021) has a default setting for that guarantees not more than 1% error in the difference between and ; the user can also override this choice with any desired value of .
Appendix B: Commuting the Filter and Derivatives
This section explores conditions under which our filters commute with spatial derivatives, which was one of the main goals in the design of convolutionbased spatial filters on the sphere in Aluie (2019). Filters with spatially varying properties (cf. Section 15) do not commute with derivatives, since they are analogous to integration against a spatially varying kernel (i.e., Equation 8). (Note that anisotropic diffusion with tensor does not generally commute with derivatives on a curved surface even when the disparate length scales of the filter are constant.) We thus consider in this section only the versions of our filters with a fixed length scale. We first consider domains with boundaries, showing that our filters do not commute in this case, and then turn to the surface of a full sphere, without topographic boundaries.
This filter obviously commutes with derivatives, but it is in some sense not the correct continuous version of our discrete filter. The reason is that the discrete version always assumes noflux boundary conditions on the data, because no other boundary condition is guaranteed to conserve the integral. Indeed the filter (B1) is not guaranteed to conserve the integral unless satisfies noflux (or periodic) boundary conditions. This is no limitation in the discrete case, since the noflux Laplacian can be computed for any data. On the other hand, if one applies the discrete Laplacian with a noflux assumption and then takes the limit of infinite resolution the result does not converge to unless actually satisfies noflux boundary conditions. Instead, it converges to plus Dirac delta distributions on the boundary. (This is analogous to the delta sheets of potential vorticity discussed by Bretherton [1966]).
In the correct continuous limit, equation (B1) is only defined for functions that satisfy . With this more careful definition of the continuous limit of the filter, one can ask again whether it commutes with the spatial derivative. If one attempts to define and then apply the filter to , the result is not defined unless also satisfies noflux conditions, that is, . So in the continuous limit, the filter will not commute with differentiation for functions with on the boundaries. For higherorder filters the conditions for commutation are even more stringent, requiring derivatives up to high order to all be zero on the boundary.
An alternative perspective is afforded by the fact that our discrete filter is equivalent to a discrete kernel smoothing, per the arguments of Section 17. In the presence of boundaries, the shape of the kernel varies in space, as can be seen in Figure 6. The continuous analog is integrated against a spatially varying kernel (Equation 8), which does not commute with spatial derivatives.
In the case without boundaries, for example, on a sphere, there is no such difficulty. As long as the continuous differential operators commute (e.g., a Laplacian and a gradient), the discrete operators should also commute, at least up to discretization errors. The convolutionbased spatial filters of Aluie (2019) only commute with derivatives in the absence of boundaries; this difficulty can be avoided by treating velocity values outside the domain (e.g., on land) as zero (Aluie et al., 2018). A similar method can be used with our filters if desired: values outside the domain can be treated as zero (see right panel of Figure 9).
Open Research
Data Availability Statement
Scripts used to generate the figures, including links to the publicly available data, can be found at (Loose et al., 2021). The authors are grateful to J. Kenigson for providing us with output from a MOM6 model simulation. An opensource Python package implementing this algorithm, called gcmfilters, is currently under development (see gcmfilters, 2021). An early version of the package was used to generate the results in this paper. A study describing the software itself is in preparation for Journal of Open Source Software, to coincide with the first release. In the present manuscript, our focus is the algorithm itself, not the implementation.