pysteps.utils.dimension.square_domain

pysteps.utils.dimension.square_domain(R, metadata, method='pad', inverse=False)

Either pad or crop a field to obtain a square domain.

Parameters:
R : array-like

Array of shape (m,n) or (t,m,n) containing the input fields.

metadata : dict

Metadata dictionary containing the x1, x2, y1, y2, xpixelsize, ypixelsize, attributes as described in the documentation of pysteps.io.importers.

method : {‘pad’, ‘crop’}, optional

Either pad or crop. If pad, an equal number of zeros is added to both ends of its shortest side in order to produce a square domain. If crop, an equal number of pixels is removed to both ends of its longest side in order to produce a square domain. Note that the crop method involves an irreversible loss of data.

inverse : bool, optional

Perform the inverse method to recover the original domain shape. After a crop, the inverse is performed by padding the field with zeros.

Returns:
R : array-like

the reshape dataset

metadata : dict

the metadata with updated attributes.