# Path: ccdproc/core.py
# def ccd_process(ccd, oscan=None, trim=None, error=False, master_bias=None,
#                 dark_frame=None, master_flat=None, bad_pixel_mask=None,
#                 gain=None, readnoise=None, oscan_median=True, oscan_model=None,
#                 min_value=None, dark_exposure=None, data_exposure=None,
#                 exposure_key=None, exposure_unit=None,
#                 dark_scale=False, gain_corrected=True):
# def create_deviation(ccd_data, gain=None, readnoise=None, disregard_nan=False):
# def subtract_overscan(ccd, overscan=None, overscan_axis=1, fits_section=None,
#                       median=False, model=None):
# def trim_image(ccd, fits_section=None):
# def subtract_bias(ccd, master):
# def subtract_dark(ccd, master, dark_exposure=None, data_exposure=None,
#                   exposure_time=None, exposure_unit=None,
#                   scale=False):
# def gain_correct(ccd, gain, gain_unit=None):
# def flat_correct(ccd, flat, min_value=None, norm_value=None):
# def transform_image(ccd, transform_func, **kwargs):
# def wcs_project(ccd, target_wcs, target_shape=None, order='bilinear'):
# def sigma_func(arr, axis=None, ignore_nan=False):
# def setbox(x, y, mbox, xmax, ymax):
# def background_deviation_box(data, bbox):
# def background_deviation_filter(data, bbox):
# def rebin(ccd, newshape):
# def block_reduce(ccd, block_size, func=np.sum):
# def block_average(ccd, block_size):
# def block_replicate(ccd, block_size, conserve_sum=True):
# def _blkavg(data, newshape):
# def median_filter(data, *args, **kwargs):
# def cosmicray_lacosmic(ccd, sigclip=4.5, sigfrac=0.3,
#                        objlim=5.0, gain=1.0, readnoise=6.5,
#                        satlevel=65535.0, pssl=0.0, niter=4,
#                        sepmed=True, cleantype='meanmask', fsmode='median',
#                        psfmodel='gauss', psffwhm=2.5, psfsize=7,
#                        psfk=None, psfbeta=4.765, verbose=False,
#                        gain_apply=True,
#                        inbkg=None, invar=None):
# def _astroscrappy_gain_apply_helper(cleaned_data, gain,
#                                     gain_apply, old_interface):
# def cosmicray_median(ccd, error_image=None, thresh=5, mbox=11, gbox=0,
#                      rbox=0):
# def ccdmask(ratio, findbadcolumns=False, byblocks=False, ncmed=7, nlmed=7,
#             ncsig=15, nlsig=15, lsigma=9, hsigma=9, ngood=5):
#     def _sigma_mask(baseline, one_sigma_value, lower_sigma, upper_sigma):
# def bitfield_to_boolean_mask(bitfield, ignore_bits=0, flip_bits=None):
#     def __init__(self, name, unit=None, value=None):
#     def name(self):
#     def unit(self):
#     def value(self):
#     def value(self, value):
#     def value_from(self, header):
# class Keyword:


import numpy as np
from astropy.nddata import StdDevUncertainty, CCDData
from scipy import ndimage
from ccdproc import core
# Licensed under a 3-clause BSD style license - see LICENSE.rst






def test_medianfilter_correct():
    ccd = CCDData([[2, 6, 6, 1, 7, 2, 4, 5, 9, 1],
                   [10, 10, 9, 0, 2, 10, 8, 3, 9, 7],
                   [2, 4, 0, 4, 4, 10, 0, 5, 6, 5],
                   [7, 10, 8, 7, 7, 0, 5, 3, 5, 9],
                   [9, 6, 3, 8, 6, 9, 2, 8, 10, 10],
                   [6, 5, 1, 7, 8, 0, 8, 2, 9, 3],
                   [0, 6, 0, 6, 3, 10, 8, 9, 7, 8],
                   [5, 8, 3, 2, 3, 0, 2, 0, 3, 5],
                   [9, 6, 3, 7, 1, 0, 5, 4, 8, 3],
                   [5, 6, 9, 9, 0, 4, 9, 1, 7, 8]], unit='adu')

# Path: ccdproc/core.py
# def ccd_process(ccd, oscan=None, trim=None, error=False, master_bias=None,
#                 dark_frame=None, master_flat=None, bad_pixel_mask=None,
#                 gain=None, readnoise=None, oscan_median=True, oscan_model=None,
#                 min_value=None, dark_exposure=None, data_exposure=None,
#                 exposure_key=None, exposure_unit=None,
#                 dark_scale=False, gain_corrected=True):
# def create_deviation(ccd_data, gain=None, readnoise=None, disregard_nan=False):
# def subtract_overscan(ccd, overscan=None, overscan_axis=1, fits_section=None,
#                       median=False, model=None):
# def trim_image(ccd, fits_section=None):
# def subtract_bias(ccd, master):
# def subtract_dark(ccd, master, dark_exposure=None, data_exposure=None,
#                   exposure_time=None, exposure_unit=None,
#                   scale=False):
# def gain_correct(ccd, gain, gain_unit=None):
# def flat_correct(ccd, flat, min_value=None, norm_value=None):
# def transform_image(ccd, transform_func, **kwargs):
# def wcs_project(ccd, target_wcs, target_shape=None, order='bilinear'):
# def sigma_func(arr, axis=None, ignore_nan=False):
# def setbox(x, y, mbox, xmax, ymax):
# def background_deviation_box(data, bbox):
# def background_deviation_filter(data, bbox):
# def rebin(ccd, newshape):
# def block_reduce(ccd, block_size, func=np.sum):
# def block_average(ccd, block_size):
# def block_replicate(ccd, block_size, conserve_sum=True):
# def _blkavg(data, newshape):
# def median_filter(data, *args, **kwargs):
# def cosmicray_lacosmic(ccd, sigclip=4.5, sigfrac=0.3,
#                        objlim=5.0, gain=1.0, readnoise=6.5,
#                        satlevel=65535.0, pssl=0.0, niter=4,
#                        sepmed=True, cleantype='meanmask', fsmode='median',
#                        psfmodel='gauss', psffwhm=2.5, psfsize=7,
#                        psfk=None, psfbeta=4.765, verbose=False,
#                        gain_apply=True,
#                        inbkg=None, invar=None):
# def _astroscrappy_gain_apply_helper(cleaned_data, gain,
#                                     gain_apply, old_interface):
# def cosmicray_median(ccd, error_image=None, thresh=5, mbox=11, gbox=0,
#                      rbox=0):
# def ccdmask(ratio, findbadcolumns=False, byblocks=False, ncmed=7, nlmed=7,
#             ncsig=15, nlsig=15, lsigma=9, hsigma=9, ngood=5):
#     def _sigma_mask(baseline, one_sigma_value, lower_sigma, upper_sigma):
# def bitfield_to_boolean_mask(bitfield, ignore_bits=0, flip_bits=None):
#     def __init__(self, name, unit=None, value=None):
#     def name(self):
#     def unit(self):
#     def value(self):
#     def value(self, value):
#     def value_from(self, header):
# class Keyword:


# Path: ccdproc/tests/test_wrapped_external_funcs.py
import numpy as np
from astropy.nddata import StdDevUncertainty, CCDData
from scipy import ndimage
from ccdproc import core

# Licensed under a 3-clause BSD style license - see LICENSE.rst






def test_medianfilter_correct():
    ccd = CCDData([[2, 6, 6, 1, 7, 2, 4, 5, 9, 1],
                   [10, 10, 9, 0, 2, 10, 8, 3, 9, 7],
                   [2, 4, 0, 4, 4, 10, 0, 5, 6, 5],
                   [7, 10, 8, 7, 7, 0, 5, 3, 5, 9],
                   [9, 6, 3, 8, 6, 9, 2, 8, 10, 10],
                   [6, 5, 1, 7, 8, 0, 8, 2, 9, 3],
                   [0, 6, 0, 6, 3, 10, 8, 9, 7, 8],
                   [5, 8, 3, 2, 3, 0, 2, 0, 3, 5],
                   [9, 6, 3, 7, 1, 0, 5, 4, 8, 3],
                   [5, 6, 9, 9, 0, 4, 9, 1, 7, 8]], unit='adu')

    result = core.median_filter(ccd, 3)