Filtering
The filter API, plans, mask strategies, engine selection, the process shares and the workers' plan copies. The real-space engines are on Filtering engines, and the vector filter of the sphere on Filtering on the sphere.
CoarseGrainingEnergyFluxes.Filtering.filter_field! — Method
filter_field!(out, field, grid, kernel, scale; mask_strategy = ZeroFill(), filter_plan = nothing,
execution = AutoBackend(), method = RealSpace(), transform = AutoSpectralBackend(), kwargs...)Filter a field on a grid using kernel at characteristic full width scale (ℓ), writing the result to out (returned): filter_apply! of the plan_filter the keywords build.
Keyword Arguments
mask_strategy::AbstractMaskStrategy=ZeroFill(): how masked cells and a bounded edge enter the filter.ZeroFillfilters the field extended by zero over masked cells and past each bounded edge, normalized by the kernel's full mass over the lattice continued at its edge spacing, so filtering commutes with spatial derivatives, conserves the integral over all space, and defines the output at masked cells too; a uniform field falls toward a coast.Deformablenormalizes over the active in-domain cells of each window and zeroes masked cells, so a constant is reproduced next to a boundary and the kernel changes shape there.filter_plan::Union{Nothing,AbstractFilterPlan}=nothing: a prebuiltplan_filterresult, reused across calls on the same grid, kernel and scale. When supplied, every other keyword is ignored.execution::AbstractExecutionBackend=AutoBackend(): execution backend (SerialBackend, ThreadedBackend, GPUBackend, …).method,transformand every other keyword: as forplan_filter, which raises on a keyword the method does not take.
For spherical grids the longitude footprint wraps only when the grid is periodic (isperiodic); distances use the great-circle (Haversine) metric.
Examples
geom = CartesianGeometry()
grid = StructuredGrid(geom, 0.0:1000.0:99_000.0, 0.0:1000.0:99_000.0, mask)
out = zeros(100, 100)
filter_field!(out, field, grid, TopHatKernel(), 5000.0; mask_strategy = Deformable())CoarseGrainingEnergyFluxes.Filtering.apply_footprint_nd_batch! — Method
apply_footprint_nd_batch!(outs, fields, grid, fp, strategy) -> outsBatched point-indexed apply over the whole grid: each point's neighbours are enumerated once for all fields.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint_nd_batch_over! — Method
apply_footprint_nd_batch_over!(outs, fields, grid, fp, strategy, indices) -> outsThe batched apply restricted to indices. Each point writes only its own output, so disjoint index blocks may run concurrently. The caller zeroes outs.
CoarseGrainingEnergyFluxes.Filtering.apply_footprint_row_batch! — Method
apply_footprint_row_batch!(outs, fields, grid, fp, strategy, periodic_x, periodic_y, j) -> outsRow j of the batched banded apply: each field's numerator by one contiguous axpy per tap, scaled by the plan's precomputed inverse window mass invden, which depends on the geometry, the mask and the strategy alone.
CoarseGrainingEnergyFluxes.Filtering.AbstractCacheStrategy — Type
AbstractCacheStrategyWhether a real-space footprint over a nonuniform axis (StructuredGrid with a Vector axis, CurvilinearGrid, or ND with a non-Range axis) stores its per-point neighbour list for reuse across filter_apply! calls, or recomputes it at every apply. Both give the same neighbours and weights.
CoarseGrainingEnergyFluxes.Filtering.AlwaysCache — Type
AlwaysCache <: AbstractCacheStrategyStore the per-point neighbour list, the default: built in one pass of the ball query, it makes every apply a pass over the list. It holds each target's neighbours, an index and a weight per neighbour.
CoarseGrainingEnergyFluxes.Filtering.NeverCache — Type
NeverCache <: AbstractCacheStrategyRecompute neighbours at every filter_apply!/filter_apply_batch! call and store no list: each apply runs the ball query the list is built from, in no memory beyond the plan's.
CoarseGrainingEnergyFluxes.Filtering._cache_keep — Method
_cache_keep(strategy) -> BoolWhether a footprint built under strategy keeps its neighbour list.
CoarseGrainingEnergyFluxes.Filtering._allocate — Method
_allocate(backend, T, dims) -> array
_on_backend(backend, x) -> array
_host_memory(backend) -> BoolZeroed storage of element type T, and a copy of the host array x, in the memory backend runs in, and whether that memory is the host's. It is host memory for every backend but a GPUBackend on a device other than KernelAbstractions' CPU, whose memory the KernelAbstractions extension allocates. An MPI rank runs in its inner backend's memory; a DistributedBackend plan's caller holds host memory, and its workers their inner backend's.
CoarseGrainingEnergyFluxes.Filtering._library_threads — Method
_library_threads(backend) -> IntThe thread count a transform library runs at in a plan built for backend: 1 under SerialBackend, the backend a threaded slice or batch loop builds its plans with; Threads.nthreads() under ThreadedBackend, AutoBackend and GPUBackend. A distributed backend runs each process's share at the count of its inner backend.
CoarseGrainingEnergyFluxes.Filtering._owned — Method
_owned(backend, n) -> Vector{Int} or nothing
_sum_across!(backend, A) -> AThe points of n this process transforms, nothing for all of them, and the sum of A over the processes that share the transform, in place. Under MPIBackend (MPI extension) each rank owns the points rank + 1, rank + 1 + nproc, … of a field every rank holds, and the sum is an Allreduce.
CoarseGrainingEnergyFluxes.Filtering._resident — Method
_resident(backend, x) -> arrayThe host array x in the memory backend runs in: x itself where that memory is the host's, a copy (_on_backend, see _allocate) elsewhere. The caller hands x over and holds no other reference to it.
CoarseGrainingEnergyFluxes.Filtering._resident_apply! — Function
_resident_apply!(out, field, grid, fp, strategy) -> outThe apply of a footprint whose arrays live in its plan's execution memory, by broadcasts and library transforms: the padded and zonal FFTs. A GPU backend's extension calls it for a footprint it has no kernel for; out and field are in the same memory as fp.
CoarseGrainingEnergyFluxes.Filtering.spectral_grid_plan — Method
spectral_grid_plan(spectral_backend, grid, kernel; mask_strategy, execution, batch, max_scale = 0)
-> AbstractGridPlan or nothingThe half of a spectral plan a sweep shares: the transform objects themselves, the wavenumber grids, and the mask. The transfer function Ĝ(|k|, ℓ) and the Deformable renormalization depend on the filter scale, so a sweep builds this once and each scale keeps only those two. A bounded Cartesian direction is zero-padded so that kernel at every scale up to max_scale stays clear of the domain's periodic copies; a filter plan at a larger scale raises. max_scale = 0 pads to twice the direction's length. The transforms run on _library_threads(execution) threads.
Returns nothing for a backend with no grid plan; a sweep then builds a full plan per scale.
CoarseGrainingEnergyFluxes.Filtering.spectral_scratch — Method
spectral_scratch(grid_plan) -> AbstractFilterScratch or nothingThe transient half of a spectral plan — the complex spectrum buffer, the mask · field staging array, and whatever else the apply overwrites — sized from grid_plan (see spectral_grid_plan). A sweep hands one to every scale; a driver that applies concurrently builds one per worker.
Returns nothing for a backend that keeps no apply-time buffers.
CoarseGrainingEnergyFluxes.Filtering.AbstractFilterScratch — Type
AbstractFilterScratchTransient per-apply buffers, sized by the grid and the applied array's rank: the only part of a plan filter_apply! mutates. Concurrent applies need one scratch each; the sequential scales of one sweep share one.
CoarseGrainingEnergyFluxes.Filtering.AbstractGridPlan — Type
AbstractGridPlanPrecomputation that depends on the grid, the kernel family, the mask strategy and the method, and is independent of the filter scale. One instance serves every scale of a sweep; see plan_filter_sweep.
CoarseGrainingEnergyFluxes.Filtering.AbstractEngine — Type
AbstractEngineThe real-space engine a plan_filter builds, its engine keyword: AutoEngine, the default, or one named. PaddedFFTEngine and ZonalFFTEngine evaluate the footprint sum by transforms on a rectilinear grid, BinnedTopHatEngine and NUFFTSumEngine over Cartesian points, and FootprintEngine is the grid's own build_footprint.
CoarseGrainingEnergyFluxes.Filtering.AbstractScaleRates — Type
AbstractScaleRatesplan_filter_sweep's scale_rates: ScaleRates to build each real-space plan's scale_rate with the family, ScaleCurvatures to build its second derivative as well, NoScaleRates (the default) to leave them to the sweep.
CoarseGrainingEnergyFluxes.Filtering.AbstractSeriesForm — Type
AbstractSeriesFormWhat a plan's output is as a function of position, by series_form: NoSeries, Series or SeriesRatio.
CoarseGrainingEnergyFluxes.Filtering.AutoEngine — Type
AutoEngine()The engine _select_engine picks, once, at plan build.
CoarseGrainingEnergyFluxes.Filtering.BinnedTopHatEngine — Type
BinnedTopHatEngine()The top-hat over Cartesian points by prefix sums over the point bins.
CoarseGrainingEnergyFluxes.Filtering.FootprintEngine — Type
FootprintEngine()The grid's own real-space footprint, build_footprint: the banded, separable, prefix-sum, cell-by-cell or node engine its type selects.
CoarseGrainingEnergyFluxes.Filtering.NUFFTSumEngine — Type
NUFFTSumEngine()The kernel sum over Cartesian points by nonuniform FFTs, for a kernel with a transfer cutoff.
CoarseGrainingEnergyFluxes.Filtering.NoScaleRates — Type
NoScaleRates()A family holding no scale_rates; a sweep's exact filtering spectrum builds them per call.
CoarseGrainingEnergyFluxes.Filtering.NoSeries — Type
NoSeries()A plan whose output has no series form at hand: a real-space footprint sum.
CoarseGrainingEnergyFluxes.Filtering.PaddedFFTEngine — Type
PaddedFFTEngine()The footprint sum of any kernel on a uniform Cartesian grid by FFTs over the padded box.
CoarseGrainingEnergyFluxes.Filtering.PhysicalFilterPlan — Type
PhysicalFilterPlanA physical-space filter plan: the precomputed footprint, with the grid, mask strategy, kernel, scale and resolved execution backend it was built for. kernel and scale are passed to the backend hooks, which take them positionally; the footprint is never rebuilt from them.
CoarseGrainingEnergyFluxes.Filtering.ScaleCurvatures — Type
ScaleCurvatures()A family holding each plan's scale_rate with its second derivative in the width, which a sweep's spectral slopes read. Every plan must be a real-space plan whose kernel has both (curvature_available).
CoarseGrainingEnergyFluxes.Filtering.ScaleRates — Type
ScaleRates()A family holding each plan's scale_rate, built once with it. Every plan must be a real-space plan whose kernel has a derivative in its width (rate_available).
CoarseGrainingEnergyFluxes.Filtering.Series — Type
Series()A plan whose output is ū(x) = Σ_k w_k Ĝ(k) F̂(k) e^{ik·x}, F̂ the analysis filter_analyze! writes (analyze_buffer).
CoarseGrainingEnergyFluxes.Filtering.SeriesRatio — Type
SeriesRatio()A plan whose output is ū = N/M, N the field's series and M its window mass's, both of Series's form: a renormalized window.
CoarseGrainingEnergyFluxes.Filtering.ZonalFFTEngine — Type
ZonalFFTEngine()The footprint sum on a sphere of uniform longitude by FFTs along longitude, for weights that depend on the longitude offset alone.
CoarseGrainingEnergyFluxes.Filtering.analysis_status — Function
analysis_status(plan) -> FlowTransformBindings.SolverResult
analysis_status(workspace) -> FlowTransformBindings.SolverResultThe outcome of the least-squares fit of plan's last apply: NUFSHT's over a spherical node set under LeastSquares, combined with its mask's fit; a fit that stops short still writes its coefficients, and is reported here. A diagnostic workspace reports the worst of the fits its generalized convolution has run. A plan or workspace whose analysis is a quadrature or an exact transform fits nothing and has no method.
CoarseGrainingEnergyFluxes.Filtering.curvature_available — Method
curvature_available(plan, kernel) -> BoolWhether plan's filter has a second derivative in its width with kernel: rate_available of the first derivative's kernel, Kernels.TransferRate(kernel) for a spectral plan or a kernel sum and Kernels.ScaleRate(kernel) for a footprint sum.
CoarseGrainingEnergyFluxes.Filtering.filter_synthesize_derivative! — Function
filter_synthesize_derivative!(out, F̂, ū, plan, d) -> out∂ū/∂x_d at the plan's points, ū the filtered field and F̂ its field's analysis: the synthesis of i k_d Ĝ F̂ for a Series plan, and for a SeriesRatio one the quotient rule, (∂_d N − ū ∂_d M)/M, with ∂_d M synthesized once at plan build. A method per plan type whose series_form is not NoSeries and whose series_gradient is nothing; a sphere's plans differentiate through filter_synthesize_gradient!.
CoarseGrainingEnergyFluxes.Filtering.filter_synthesize_gradient! — Method
filter_synthesize_gradient!(g1, g2, F̂, ū, plan, gradient) -> (g1, g2)∂ū/∂x_1 and ∂ū/∂x_2 at the plan's points, as filter_synthesize_derivative! takes each; gradient is series_gradient(plan). On a sphere the east and north components per unit distance, from one spin-1 synthesis of ðū = ∂_n ū − i∂_e ū.
CoarseGrainingEnergyFluxes.Filtering.plan_execution — Function
plan_execution(plan) -> AbstractExecutionBackendThe execution backend plan was built for, whose memory its inputs and outputs live in. Every plan type defines a method.
CoarseGrainingEnergyFluxes.Filtering.plan_filter — Method
plan_filter(grid, kernel, scale; mask_strategy = ZeroFill(), execution = AutoBackend(),
method = RealSpace(), transform = AutoSpectralBackend(), cache_strategy = AlwaysCache(),
grid_plan = nothing, scratch = nothing, engine = AutoEngine(), fft_options = (;)) -> AbstractFilterPlanA reusable filter plan for execution, applied by filter_apply!(out, field, plan): the real-space footprint, or under method = Spectral() the transform plan. engine names the real-space engine (AbstractEngine); AutoEngine() takes the one with the fewest operations (_select_engine). A spectral plan also takes batch = nb for a trailing batch axis and, over a spherical node set, nufft, the NUFFT library NUFSHT runs, and analysis (AbstractAnalysis); a keyword the method does not take raises an ArgumentError. grid_plan and scratch are the parts a sweep shares; see plan_filter_sweep. fft_options are the planner keywords of the FFTs the plan makes (the spectral FFT filter, the padded and zonal FFT engines), passed to the FFT library's plan_* as they stand, e.g. (; flags = FFTW.MEASURE) under FFTW.
A transform runs on 1 thread under SerialBackend() and on Threads.nthreads() under ThreadedBackend(), AutoBackend() and GPUBackend(), in the device's memory under the last. Under MPIBackend(inner) every rank holds the field and the output. A nonuniform transform (NUFFT, NUFSHT) gives each rank a disjoint share of the points: the analysis F_k = Σⱼ wⱼ cⱼ exp(−i k⋅xⱼ) is a sum over points, so the ranks' partial sums add to it exactly, and each rank evaluates the filtered series at its own points. An FFT or FastSphericalHarmonics transform runs whole on every rank. Under DistributedBackend(inner) the worker processes share the transform, a nonuniform one by blocks of points and an FFT by blocks of columns and then of rows, each at inner's thread count; a FastSphericalHarmonics transform runs in the calling process.
CoarseGrainingEnergyFluxes.Filtering.plan_method — Method
plan_method(plan) -> AbstractFilterMethodThe method a plan evaluates: RealSpace() for a physical-space plan, Spectral() for a transfer-function plan.
CoarseGrainingEnergyFluxes.Filtering.plan_strategy — Function
plan_strategy(plan) -> AbstractMaskStrategyThe mask strategy plan filters under. Every plan type defines a method.
CoarseGrainingEnergyFluxes.Filtering.prepare_workspace — Method
prepare_workspace(backend, grid, footprint) -> workspaceBackend hook plan_filter calls once; its result is stored as the plan's footprint. The default returns footprint unchanged; a backend with its own memory, such as a GPU's device buffers, returns the resident form its apply step reads.
CoarseGrainingEnergyFluxes.Filtering.rate_available — Method
rate_available(plan, kernel) -> BoolWhether rate_plan serves plan with kernel: a spectral plan whose transfer the kernel differentiates in its width (Kernels.has_transfer_rate on the plane, Kernels.has_degree_rate on a sphere).
CoarseGrainingEnergyFluxes.Filtering.rate_plan — Function
rate_plan(plan, kernel, scale) -> planplan with its transfer replaced by ∂_ℓĜ (Kernels.TransferRate(kernel)) at scale, everything else shared: its synthesis of an analysis plan writes is ∂_ℓN/M, with M the window mass a renormalized plan divides by (1 otherwise), so ∂_ℓū = synth(F̂) − ū · synth(M̂), M̂ the analysis of a field of ones. A method per spectral plan type; rate_available answers where the kernel has the derivative.
CoarseGrainingEnergyFluxes.Filtering.series_form — Method
series_form(plan) -> AbstractSeriesFormWhat plan's output is; filter_synthesize_derivative! differentiates a Series or a SeriesRatio.
CoarseGrainingEnergyFluxes.Filtering.series_gradient — Method
series_gradient(plan) -> gradient state or nothingWhat filter_synthesize_gradient! reads beyond plan itself: on a sphere the spin-1 synthesis of the surface gradient, built here so that a plan used only to filter holds none; nothing for a plan whose filter_synthesize_derivative! needs nothing more.
CoarseGrainingEnergyFluxes.Filtering.SumRate — Type
SumRateA nonuniform-FFT kernel sum's scale_rate: the plan, its rate_plan, B = ℓ ∂_ℓM/M and three analysis buffers, so ℓ∂_ℓū = A − ū·B with A = ℓ ∂_ℓN/M synthesized from the field's analysis; and second, nothing or the SumSecond of the second derivative.
CoarseGrainingEnergyFluxes.Filtering.SumSecond — Type
SumSecondThe second derivative of a SumRate: the rate_plan of Kernels.TransferRate(kernel), whose synthesis is ∂²_ℓN/M, and B = D²M/M = ℓ²∂²_ℓM/M + ℓ∂_ℓM/M, so D²ū = A − ū·B − 2(Dū)·B₁ with A = ℓ²∂²_ℓN/M + ℓ∂_ℓN/M.
CoarseGrainingEnergyFluxes.Filtering.WindowRate — Type
WindowRateA real-space plan's scale_rate: its rate_plans, ρ_p = M_p/M from the window masses, and B = Σ_p ρ_p, so ℓ∂_ℓū = A − ū·B with A = Σ_p ρ_p ū_p; and second, nothing or the WindowSecond of the second derivative.
CoarseGrainingEnergyFluxes.Filtering.WindowSecond — Type
WindowSecondThe second derivative of a WindowRate: the plans of the second-order weights and ρ_p = c_p M_p/M, c_p the term's multiplicity, with B = Σ_p ρ_p = D²M/M, so D²ū = A − ū·B − 2(Dū)·B₁ with A = Σ_p ρ_p ū_p, D = ℓ∂_ℓ and B₁ the first derivative's.
CoarseGrainingEnergyFluxes.Filtering.rate_plans — Method
rate_plans(plan::PhysicalFilterPlan) -> TupleThe plans whose filters give plan's derivative in its width, ℓ∂_ℓū = Σ_p (M_p/M)(ū_p − ū) with M each plan's window_mass!: one of Kernels.ScaleRate(kernel) for radial weights, and for a separable kernel's tables one of Kernels.AxisRate(kernel, Val(d)) per axis. Each is built on plan's grid, strategy, backend and engine, over the cells plan sums, caching its neighbours where plan does and sharing its pass buffers.
CoarseGrainingEnergyFluxes.Filtering.scale_rate — Function
scale_rate(plan::PhysicalFilterPlan[, order = ScaleRates()]) -> WindowRate or SumRateWhat plan's derivative in its width reads beyond a field, built from the plan alone: a WindowRate for a footprint sum, a SumRate for a nonuniform-FFT kernel sum; with order = ScaleCurvatures() their second derivatives as well. Raises where rate_available, or for the second derivative curvature_available, is false.
CoarseGrainingEnergyFluxes.Filtering.window_mass! — Method
window_mass!(m, plan::PhysicalFilterPlan) -> mEach target's window mass, the sum of weights plan divides by, into m in the plan's memory, shaped like the grid's mask; zero at a target the strategy leaves unfiltered. Read from the footprint where it holds it, and summed by the engine's own loops where it forms it per target.
CoarseGrainingEnergyFluxes.Filtering.FilterPlanFamily — Type
FilterPlanFamily(grid_plan, plans, scratch[, rates, rate_order])The plans for a sweep of scales over one grid, with the scale-independent AbstractGridPlan and the per-apply AbstractFilterScratch they share; either is nothing for an engine with nothing to share. rates holds each plan's scale_rate when the family was built with ScaleRates or ScaleCurvatures, the tag rate_order holds, and is nothing otherwise. A family is an AbstractVector of its plans.
The plans of one family share one scratch, so they must not be applied concurrently; give each concurrent worker a worker_copy of the family, which shares its tables.
CoarseGrainingEnergyFluxes.Filtering._default_method — Method
_default_method(grid) -> AbstractFilterMethodThe method plan_filter and plan_filter_sweep take on grid when the caller names none: RealSpace() on every grid, the compact-kernel convolution that defines coarse graining (Aluie 2019). The transfer-function filter is reached only by an explicit method = Spectral().
CoarseGrainingEnergyFluxes.Filtering._is_flat_cell — Method
_is_flat_cell(grid) -> BoolWhether grid names a cell by a single integer, FlowGeometries.Grids.FlatCells(): a node set, or a spherical pixelization whose cells carry one id. The node CSR engine reads such a grid only through fold_within(grid, t), measure(grid, j) and isactive(grid, t). A CartesianCells() grid names a cell by an index tuple and takes the rectilinear or curvilinear engines.
CoarseGrainingEnergyFluxes.Filtering._nufft_sum_ops — Method
_nufft_sum_ops(grid, kernel, scale, cutoff) -> (transform, entries, build)The operations of one apply over Cartesian points by the nonuniform-FFT sum, and the neighbour list's entries (one operation each per apply) and the operations of its build. The sum is two transforms of M·w^D spreading and 2.5 N log₂ N over the twice-oversampled box of n_d = 2⌊K L_d/2π⌋ + 1 modes, w the spreading width ⌈−log₁₀ tol⌉ + 1 and L_d the box of _KernelBox; building its plan is one such apply, the window masses. The list holds each point's neighbours at the mean density, V_D r^D · M/ΣA, and is built from the point bins (_binned_csr) in two passes over the points of the bins within reach, D + 1 operations each (a squared distance and its test), and a weight and a store per entry.
CoarseGrainingEnergyFluxes.Filtering._padded_fft_ops — Method
_padded_fft_ops(grid, kernel, scale) -> (transform, realspace)The operations of one apply on a uniform Cartesian grid by the zero-padded transform and by the real-space engine build_footprint takes for kernel (_real_space_ops).
CoarseGrainingEnergyFluxes.Filtering._padded_halfwidths — Method
_padded_halfwidths(grid, kernel, scale) -> NTuple{N,Int}The half-widths in cells of the direct footprint the padded transform samples on a uniform Cartesian grid: the ball of kernel_radius for a radial kernel, the separable engine's stencil for a separable one. A bounded axis reaches no farther than its extent.
CoarseGrainingEnergyFluxes.Filtering._real_space_ops — Method
_real_space_ops(grid, kernel, scale) -> Float64The operations of one apply on a uniform Cartesian grid by the real-space engine for kernel: the direct sum over the ball of radius kernel_radius, the prefix-sum top-hat (in two and three directions), or the separable passes.
CoarseGrainingEnergyFluxes.Filtering._select_engine — Method
_select_engine(grid, kernel, scale, resolved) -> AbstractEngineThe engine AutoEngine takes on the resolved backend. On a backend whose applies run in this process' loops: the binned top-hat and the nonuniform-FFT sum over Cartesian points; there and on a GPU backend, the padded and zonal transforms over rectilinear grids where an FFT library serves the backend's memory; each where it applies and costs fewer operations than the footprint, the footprint otherwise. check_setup reports from the same choice.
CoarseGrainingEnergyFluxes.Filtering._zonal_fft_ops — Method
_zonal_fft_ops(grid, kernel, scale) -> (transform, realspace)The operations of one apply on a sphere of uniform longitude by the transform along longitude and by the banded sum. Per pair of latitude rows the taps are the longitude offsets within great-circle distance rad, sin²(Δλ/2) ≤ (sin²(rad/2R) − sin²(Δφ/2)) / (cos φ cos φ′).
CoarseGrainingEnergyFluxes.Filtering.analyze_buffer — Function
analyze_buffer(plan, field) -> F̂ or nothing
filter_analyze!(F̂, field, plan) -> F̂
filter_synthesize!(out, F̂, plan) -> outA spectral apply in two halves: filter_analyze!, the forward transform, and filter_synthesize!, the multiply by Ĝ(|k|, ℓ) and the inverse transform. Only the second depends on the scale, so a sweep analyzes each field once and synthesizes it at every scale: F̂ analyzed with one plan may be synthesized with the plan for any other scale over the same grid.
analyze_buffer returns a buffer for F̂, or nothing for an engine with no scale-independent half; callers then use filter_apply!.
CoarseGrainingEnergyFluxes.Filtering.filter_apply! — Method
filter_apply!(out, field, plan) -> outApply the prebuilt plan (see plan_filter) to field, writing out, on the backend the plan was built for. Every backend applies the footprint stored in plan.
CoarseGrainingEnergyFluxes.Filtering.filter_apply_batch! — Method
filter_apply_batch!(outs, fields, plan) -> outsApply one prebuilt plan to several separate fields on its grid, writing outs[i] from fields[i]; the result equals filter_apply! per field. The scattered footprints derive each target point's neighbourhood once for the whole batch.
outs and fields are equal-length collections of matching arrays: an NTuple{K,V} for a batch size known at compile time (stack accumulators), or an AbstractVector. Arrays with a trailing batch axis go through filter_apply_batched!. For independent fields on different grids, see filter_slices!.
CoarseGrainingEnergyFluxes.Filtering.filter_apply_batched! — Method
filter_apply_batched!(out, field, plan) -> outApply plan to each slice along a trailing batch axis: out and field are (spatial..., Nb) over the plan's grid. On a device with a fused kernel for the engine this is one launch of prod(spatial) * Nb work items; otherwise it loops over the slices. For several separate arrays on one grid, see filter_apply_batch!.
CoarseGrainingEnergyFluxes.Filtering.filter_fields! — Method
filter_fields!(outs, fields, grid, kernel, scale; mask_strategy = ZeroFill(), filter_plan = nothing,
execution = AutoBackend())Filter several fields on one grid at one kernel and scale with a single plan, filter_plan or one built by plan_filter, through filter_apply_batch!. outs and fields are indexable collections of matching arrays, such as a tuple of velocity components.
CoarseGrainingEnergyFluxes.Filtering.plan_filter — Method
plan_filter(grid, kernel, scale; mask_strategy = ZeroFill(), execution = AutoBackend(),
method = _default_method(grid), transform = AutoSpectralBackend(), kwargs...)The plan for a grid with no rectilinear or curvilinear engine of its own; method defaults to _default_method. In real space a flat-cell grid (see _is_flat_cell) has the node CSR engine over its own ball query, and any other grid raises. Under method = Spectral() the grid is filtered over its cells by the nonuniform transform of its geometry: NUFFT for a Cartesian one, NUFSHT for a spherical one.
RealSpace() applies the kernel with its compact support. A transform is exact for a band-limited field and its per-apply cost is independent of the filter scale; its support is global.
CoarseGrainingEnergyFluxes.Filtering.plan_filter_sweep — Method
plan_filter_sweep(grid, kernel, scales; mask_strategy = ZeroFill(), method = nothing,
scale_rates = NoScaleRates(), kwargs...) -> FilterPlanFamilyOne plan_filter per scale in scales, all sharing one grid-determined half of the engine and one per-apply scratch: the scales' plans whose buffers have the same shapes hold one set of them. For the prefix-sum top-hat engine the shared half is the measure prefix scans, the ordered axis-1 coordinates and the mask scan. method = nothing takes the grid's default method. scale_rates = ScaleRates() also builds each real-space plan's scale_rate, which a sweep's exact filtering spectrum reads, so a family reused across calls builds them once; ScaleCurvatures() builds their second derivatives too, which the spectral slopes read.
Forwards every other plan_filter keyword.
family = plan_filter_sweep(grid, TopHatKernel(), scales)
for (s, plan) in zip(scales, family)
filter_apply!(out, field, plan)
endCoarseGrainingEnergyFluxes.Filtering.AbstractProcessShare — Type
AbstractProcessShare
_share_workspace(inner, grid, fp) -> footprint or share
_process_passes(inner, fp) -> Val(n)
_share_staging(share) -> host array or nothingWhat a process of a process backend holds to run its shares on inner, and the passes it runs: the host footprint itself with its passes on a host backend; on a device backend the share the device's extension builds (an AbstractProcessShare), whose one pass runs the engine on the device. _share_staging is the host buffer a share's output passes through when it is reduced across processes.
CoarseGrainingEnergyFluxes.Filtering._share_pass! — Function
_share_passes(fp) -> Val(n)
_share_pass!(out, field, grid, fp, strategy, ::Val{p}, k, nk, inner) -> nothing
_share_dst(out, fp, ::Val{p}) -> Tuple of arrays
_share_local(fp, ::Val{p}) -> BoolThe n passes of fp's apply; share k of nk of pass p, run on inner, reading the whole field (and the whole output of pass p − 1) and writing its units of out or of fp's pass buffers; the arrays pass p writes, which a backend holding a separate memory per process assembles after the pass; and whether pass p costs less to run whole on every process than to assemble, O(N) work with nothing to exchange before it.
CoarseGrainingEnergyFluxes.Filtering._share_run — Method
_share_run(f, inner, units)Calls f(chunk) for chunks covering units on the inner backend, each chunk one task with its own scratch: one chunk under a serial backend; the OhMyThreads extension splits them among threads.
CoarseGrainingEnergyFluxes.Filtering.apply_slice_serial! — Method
apply_slice_serial!(out, field, plan) -> outApply plan to one slice on the serial engine, whatever backend plan records; see filter_slices!.
CoarseGrainingEnergyFluxes.Filtering.filter_slices! — Method
filter_slices!(outs, fields, plans; execution = AutoBackend()) -> outsApply plans[t] to fields[t], writing outs[t], for every slice t. Slices are independent, each with its own grid and plan; for several fields on one grid, see filter_apply_batch!.
execution parallelizes over the slices. Each slice runs serially inside, whatever execution backend its own plan carries.
CoarseGrainingEnergyFluxes.Filtering.slice_costs — Method
slice_costs(plans) -> Vector{Int}Per-slice work proxy for a longest-first schedule: the number of target points a physical-space plan writes, and 1 for any other plan. A slice's cost grows at least linearly in it.
CoarseGrainingEnergyFluxes.Filtering.AbstractFilterMethod — Type
AbstractFilterMethodHow the convolution is evaluated: RealSpace (physical-space footprint, any grid/mask) or Spectral (transform-space multiply, provided by extensions: an FFT on a uniform Cartesian grid, zero-padded along a bounded axis; spherical harmonics on a Fejér first-rule sphere; a NUFFT or NUFSHT on scattered points).
CoarseGrainingEnergyFluxes.Filtering.AbstractFilterPlan — Type
AbstractFilterPlanA prebuilt filter (grid + kernel + scale + mask strategy + execution backend), applied to many fields with no repeated setup. A physical-space plan holds a precomputed footprint; a spectral plan holds its transform plans.
CoarseGrainingEnergyFluxes.Filtering.AbstractMaskStrategy — Type
AbstractMaskStrategyHow masked (inactive) cells enter the filter normalization.
CoarseGrainingEnergyFluxes.Filtering.Deformable — Type
Deformable <: AbstractMaskStrategyMasked cells and the exterior are excluded from both numerator and denominator, so the kernel is renormalized over the active cells in its window ("deformable kernel"), and a masked cell is zero. A constant is reproduced exactly next to a boundary, but the kernel changes shape there, so filtering neither commutes with derivatives nor conserves the domain integral.
CoarseGrainingEnergyFluxes.Filtering.RealSpace — Type
RealSpace <: AbstractFilterMethodThe physical-space convolution with the compact kernel, on any grid, mask and geometry. The grid and kernel decide the engine that evaluates its sum. On a host backend that includes a transform of the same sampled kernel where the grid allows one: the FFT on a uniform Cartesian grid (circular along periodic axes, zero-padded along bounded ones) and the transform along longitude on a sphere of uniform longitude, which agree with the direct sum to round-off. Spectral, which multiplies by the kernel's transfer function, is a different discretization.
CoarseGrainingEnergyFluxes.Filtering.Spectral — Type
Spectral <: AbstractFilterMethodTransform-space filtering (kernel applied as a multiply on the transformed field). Requires a spectral extension and a compatible grid (e.g. using FFTW for a uniform Cartesian grid, periodic or bounded).
CoarseGrainingEnergyFluxes.Filtering.ZeroFill — Type
ZeroFill <: AbstractMaskStrategyMasked cells and the domain's exterior are zero-velocity water (Aluie et al. 2018; Storer et al. 2022): they contribute nothing to the numerator, and the kernel keeps its full mass, the cells past a bounded edge included. The kernel is then the same everywhere, so filtering commutes with derivatives and conserves the integral over all space, which on a periodic grid is the grid (Aluie 2019; Grooms et al. 2021, eq. 7).
The filtered field is defined at every cell, a masked one too: within the kernel's reach of an active cell it is nonzero over land.
CoarseGrainingEnergyFluxes.Filtering.ApplyBuffers — Type
ApplyBuffers(buffers)The arrays a footprint's apply writes where the footprint holds them as fields of its own, as one scratch value; a nothing entry stands for a buffer the footprint does not hold.
CoarseGrainingEnergyFluxes.Filtering._grid_plan — Method
_grid_plan(plan_or_footprint) -> grid plan or nothing
_with_grid_plan(plan_or_footprint, grid_plan) -> plan_or_footprint
_fresh_grid_plan(grid_plan) -> grid planA plan's grid plan where it holds state an apply writes, nothing otherwise; the plan rebound to another; and a grid plan sharing the tables of grid_plan with its own library plans. A grid plan holding no such state is its own.
CoarseGrainingEnergyFluxes.Filtering._scratch — Method
_scratch(plan_or_footprint) -> scratch or nothing
_with_scratch(plan_or_footprint, scratch) -> plan_or_footprint
_fresh(scratch) -> scratch
_alike(a, b) -> BoolThe buffers an apply writes, as one value whose identity (===) is the buffers', nothing for an apply writing none; the plan rebound to other buffers; new buffers of the same shapes, zero where an apply reads zero padding; and whether two such values serve the same plans, one type and the same shapes, so that the sequential scales of one family may share one.
CoarseGrainingEnergyFluxes.Filtering._share_scratch — Method
_share_scratch(plans) -> plansplans with each one's scratch replaced by the first earlier one's that is _alike (see _scratch), so the sequential scales of one family hold one scratch per kind of buffers.
CoarseGrainingEnergyFluxes.Filtering._worker_fit — Method
_worker_fit(fit) -> SpinFit or nothingA worker's least-squares analysis: the weights and the unit transfer shared, the scratch and LSMR workspace (arrays alone) its own, its outcome reset.
CoarseGrainingEnergyFluxes.Filtering._worker_transforms — Function
_worker_transforms(tr) -> AbstractSpinTransformsThe spin transforms a worker holds: tr's node tables and longitude step shared, the arrays a transform writes its own; a library's transforms, whose plans hold their execution's buffers, planned anew.
CoarseGrainingEnergyFluxes.Filtering.worker_copy — Method
worker_copy(plan) -> plan
worker_copy(family::FilterPlanFamily) -> FilterPlanFamilyA plan that applies as plan does, sharing its read-only tables and holding its own scratch (AbstractFilterScratch), so that the two may apply concurrently. Each concurrent worker of a batch takes one: W workers hold one set of tables and W scratch sets. A family's copy shares its grid plan and the tables of every scale, gives the plans that shared one scratch one new scratch to share, and copies its held scale_rates alike. A nonuniform transform's library plan holds the state of its execution and is planned anew over the same nodes. A plan whose applies run on a device or across processes raises.