Volume 13, Issue 9 e2021MS002552
Research Article
Open Access

Diffusion-Based Smoothers for Spatial Filtering of Gridded Geophysical Data

I. Grooms

Corresponding Author

I. Grooms

Department of Applied Mathematics, University of Colorado, Boulder, CO, USA

Correspondence to:

I. Grooms,

[email protected]

Search for more papers by this author
N. Loose

N. Loose

Department of Applied Mathematics, University of Colorado, Boulder, CO, USA

Search for more papers by this author
R. Abernathey

R. Abernathey

Department of Earth and Environmental Sciences, Lamont Doherty Earth Observatory of Columbia University, Palisades, NY, USA

Search for more papers by this author
J. M. Steinberg

J. M. Steinberg

Department of Physical Oceanography, Woods Hole Oceanographic Institution, Woods Hole, MA, USA

Search for more papers by this author
S. D. Bachman

S. D. Bachman

Climate and Global Dynamics Division, National Center for Atmospheric Research, Boulder, CO, USA

Search for more papers by this author
G. Marques

G. Marques

Climate and Global Dynamics Division, National Center for Atmospheric Research, Boulder, CO, USA

Search for more papers by this author
A. P. Guillaumin

A. P. Guillaumin

Center for Atmosphere Ocean Science, Courant Institute of Mathematical Sciences, New York University, New York, NY, USA

Search for more papers by this author
E. Yankovsky

E. Yankovsky

Center for Atmosphere Ocean Science, Courant Institute of Mathematical Sciences, New York University, New York, NY, USA

Search for more papers by this author
First published: 29 August 2021
Citations: 18


We describe a new way to apply a spatial filter to gridded data from models or observations, focusing on low-pass 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 diffusion-based smoother's properties are illustrated with examples from ocean model data and ocean observational products. An open-source Python package implementing this algorithm, called gcm-filters, is currently under development.

Key Points

  • A new way to apply a spatial low-pass 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 remote-sensing 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.

Spatial filtering, long a staple of large eddy simulation (LES; Sagaut, 2006), has recently begun to replace time averages and zonal averages in a priori studies of subgrid-scale parameterization for ocean models. A canonical model for spatial filtering is given by kernel convolution
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0002 is the convolution kernel, urn:x-wiley:19422466:media:jame21433:jame21433-math-0003 is a dummy integration variable, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0004 denotes the set of all real vectors of dimension urn:x-wiley:19422466:media:jame21433:jame21433-math-0005. Berloff (2018), Bolton and Zanna (2019), Ryzhov et al. (2019), and Haigh et al. (2020) all used convolution filters to study subgrid-scale parameterization in the context of quasigeostrophic dynamics in a rectangular Cartesian domain. Lu et al. (2016), Aluie et al. (2018), Khani et al. (2019), Stanley, Bachman, et al. (2020), and Guillaumin and Zanna (2021) used approximate spatial convolutions on the sphere to filter ocean general circulation model output, and Aluie (2019) showed how to correctly define convolution on the sphere in such a way that the filter commutes with spatial derivatives. A “top hat” or “boxcar” kernel (i.e., an indicator function over a circle or a square, respectively) is used in all these studies, except for Bolton and Zanna (2019), Stanley, Bachman, et al. (2020), and Guillaumin and Zanna (2021) who used Gaussian kernels. Spatial convolution is not the only way to define or implement spatial filters. For example, Nadiga (2008) and Grooms et al. (2013) used an elliptic inversion to define spatial filters for quasigeostrophic model output, and Grooms and Kleiber (2019) used Fourier-based filtering methods for primitive equation model output, all in rectangular Cartesian domains. Fourier methods with windowing can be used for filtering over local patches (e.g., Arbic et al., 2013), though this can lead to artifacts, as shown by Aluie et al. (2018).

We make a semantic distinction between spatial filtering and coarse-graining. In our use of the terms, coarse-graining 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 coarse-graining was used in the context of ocean model subgrid-scale parameterization. The term “averaging” is sometimes used instead of filtering. They are essentially synonymous when the filter kernel urn:x-wiley:19422466:media:jame21433:jame21433-math-0006 is non-negative, but a filter whose kernel has negative values cannot be described as an average, so we opt to use the more general term. A low-pass filter can be described as a smoother, which is the focus here, but the methods described here can be straightforwardly adapted to band-pass or high-pass 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 diffusion-based 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 well-developed 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 finite-difference weather models by removing energy near the grid-scale 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 convolution-based filtering for large-eddy 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.

Germano (1986) introduced an implicit differential filter of the form
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0008 is the filtered field, urn:x-wiley:19422466:media:jame21433:jame21433-math-0009 is the filter length scale, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0010 is the Laplacian. It is “implicit” because applying the filter to data involves solving a system of equations; the convolution filters of Shapiro (1970) and Sagaut and Grohens (1999) are called “explicit” in contrast. Germano's implicit filter appears in the Leray-urn:x-wiley:19422466:media:jame21433:jame21433-math-0011 and Lagrangian-averaged Navier-Stokes-urn:x-wiley:19422466:media:jame21433:jame21433-math-0012 models (Chen et al., 1998). Implicit differential filters were used by Nadiga (2008) and Grooms et al. (2013) in the context of subgrid-scale parameterization in quasigeostrophic ocean models, and a similar fractional elliptic equation underlies the approach to spatial filtering of scattered data recently developed by Robinson and Grooms (2020). Raymond (1988) and Raymond and Garder (1991) developed implicit filters for meteorological applications using higher-order differential operators. Guedot et al. (2015) developed higher-order implicit differential filters on unstructured meshes for engineering applications. Note that the term “high order” here refers to the differential operator, though it has been used elsewhere with different meanings (Sagaut & Grohens, 1999; Sadek & Aluie, 2018).

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 well-known convolution theorem (e.g., Hunter & Nachtergaele, 2001, Theorem 11.35) states that the Fourier transform of urn:x-wiley:19422466:media:jame21433:jame21433-math-0013 is proportional to urn:x-wiley:19422466:media:jame21433:jame21433-math-0014, where urn:x-wiley:19422466:media:jame21433:jame21433-math-0015 denotes the Fourier transform and the proportionality constant depends on the dimension urn:x-wiley:19422466:media:jame21433:jame21433-math-0016 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0017 to be a sum of many Fourier modes, each of which has a distinct spatial scale. The Fourier transform of the kernel, urn:x-wiley:19422466:media:jame21433:jame21433-math-0018, then describes how each Fourier mode is modified by the spatial filtering operation. Filter kernels are usually symmetric about the origin, which makes urn:x-wiley:19422466:media:jame21433:jame21433-math-0019 real-valued, so that spatial filtering only changes the amplitude of the Fourier modes and not their phase. If urn:x-wiley:19422466:media:jame21433:jame21433-math-0020 for a particular Fourier mode then the corresponding length scale is left unchanged in urn:x-wiley:19422466:media:jame21433:jame21433-math-0021, whereas if urn:x-wiley:19422466:media:jame21433:jame21433-math-0022 for a particular Fourier mode then the corresponding length scale is removed from urn:x-wiley:19422466:media:jame21433:jame21433-math-0023. By modifying the amplitudes of the Fourier modes, spatial filtering controls the scale content of urn:x-wiley:19422466:media:jame21433:jame21433-math-0024.

One of the simplest kernels is the so-called boxcar function, defined in one spatial dimension as
Convolution against this kernel represents averaging all the points in the neighborhood with the same weight, and the parameter urn:x-wiley:19422466:media:jame21433:jame21433-math-0026 defines the size of the neighborhood. (In higher dimensions the boxcar filter is nonzero over a square region, while a “top-hat” filter is nonzero over a circular or spherical region.) The Fourier transform of the boxcar filter of width urn:x-wiley:19422466:media:jame21433:jame21433-math-0027 is
where sincurn:x-wiley:19422466:media:jame21433:jame21433-math-0029 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0030 is the wavenumber. This function decays only as urn:x-wiley:19422466:media:jame21433:jame21433-math-0031 at large urn:x-wiley:19422466:media:jame21433:jame21433-math-0032, so it does not correspond to a sharp separation between length scales. Conversely, a “spectral truncation” filter has a kernel whose Fourier transform is a boxcar, and the kernel itself is a sinc function. The boxcar and spectral truncation filters illustrate the concept that a short-range kernel does not separate scales well, and a filter that makes a sharp separation between scales requires a very long-range kernel. Figure 1 shows the boxcar and sinc convolution kernels, to illustrate that the more scale-selective sinc kernel has a much longer range. In practice, there is a tradeoff between choosing a kernel that makes as clean a scale separation as possible and choosing a kernel whose range is short enough to apply efficiently, analogous to the uncertainty principle in quantum physics.
Details are in the caption following the image

The boxcar function of width 1 and sincurn:x-wiley:19422466:media:jame21433:jame21433-math-0033.

It is usually desirable for the filter to preserve the integral, and to commute with derivatives, that is,
Any convolution filter commutes with derivatives, and preservation of the integral is easily ensured by the condition
In the presence of boundaries the convolution 1 no longer works, since urn:x-wiley:19422466:media:jame21433:jame21433-math-0037 is not defined on urn:x-wiley:19422466:media:jame21433:jame21433-math-0038. One option, used by Aluie et al. (2018), is to simply extend urn:x-wiley:19422466:media:jame21433:jame21433-math-0039 outside the domain boundaries. For velocity, the values on land can be set to zero, though for tracers it is less clear how to set values on land. The more common option is to vary the kernel near the boundaries so that the filter formula changes to
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0041 is the spatial domain and urn:x-wiley:19422466:media:jame21433:jame21433-math-0042 is a dummy integration variable. Unlike the convolution filter (1) the kernel urn:x-wiley:19422466:media:jame21433:jame21433-math-0043 is now a function of two arguments, to emphasize that the shape of the kernel can change over the spatial domain. This kind of spatial filter (8) no longer commutes with spatial derivatives, though it still preserves the integral as long as the kernel is appropriately normalized.

The background intuition for kernel-based spatial filters in this subsection is developed entirely for functions on Euclidean spaces. The definition of convolution-based spatial filters is considerably more complicated on a sphere; see Aluie (2019) for details.

2.3 Diffusion-Based Smoothers

2.3.1 Discrete Integral and Laplacian

To generalize the foregoing ideas to more complicated domains and grid geometries we begin with a transition to the discrete representation. The field to be filtered is no longer a continuous function, but a vector urn:x-wiley:19422466:media:jame21433:jame21433-math-0044; for example, if we wish to filter temperature on a grid of urn:x-wiley:19422466:media:jame21433:jame21433-math-0045 points, then we think of the values of temperature on the grid as a vector in urn:x-wiley:19422466:media:jame21433:jame21433-math-0046. To lay a foundation for the analysis we need two ingredients; the first is a discrete integral
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0048 denotes the spatial domain and urn:x-wiley:19422466:media:jame21433:jame21433-math-0049 are positive weights. Cartesian geometry is assumed for ease of presentation, but the discrete integral could easily approximate an integral over the sphere or some other smooth manifold without changing the analysis. For a typical finite-volume model the weight urn:x-wiley:19422466:media:jame21433:jame21433-math-0050 will simply be the area (or volume, if the integral is over three spatial dimensions) of the urn:x-wiley:19422466:media:jame21433:jame21433-math-0051 grid cell. If the weights urn:x-wiley:19422466:media:jame21433:jame21433-math-0052 are all positive then we can define a discrete inner product

The area integral can be expressed in terms of the inner product as urn:x-wiley:19422466:media:jame21433:jame21433-math-0054, where urn:x-wiley:19422466:media:jame21433:jame21433-math-0055 is a vector whose entries are all 1.

The second ingredient is a discrete Laplacian, that is, some operation on urn:x-wiley:19422466:media:jame21433:jame21433-math-0056 that produces an approximation of urn:x-wiley:19422466:media:jame21433:jame21433-math-0057 on the grid. The development in this section does not explicitly require Cartesian or spherical geometry; it only requires a discretization of a Laplacian operator that is appropriate to the geometry of the data. We write this operation in matrix form as urn:x-wiley:19422466:media:jame21433:jame21433-math-0058, though it is certainly not necessary to actually construct the matrix urn:x-wiley:19422466:media:jame21433:jame21433-math-0059. We assume that the discrete Laplacian is negative semi-definite, and self-adjoint with respect to the discrete inner product, that is, for any urn:x-wiley:19422466:media:jame21433:jame21433-math-0060 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0061

This is automatically guaranteed for finite-volume discretizations of the Laplacian with no-flux boundary conditions.

2.3.2 Connecting the Discrete Laplacian to Spatial Scales

Since the discrete Laplacian is self-adjoint and negative semi-definite, the eigenvalues of urn:x-wiley:19422466:media:jame21433:jame21433-math-0063 are all real and non-positive, and there is an eigenvector basis urn:x-wiley:19422466:media:jame21433:jame21433-math-0064 of urn:x-wiley:19422466:media:jame21433:jame21433-math-0065 that is orthonormal with respect to the discrete inner product. This is directly analogous to the Fourier analysis of the foregoing section: Fourier modes on urn:x-wiley:19422466:media:jame21433:jame21433-math-0066 are eigenfunctions of the Laplacian on urn:x-wiley:19422466:media:jame21433:jame21433-math-0067. In fact, with an equispaced grid and periodic boundaries the eigenvectors urn:x-wiley:19422466:media:jame21433:jame21433-math-0068 are exactly the discrete Fourier modes. In both the Fourier version and the discrete version the eigenvalues can be interpreted as describing the spatial scale of the corresponding eigenfunction:

On the left in the above expression urn:x-wiley:19422466:media:jame21433:jame21433-math-0070 represents the familiar Fourier wavenumber corresponding to a wavelength of urn:x-wiley:19422466:media:jame21433:jame21433-math-0071, while on the right the eigenvalue urn:x-wiley:19422466:media:jame21433:jame21433-math-0072 has been written with similar notation to emphasize the similarity. Precisely because urn:x-wiley:19422466:media:jame21433:jame21433-math-0073 is a discretization of the Laplacian, the length urn:x-wiley:19422466:media:jame21433:jame21433-math-0074 should roughly correspond to the length scale of the eigenvector urn:x-wiley:19422466:media:jame21433:jame21433-math-0075. We assume that the eigenvalues are ordered such that urn:x-wiley:19422466:media:jame21433:jame21433-math-0076.

Continuing the analogy with the previous section, it is possible to write the vector to be filtered as a sum over eigenfunctions of the discrete Laplacian:
We next show that we can filter urn:x-wiley:19422466:media:jame21433:jame21433-math-0078 by applying a function urn:x-wiley:19422466:media:jame21433:jame21433-math-0079 to it. From Equation 13, we see that this results in
where the notation urn:x-wiley:19422466:media:jame21433:jame21433-math-0081 has been deliberately used to emphasize the connection to the Fourier convolution theorem recalled in the previous section: if the expansion coefficients of urn:x-wiley:19422466:media:jame21433:jame21433-math-0082 are urn:x-wiley:19422466:media:jame21433:jame21433-math-0083, then the expansion coefficients of urn:x-wiley:19422466:media:jame21433:jame21433-math-0084 are urn:x-wiley:19422466:media:jame21433:jame21433-math-0085. (The notation urn:x-wiley:19422466:media:jame21433:jame21433-math-0086 is used for both the matrix and scalar versions of the function; a familiar example might be urn:x-wiley:19422466:media:jame21433:jame21433-math-0087 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0088.) If one defined the function urn:x-wiley:19422466:media:jame21433:jame21433-math-0089 in such a way that
then multiplying urn:x-wiley:19422466:media:jame21433:jame21433-math-0091 by urn:x-wiley:19422466:media:jame21433:jame21433-math-0092 would correspond to projecting urn:x-wiley:19422466:media:jame21433:jame21433-math-0093 onto large-scale modes defined by urn:x-wiley:19422466:media:jame21433:jame21433-math-0094. This would be analogous to a spectral truncation filter. Since the discrete filter is a function of a discrete Laplacian, it is natural to suspect that the filter should commute with derivatives; this question is addressed in Appendix B.

The assumption that the eigenvalue urn:x-wiley:19422466:media:jame21433:jame21433-math-0095 corresponds to a physical length scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0096 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 non-smooth 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0097 is prohibitively expensive, and even solving linear systems involving urn:x-wiley:19422466:media:jame21433:jame21433-math-0098 can be expensive. By contrast, simply applying urn:x-wiley:19422466:media:jame21433:jame21433-math-0099 is usually inexpensive. In practice this means that it is inexpensive to compute urn:x-wiley:19422466:media:jame21433:jame21433-math-0100 when urn:x-wiley:19422466:media:jame21433:jame21433-math-0101 is a polynomial. (The implicit differential filters of Germano (1986) and Guedot et al. (2015) correspond to letting urn:x-wiley:19422466:media:jame21433:jame21433-math-0102 be a polynomial.)

We propose to define our new filters as urn:x-wiley:19422466:media:jame21433:jame21433-math-0103, where urn:x-wiley:19422466:media:jame21433:jame21433-math-0104 is a polynomial
The polynomial coefficients urn:x-wiley:19422466:media:jame21433:jame21433-math-0106 will be chosen as described below to obtain the desired filter shape, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0107 is the identity matrix. To show that such a filter preserves the integral, note that urn:x-wiley:19422466:media:jame21433:jame21433-math-0108 is self-adjoint with respect to the discrete inner product, and
where we have used the fact that urn:x-wiley:19422466:media:jame21433:jame21433-math-0110 for any consistent discretization of the Laplacian with no-flux boundary conditions. The condition urn:x-wiley:19422466:media:jame21433:jame21433-math-0111 thus guarantees that the spatial filter will preserve the integral. It also ensures that the filter will leave large scales approximately unchanged; in order to remove small scales urn:x-wiley:19422466:media:jame21433:jame21433-math-0112 should decay toward zero as urn:x-wiley:19422466:media:jame21433:jame21433-math-0113 increases.
We can choose a specific shape for urn:x-wiley:19422466:media:jame21433:jame21433-math-0114 by means of standard polynomial approximation of a “target” filter urn:x-wiley:19422466:media:jame21433:jame21433-math-0115. For example, note that the Fourier transform of a Gaussian convolution kernel with standard deviation urn:x-wiley:19422466:media:jame21433:jame21433-math-0116 is

To construct a filter that acts like a convolution-based spatial filter with a Gaussian kernel of standard deviation urn:x-wiley:19422466:media:jame21433:jame21433-math-0118, one might choose a target filter of the form urn:x-wiley:19422466:media:jame21433:jame21433-math-0119. It is worth emphasizing that the connection to convolution is only heuristic; near boundaries or in non-Euclidean geometry the target filter is not exactly the same as a convolution-based 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0120 is based on Equation 14: the expansion coefficient urn:x-wiley:19422466:media:jame21433:jame21433-math-0121 is multiplied by urn:x-wiley:19422466:media:jame21433:jame21433-math-0122.

The goal would then be to find a polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0123 such that urn:x-wiley:19422466:media:jame21433:jame21433-math-0124. In general this is not possible with an explicit filter because polynomials grow without bound as urn:x-wiley:19422466:media:jame21433:jame21433-math-0125; thankfully it is only necessary for the approximation to hold over the range of scales represented on the grid, specifically for urn:x-wiley:19422466:media:jame21433:jame21433-math-0126 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0127 is the most-negative eigenvalue of urn:x-wiley:19422466:media:jame21433:jame21433-math-0128. If urn:x-wiley:19422466:media:jame21433:jame21433-math-0129 is not known, some reasonable proxy can be used to define the range of scales over which urn:x-wiley:19422466:media:jame21433:jame21433-math-0130 should act like a spatial filter. For example, on a quadrilateral grid one might use urn:x-wiley:19422466:media:jame21433:jame21433-math-0131durn:x-wiley:19422466:media:jame21433:jame21433-math-0132 where durn:x-wiley:19422466:media:jame21433:jame21433-math-0133 is the length of the smallest grid cell edge and urn:x-wiley:19422466:media:jame21433:jame21433-math-0134 is the spatial dimension of the grid.

In Appendix A, we present a least-squares approach for finding a polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0135 such that urn:x-wiley:19422466:media:jame21433:jame21433-math-0136 approximates urn:x-wiley:19422466:media:jame21433:jame21433-math-0137. The left column of Figure 2 shows three examples of target filters, along with their approximations urn:x-wiley:19422466:media:jame21433:jame21433-math-0138 using polynomials of degree urn:x-wiley:19422466:media:jame21433:jame21433-math-0139 and 21. The top row shows the boxcar target shown in Equation 4 with length scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0140 (nondimensional), and the middle row shows the Gaussian target that corresponds to a Gaussian kernel with standard deviation urn:x-wiley:19422466:media:jame21433:jame21433-math-0141(nondimensional). The bottom row shows a target that we here label “taper.”

Details are in the caption following the image

Left: Target filters urn:x-wiley:19422466:media:jame21433:jame21433-math-0142 and their approximations urn:x-wiley:19422466:media:jame21433:jame21433-math-0143. Right: The equivalent kernel weights in one dimension on an equispaced grid of size 1. Top Row: A boxcar filter of width 8; Middle Row: A Gaussian filter with standard deviation urn:x-wiley:19422466:media:jame21433:jame21433-math-0144; Bottom Row: The taper filter. All length scales in this figure are nondimensional. There is no blue line in the lower right panel because the taper filter is defined directly in terms of its target urn:x-wiley:19422466:media:jame21433:jame21433-math-0145, rather than via its convolution kernel, as for the boxcar and Gaussian filters.

The taper target is developed as an example of a filter that is more scale-selective 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0146 for urn:x-wiley:19422466:media:jame21433:jame21433-math-0147 above some cutoff urn:x-wiley:19422466:media:jame21433:jame21433-math-0148, with urn:x-wiley:19422466:media:jame21433:jame21433-math-0149 (nondimensional) in Figure 2. For urn:x-wiley:19422466:media:jame21433:jame21433-math-0150 it takes the value urn:x-wiley:19422466:media:jame21433:jame21433-math-0151 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0152 controls the width of the transition region; urn:x-wiley:19422466:media:jame21433:jame21433-math-0153 in Figure 2. For wavenumbers in the transition region urn:x-wiley:19422466:media:jame21433:jame21433-math-0154 the taper target is a cubic polynomial. As the width of the transition region goes to zero (urn:x-wiley:19422466:media:jame21433:jame21433-math-0155) the taper target approaches the spectral truncation filter, which is a step function at wavenumber urn:x-wiley:19422466:media:jame21433:jame21433-math-0156. The left column of Figure 2 shows that the number of steps urn:x-wiley:19422466:media:jame21433:jame21433-math-0157 required to achieve an accurate approximation of the target filter depends on the shape of the target filter, with more scale-selective targets like the taper requiring more steps urn:x-wiley:19422466:media:jame21433:jame21433-math-0158.

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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0159 (not the half-width). Per Equation 4, the boxcar filter exactly zeros out the wavenumber urn:x-wiley:19422466:media:jame21433:jame21433-math-0160. Since the taper filter also zeros out wavenumber urn:x-wiley:19422466:media:jame21433:jame21433-math-0161, it is natural to let urn:x-wiley:19422466:media:jame21433:jame21433-math-0162 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” urn:x-wiley:19422466:media:jame21433:jame21433-math-0163 for a Gaussian to be urn:x-wiley:19422466:media:jame21433:jame21433-math-0164 times the standard deviation of the Gaussian kernel, that is, to extract the standard deviation urn:x-wiley:19422466:media:jame21433:jame21433-math-0165 from the filter scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0166 use urn:x-wiley:19422466:media:jame21433:jame21433-math-0167. 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0168 across target filters, which can be used in non-Euclidean geometry, for example, on the sphere.

2.3.5 Filter Algorithm

Once the approximating polynomial has been found, the filtered field urn:x-wiley:19422466:media:jame21433:jame21433-math-0169 can be efficiently computed using an iterative algorithm based on the polynomial roots. In general, any polynomial with real coefficients has roots that are either real, or come in complex-conjugate pairs. We can thus write
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0171 is the number of real roots, the roots are urn:x-wiley:19422466:media:jame21433:jame21433-math-0172, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0173 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0174 denote the real and imaginary parts of a complex number, respectively. The quadratic terms can also be written urn:x-wiley:19422466:media:jame21433:jame21433-math-0175. The condition urn:x-wiley:19422466:media:jame21433:jame21433-math-0176 implies
Based on this representation, the filtered field urn:x-wiley:19422466:media:jame21433:jame21433-math-0178 can be computed in urn:x-wiley:19422466:media:jame21433:jame21433-math-0179 stages as follows. First the real roots are dealt with via
These stages are called Laplacian stages. Next the complex roots are dealt with via

These stages are called biharmonic stages because of the need to apply the discrete biharmonic operator urn:x-wiley:19422466:media:jame21433:jame21433-math-0184.

In the absence of roundoff errors the Laplacian and biharmonic stages can be applied in any order, and once they are both complete urn:x-wiley:19422466:media:jame21433:jame21433-math-0185 contains the filtered field (though at any point in the middle of the iterations urn:x-wiley:19422466:media:jame21433:jame21433-math-0186 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 Laplace-Beltrami 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0187 to be a discretization of the appropriate continuous operator, for example, the vector or tensor Laplacian on a sphere. In this case urn:x-wiley:19422466:media:jame21433:jame21433-math-0188 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0189 while the grid values of meridional velocity could be arranged as the second half of urn:x-wiley:19422466:media:jame21433:jame21433-math-0190.

2.3.7 Computational Cost

Typically the computational cost (in terms of floating point operations) of applying the discrete Laplacian urn:x-wiley:19422466:media:jame21433:jame21433-math-0191 is urn:x-wiley:19422466:media:jame21433:jame21433-math-0192 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0193 is the number of grid points. The total number of discrete applications of the Laplacian is urn:x-wiley:19422466:media:jame21433:jame21433-math-0194, so the cost to apply the filter is urn:x-wiley:19422466:media:jame21433:jame21433-math-0195. The number of stages urn:x-wiley:19422466:media:jame21433:jame21433-math-0196 depends on the shape of the target filter and the ratio of the filter scale to the grid scale, called the filter factor urn:x-wiley:19422466:media:jame21433:jame21433-math-0197. For both the Gaussian and taper filters the number of stages needed to achieve a fixed accuracy scales (empirically) linearly with urn:x-wiley:19422466:media:jame21433:jame21433-math-0198, so the overall cost of applying the filter is urn:x-wiley:19422466:media:jame21433:jame21433-math-0199.

This is directly comparable to a convolution-type filter implemented using quadrature. In a convolution-type filter, one is required to compute a quadrature at each of the urn:x-wiley:19422466:media:jame21433:jame21433-math-0200 grid points. The number of nonzero elements in the kernel, and thus the number of floating-point operations required to compute the quadrature, is linearly related to the ratio of the grid-scale to the width of the kernel, that is, the filter factor. The cost of applying a convolution-type filter is thus also urn:x-wiley:19422466:media:jame21433:jame21433-math-0201: at each of urn:x-wiley:19422466:media:jame21433:jame21433-math-0202 grid points one must compute a quadrature that costs urn:x-wiley:19422466:media:jame21433:jame21433-math-0203 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

Recall that per Equation 13, we can formally expand the field to be filtered as a sum of eigenvectors of the discrete Laplacian, and that per Equation 14, the effect of the filter is simply to modify the coefficients in this expansion. The same idea applies to a single stage in the iterative application of the filter. A single Laplacian stage multiplies the expansion coefficients by

Any modes urn:x-wiley:19422466:media:jame21433:jame21433-math-0205 such that urn:x-wiley:19422466:media:jame21433:jame21433-math-0206 will have their coefficients urn:x-wiley:19422466:media:jame21433:jame21433-math-0207 amplified at this stage, and smaller scales will experience greater amplification. (The sign of the coefficients will also be changed; the real roots urn:x-wiley:19422466:media:jame21433:jame21433-math-0208 are generally positive.) In contrast, when urn:x-wiley:19422466:media:jame21433:jame21433-math-0209 none of the modes will experience amplification and the smallest scales will be damped.

A single biharmonic stage multiplies the expansion coefficients by

As a function of urn:x-wiley:19422466:media:jame21433:jame21433-math-0211 this is a positive parabola that equals 1 at urn:x-wiley:19422466:media:jame21433:jame21433-math-0212. When the real part of urn:x-wiley:19422466:media:jame21433:jame21433-math-0213 is negative all modes are amplified with increasing amplification at small scales. When the real part of urn:x-wiley:19422466:media:jame21433:jame21433-math-0214 is positive, modes with urn:x-wiley:19422466:media:jame21433:jame21433-math-0215 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 grid-scale. To achieve this, the polynomial approximation algorithm from Appendix A selects a range of roots urn:x-wiley:19422466:media:jame21433:jame21433-math-0216, with some of the roots corresponding to scales much larger than the grid scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0217. The stages with urn:x-wiley:19422466:media:jame21433:jame21433-math-0218 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 grid-scale), 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0219, 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 one-dimensional, periodic, equispaced grid of 256 points in a nondimensional domain of size urn:x-wiley:19422466:media:jame21433:jame21433-math-0220, and a spectral discrete Laplacian. The eigenvectors of the discrete Laplacian are the discrete Fourier modes with wavenumbers urn:x-wiley:19422466:media:jame21433:jame21433-math-0221, and the eigenvalues are exactly urn:x-wiley:19422466:media:jame21433:jame21433-math-0222. The filter polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0223 is constructed by directly specifying the roots urn:x-wiley:19422466:media:jame21433:jame21433-math-0224, rather than by approximating some target filter urn:x-wiley:19422466:media:jame21433:jame21433-math-0225. The roots urn:x-wiley:19422466:media:jame21433:jame21433-math-0226 are the integers from 43 to 170, squared, that is, there are urn:x-wiley:19422466:media:jame21433:jame21433-math-0227 stages with roots on both sides of the cutoff scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0228. This filter should thus exactly zero out all discrete wavenumbers with urn:x-wiley:19422466:media:jame21433:jame21433-math-0229, while smoothly damping wavenumbers with urn:x-wiley:19422466:media:jame21433:jame21433-math-0230. The field to be filtered is constructed to have discrete Fourier transform urn:x-wiley:19422466:media:jame21433:jame21433-math-0231 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0232 are independent and uniformly distributed on urn:x-wiley:19422466:media:jame21433:jame21433-math-0233. 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0234.

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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0235 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0236 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0237.

Details are in the caption following the image

Amplitude of the Fourier coefficients of urn:x-wiley:19422466:media:jame21433:jame21433-math-0238 as it proceeds through the filter stages. In each panel, the abscissa is filter stage while the ordinate is the wavenumber. In the left panel, urn:x-wiley:19422466:media:jame21433:jame21433-math-0239 are arranged in increasing order. In the center panel, the urn:x-wiley:19422466:media:jame21433:jame21433-math-0240 are decreasing. In the right panel, the damping and amplifying stages alternate.

The center panel of Figure 3 shows the effect of arranging urn:x-wiley:19422466:media:jame21433:jame21433-math-0241 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0242. 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0243 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 well-behaved 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0244 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 next-smallest 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0245 then the time step sizes are durn:x-wiley:19422466:media:jame21433:jame21433-math-0246. (The urn:x-wiley:19422466:media:jame21433:jame21433-math-0247 serves to distinguish this urn:x-wiley:19422466:media:jame21433:jame21433-math-0248, which is dimensional, from the urn:x-wiley:19422466:media:jame21433:jame21433-math-0249 introduced in Section 15, which is nondimensional). There is no analogy for the biharmonic stages, or for negative urn:x-wiley:19422466:media:jame21433:jame21433-math-0250, so the analogy only holds when all the urn:x-wiley:19422466:media:jame21433:jame21433-math-0251 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0252 must be real, positive, and equal. In this case the Courant-Friedrichs-Lewy (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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0253. Written in terms of the time step this CFL condition takes the form durn:x-wiley:19422466:media:jame21433:jame21433-math-0254. Inserting the approximation urn:x-wiley:19422466:media:jame21433:jame21433-math-0255durn:x-wiley:19422466:media:jame21433:jame21433-math-0256 yields a more familiar form for the CFL condition for diffusion: urn:x-wiley:19422466:media:jame21433:jame21433-math-0257durn:x-wiley:19422466:media:jame21433:jame21433-math-0258 (recall that urn:x-wiley:19422466:media:jame21433:jame21433-math-0259 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0260 is finite.

2.5 Impact of the Order of Accuracy of the Discrete Laplacian

This section gives a simple example to show that higher-order discretizations of the Laplacian should be better able to sharply distinguish between scales near the grid-scale. Throughout this section, “small” length scales refer to scales near the grid-scale. 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0261 is an eigenvalue of the discrete Laplacian then the length scale of the corresponding eigenvector urn:x-wiley:19422466:media:jame21433:jame21433-math-0262 is assumed to be urn:x-wiley:19422466:media:jame21433:jame21433-math-0263. This connection between eigenvalues and length scales can be inaccurate at small length scales.

For example, consider the following two discrete Laplacians on an infinite or periodic one-dimensional equispaced grid with grid spacing 1 (nondimensional)
For both of these Laplacians the discrete Fourier modes
are eigenvectors, where urn:x-wiley:19422466:media:jame21433:jame21433-math-0267 is the discrete wavenumber, urn:x-wiley:19422466:media:jame21433:jame21433-math-0268 is the second order, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0269 is the fourth order. (Note that notation has been changed from urn:x-wiley:19422466:media:jame21433:jame21433-math-0270 in Section 4 to urn:x-wiley:19422466:media:jame21433:jame21433-math-0271 here, so that urn:x-wiley:19422466:media:jame21433:jame21433-math-0272 is the discrete wavenumber rather than urn:x-wiley:19422466:media:jame21433:jame21433-math-0273.) For a spectral discretization the eigenvalues would be urn:x-wiley:19422466:media:jame21433:jame21433-math-0274, but the eigenvalues for the second and fourth order Laplacians are

The fact that these are not equal to urn:x-wiley:19422466:media:jame21433:jame21433-math-0277 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0278. In both cases, the wavenumber implied by the eigenvalue is smaller than the true wavenumber urn:x-wiley:19422466:media:jame21433:jame21433-math-0279, meaning that these Laplacians treat small scales as if they were larger-scale than they really are. Both Laplacians have accurate eigenvalues at large scales, but the fourth-order Laplacian's eigenvalues are more accurate at small scales. A filter that uses the fourth-order 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 grid-scale using the diffusion-based 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 high-order discretization of the Laplacian. On the other hand, if the filter is attempting to remove the entire range of small scales where the second-order Laplacian is inaccurate, then the second-order Laplacian will work as well as higher-order Laplacians.

Details are in the caption following the image

The ratio of the eigenvalues urn:x-wiley:19422466:media:jame21433:jame21433-math-0280 of the discrete Laplacians to the true value urn:x-wiley:19422466:media:jame21433:jame21433-math-0281. The second-order Laplacian is shown in blue and the fourth-order Laplacian is shown in green. urn:x-wiley:19422466:media:jame21433:jame21433-math-0282 corresponds to the Nyquist wavenumber, that is, the wavenumber associated with the grid-scale.

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 well-resolved in both data sets. If the filter scale is close to the grid-scale of one of the data sets and the discrete Laplacian uses a low-order 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0283 be a discretization of urn:x-wiley:19422466:media:jame21433:jame21433-math-0284 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0285 is a symmetric and positive definite tensor that varies in space (cf. Báez Vidal et al., 2016). (In this context urn:x-wiley:19422466:media:jame21433:jame21433-math-0286 is nondimensional, since the dimensions are carried by the polynomial roots urn:x-wiley:19422466:media:jame21433:jame21433-math-0287.)

Consider first the isotropic case urn:x-wiley:19422466:media:jame21433:jame21433-math-0288 with constant urn:x-wiley:19422466:media:jame21433:jame21433-math-0289, and assume that the filter polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0290 has been designed as described in Section 4 under the assumption urn:x-wiley:19422466:media:jame21433:jame21433-math-0291. If the filter polynomial is used with constant urn:x-wiley:19422466:media:jame21433:jame21433-math-0292 then the filter polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0293 is replaced by urn:x-wiley:19422466:media:jame21433:jame21433-math-0294. This is tantamount to rescaling the filter length scale by urn:x-wiley:19422466:media:jame21433:jame21433-math-0295. For example, if the original filter with urn:x-wiley:19422466:media:jame21433:jame21433-math-0296 had a characteristic length scale of urn:x-wiley:19422466:media:jame21433:jame21433-math-0297 then the filter using urn:x-wiley:19422466:media:jame21433:jame21433-math-0298 has a characteristic length scale of urn:x-wiley:19422466:media:jame21433:jame21433-math-0299.

Next consider the case of an isotropic Laplacian with spatially varying urn:x-wiley:19422466:media:jame21433:jame21433-math-0300, and assume that urn:x-wiley:19422466:media:jame21433:jame21433-math-0301 varies slowly over the domain. The filter polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0302 is designed to have length scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0303 if urn:x-wiley:19422466:media:jame21433:jame21433-math-0304. In regions where urn:x-wiley:19422466:media:jame21433:jame21433-math-0305 the filter will have a longer length scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0306, while in regions where urn:x-wiley:19422466:media:jame21433:jame21433-math-0307 the filter will have a smaller length scale. (If urn:x-wiley:19422466:media:jame21433:jame21433-math-0308 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0309 that varies over the domain. At each point in the domain urn:x-wiley:19422466:media:jame21433:jame21433-math-0310 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 grid-scale, which is especially relevant for Earth system models whose grid cell sizes vary in space. This can be achieved by aligning the eigenvectors of urn:x-wiley:19422466:media:jame21433:jame21433-math-0311 with the local orthogonal grid directions, and letting the respective eigenvalues determine the amount of filtering in each direction.

A major caveat to the above discussion is that values of urn:x-wiley:19422466:media:jame21433:jame21433-math-0312 can lead to unexpected behavior. Consider, for example, the filter polynomial
where the scales that can be represented on the grid are associated with wavenumbers urn:x-wiley:19422466:media:jame21433:jame21433-math-0314 and the standard case uses urn:x-wiley:19422466:media:jame21433:jame21433-math-0315. The blue line in Figure 5 shows that urn:x-wiley:19422466:media:jame21433:jame21433-math-0316 only acts as a smoother over the range of scales associated with urn:x-wiley:19422466:media:jame21433:jame21433-math-0317; at larger urn:x-wiley:19422466:media:jame21433:jame21433-math-0318 that are not represented on the grid the filter will significantly amplify these scales. Using urn:x-wiley:19422466:media:jame21433:jame21433-math-0319 has the effect of bringing this undesirable filter behavior into the range of scales represented on the grid, as can be seen in the green line corresponding to urn:x-wiley:19422466:media:jame21433:jame21433-math-0320 in Figure 5. In contrast, using urn:x-wiley:19422466:media:jame21433:jame21433-math-0321 has no such problems (blue and red in Figure 5). It is thus desirable to specify urn:x-wiley:19422466:media:jame21433:jame21433-math-0322 whenever possible.
Details are in the caption following the image

The effect of changing urn:x-wiley:19422466:media:jame21433:jame21433-math-0323 on the filter polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0324 for the polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0325 from Equation 30.

Consider, for example, a one-dimensional non-uniform grid with maximum grid spacing urn:x-wiley:19422466:media:jame21433:jame21433-math-0326, minimum grid spacing urn:x-wiley:19422466:media:jame21433:jame21433-math-0327, and local grid spacing urn:x-wiley:19422466:media:jame21433:jame21433-math-0328. To apply a filter that smooths locally to a scale urn:x-wiley:19422466:media:jame21433:jame21433-math-0329 times larger than the local grid, one could choose the filter scale to be urn:x-wiley:19422466:media:jame21433:jame21433-math-0330 and then set urn:x-wiley:19422466:media:jame21433:jame21433-math-0331. Locally the filter scale is rescaled to urn:x-wiley:19422466:media:jame21433:jame21433-math-0332 as desired, but at the same time urn:x-wiley:19422466:media:jame21433:jame21433-math-0333 which will lead to undesirable behavior at the small scales. Instead, one can achieve the same effect by setting the filter scale to urn:x-wiley:19422466:media:jame21433:jame21433-math-0334, and then setting urn:x-wiley:19422466:media:jame21433:jame21433-math-0335. The local filter scale is again urn:x-wiley:19422466:media:jame21433:jame21433-math-0336, but with urn:x-wiley:19422466:media:jame21433:jame21433-math-0337 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.

Let urn:x-wiley:19422466:media:jame21433:jame21433-math-0338 be the discretization of the Laplacian if all the cells had the same size. Since the cell sizes are assumed equal, the matrix urn:x-wiley:19422466:media:jame21433:jame21433-math-0339 should be symmetric. If we simply replaced urn:x-wiley:19422466:media:jame21433:jame21433-math-0340 by urn:x-wiley:19422466:media:jame21433:jame21433-math-0341 in the definition of the filter it would imply that we were filtering as if all the grid cells were the same size, which is equivalent to making the scale of the filter relative to the scale of the local grid. Unfortunately, this would no longer preserve the integral. To rectify this problem we propose a cell-size weighted filter, which amounts to the following recipe:
  1. Weight the input data by cell sizes

  2. Apply the filter assuming the cell sizes are equal

  3. Divide the result by the cell sizes

We next show that this filter preserves the integral at the discrete level. First note that weighting by the cell size is equivalent to multiplication by a diagonal matrix urn:x-wiley:19422466:media:jame21433:jame21433-math-0342 whose diagonal entries are the cell sizes, so the above filter corresponds to
The inner product (10) can be written in the form urn:x-wiley:19422466:media:jame21433:jame21433-math-0344, and recall that the discrete integral is urn:x-wiley:19422466:media:jame21433:jame21433-math-0345. To prove that the new filter conserves the integral we follow (17), and find that

The above sequence uses the facts that urn:x-wiley:19422466:media:jame21433:jame21433-math-0347 is symmetric, which implies urn:x-wiley:19422466:media:jame21433:jame21433-math-0348, that any consistent discretization of the Laplacian with no-flux boundary conditions will have urn:x-wiley:19422466:media:jame21433:jame21433-math-0349, and that urn:x-wiley:19422466:media:jame21433:jame21433-math-0350.

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 non-uniform.

2.7 Variance Reduction

In some situations, it is desirable to enforce that the filtered field has less total variance than the unfiltered field, that is, for functions
and for the discrete case
To translate this into a condition on the diffusion-based smoothers developed here, expand urn:x-wiley:19422466:media:jame21433:jame21433-math-0353 in the orthonormal basis of eigenvectors of urn:x-wiley:19422466:media:jame21433:jame21433-math-0354
The condition of variance reduction becomes

In order for this to be satisfied for any possible vector urn:x-wiley:19422466:media:jame21433:jame21433-math-0357 this requires urn:x-wiley:19422466:media:jame21433:jame21433-math-0358 for every urn:x-wiley:19422466:media:jame21433:jame21433-math-0359 up to the largest one represented on the model grid, that is, urn:x-wiley:19422466:media:jame21433:jame21433-math-0360. The eigenvalues urn:x-wiley:19422466:media:jame21433:jame21433-math-0361 of the discrete Laplacian are usually not known exactly, so a sufficient condition for variance reduction would be that urn:x-wiley:19422466:media:jame21433:jame21433-math-0362 for every urn:x-wiley:19422466:media:jame21433:jame21433-math-0363 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0364. It is worth noting that this condition applies to urn:x-wiley:19422466:media:jame21433:jame21433-math-0365 and not to the target filter. Even if the target filter satisfies this condition, the polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0366 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 Diffusion-Based Filter

If the spatial filter were defined by a discrete approximation of a kernel-based spatial filter (8) then the value of urn:x-wiley:19422466:media:jame21433:jame21433-math-0367 at the urn:x-wiley:19422466:media:jame21433:jame21433-math-0368 grid cell would be
where urn:x-wiley:19422466:media:jame21433:jame21433-math-0370 is the effective filter kernel corresponding to the urn:x-wiley:19422466:media:jame21433:jame21433-math-0371 cell. Note that urn:x-wiley:19422466:media:jame21433:jame21433-math-0372, where urn:x-wiley:19422466:media:jame21433:jame21433-math-0373 is a vector of zeros with 1 at the urn:x-wiley:19422466:media:jame21433:jame21433-math-0374 grid cell. Next note that

which implies that urn:x-wiley:19422466:media:jame21433:jame21433-math-0376. We can thus compute the effective filter kernel that corresponds to urn:x-wiley:19422466:media:jame21433:jame21433-math-0377 at the urn:x-wiley:19422466:media:jame21433:jame21433-math-0378 grid cell by applying the filter to urn:x-wiley:19422466:media:jame21433:jame21433-math-0379 and then dividing the result by urn:x-wiley:19422466:media:jame21433:jame21433-math-0380. The same arguments can be used to find the effective filter kernel associated with the spatially varying filters of Section 15.

Note that if the filter kernel is non-negative urn:x-wiley:19422466:media:jame21433:jame21433-math-0381, then applying the filter to a positive quantity will yield a positive result, since the sum in Equation 37 has both positive and zero terms, but no negative terms. In particular, if the weights are non-negative it will guarantee that the variance is also non-negative. To see this, note

which uses the fact that urn:x-wiley:19422466:media:jame21433:jame21433-math-0383 and the definition of urn:x-wiley:19422466:media:jame21433:jame21433-math-0384 (37), and assumes urn:x-wiley:19422466:media:jame21433:jame21433-math-0385. Equation 39 directly implies that urn:x-wiley:19422466:media:jame21433:jame21433-math-0386.

The proof above can be lifted to the continuous case as follows. Supposing that the convolution kernel urn:x-wiley:19422466:media:jame21433:jame21433-math-0387 in Equation 8, we may define

The result that urn:x-wiley:19422466:media:jame21433:jame21433-math-0389 follows by plugging in urn:x-wiley:19422466:media:jame21433:jame21433-math-0390.

Note that if the filter kernel ever takes a negative value, then it is no longer guaranteed to preserve positivity in the sense that urn:x-wiley:19422466:media:jame21433:jame21433-math-0391 may have negative values even when all the values in urn:x-wiley:19422466:media:jame21433:jame21433-math-0392 are positive. Similarly if the filter kernel ever takes a negative value then it could produce a negative local variance urn:x-wiley:19422466:media:jame21433:jame21433-math-0393. 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, second-order 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 one-to-one match to the discrete version. Another reason is that the effective kernel depends on the discretization of the Laplacian; a higher-order 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 open-source Python package implementing the diffusion-based filters described in Section 2, called gcm-filters, 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 two-dimensional data use a second-order discrete Laplacian (on a 5-point stencil) with no-flux 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 (urn:x-wiley:19422466:media:jame21433:jame21433-math-0394W, urn:x-wiley:19422466:media:jame21433:jame21433-math-0395S), 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 convolution-type filter.

Details are in the caption following the image

Effective filter kernels for Gaussian (top) and Taper (bottom) filters with various filter scales on the 2/3° MOM6 grid, centered at four points in the Antarctic Circumpolar Current. Top left: Filter scale is 100 km for the effective kernel centered at (urn:x-wiley:19422466:media:jame21433:jame21433-math-0396W, urn:x-wiley:19422466:media:jame21433:jame21433-math-0397S), and 1,000 km for the remaining three kernels. Bottom left: Same filter scales as top left, except that the large filter scale was reduced from 1,000  to 300 km. Right column: The anisotropic versions of the filters in the left column, but with a third of the length scale in the meridional direction. MOM6 land points are shaded in gray.

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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0398 as described in Section 15. We filter the vertical component of relative vorticity at the surface from the submesoscale-resolving MITgcm simulation of the Scotia Sea with a resolution of urn:x-wiley:19422466:media:jame21433:jame21433-math-0399 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0400 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0401 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).

Details are in the caption following the image

Surface relative vorticity from the MITgcm simulation in Bachman et al. (2017) demonstrating a spatially variable filter scale using a Gaussian target filter. The filter applied to the raw field (top panel) results in smoothing where the first baroclinic deformation radius is small compared to the scale of the motion (middle panel), which is reflected in the difference between the raw and filtered fields (bottom panel). Units are urn:x-wiley:19422466:media:jame21433:jame21433-math-0402.

3.3 Non-Commutation 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 large-scale 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0403, and second by computing the vertical vorticity directly from the velocity and then applying the filter to the result urn:x-wiley:19422466:media:jame21433:jame21433-math-0404. The filter is isotropic, and uses a Gaussian target with a length scale of 300 km. The data are from a state-of-the-art climate model, GFDL-CM2.6 (Delworth et al., 2012; Griffies et al., 2015), obtained through the Pangeo cloud data library (Abernathey et al., 2021). The ocean component of GFDL-CM2.6 utilizes the GFDL-MOM5 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.

Details are in the caption following the image

Surface relative vorticity fields taken from GFDL-CM2.6 data. The upper left panel shows the unfiltered vorticity, the upper right shows the filtered vorticity (using a scalar Laplacian), the bottom left panel shows the vorticity computed from filtered velocities (using a vector Laplacian), and the bottom right panel shows the difference between the latter two fields. The filter length scale is 300 km.

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 stress-free 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 stress-free 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 JRA55-forced 2/3° MOM6 simulation; the filter has a length scale of 500 km and a Gaussian target.

Details are in the caption following the image

The upper two panels show the surface velocity of a JRA55-forced 2/3° MOM6 simulation averaged over 1 month. The second row shows the velocities filtered with a Gaussian target and a filter scale of 500 km. The filter uses a vector Laplacian with a stress-free boundary condition. The third row shows filtered velocities as in the second row, but ignoring land boundaries with velocity values set to zero on land. The fourth row is the second row minus the third row. The left column shows zonal components of velocity while the right column shows meridional components.

3.4 Negative Weights and Eddy Kinetic Energy

The Gaussian filter's effective kernel has positive weights, while the more scale-selective taper filter's effective kernel typically has negative weights reminiscent of the sinc kernel that corresponds to the spectral truncation filter. These negative weights can produce negative values for non-negative quantities like eddy kinetic energy (EKE). We define EKE as

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 non-negative this definition of EKE will also be non-negative, 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 5-day 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0406. To compute mean surface kinetic energy we use the simple fixed factor Laplacian with a filter scale four times the local grid-scale, that is, a filter scale of 1°. The center panel in the upper row shows the mean kinetic energy defined as urn:x-wiley:19422466:media:jame21433:jame21433-math-0407 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.

Details are in the caption following the image

The left panel shows surface kinetic energy calculated from absolute geostrophic velocities estimated using AVISO measurements of sea surface height. Velocities are provided on a 1/urn:x-wiley:19422466:media:jame21433:jame21433-math-0408 degree grid and filtered using a Gaussian (middle column) and taper (right column) simple fixed filter with filter scale four times the local grid scale. Definitions of mean kinetic energy (MKE) and eddy kinetic energy (EKE) are provided in the text.

The alternative definition urn:x-wiley:19422466:media:jame21433:jame21433-math-0409 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0410 can also produce negative values of EKE when the filter has negative weights. As a simple example consider the case where urn:x-wiley:19422466:media:jame21433:jame21433-math-0411 is nonzero at only one grid point. Then urn:x-wiley:19422466:media:jame21433:jame21433-math-0412 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 One-Dimensional Observational Data

Our final example in Figure 11 illustrates the application of our filters to one-dimensional data, specifically along-track altimeter observations of absolute dynamic topography used to estimate cross-track geostrophic velocity. This example is included not only to highlight additional capabilities of this filtering framework, but also to encourage its use on in-situ velocity or tracer measurements to permit scale-aware observational-model comparisons. We apply three filters (boxcar, Gaussian, and taper) to cross-track geostrophic velocity estimates along a single track of the Jason-2 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 cross-track geostrophic velocity as a function of along-track distance moving north to south (gray lines show all cycles completed at 10-day intervals over a 2-year 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 large-scale 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.

Details are in the caption following the image

The upper panel shows cross-track geostrophic velocities along the Jason-2 altimeter track number 176 spanning a 2-year period (gray). A single cycle is selected (black) and filtered using the boxcar (blue), taper (red), and Gaussian (green) filters using a 100 km filter scale. The inset figure locates track 176 in the Western North Atlantic with along-track distance increasing north to south. The lower panel shows eddy kinetic energy defined using the cross-track geostrophic velocities above and filtered using boxcar, taper, and Gaussian filters. Shaded black regions identify locations of negative EKE associated with the taper filter.

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, direction-dependent, as well as spatially varying filter scales. It is our hope that the new method and forthcoming software package will enable an increase in scale-dependent analysis of Earth system data, particularly for the purposes of subgrid-scale parameterization, though by no means limited to such.


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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0501cm-filters 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

    We may find a polynomial that approximates the target filter by solving an optimization problem of the form
    where urn:x-wiley:19422466:media:jame21433:jame21433-math-0414 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0415 is a polynomial that must satisfy urn:x-wiley:19422466:media:jame21433:jame21433-math-0416. To enable rapid solution of this optimization problem it is convenient to use a weighted urn:x-wiley:19422466:media:jame21433:jame21433-math-0417 norm on urn:x-wiley:19422466:media:jame21433:jame21433-math-0418, where (as noted above) we may set urn:x-wiley:19422466:media:jame21433:jame21433-math-0419durn:x-wiley:19422466:media:jame21433:jame21433-math-0420 where urn:x-wiley:19422466:media:jame21433:jame21433-math-0421 is the dimension of the spatial domain. Using the Chebyshev norm is known to produce solutions that are close to the solution obtained from the max norm (Trefethen, 2019, theorem 16.1), so we adopt the Chebyshev norm
    The polynomial must satisfy urn:x-wiley:19422466:media:jame21433:jame21433-math-0423 in order to conserve the integral, and for convenience we also apply the condition urn:x-wiley:19422466:media:jame21433:jame21433-math-0424. This allows us to solve the optimization problem using the Galerkin basis described by Shen (1995). To be precise, we let
    where urn:x-wiley:19422466:media:jame21433:jame21433-math-0426 are the polynomial basis of Shen (1995), satisfying urn:x-wiley:19422466:media:jame21433:jame21433-math-0427, and urn:x-wiley:19422466:media:jame21433:jame21433-math-0428 is a polynomial of degree urn:x-wiley:19422466:media:jame21433:jame21433-math-0429. Collecting the Galerkin coefficients urn:x-wiley:19422466:media:jame21433:jame21433-math-0430 into a vector urn:x-wiley:19422466:media:jame21433:jame21433-math-0431, the loss function (A2) can be written
    and urn:x-wiley:19422466:media:jame21433:jame21433-math-0435 denotes the Chebyshev inner product. The entries of urn:x-wiley:19422466:media:jame21433:jame21433-math-0436 are known analytically (Shen, 1995), and the entries of urn:x-wiley:19422466:media:jame21433:jame21433-math-0437 are computed using Gauss-Chebyshev quadrature with urn:x-wiley:19422466:media:jame21433:jame21433-math-0438 points. Setting the gradient of this quadratic loss function to zero yields the following linear system for the optimal polynomial coefficients

    Once a target filter urn:x-wiley:19422466:media:jame21433:jame21433-math-0440 has been specified, one must also choose the degree urn:x-wiley:19422466:media:jame21433:jame21433-math-0441 of the polynomial urn:x-wiley:19422466:media:jame21433:jame21433-math-0442. As urn:x-wiley:19422466:media:jame21433:jame21433-math-0443 increases the filter approaches the target filter—the approximation converges provided that urn:x-wiley:19422466:media:jame21433:jame21433-math-0444 is absolutely continuous (Trefethen, 2013, Theorem 7.2). As urn:x-wiley:19422466:media:jame21433:jame21433-math-0445 increases the computational cost of the filter grows because applying the filter requires applying the discrete Laplacian urn:x-wiley:19422466:media:jame21433:jame21433-math-0446 times. It is therefore desirable to choose some tradeoff between cost and accuracy. The Python packageg gcm-filters (gcm-filters, 2021) has a default setting for urn:x-wiley:19422466:media:jame21433:jame21433-math-0447 that guarantees not more than 1% error in the difference between urn:x-wiley:19422466:media:jame21433:jame21433-math-0448 and urn:x-wiley:19422466:media:jame21433:jame21433-math-0449; the user can also override this choice with any desired value of urn:x-wiley:19422466:media:jame21433:jame21433-math-0450.

    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 convolution-based 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0451 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.

    Although our filters are defined entirely in discrete terms, it is natural to think in terms of the continuous limit, and this limit causes confusion. Consider for simplicity the case of the following filter for a scalar function urn:x-wiley:19422466:media:jame21433:jame21433-math-0452 on urn:x-wiley:19422466:media:jame21433:jame21433-math-0453:

    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 no-flux 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0455 satisfies no-flux (or periodic) boundary conditions. This is no limitation in the discrete case, since the no-flux Laplacian can be computed for any data. On the other hand, if one applies the discrete Laplacian with a no-flux assumption and then takes the limit of infinite resolution the result does not converge to urn:x-wiley:19422466:media:jame21433:jame21433-math-0456 unless urn:x-wiley:19422466:media:jame21433:jame21433-math-0457 actually satisfies no-flux boundary conditions. Instead, it converges to urn:x-wiley:19422466:media:jame21433:jame21433-math-0458 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0459 that satisfy urn:x-wiley:19422466:media:jame21433:jame21433-math-0460. 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 urn:x-wiley:19422466:media:jame21433:jame21433-math-0461 and then apply the filter to urn:x-wiley:19422466:media:jame21433:jame21433-math-0462, the result is not defined unless urn:x-wiley:19422466:media:jame21433:jame21433-math-0463 also satisfies no-flux conditions, that is, urn:x-wiley:19422466:media:jame21433:jame21433-math-0464. So in the continuous limit, the filter will not commute with differentiation for functions with urn:x-wiley:19422466:media:jame21433:jame21433-math-0465 on the boundaries. For higher-order 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 convolution-based 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).

    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 open-source Python package implementing this algorithm, called gcm-filters, is currently under development (see gcm-filters, 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.