integ_gaussian2D_erf#
- integ_gaussian2D_erf(xy_edges, sigma, mu=(0, 0), normed=True)[source]#
Return a 2D Gaussian integrated over pixels (exact).
The Gaussian is aligned with the x and y axes (no rotation), and the integral over each pixel is computed analytically with the error function.
- Parameters:
xy_edges (
tupleofnumpy.ndarray) –(x_edges, y_edges)coordinates of the pixel edges, as an “open” mesh-grid of shapes(1, nx+1)and(ny+1, 1)(seenumpy.ogrid).sigma (array_like) – Gaussian standard deviations, in the same units as
xy_edges, of shape(..., 2)with the last axis being(sigma_y, sigma_x). A 2D input of shape(nsig, 2)is reshaped as(nsig, 1, 2).mu (
tupleoffloator array_like, optional) –(x, y)center of the 2D Gaussian; it must broadcast to the shape ofsigma. Default is (0, 0).normed (
bool, optional) – If True, use a unit-integral Gaussian; otherwise use a Gaussian of unit peak amplitude. Default is True.
- Returns:
numpy.ndarray– Integrated Gaussian of shape(ny, nx)for a singlesigma, or(nsig, ny, nx)forsigmaof shape(nsig, 2)or(nsig, 1, 2).- Raises:
NotImplementedError – If
xy_edgesis not an open mesh-grid.
Examples
>>> y, x = np.ogrid[-5:5.1, -6:6.1] >>> pixels = integ_gaussian2D_erf((x, y), sigma=[1, 1]) >>> pixels.shape (10, 12) >>> np.isclose(pixels.sum(), 1) np.True_ >>> integ_gaussian2D_erf((x, y), sigma=[[1, 1], [2, 2], [3, 3]]).shape (3, 10, 12)