pcmdi_metrics.effective_resolution.compute_power_spectrum
- pcmdi_metrics.effective_resolution.compute_power_spectrum(field, lat, ntrunc=None, gridtype='auto', rsphere=6371000.0)[source]
Compute power spectrum of a 2D scalar field via spherical harmonics.
- Parameters:
field (
ndarray,shape (nlat,nlon)) – 2D scalar field (e.g., temperature, geopotential height, precipitation).lat (
ndarray,shape (nlat,)) – Latitude in degrees.ntrunc (
intorNone, optional) – Triangular truncation wavenumber. DefaultNoneisnlat - 1.gridtype (
{"auto", "regular", "gaussian"}, optional) – Grid type for selecting quadrature weights.rsphere (
float, optional) – Earth radius in meters. Default is EARTH_RADIUS.
- Returns:
ds (
xarray.Dataset) – Dataset containing: -power_spectrum(wavenumber,): Power \(E(l) = \sum_m |C_{l,m}|^2\) -wavenumber(wavenumber,): Total wavenumber \(l\) -eddy_scale(wavenumber,): Half-wavelength scale in km
Notes
For a scalar field \(\phi\) with spherical harmonic expansion \(\phi = \sum_l \sum_m C_{l,m} Y_{l,m}\), the power spectrum is:
\[E(l) = \sum_{m=-l}^{l} |C_{l,m}|^2\]This represents the variance of the field at each total wavenumber \(l\).
- Physical Interpretation:
\(E(l)\) = variance of field at wavenumber \(l\)
Steepening = loss of variance at small scales
Effective resolution = scale below which variance is artificially damped
- Differences from Kinetic Energy Spectra:
Wind fields: KE spectrum from vorticity/divergence decomposition
Scalar fields: Direct power spectrum from field variance
Both use same methodology for detecting spectral steepening
Examples
>>> # Temperature field >>> temp = np.random.randn(96, 192) >>> lat = np.linspace(-89.0, 89.0, 96) >>> ds = compute_power_spectrum(temp, lat) >>> ds['power_spectrum'] <xarray.DataArray 'power_spectrum' (wavenumber: 96)>
See also
field_to_spherical_harmonicsTransform field → spherical harmonic coefficients
compute_ke_spectraWind fields → kinetic energy spectra