def find_completeness(target, comp_val, ast_kw=None): ast_kw = ast_kw or {} ast_kw = dict({'combined_filters': True, 'interpolate': True}.items() + ast_kw.items()) ast_dict = {} fake_files = galaxy_tests.get_fake_files(target) for band, fake_file in zip(['opt', 'ir'], fake_files): asts = rsp.Galaxies.artificial_star_tests(fake_file) asts.completeness(**ast_kw) (ast_dict['%s_filter1' % band], ast_dict['%s_filter2' % band]) = \ asts.get_completeness_fraction(comp_val) return ast_dict
def completeness_below_trgb(): targets = galaxy_tests.ancients() ast_kw = {'combined_filters': True, 'interpolate': True} for target in targets: fake_files = galaxy_tests.get_fake_files(target) for band, fake_file in zip(['opt', 'ir'], fake_files): if band == 'opt': fits_src = snap_src + '/data/angst_no_trim' else: continue fits_src = 'default' gal = galaxy_tests.load_galaxy(target, band=band, fits_src=fits_src) gal.make_hess(binsize=0.1, hess_kw={'cbinsize': 0.05}) asts = rsp.Galaxies.artificial_star_tests(fake_file) asts.completeness(**ast_kw) imag, icol = np.argwhere(gal.hess[2] == gal.hess[2].max())[0] rc_mag2 = gal.hess[1][imag] comp = asts.fcomp2(rc_mag2 - 1.) print '%s %s %.3f %.3f' % (target, band, rc_mag2, comp)
def completeness_corrections(dmag=0.1): ''' get the completeness fraction for a given list of magnitudes. mag_bins can be either mag1 or mag2, will return both completeness fractions. ''' ags = load_default_ancient_galaxies() ast_kw = {'combined_filters': True, 'interpolate': True} ast_dict = {} for i, target in enumerate(ags.data.target): fake_files = galaxy_tests.get_fake_files(target) ast_dict[target] = {} for band, fake_file in zip(['opt', 'ir'], fake_files): mag_bins = np.arange(ags.data['%s_min' % band][i], ags.data['%s_max' % band][i], dmag) asts = rsp.Galaxies.artificial_star_tests(fake_file) asts.completeness(**ast_kw) ast_c = asts.fcomp2(mag_bins) ast_dict[target]['%s_correction' % band] = ast_c ast_dict[target]['%s_bins' % band] = mag_bins return ast_dict