# Path: photutils/background/_utils.py
# def nanmean(array, axis=None):
#     """
#     A nanmean function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanmean(array, axis=axis))
#         else:
#             return bn.nanmean(array, axis=axis)
#     else:
#         return np.nanmean(array, axis=axis)
# 
# def nanmedian(array, axis=None):
#     """
#     A nanmedian function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanmedian(array, axis=axis))
#         else:
#             return bn.nanmedian(array, axis=axis)
#     else:
#         return np.nanmedian(array, axis=axis)
# 
# def nanstd(array, axis=None, ddof=0):
#     """
#     A nanstd function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanstd(array, axis=axis, ddof=ddof))
#         else:
#             return bn.nanstd(array, axis=axis, ddof=ddof)
#     else:
#         return np.nanstd(array, axis=axis, ddof=ddof)


import abc
import warnings
import numpy as np
from astropy.stats import (biweight_location, biweight_scale, mad_std,
                           SigmaClip)
from ._utils import nanmean, nanmedian, nanstd
            if isinstance(data, np.ma.MaskedArray):
                data = data.filled(np.nan)

        # ignore RuntimeWarning where axis is all NaN
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', RuntimeWarning)
            result = nanstd(data, axis=axis)

        if masked and isinstance(result, np.ndarray):
            result = np.ma.masked_where(np.isnan(result), result)

        return result


class MADStdBackgroundRMS(BackgroundRMSBase):
    r"""
    Class to calculate the background RMS in an array as using the
    `median absolute deviation (MAD)
    <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_.

    The standard deviation estimator is given by:

    .. math::

        \sigma \approx \frac{{\textrm{{MAD}}}}{{\Phi^{{-1}}(3/4)}}
            \approx 1.4826 \ \textrm{{MAD}}

    where :math:`\Phi^{{-1}}(P)` is the normal inverse cumulative
    distribution function evaluated at probability :math:`P = 3/4`.


# Path: photutils/background/_utils.py
# def nanmean(array, axis=None):
#     """
#     A nanmean function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanmean(array, axis=axis))
#         else:
#             return bn.nanmean(array, axis=axis)
#     else:
#         return np.nanmean(array, axis=axis)
# 
# def nanmedian(array, axis=None):
#     """
#     A nanmedian function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanmedian(array, axis=axis))
#         else:
#             return bn.nanmedian(array, axis=axis)
#     else:
#         return np.nanmedian(array, axis=axis)
# 
# def nanstd(array, axis=None, ddof=0):
#     """
#     A nanstd function that uses bottleneck if available.
#     """
#     if HAS_BOTTLENECK:
#         if isinstance(axis, tuple):
#             array = move_tuple_axes_first(array, axis=axis)
#             axis = 0
# 
#         if isinstance(array, u.Quantity):
#             return array.__array_wrap__(bn.nanstd(array, axis=axis, ddof=ddof))
#         else:
#             return bn.nanstd(array, axis=axis, ddof=ddof)
#     else:
#         return np.nanstd(array, axis=axis, ddof=ddof)


# Path: photutils/background/core.py
import abc
import warnings
import numpy as np
from astropy.stats import (biweight_location, biweight_scale, mad_std,
                           SigmaClip)
from ._utils import nanmean, nanmedian, nanstd

            if isinstance(data, np.ma.MaskedArray):
                data = data.filled(np.nan)

        # ignore RuntimeWarning where axis is all NaN
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', RuntimeWarning)
            result = nanstd(data, axis=axis)

        if masked and isinstance(result, np.ndarray):
            result = np.ma.masked_where(np.isnan(result), result)

        return result


class MADStdBackgroundRMS(BackgroundRMSBase):
    r"""
    Class to calculate the background RMS in an array as using the
    `median absolute deviation (MAD)
    <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_.

    The standard deviation estimator is given by:

    .. math::

        \sigma \approx \frac{{\textrm{{MAD}}}}{{\Phi^{{-1}}(3/4)}}
            \approx 1.4826 \ \textrm{{MAD}}

    where :math:`\Phi^{{-1}}(P)` is the normal inverse cumulative
    distribution function evaluated at probability :math:`P = 3/4`.


    Parameters