# 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
    >>> data = np.arange(100)
    >>> sigma_clip = SigmaClip(sigma=3.0)
    >>> bkgrms = StdBackgroundRMS(sigma_clip)

    The background RMS value can be calculated by using the
    `calc_background_rms` method, e.g.:

    >>> bkgrms_value = bkgrms.calc_background_rms(data)
    >>> print(bkgrms_value)  # doctest: +FLOAT_CMP
    28.86607004772212

    Alternatively, the background RMS value can be calculated by calling
    the class instance as a function, e.g.:

    >>> bkgrms_value = bkgrms(data)
    >>> print(bkgrms_value)  # doctest: +FLOAT_CMP
    28.86607004772212
    """

    def calc_background_rms(self, data, axis=None, masked=False):
        if self.sigma_clip is not None:
            data = self.sigma_clip(data, axis=axis, masked=False)
        else:
            # convert to ndarray with masked values as np.nan
            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)

# 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

    >>> data = np.arange(100)
    >>> sigma_clip = SigmaClip(sigma=3.0)
    >>> bkgrms = StdBackgroundRMS(sigma_clip)

    The background RMS value can be calculated by using the
    `calc_background_rms` method, e.g.:

    >>> bkgrms_value = bkgrms.calc_background_rms(data)
    >>> print(bkgrms_value)  # doctest: +FLOAT_CMP
    28.86607004772212

    Alternatively, the background RMS value can be calculated by calling
    the class instance as a function, e.g.:

    >>> bkgrms_value = bkgrms(data)
    >>> print(bkgrms_value)  # doctest: +FLOAT_CMP
    28.86607004772212
    """

    def calc_background_rms(self, data, axis=None, masked=False):
        if self.sigma_clip is not None:
            data = self.sigma_clip(data, axis=axis, masked=False)
        else:
            # convert to ndarray with masked values as np.nan
            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)