healpix_resample.base.estimate_pixel_area#

healpix_resample.base.estimate_pixel_area(lon_deg, lat_deg, radius=6371000.0, min_points_per_ring=3.0)[source]#

Estimate each sample’s pixel area from shared-latitude “ring” structure.

Many native lon/lat grids – regular lat/lon grids, and reduced Gaussian grids such as ECMWF’s N-grids (see the ERA5 tutorial) – have samples that share exact latitude values, with the number of longitude points per ring possibly varying (e.g. shrinking towards the poles). When that structure is present, each sample’s cell area can be computed exactly as a spherical zone: the latitudinal width from the midpoints with neighbouring rings, times the longitudinal width implied by how many samples share that ring.

This does not detect grids that are regular in a different projection (e.g. a UTM pixel grid): after reprojection to lon/lat, such grids generally have no two samples sharing an exact latitude, so no ring structure is found.

Parameters:
  • lon_deg, lat_deg (array-like, shape (N,)) – Sample coordinates in degrees.

  • radius (float) – Sphere radius; the returned area is in the same squared units (default: metres, giving an area in m^2).

  • min_points_per_ring (float) – Minimum average number of samples per unique latitude value for the ring structure to be considered genuine rather than incidental (default 3 – comfortably above 1, which would just mean every sample has a numerically-unique latitude).

Returns:

numpy.ndarray, shape (N,), or None – Per-sample area estimate, or None if no ring structure was detected – callers should then fall back to a uniform weight.