def smoothing(self, f, w, sm, smtol, gstol):
        """
        Smooths a surface f by choosing nodal function values and gradients to
        minimize the linearized curvature of F subject to a bound on the
        deviation from the data values. This is more appropriate than interpolation
        when significant errors are present in the data.

        Parameters
        ----------
         f : array of floats, shape (n,)
            field to apply smoothing on
         w : array of floats, shape (n,)
            weights associated with data value in f
            w[i] = 1/sigma_f^2 is a good rule of thumb.
         sm : float
            positive parameter specifying an upper bound on Q2(f).
            generally n-sqrt(2n) <= sm <= n+sqrt(2n)
         smtol : float
            specifies relative error in satisfying the constraint
            sm(1-smtol) <= Q2 <= sm(1+smtol) between 0 and 1.
         gstol : float
            tolerance for convergence.
            gstol = 0.05*mean(sigma_f)^2 is a good rule of thumb.

        Returns
        -------
         f_smooth : array of floats, shape (n,)
            smoothed version of f
         (dfdx, dfdy, dfdz) : tuple of floats, tuple of 3 shape (n,) arrays
            first derivatives of f_smooth in the x, y, and z directions
        """

        if f.size != self.npoints or f.size != w.size:
            raise ValueError('f and w should be the same size as mesh')

        f, w = self._shuffle_field(f, w)

        sigma = 0
        iflgs = 0
        prnt = -1

        f_smooth, df, ierr = _ssrfpack.smsurf(self._x, self._y, self._z, f, self.lst, self.lptr, self.lend,\
                                             iflgs, sigma, w, sm, smtol, gstol, prnt)

        if ierr < 0:
            raise ValueError('ierr={} in gradg\n{}'.format(ierr, _ier_codes[ierr]))
        if ierr == 1:
            raise RuntimeWarning("No errors were encountered but the constraint is not active --\n\
                  F, FX, and FY are the values and partials of a linear function \
                  which minimizes Q2(F), and Q1 = 0.")
        if ierr == 2:
            raise RuntimeWarning("The constraint could not be satisfied to within SMTOL\
                  due to ill-conditioned linear systems.")

        return self._deshuffle_field(f_smooth), self._deshuffle_field(df[0], df[1], df[2])
def smoothing ( self , f , w , sm , smtol , gstol ) : if f . size != self . npoints or f . size != w . size : raise ValueError ( 'f and w should be the same size as mesh' ) f , w = self . _shuffle_field ( f , w ) sigma = 0 iflgs = 0 prnt = - 1 f_smooth , df , ierr = _ssrfpack . smsurf ( self . _x , self . _y , self . _z , f , self . lst , self . lptr , self . lend , iflgs , sigma , w , sm , smtol , gstol , prnt ) if ierr < 0 : raise ValueError ( 'ierr={} in gradg\n{}' . format ( ierr , _ier_codes [ ierr ] ) ) if ierr == 1 : raise RuntimeWarning ( "No errors were encountered but the constraint is not active --\n\
                  F, FX, and FY are the values and partials of a linear function \
                  which minimizes Q2(F), and Q1 = 0." ) if ierr == 2 : raise RuntimeWarning ( "The constraint could not be satisfied to within SMTOL\
                  due to ill-conditioned linear systems." ) return self . _deshuffle_field ( f_smooth ) , self . _deshuffle_field ( df [ 0 ] , df [ 1 ] , df [ 2 ] )
Smooths a surface f by choosing nodal function values and gradients to
        minimize the linearized curvature of F subject to a bound on the
        deviation from the data values. This is more appropriate than interpolation
        when significant errors are present in the data.

        Parameters
        ----------
         f : array of floats, shape (n,)
            field to apply smoothing on
         w : array of floats, shape (n,)
            weights associated with data value in f
            w[i] = 1/sigma_f^2 is a good rule of thumb.
         sm : float
            positive parameter specifying an upper bound on Q2(f).
            generally n-sqrt(2n) <= sm <= n+sqrt(2n)
         smtol : float
            specifies relative error in satisfying the constraint
            sm(1-smtol) <= Q2 <= sm(1+smtol) between 0 and 1.
         gstol : float
            tolerance for convergence.
            gstol = 0.05*mean(sigma_f)^2 is a good rule of thumb.

        Returns
        -------
         f_smooth : array of floats, shape (n,)
            smoothed version of f
         (dfdx, dfdy, dfdz) : tuple of floats, tuple of 3 shape (n,) arrays
            first derivatives of f_smooth in the x, y, and z directions