Skip to content

Commit

Permalink
fix simple module names
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidney Mau committed Aug 6, 2018
1 parent b82ef83 commit 4f6e288
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
54 changes: 27 additions & 27 deletions simple/diagnostic_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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')

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions simple/fits_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

###
Expand Down
18 changes: 9 additions & 9 deletions simple/make_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions simple/search_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4f6e288

Please sign in to comment.