API Reference

Unit registry

ureg

The unit registry stores the definitions and relationships between units.

Dataset downloads

Convenient wrappers for python APIs used to download climatological datasets.

cmip()

Download CMIP5 model data.

era(params, stream, levtype[, daterange, …])

Retrieves ERA reanalysis data using the provided API.

merra()

Download MERRA data.

ncar()

Download NCAR CFSL data.

satellite()

Download satellite data.

Finite differences

Various finite difference schemes.

integral(x, y, /[, y0, axis])

Return the integral approximation along an arbitrary axis.

deriv1(h, y, /[, axis, accuracy, keepleft, …])

Return an estimate of the first derivative along an arbitrary axis using first order centered finite differencing.

deriv2(h, y, /[, axis, accuracy, keepleft, …])

Return an estimate of the second derivative along an arbitrary axis using second order centered finite differencing.

deriv3(h, y, /[, axis, accuracy, keepleft, …])

Return an estimate of the third derivative along an arbitrary axis using third order centered finite differencing.

deriv_half(x, y, /[, order, axis])

Return an arbitrary order finite difference approximation by taking successive half-level differences.

deriv_uneven(x, y, /[, order, axis, …])

Return an arbitrary order centered finite difference approximation for arbitrarily spaced coordinates using the [For88] method.

Spectral analysis

Spectral analysis tools. Many of these are adapted from examples and course notes provided by Professors Elizabeth Barnes and Dennis Hartmann.

Note

The convention for this package is to use linear wave properties, i.e. the wavelength in <units> per \(2\pi\) radians, and wavenumber \(2\pi\) radians per <units>.

butterworth(dx, order, cutoff, /[, btype])

Applies Butterworth filter to data.

copower(dx, y1, y2[, axis])

Return the co-spectral decomposition and related quantities for two real-valued arrays along an arbitrary axis.

copower2d(dx_time, dy_lon, y1, y2[, …])

Return the 2D spectral decomposition of two real-valued arrays with along an arbitrary time dimension and cyclic dimension.

filter(x, b, /[, a, n, axis, center, pad, …])

Apply scipy.signal.lfilter to data.

harmonics(x, k, /[, axis])

Select the first Fourier harmonics of the time series.

highpower(x, k, /[, axis])

Select only the highest power frequencies.

lanczos(dx, width, cutoff)

Returns coefficients for Lanczos high-pass filter with desired wavelength specified.

power(dx, y1, /[, axis])

Return the spectral decomposition of a real-valued array along an arbitrary axis.

power2d(dx, dy, y1[, axis_lon, axis_time])

Return the spectral decomposition of a real-valued array along an arbitrary axis.

response(dx, b[, a, n, simple])

Calculate the response function given the a and b coefficients for some analog filter.

running(x, w, /[, axis, pad, pad_value])

Apply running average to array.

waves(x, /[, wavenums, wavelengths, phase])

Compose array of sine waves.

window(wintype, n)

Retrieve the get_window weighting function window.

Variability analysis

Analyses of variance and trends. Many of these are adapted from examples and course notes provided by Professors Elizabeth Barnes and Dennis Hartmann.

autocorr(dt, z[, axis])

Return the autocorrelation spectrum at successive lags.

autocovar(dt, z[, axis])

Return the autocovariance spectrum at successive lags.

corr(dt, z1, z2[, axis])

Return the correlation spectrum at successive lags.

covar(dt, z1, z2[, axis])

Return the covariance spectrum at successive lags.

eof(data, /[, neof, axis_time, axis_space, …])

Calculate the first N EOFs using the scipy algorithm for Hermetian matrices on the covariance matrix.

eot(data[, neof])

EOTs, whatever they are.

reof(data[, neof])

Rotated EOFs, e.g.

gaussian(z[, mean, stdev, sigma])

Returns sample points on Gaussian curve.

hist(bins, y, /[, axis])

Get the histogram along axis axis.

linefit(x, y, /[, axis])

Get linear regression along axis, ignoring NaNs.

rednoise(a[, ntime, nsamples, mean, stdev])

Return one or more artificial red noise time series with prescribed mean and standard deviation.

rednoisefit(dt, a, /[, nlag, nlag_fit, axis])

Return the \(e\)-folding autocorrelation timescale for the input autocorrelation spectra along an arbitrary axis.

wilks(percentiles[, alpha])

Return the precentile threshold from an array of percentiles that satisfies the given false discovery rate.

Spherical coordinates

Mathematical operations on the surface of the sphere.

geopad(lon, lat, data[, nlon, nlat])

Return array padded circularly along longitude and over the poles for finite difference methods.

geomean(lon, lat, data[, box, weights, keepdims])

Take area mean of data time series.

geogradient(lon, lat, data)

Calculate gradient in spherical coordinates.

geolaplacian(lon, lat, data[, accuracy])

Calculate Laplacian in spherical coordinates.

haversine(lon1, lat1, lon2, lat2)

Calculate the great circle distance between two points on Earth, specified in degrees.

Wave diagnostics

Various diagnostics for quantifying wave activity, tracking wave packets, and detecting blocking patterns. Incorporates code developed by Clare Huang.

Warning

This codebase out of date and poorly tested. It will eventually be cleaned up. In the meantime, feel free to copy and modify it.

eqlat(lon, lat, q[, skip, sigma])

Get equivalent latitudes corresponding to PV levels evenly sampled from the distribution of sorted PVs.

waq(lon, lat, q[, sigma, omega, flip, skip])

Return the finite-amplitude wave activity.

waqlocal(lon, lat, q[, omega, sigma, flip, skip])

Return the local finite-amplitude wave activity.

Miscellaneous utilities

Includes miscellaneous mathematical functions.

dt2cal(dt)

Convert array of datetime64 to a calendar array of year, month, day, hour, minute, and seconds with these quantites indexed on the last axis.

intersection(x, y1, y2[, xlog])

Find the (first) intersection point for two line segments.

linetrack(xs[, ys, sep, seed, ntrack])

Track individual “lines” across lists of coordinates.

match(*args)

Return the overlapping points for a group of 1D vectors.

zerofind(x, y[, axis, diff, centered, which])

Find the location of the zero value for a given data array.

Physical constants

A variety of physical constants.

G

Gravitational constant

H

Rule-of-thumb 7km atmospheric scale height

Md

Dry air molar mass

Mw

Water vapor molar mass

Na

Avogadro constant.

Omega

Earth rotation rate

R

Ideal gas constant

a

Earth mean radius

c

Speed of light in a vacuum

cp

Specific heat capacity at constant pressure for dry air at \(0^{\circ}\mathrm{C}\)

cv

Specific heat capacity at constant volume for dry air at \(0^{\circ}\mathrm{C}\)

e

Euler’s number

g

Standard acceleration due to gravity

h

Planck constant

p0

Standard reference pressure

psfc

Earth mean sea-level pressure

pi

\(\pi\) (3.14159…)

tau

\(\tau\) (6.28318…)

Rd

Dry air gas constant

Rm

Water vapor gas constant

kappa

Poisson constant for dry air.

kb

Boltzmann constant

sigma

Stefan-Boltzmann constant