easyclimate.filter.mask

Custom mask methods

Functions

mask_custom_rectangular_box(da, lon1, lon2, lat1, lat2)

Generate a mask for a custom geographical rectangular box with optional rotation.

Module Contents

easyclimate.filter.mask.mask_custom_rectangular_box(da: xarray.DataArray, lon1: float, lon2: float, lat1: float, lat2: float, angle: float = 0.0, center: Literal['center', 'lowerleft'] = 'center', use_coslat: bool = True, lat_dim: str = 'lat', lon_dim: str = 'lon')

Generate a mask for a custom geographical rectangular box with optional rotation.

Parameters

daxarray.DataArray

Input data array containing latitude and longitude coordinates. The mask is generated on the horizontal grid defined by lat_dim and lon_dim.

lon1, lon2: float.

Rectangular box longitude point. The applicable value should be between -180 \(^\circ\) and 360 \(^\circ\). lon1 and lon2 are used to define the unrotated box extent, and do not strictly require the size relationship between them.

lat1, lat2: float.

Rectangular box latitude point. The applicable value should be between -90 \(^\circ\) and 90 \(^\circ\). lat1 and lat2 are used to define the unrotated box extent, and do not strictly require the size relationship between them.

angle: float, default: 0.0.

Counterclockwise rotation angle in degrees.

center: str, default: “center”.

Rotation pivot of the rectangular box.

  • “center”: rotate around the box center.

  • “lowerleft”: rotate around the lower-left corner of the box.

use_coslat: bool, default: True.

Whether to apply local geographical metric correction before rotation. If True, longitude is scaled by \(\cos(lat0)\) using the selected pivot latitude so that longitude and latitude have a locally comparable distance scale.

lat_dim: str, default: “lat”.

Name of the latitude coordinate in da.

lon_dim: str, default: “lon”.

Name of the longitude coordinate in da.

Returns

maskxarray.DataArray

Boolean mask on the same horizontal grid as da, where values are True inside the rotated rectangular box and False outside.