deltametrics.plan.compute_land_area

deltametrics.plan.compute_land_area(land_mask)

Compute land (delta) area.

Computes the land area for a LandMask as:

\[\sum_{i=1}^L \sum_{j=1}^W A_{ij}\]

where \(L\) and \(W\) are the mask dimensions, and \(A_{ij}\) is the area of each cell where \(A_{ij} =dx^2\) if the mask is True, otherwise \(A_{ij} = 0\).

Will return area with the same base units as the spatial coordinates of input array (i.e., for a Mask or xarray.DataArray). In the case of a numpy array without coordinates, a unit dimension is assumed for each cell.

Note

In implementation, this is a simple 1-liner summation over the mask. It is implemented as a function here for convenience and consistency in the api.

land_area = np.sum(land_mask.integer_mask) * dx * dx
Parameters:

land_mask (LandMask, ndarray) – Land mask. Can be a LandMask object, or a binarized array.

Returns:

land_area – Land area, computed as described above.

Return type:

float

Examples

golf = dm.sample_data.golf()

lm = dm.mask.LandMask(
    golf['eta'][-1, :, :],
    elevation_threshold=golf.meta['H_SL'][-1],
    elevation_offset=-0.5)

lm.trim_mask(length=golf.meta['L0'].data+1)

land_area = dm.plan.compute_land_area(lm)

fig, ax = plt.subplots()
lm.show(ax=ax, ticks=True)
ax.set_title(f'Land area is {land_area/1e6:.1f} km$^2$')
plt.show()

(png, hires.png)

../_images/deltametrics-plan-compute_land_area-1.png