'Parameters
model : `~astropy.modeling.FittableModel`
An analytic model which will be fit to the provided data.
This also contains the initial guess for an optimization
algorithm.
x : array-like
Input coordinates.
y : array-like
Data measurements (1D case) or input coordinates (2D case).
z : array-like (optional)
Data measurements (2D case).
weights : array-like (optional)
Weights to be passed to the fitter.
kwargs : dict (optional)
Keyword arguments to be passed to the fitter.
Returns
filtered_data : numpy.ma.core.MaskedArray
Data used to perform the fitting after outlier removal.
fitted_model : `~astropy.modeling.FittableModel`
Fitted model after outlier removal.'

def __call__(self, model, x, y, z=None, weights=None, **kwargs):

    fitted_model = self.fitter(model, x, y, z, weights=weights, **kwargs)
    if (z is None):
        filtered_data = y
        for n in range(self.niter):
            filtered_data = self.outlier_func((filtered_data - fitted_model(x)), **self.outlier_kwargs)
            filtered_data += fitted_model(x)
            fitted_model = self.fitter(fitted_model, x[(~ filtered_data.mask)], filtered_data.data[(~ filtered_data.mask)], **kwargs)
    else:
        filtered_data = z
        for n in range(self.niter):
            filtered_data = self.outlier_func((filtered_data - fitted_model(x, y)), **self.outlier_kwargs)
            filtered_data += fitted_model(x, y)
            fitted_model = self.fitter(fitted_model, x[(~ filtered_data.mask)], y[(~ filtered_data.mask)], filtered_data.data[(~ filtered_data.mask)], **kwargs)
    return (filtered_data, fitted_model)
