Derivatives (rojak.core.derivatives)#

Coordinate-aware spatial derivatives on a latitude/longitude grid

This module computes gradients, divergence, and the Laplacian of fields defined on a geographic (latitude/ longitude) grid, accounting for the physical (geodesic) distance between grid points and, where relevant, the distortion introduced by a map projection. It underlies the derivative-based turbulence diagnostics in rojak.turbulence.calculations and rojak.turbulence.diagnostic.

Grid spacing between adjacent points can be computed either from the true geodesic distance at every grid point (grid_spacing()) or, more cheaply, from a nominal spacing measured along the equator and prime meridian (nominal_grid_spacing()). get_projection_correction_factors() computes the map projection scale factors used to correct raw Cartesian derivatives (spatial_gradient(), in GradientMode.GEOSPATIAL mode) for projection distortion, and vector_derivatives() computes the full set of horizontal velocity derivatives (du/dx, du/dy, dv/dx, dv/dy) with this correction applied. divergence() and spatial_laplacian() build on spatial_gradient().

Functions

divergence(u, v, *, units[, geod, crs])

Horizontal divergence of a 2D vector field

first_derivative(array, ...)

First derivative of array along axis, with respect to physical distance

get_dimension_number(name, data_array)

Get the axis position of a named dimension in a DataArray

get_projection_correction_factors(latitude, ...)

Compute the map projection scale factors at each point of a latitude/longitude grid

grid_spacing(latitude, longitude, units[, geod])

Compute the geodesic distance between adjacent points of a 2D latitude/longitude grid

nominal_grid_spacing(latitude, longitude, units)

Estimate the grid spacing of a regular latitude/longitude grid from a single row and column

spatial_gradient(array, units, gradient_mode)

Spatial gradient of a scalar field on a latitude/longitude grid

spatial_laplacian(array, units, gradient_mode)

Laplacian of a scalar field on a latitude/longitude grid

vector_derivatives(u, v, units[, ...])

Horizontal derivatives of a 2D velocity field, corrected for map projection distortion

Classes

CartesianDimension(*values)

Cartesian x/y direction, and the corresponding geographic coordinate/grid spacing/scale factor

GradientMode(*values)

How spatial_gradient() should compute the gradient

GridSpacing(dx, dy)

Grid spacing (in meters) along the x and y Cartesian directions, e.g. as computed by grid_spacing().

LatLonUnits(*values)

Units latitude/longitude coordinates are expressed in

ProjectionCorrectionFactors(parallel_scale, ...)

Map projection scale factors, as computed by get_projection_correction_factors()

SpatialGradient(dfdx, dfdy)

x and y components of a spatial gradient, as computed by spatial_gradient()

VelocityDerivative(*values)

The four horizontal derivatives of a 2D velocity field, as computed by vector_derivatives()