From 4f6e288f4453f22912cccda7f6329008fe18091b Mon Sep 17 00:00:00 2001 From: Sidney Mau Date: Mon, 6 Aug 2018 11:12:43 -0500 Subject: [PATCH] fix simple module names --- simple/diagnostic_plots.py | 54 +++++++++++++++++++------------------- simple/fits_find.py | 4 +-- simple/make_plot.py | 18 ++++++------- simple/search_algorithm.py | 22 ++++++++-------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/simple/diagnostic_plots.py b/simple/diagnostic_plots.py index 9ca7d7b..04a71f4 100644 --- a/simple/diagnostic_plots.py +++ b/simple/diagnostic_plots.py @@ -76,34 +76,34 @@ def analysis(targ_ra, targ_dec, mod, mc_source_id): pix_nside_neighbors = np.concatenate([[pix_nside_select], healpy.get_all_neighbours(nside, pix_nside_select)]) # Construct data - #data = simple_utils.construct_modal_data(mode, pix_nside_neighbors) - data = simple_utils.construct_real_data(pix_nside_neighbors) + #data = simple.simple_utils.construct_modal_data(mode, pix_nside_neighbors) + data = simple.simple_utils.construct_real_data(pix_nside_neighbors) if (mode == 0): print('mode = 0: running only on real data') elif (mode == 1): print('mode = 1: running on real data and simulated data') # inject objects for simulated object of mc_source_id - sim_data = simple_utils.construct_sim_data(pix_nside_neighbors, mc_source_id) - data = simple_utils.inject_sim(data, sim_data, mc_source_id) + sim_data = simple.simple_utils.construct_sim_data(pix_nside_neighbors, mc_source_id) + data = simple.simple_utils.inject_sim(data, sim_data, mc_source_id) else: print('No mode specified; running only on real data') print('Loading data...') - data = simple_utils.construct_modal_data(mode, pix_nside_neighbors, mc_source_id) - quality_cut = filters.quality_filter(survey, data) + data = simple.simple_utils.construct_modal_data(mode, pix_nside_neighbors, mc_source_id) + quality_cut = simple.filters.quality_filter(survey, data) data = data[quality_cut] print('Found {} objects...').format(len(data)) - data = filters.dered_mag(survey, data) + data = simple.filters.dered_mag(survey, data) # This should be generalized to also take the survey iso = isochrone_factory(name=isoname, survey=isosurvey, age=12, z=0.0001, distance_modulus=mod, band_1=band_1.lower(), band_2=band_2.lower()) # g_radius estimate - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) - iso_filter = simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) + iso_filter = simple.simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) angsep = ugali.utils.projector.angsep(targ_ra, targ_dec, data[basis_1], data[basis_2]) @@ -165,17 +165,17 @@ def densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, type): """Stellar density plot""" if type == 'stars': - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) plt.title('Stellar Density') elif type == 'galaxies': - filter = filters.galaxy_filter(survey, data) + filter = simple.filters.galaxy_filter(survey, data) plt.title('Galactic Density') elif type == 'blue_stars': - filter = filters.color_filter(survey, data) \ - & filters.star_filter(survey, data) + filter = simple.filters.color_filter(survey, data) \ + & simple.filters.star_filter(survey, data) plt.title('Blue Stellar Density') - iso_filter = simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) + iso_filter = simple.simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) # projection of image proj = ugali.utils.projector.Projector(targ_ra, targ_dec) @@ -206,9 +206,9 @@ def densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, type): def starPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd): """Star bin plot""" - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) - iso_filter = simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) + iso_filter = simple.simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) # projection of image proj = ugali.utils.projector.Projector(targ_ra, targ_dec) @@ -230,13 +230,13 @@ def cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, type): annulus = (angsep > g_radius) & (angsep < 1.) if type == 'stars': - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) plt.title('Stellar Color-Magnitude') elif type == 'galaxies': - filter = filters.galaxy_filter(survey, data) + filter = simple.filters.galaxy_filter(survey, data) plt.title('Galactic Color-Magnitude') - iso_filter = simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) + iso_filter = simple.simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) # Plot background objects plt.scatter(data[mag_dered_1][filter & annulus] - data[mag_dered_2][filter & annulus], data[mag_dered_1][filter & annulus], c='k', alpha=0.1, edgecolor='none', s=1) @@ -260,7 +260,7 @@ def cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, type): def hessPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd): """Hess plot""" - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) plt.title('Hess') @@ -311,15 +311,15 @@ def radialPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, field_density=None) """Radial distribution plot""" ## Deprecated? - #filter_s = filters.star_filter(survey, data) - #filter_g = filters.galaxy_filter(survey, data) + #filter_s = simple.filters.star_filter(survey, data) + #filter_g = simple.filters.galaxy_filter(survey, data) plt.title('Radial Distribution') angsep = ugali.utils.projector.angsep(targ_ra, targ_dec, data[basis_1], data[basis_2]) # Isochrone filtered/unfiltered - iso_seln_f = simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) + iso_seln_f = simple.simple_utils.cutIsochronePath(data[mag_dered_1], data[mag_dered_2], data[mag_err_1], data[mag_err_2], iso, radius=0.1, return_all=False) iso_seln_u = ~iso_seln_f bins = np.linspace(0, 0.4, 21) # deg @@ -328,9 +328,9 @@ def radialPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, field_density=None) def interp_values(type, seln): if type == 'stars': - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) elif type == 'galaxies': - filter = filters.galaxy_filter(survey, data) + filter = simple.filters.galaxy_filter(survey, data) if seln == 'f': iso_filter = iso_seln_f @@ -347,9 +347,9 @@ def interp_values(type, seln): def value_errors(type, seln): if type == 'stars': - filter = filters.star_filter(survey, data) + filter = simple.filters.star_filter(survey, data) elif type == 'galaxies': - filter = filters.galaxy_filter(survey, data) + filter = simple.filters.galaxy_filter(survey, data) if seln == 'f': iso_filter = iso_seln_f elif seln == 'u': diff --git a/simple/fits_find.py b/simple/fits_find.py index 7996399..0111105 100644 --- a/simple/fits_find.py +++ b/simple/fits_find.py @@ -88,9 +88,9 @@ data_array.append(fits.read(infile)) data = np.concatenate(data_array) -#data = filters.dered_mag(survey, data) +#data = simple.filters.dered_mag(survey, data) -#filter = filters.star_filter(survey, data) +#filter = simple.filters.star_filter(survey, data) #data = data[filter] ### diff --git a/simple/make_plot.py b/simple/make_plot.py index 0bf572f..323ecb3 100644 --- a/simple/make_plot.py +++ b/simple/make_plot.py @@ -51,33 +51,33 @@ fig.subplots_adjust(wspace=0.3, hspace=0.3) gs = gridspec.GridSpec(3, 3) -data, iso, g_radius, nbhd = diagnostic_plots.analysis(targ_ra, targ_dec, mod, mc_source_id) +data, iso, g_radius, nbhd = simple.diagnostic_plots.analysis(targ_ra, targ_dec, mod, mc_source_id) print('Making diagnostic plots for ({}, {}) = ({}, {})...'.format(basis_1, basis_2, targ_ra, targ_dec)) fig.add_subplot(gs[0,0]) -diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'stars') +simple.diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'stars') fig.add_subplot(gs[1,0]) -diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'galaxies') +simple.diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'galaxies') fig.add_subplot(gs[2,0]) -diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'blue_stars') +simple.diagnostic_plots.densityPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'blue_stars') fig.add_subplot(gs[0,1]) -diagnostic_plots.cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'stars') +simple.diagnostic_plots.cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'stars') fig.add_subplot(gs[1,1]) -diagnostic_plots.cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'galaxies') +simple.diagnostic_plots.cmPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, 'galaxies') fig.add_subplot(gs[0,2]) -diagnostic_plots.hessPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd) +simple.diagnostic_plots.hessPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd) fig.add_subplot(gs[1,2]) -diagnostic_plots.starPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd) +simple.diagnostic_plots.starPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd) fig.add_subplot(gs[2,1:3]) -diagnostic_plots.radialPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, field_density) +simple.diagnostic_plots.radialPlot(targ_ra, targ_dec, data, iso, g_radius, nbhd, field_density) # Name try: # ugali diff --git a/simple/search_algorithm.py b/simple/search_algorithm.py index 9c9234a..cac30e7 100644 --- a/simple/search_algorithm.py +++ b/simple/search_algorithm.py @@ -101,7 +101,7 @@ # Construct data #data = simple_utils.construct_modal_data(mode, pix_nside_neighbors, mc_source_id) -data = simple_utils.construct_real_data(pix_nside_neighbors) +data = simple.simple_utils.construct_real_data(pix_nside_neighbors) print('MC_SOURCE_ID = {}'.format(mc_source_id)) if (mode == 0): @@ -110,25 +110,25 @@ print('mode = 1: running on real data and simulated data') # inject objects for simulated object of mc_source_id - sim_data = simple_utils.construct_sim_data(pix_nside_neighbors, mc_source_id) - data = simple_utils.inject_sim(data, sim_data, mc_source_id) + sim_data = simple.simple_utils.construct_sim_data(pix_nside_neighbors, mc_source_id) + data = simple.simple_utils.inject_sim(data, sim_data, mc_source_id) elif (mode == 2): print('mode = 2: running only on real data') else: print('No/unsupported mode specified; running only on real data') # Quality cut -quality = filters.quality_filter(survey, data) +quality = simple.filters.quality_filter(survey, data) data = data[quality] # Deredden magnitudes -data = filters.dered_mag(survey, data) +data = simple.filters.dered_mag(survey, data) print('Found {} objects...').format(len(data)) print('Applying cuts...') -cut = filters.star_filter(survey, data) -cut_gal = filters.galaxy_filter(survey, data) +cut = simple.filters.star_filter(survey, data) +cut_gal = simple.filters.galaxy_filter(survey, data) data_gal = data[cut_gal] # this isn't used at all other than for noting number of galaxy-like objects in ROI data = data[cut] @@ -160,7 +160,7 @@ if (mode == 0): for distance_modulus in distance_modulus_search_array: - ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple_utils.searchByDistance(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) + ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.searchByDistance(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) ra_peak_array.append(ra_peaks) dec_peak_array.append(dec_peaks) r_peak_array.append(r_peaks) @@ -176,7 +176,7 @@ distance_modulus_select = sim_pop[sim_pop['MC_SOURCE_ID'] == mc_source_id]['DISTANCE_MODULUS'][0] distance_modulus = distance_modulus_search_array[np.argmin(np.fabs(distance_modulus_search_array - distance_modulus_select))] - ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple_utils.searchBySimulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) + ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.searchBySimulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) ra_peak_array.append(ra_peaks) dec_peak_array.append(dec_peaks) r_peak_array.append(r_peaks) @@ -193,7 +193,7 @@ distance_modulus_select = sim_pop[sim_pop['MC_SOURCE_ID'] == mc_source_id]['DISTANCE_MODULUS'][0] distance_modulus = distance_modulus_search_array[np.argmin(np.fabs(distance_modulus_search_array - distance_modulus_select))] - ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple_utils.searchBySimulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) + ra_peaks, dec_peaks, r_peaks, sig_peaks, dist_moduli, n_obs_peaks, n_obs_half_peaks, n_model_peaks = simple.simple_utils.searchBySimulation(nside, data, distance_modulus, pix_nside_select, ra_select, dec_select, mag_max, fracdet) ra_peak_array.append(ra_peaks) dec_peak_array.append(dec_peaks) r_peak_array.append(r_peaks) @@ -257,7 +257,7 @@ # Write output if (len(sig_peak_array) > 0): - simple_utils.writeOutput(results_dir, nside, pix_nside_select, ra_peak_array, dec_peak_array, r_peak_array, distance_modulus_array, + simple.simple_utils.writeOutput(results_dir, nside, pix_nside_select, ra_peak_array, dec_peak_array, r_peak_array, distance_modulus_array, n_obs_peak_array, n_obs_half_peak_array, n_model_peak_array, sig_peak_array, mc_source_id_array, mode, outfile) else: