fastscapelib.HealpixGrid

class fastscapelib.HealpixGrid

A HEALPix (Hierarchical Equal Area isoLatitude Pixelation) grid defined on the sphere.

__init__(nside: int, nodes_status: numpy.ndarray, radius: float = 6.371e6) None

HEALPix grid initializer.

Parameters:
  • nside (int) – Number of divisions along the side of a HEALPix base-resolution pixel. A higher value sets a grid with a finer resolution and a greater size N (i.e., total number of grid nodes).

  • nodes_status (array-like) – Array of shape [N] setting the status of all grid nodes at once.

  • radius (float, optional) – Sphere radius (default, Earth radius in meters).

Methods

__init__(nside, nodes_status[, radius])

HEALPix grid initializer.

neighbors(idx)

Returns the neighbors of a given node.

neighbors_count(idx)

Returns the number of neighbors at a given node.

neighbors_distances(idx)

Returns the distances from a given node to its neighbors.

neighbors_indices(idx)

Returns the (flat) indices of the neighbors of a given node.

nodes_areas(*args)

Returns the area of the direct vicinity of a given node or all nodes.

nodes_indices(*args)

Returns the (flattened) indices of grid nodes, possibly filtered by node status.

nodes_lonlat(*args)

Return the longitude and latitude coordinates of one or all grid nodes (HEALPix cell centroids), in radians.

nodes_status(*args)

Returns the status of a given node or all nodes.

nodes_xyz(*args)

Return the x,y,z cartesian coordinates of one or all grid nodes (HEALPix cell centroids).

Attributes

is_structured

is_uniform

n_neighbors_max

nside

HEALPix's Nside (number of division along the side of a HEALPix base-resolution pixel).

radius

Sphere radius

shape

Returns the shape of the grid node arrays.

size

Returns the total number of grid nodes.

neighbors(idx: int) List[Neighbor]

Returns the neighbors of a given node.

Parameters:

idx (int) – The grid node (flat) index.

Returns:

neighbors (list) – A list of Neighbor instances.

Notes

For a RasterGrid, it is also possible to provide row and col indices as arguments, which returns a list of RasterNeighbor instances.

neighbors_count(idx: int) int

Returns the number of neighbors at a given node.

Parameters:

idx (int) – The grid node (flat) index.

neighbors_distances(idx: int) numpy.ndarray

Returns the distances from a given node to its neighbors.

Parameters:

idx (int) – The grid node (flat) index.

Returns:

distances (numpy.ndarray) – A 1-dimensional array of node distances (float). The neighbor order is the same than the one returned by neighbors_indices(idx).

neighbors_indices(idx: int) numpy.ndarray

Returns the (flat) indices of the neighbors of a given node.

Parameters:

idx (int) – The grid node (flat) index.

Returns:

indices (numpy.ndarray) – A 1-dimensional array of node (flat) indices (int).

Notes

For a RasterGrid, it is also possible to provide row and col indices as arguments.

nodes_areas(*args) float | numpy.ndarray

Returns the area of the direct vicinity of a given node or all nodes.

Overloaded method that supports the following signatures:

  1. nodes_areas() -> numpy.ndarray

  2. nodes_areas(idx: int) -> float

Parameters:

idx (int) – The grid node (flat) index.

nodes_indices(*args) numpy.ndarray

Returns the (flattened) indices of grid nodes, possibly filtered by node status.

Overloaded method that supports the following signatures:

  1. nodes_indices() -> numpy.ndarray

  2. nodes_indices(status: NodeStatus) -> numpy.ndarray

Parameters:

status (NodeStatus) – The status of the grid nodes to filter in.

Returns:

indices (numpy.ndarray) – A new, 1-dimensional array with grid node (filtered) flat indices.

nodes_lonlat(*args) tuple

Return the longitude and latitude coordinates of one or all grid nodes (HEALPix cell centroids), in radians.

Overloaded method that supports the following signatures:

  1. nodes_lonlat(idx: int) -> tuple[double, double]

  2. nodes_lonlat() -> tuple[numpy.ndarray, numpy.ndarray]

Parameters:

idx (int) – Grid node indice.

Returns:

lonlat (tuple) – Longitude and latitude coordinates (scalars or arrays) in radians.

nodes_status(*args) NodeStatus | numpy.ndarray

Returns the status of a given node or all nodes.

Overloaded method that supports the following signatures:

  1. nodes_status() -> numpy.ndarray

  2. nodes_status(idx: int) -> NodeStatus

Parameters:

idx (int) – The grid node (flat) index.

Returns:

status (NodeStatus or numpy.ndarray) – If an array is returned, it is a copy of the original array and has the NodeStatus enum class values (int) as values.

nodes_xyz(*args) tuple

Return the x,y,z cartesian coordinates of one or all grid nodes (HEALPix cell centroids).

Overloaded method that supports the following signatures:

  1. nodes_xyz(idx: int) -> tuple[double, double, double]

  2. nodes_xyz() -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Parameters:

idx (int) – Grid node indice.

Returns:

x, y, z (floats (scalar or arrays)) – X, Y and Z coordinates in the same scale and units than the grid’s sphere radius.

property nside

HEALPix’s Nside (number of division along the side of a HEALPix base-resolution pixel).

property radius

Sphere radius

property shape

Returns the shape of the grid node arrays.

property size

Returns the total number of grid nodes.