MCPcopy Create free account
hub / github.com/NCAR/wrf-python / smooth2d

Function smooth2d

src/wrf/computation.py:681–732  ·  view source on GitHub ↗

Return the field smoothed. The smoothing kernel applied is: .. math:: \\frac{1}{4 + cenweight} * \\begin{bmatrix} 0 & 1 & 0 \\\\ 1 & cenweight & 1 \\\\ 0 & 1 & 0

(field, passes, cenweight=2.0, meta=True)

Source from the content-addressed store, hash-verified

679
680@set_smooth_metdata()
681def smooth2d(field, passes, cenweight=2.0, meta=True):
682 """Return the field smoothed.
683
684 The smoothing kernel applied is:
685
686 .. math::
687
688 \\frac{1}{4 + cenweight} * \\begin{bmatrix}
689 0 & 1 & 0 \\\\
690 1 & cenweight & 1 \\\\
691 0 & 1 & 0
692 \\end{bmatrix}
693
694 Data values along the borders are left unchanged. This routine does not
695 modify the original data supplied by the *field* parameter..
696
697 If you need more general purpose multidimensional filtering tools,
698 try the :meth:`scipy.ndimage.convolve` method.
699
700 Args:
701
702 field (:class:`xarray.DataArray` or :class:`numpy.ndarray`): The field
703 to smooth, which must be at least two dimensions. Missing/fill
704 values will be ignored as long as the type is either a
705 :class:`numpy.ma.MaskedArray` or a :class:`xarray.DataArray` with
706 a *_FillValue* attribute.
707
708 passes (:obj:`int`): The number of smoothing passes.
709
710 cenweight (:obj:`float`, optional): The weight to apply to the
711 center of the smoothing kernel. Default is 2.0.
712
713 meta (:obj:`bool`): Set to False to disable metadata and return
714 :class:`numpy.ndarray` instead of
715 :class:`xarray.DataArray`. Default is True.
716
717 Returns:
718
719 :class:`xarray.DataArray`, :class:`numpy.ma.MaskedArray` or \
720 :class:`numpy.ndarray`): The smoothed field. If xarray is enabled and
721 the *meta* parameter is True, then the result will be an
722 :class:`xarray.DataArray` object. Otherwise, the result will
723 be either a :class:`numpy.ndarray` or a :class:`numpy.ma.MaskedArray`
724 depending on the type for *field*.
725
726 See Also:
727
728 :meth:`scipy.ndimage.convolve`
729
730
731 """
732 return _smooth2d(field, passes, cenweight)
733
734
735@set_cape_alg_metadata(is2d=True, copyarg="pres_hpa")

Callers

nothing calls this directly

Calls 1

_smooth2dFunction · 0.85

Tested by

no test coverage detected