regionmask.Regions_cls.mask

Regions_cls.mask(lon_or_obj, lat=None, lon_name='lon', lat_name='lat', xarray=None, wrap_lon=False)

create a grid as mask of a set of regions for given lat/ lon grid

Parameters:

lon_or_obj : array_like or object

Can either be (1) a longitude array and then lat needs to be given. Or an object where the longitude and latitude can be retrived as: lon = lon_or_obj[lon_name] lat = lon_or_obj[lat_name]

lat : array_like, (optional)

If ‘lon_or_obj’ is a longitude array, the latitude needs to be specified here.

lon_name, optional

Name of longitude in ‘lon_or_obj’. Default: ‘lon’.

lat_name, optional

Name of latgitude in ‘lon_or_obj’. Default: ‘lat’

xarray : bool or None, optional

If True returns an xarray DataArray, if False returns a numpy ndarray. If None, checks if xarray can be imported and if yes returns a xarray DataArray else a numpy ndarray. Default: None.

wrap_lon : bool | 180 | 360, optional

If the regions and the provided longitude do not have the same base (i.e. one is -180..180 and the other 0..360) one of them must be wrapped around. This can be done with wrap_lon. If wrap_lon is False, nothing is done. If wrap_lon is True, longitude data is wrapped to 360 if its minimum is smaller than 0 and wrapped to 180 if its maximum is larger than 180.

Returns:

mask : ndarray or xarray DataSet