title | tags | authors | affiliations | date | bibliography | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GCM-Filters: A Python Package for Diffusion-based Spatial Filtering of Gridded Data |
|
|
|
1 November 2021 |
paper.bib |
GCM-Filters
is a python package that allows scientists to perform spatial filtering analysis in an easy, flexible and efficient way. The package implements the filtering method based on the discrete Laplacian operator that was introduced by @grooms2021diffusion. The filtering algorithm is analogous to smoothing via diffusion; hence the name diffusion-based filters. GCM-Filters
can be used with either gridded observational data or gridded data that is produced by General Circulation Models (GCMs) of ocean, weather, and climate. Spatial filtering of observational or GCM data is a common analysis method in the Earth Sciences, for example to study oceanic and atmospheric motions at different spatial scales or to develop subgrid-scale parameterizations for ocean models.
GCM-Filters
provides filters that are highly configurable, with the goal to be useful for a wide range of scientific applications. The user has different options for selecting the filter scale and filter shape.
The filter scale can be defined in several ways: a fixed length scale (e.g., 100 km), a scale tied to a model grid scale (e.g., 1$^\circ$), or a scale tied to a varying dynamical scale (e.g., the Rossby radius of deformation). As an example, \autoref{fig1} shows unfiltered and filtered relative vorticity, where the filter scale is set to a model grid scale of 4$^\circ$. GCM-Filters
also allows for anisotropic, i.e., direction-dependent, filtering.
Finally, the filter shape -- currently: either Gaussian or Taper -- determines how sharply the filter separates scales above and below the target filter scale.
Spatial filtering is commonly used as a scientific tool for analyzing gridded data. An example of an existing spatial filtering tool in python is the ndimage.gaussian_filter
function in SciPy
[@2020SciPy-NMeth], implemented as a sequence of convolution filters. While being a valuable tool for image processing (or blurring), SciPy
's Gaussian filter is of limited use for GCM data; it assumes a regular and rectangular Cartesian grid, employs a simple boundary condition, and the definitions of filter scale and shape have little or no flexibility. The python package GCM-Filters
is specificially designed to filter GCM data, and seeks to solve a number of challenges for the user:
- GCM data comes on irregular curvilinear grids with spatially varying grid-cell geometry.
- Continental boundaries require careful and special treatment when filtering ocean GCM output.
- Earth Science applications benefit from configurable filters, where the definition of filter scale and shape is flexible.
- GCM output is often too large to process in memory, requiring distributed and / or delayed execution.
The GCM-Filters
algorithm [@grooms2021diffusion] applies a discrete Laplacian to smooth a field through an iterative process that resembles diffusion. The discrete Laplacian takes into account the varying grid-cell geometry and uses a no-flux boundary condition, mimicking how diffusion is internally implemented in GCMs. The no-flux boundary conditions ensures that the filter preserves the integral:
An important goal of GCM-Filters
is to enable computationally efficient filtering. The user can employ GCM-Filters
on either CPUs or GPUs, with NumPy
[@harris2020array] or CuPy
[@cupy2017learningsys] input data. GCM-Filters
leverages Dask
[@dask] and Xarray
[@hoyer2017xarray] to support filtering of larger-than-memory datasets and computational flexibility.
The main GCM-Filters
class that the user will interface with is the gcm_filters.Filter
object. When creating a filter object, the user specifies how they want to smooth their data, including the desired filter shape and filter scale. At this stage, the user also picks the grid type that matches their GCM data, given a predefined list of grid types. Each grid type has an associated discrete Laplacian, and requires different grid variables that the user must provide (the latter are usually available to the user as part of the GCM output). Currently, GCM-Filters
provides a number of different grid types and associated discrete Laplacians:
- Grid types with scalar Laplacians that can be used for filtering scalar fields, for example temperature or vorticity (see \autoref{fig1}). The currently implemented grid types are compatible with different ocean GCM grids including MOM5 [@mom5], MOM6 [@adcroft2019MOM6] and the POP2 [@pop2] tripole grid.
- Grid types with vector Laplacians that can be used for filtering vector fields, for example horizontal velocity
$(u,v)$ . The currently implemented grid type is compatible with ocean GCM grids that use an Arakawa C-grid convention; examples include MOM6 [@adcroft2019MOM6] and the MITgcm [@mitgcm].
Atmospheric model grids are not yet supported, but could be implemented in GCM-Filters
. Users are encouraged to contribute more grid types and Laplacians via pull requests.
While we are excited to share GCM-Filters
at version 0.2.3
, we plan to continue improving and maintaining the package for the long run and welcome new contributors from the broader community.
This work was supported by the National Science Foundation grants OCE 1912302, OCE 1912325, OCE 1912332, OCE 1912420, GEO 1912357, and the NOAA grant CVP NA19OAR4310364. Busecke received support from the Gordon and Betty Moore Foundation. This research is supported in part by the generosity of Eric and Wendy Schmidt by recommendation of Schmidt Futures, as part of its Virtual Earth System Research Institute (VESRI).