torch_harmonics.quadrature.compute_theta_cutoff#

torch_harmonics.quadrature.compute_theta_cutoff(nlat, grid='equiangular', scale=1.0)[source]#

Default angular cutoff for localized operators on the sphere.

Both the DISCO convolutions and neighborhood attention need a support radius for their filter basis. The heuristic is to take one latitudinal grid spacing of the coarser of the two grids involved, so that the basis functions of adjacent output points overlap and every output point sees more than the single latitude ring it sits on.

The spacing is taken from the grid’s actual node distribution (compute_latitude_spacing()) rather than from nlat alone. Using \(\pi / (N_\theta - 1)\) is only correct for equiangular grids; on lobatto and equiangular-trapezoidal grids it underestimates the polar spacing by ~21% and ~5x respectively, which collapses the stencil of the polar output latitudes to a single latitude ring.

Parameters:
  • nlat (int) – Number of latitudinal nodes of the grid that sets the cutoff. This is the output grid for a forward transform and the input grid for a transpose one, mirroring which of the two is the coarser.

  • grid (str, optional) – Quadrature grid type, by default "equiangular".

  • scale (float, optional) – Multiplier on the grid spacing, by default 1.0.

Returns:

Cutoff angle in radians.

Return type:

float

Warns:

UserWarning – On grids whose node spacing is not uniform in \(\theta\), where this returns a different value than the pi / (N_\theta - 1) heuristic used before v0.9.3. Equiangular grids are unaffected and do not warn.

Notes

This routine is the single place where the cutoff heuristic lives; it is intended to take a grid descriptor once the descriptor-based API lands, at which point nlat and grid collapse into a single argument.