def test_radial_profile_background(): """Test the radial profile function With background subtraction Cummulative pixels """ from astropy.convolution import Gaussian2DKernel data = Gaussian2DKernel(1.5, x_size=25, y_size=25) xx, yy = np.meshgrid(np.arange(25), np.arange(25)) x0, y0 = np.where(data.array == data.array.max()) rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2) rad_in = rad_in.ravel() flux_in = data.array.ravel() order = np.argsort(rad_in) rad_in = rad_in[order] flux_in = flux_in[order] plots = Imexamine() plots.set_data(data.array) # check the binned results plots.radial_profile_pars['pixels'][0] = False plots.radial_profile_pars['background'][0] = True rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False) good = np.where(rad_in <= np.max(rad_out)) rad_in = rad_in[good] flux_in = flux_in[good] flux_in = np.bincount(rad_in.astype(np.int), flux_in) assert_array_equal(np.arange(flux_in.size), rad_out) assert_allclose(flux_in - flux_out, flux_out * 0, atol=1e-5)
def test_radial_profile_background(): """Test the radial profile function with background subtraction""" from astropy.convolution import Gaussian2DKernel data = Gaussian2DKernel(1.5, x_size=25, y_size=25) plots = Imexamine() plots.set_data(data.array) # check the binned results plots.radial_profile_pars['pixels'][0] = False plots.radial_profile_pars['background'][0] = True x, y = plots.radial_profile(12, 12, genplot=False) rad = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] flux = [4.535423e-02, 3.007037e-01, 3.548898e-01, 1.958061e-01, 7.566620e-02, 2.469763e-02, 2.540733e-03, 1.518025e-04, 1.083221e-06, 3.605551e-10] assert_array_equal(rad, x) assert_allclose(flux, y, 1e-6)
def test_radial_profile_cumulative(): """Test the radial profile function without background subtraction with each pixel integer binned """ from astropy.convolution import Gaussian2DKernel ksize = 25 data = Gaussian2DKernel(1.5, x_size=ksize, y_size=ksize) xx, yy = np.meshgrid(np.arange(ksize), np.arange(ksize)) x0, y0 = np.where(data.array == data.array.max()) rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2) rad_in = rad_in.ravel() flux_in = data.array.ravel() indices = np.argsort(rad_in) rad_in = rad_in[indices] flux_in = flux_in[indices] # now bin the radflux like we expect rad_in = rad_in.astype(np.int) flux_in = np.bincount(rad_in, flux_in) / np.bincount(rad_in) rad_in = np.arange(len(flux_in)) assert (data.array[x0, y0] == flux_in[0]) # check the binned results plots = Imexamine() plots.set_data(data.array) plots.radial_profile_pars['pixels'][0] = False plots.radial_profile_pars['background'][0] = False plots.radial_profile_pars['clip'][0] = False rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False) # The default measurement size is not equal assert (len(rad_in) >= len(rad_out)) good = [rad_in[i] for i in rad_out if rad_out[i] == rad_in[i]] assert_array_equal(rad_in[good], rad_out[good]) assert_allclose(flux_in[good], flux_out[good], atol=1e-7)
def test_radial_profile_pixels(): """Test the radial profile function without background subtraction with each pixel unsummed """ from astropy.convolution import Gaussian2DKernel data = Gaussian2DKernel(1.5, x_size=25, y_size=25) xx, yy = np.meshgrid(np.arange(25), np.arange(25)) x0, y0 = np.where(data.array == data.array.max()) rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2) # It's going to crop things down apparently. plots = Imexamine() datasize = int(plots.radial_profile_pars["rplot"][0]) icentery = 12 icenterx = 12 rad_in = rad_in[icentery - datasize:icentery + datasize, icenterx - datasize:icenterx + datasize] flux_in = data.array[icentery - datasize:icentery + datasize, icenterx - datasize:icenterx + datasize] rad_in = rad_in.ravel() flux_in = flux_in.ravel() order = np.argsort(rad_in) rad_in = rad_in[order] flux_in = flux_in[order] plots.set_data(data.array) # check the unbinned results plots.radial_profile_pars['pixels'][0] = True out_radius, out_flux = plots.radial_profile(x0, y0, genplot=False) good = np.where(rad_in <= np.max(out_radius)) rad_in = rad_in[good] flux_in = flux_in[good] assert_allclose(rad_in, out_radius, 1e-7) assert_allclose(flux_in, out_flux, 1e-7)
def test_radial_profile(): """Test the radial profile function No background subtraction individual pixel results used """ from astropy.convolution import Gaussian2DKernel data = Gaussian2DKernel(1.5, x_size=25, y_size=25) xx, yy = np.meshgrid(np.arange(25), np.arange(25)) x0, y0 = np.where(data.array == data.array.max()) rad_in = np.sqrt((xx - x0)**2 + (yy - y0)**2) rad_in = rad_in.ravel() flux_in = data.array.ravel() order = np.argsort(rad_in) rad_in = rad_in[order] flux_in = flux_in[order] plots = Imexamine() plots.set_data(data.array) plots.radial_profile_pars['pixels'][0] = True plots.radial_profile_pars['background'][0] = False plots.radial_profile_pars['clip'][0] = False rad_out, flux_out = plots.radial_profile(x0, y0, genplot=False) order2 = np.argsort(rad_out) rad_out = rad_out[order2] flux_out = flux_out[order2] # the radial profile is done on a smaller cutout by default # and may have a fractional center radius calculation. This # looks at the first few hundred data points in both arrays assert (len(rad_out) < len(rad_in)) good = 150 assert_allclose(rad_in[:good], rad_out[:good], atol=1e-14) assert_allclose(flux_in[:good], flux_out[:good], atol=1e-14)
def test_radial_profile_pixels(): """Test the radial profile function without background subtraction""" from astropy.convolution import Gaussian2DKernel data = Gaussian2DKernel(1.5, x_size=25, y_size=25) plots = Imexamine() plots.set_data(data.array) # check the unbinned results plots.radial_profile_pars['pixels'][0] = True x, y = plots.radial_profile(12, 12, genplot=False) rad = [1.00485917e-14, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.41421356e+00, 1.41421356e+00, 1.41421356e+00, 1.41421356e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.23606798e+00, 2.82842712e+00, 2.82842712e+00, 2.82842712e+00, 2.82842712e+00, 3.00000000e+00, 3.00000000e+00, 3.00000000e+00, 3.00000000e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.16227766e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 3.60555128e+00, 4.00000000e+00, 4.00000000e+00, 4.00000000e+00, 4.00000000e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.12310563e+00, 4.24264069e+00, 4.24264069e+00, 4.24264069e+00, 4.24264069e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 4.47213595e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.00000000e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.09901951e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.38516481e+00, 5.65685425e+00, 5.65685425e+00, 5.65685425e+00, 5.65685425e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 5.83095189e+00, 6.00000000e+00, 6.00000000e+00, 6.00000000e+00, 6.00000000e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.08276253e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.32455532e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.40312424e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 6.70820393e+00, 7.00000000e+00, 7.00000000e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.07106781e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.21110255e+00, 7.28010989e+00, 7.28010989e+00, 7.28010989e+00, 7.28010989e+00, 7.61577311e+00, 7.61577311e+00, 7.61577311e+00, 7.61577311e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 7.81024968e+00, 8.06225775e+00, 8.06225775e+00, 8.06225775e+00, 8.06225775e+00, 8.48528137e+00, 8.48528137e+00, 8.48528137e+00, 8.48528137e+00, 8.60232527e+00, 8.60232527e+00, 8.60232527e+00, 8.60232527e+00, 9.21954446e+00, 9.21954446e+00, 9.21954446e+00, 9.21954446e+00, 9.89949494e+00] flux = [1.19552465e-02, 2.32856406e-02, 2.32856406e-02, 3.93558331e-03, 3.93558331e-03, 4.53542348e-02, 7.66546959e-03, 7.66546959e-03, 1.29556643e-03, 2.90802459e-02, 2.90802459e-02, 8.30691786e-04, 8.30691786e-04, 5.66405848e-02, 5.66405848e-02, 9.57301302e-03, 9.57301302e-03, 1.61796667e-03, 1.61796667e-03, 2.73457911e-04, 2.73457911e-04, 7.07355303e-02, 2.02059585e-03, 2.02059585e-03, 5.77193322e-05, 2.32856406e-02, 2.32856406e-02, 1.12421908e-04, 1.12421908e-04, 4.53542348e-02, 4.53542348e-02, 7.66546959e-03, 7.66546959e-03, 2.18967977e-04, 2.18967977e-04, 3.70085038e-05, 3.70085038e-05, 5.66405848e-02, 5.66405848e-02, 1.61796667e-03, 1.61796667e-03, 2.73457911e-04, 2.73457911e-04, 7.81146217e-06, 7.81146217e-06, 1.19552465e-02, 1.19552465e-02, 9.75533570e-06, 9.75533570e-06, 2.32856406e-02, 2.32856406e-02, 3.93558331e-03, 3.93558331e-03, 1.90007994e-05, 1.90007994e-05, 3.21138811e-06, 3.21138811e-06, 4.53542348e-02, 2.18967977e-04, 2.18967977e-04, 1.05716645e-06, 2.90802459e-02, 2.90802459e-02, 8.30691786e-04, 8.30691786e-04, 2.37291269e-05, 2.37291269e-05, 6.77834392e-07, 6.77834392e-07, 2.32856406e-02, 2.32856406e-02, 3.93558331e-03, 3.93558331e-03, 1.12421908e-04, 1.12421908e-04, 1.90007994e-05, 1.90007994e-05, 5.42767351e-07, 5.42767351e-07, 9.17349095e-08, 9.17349095e-08, 7.66546959e-03, 7.66546959e-03, 1.29556643e-03, 1.29556643e-03, 1.05716645e-06, 1.05716645e-06, 1.78675206e-07, 1.78675206e-07, 9.57301302e-03, 9.57301302e-03, 2.73457911e-04, 2.73457911e-04, 1.32024112e-06, 1.32024112e-06, 3.77133487e-08, 3.77133487e-08, 1.19552465e-02, 9.75533570e-06, 9.75533570e-06, 7.96023526e-09, 7.66546959e-03, 7.66546959e-03, 3.70085038e-05, 3.70085038e-05, 1.05716645e-06, 1.05716645e-06, 5.10394673e-09, 5.10394673e-09, 8.30691786e-04, 8.30691786e-04, 1.93626789e-08, 1.93626789e-08, 1.61796667e-03, 1.61796667e-03, 2.73457911e-04, 2.73457911e-04, 3.77133487e-08, 3.77133487e-08, 6.37405811e-09, 6.37405811e-09, 2.02059585e-03, 2.02059585e-03, 5.77193322e-05, 5.77193322e-05, 4.70982729e-08, 4.70982729e-08, 1.34538575e-09, 1.34538575e-09, 3.93558331e-03, 3.93558331e-03, 3.21138811e-06, 3.21138811e-06, 5.42767351e-07, 5.42767351e-07, 4.42891556e-10, 4.42891556e-10, 1.61796667e-03, 1.61796667e-03, 7.81146217e-06, 7.81146217e-06, 3.77133487e-08, 3.77133487e-08, 1.82078162e-10, 1.82078162e-10, 1.12421908e-04, 1.12421908e-04, 1.29556643e-03, 2.18967977e-04, 2.18967977e-04, 3.70085038e-05, 3.70085038e-05, 1.78675206e-07, 1.78675206e-07, 2.46415996e-11, 8.30691786e-04, 8.30691786e-04, 6.77834392e-07, 6.77834392e-07, 1.93626789e-08, 1.93626789e-08, 1.57997104e-11, 1.57997104e-11, 2.73457911e-04, 2.73457911e-04, 7.81146217e-06, 7.81146217e-06, 2.18967977e-04, 2.18967977e-04, 1.05716645e-06, 1.05716645e-06, 2.73457911e-04, 2.73457911e-04, 3.77133487e-08, 3.77133487e-08, 6.37405811e-09, 6.37405811e-09, 8.79064260e-13, 8.79064260e-13, 1.12421908e-04, 1.12421908e-04, 9.17349095e-08, 9.17349095e-08, 5.77193322e-05, 1.34538575e-09, 1.34538575e-09, 3.13597326e-14, 3.70085038e-05, 3.70085038e-05, 5.10394673e-09, 5.10394673e-09, 7.81146217e-06, 7.81146217e-06, 1.82078162e-10, 1.82078162e-10, 1.05716645e-06] assert_allclose(rad, x, 1e-7) assert_allclose(flux, y, 1e-7)