def main(): ds = DefaultSignal(id=signal_id()) dbg = DefaultBackground(id=background_id()) x = dbg.background_range() plt.plot(x, psi_fluctuations(ds, dbg)) plt.title(r"Background + Signal \w Fluctuations", fontsize=18) plt.ylabel("Scales", fontsize=16) plt.xlabel("Mass", fontsize=16) plt.show()
def generate_classifier_toy_dataset(): signals = all_signals() background_config = all_backgrounds()[0] wavelet_config = all_wavelets()[0] arrays = [] ids = [] for signl_config in signals: ds = DefaultSignal(signl_config['id']) dbg = DefaultBackground(background_config['id']) cmor = DefaultCWTFluctuations(wavelet_config['id']) for j in range(2000): data = psi_fluctuations(ds, dbg) [coeffs, freqs] = cmor.generate_coefficients(data) amp = np.abs(coeffs) arrays.append(amp) ids.append(signl_config['id']) x = np.stack(arrays, axis=0) y = np.array(ids) toy_data_set, labels = randomize(x, y) np.save(PATH_CLASSIFIER_TOY_DATASET, toy_data_set) np.save(PATH_CLASSIFIER_TOY_LABELS, labels) print('generated classifier_toy_dataset successfully ', toy_data_set.shape)
def main(): ds = DefaultSignal(id=signal_id()) dbg = DefaultBackground(id=background_id()) cmor = DefaultCWTFluctuations(id=wavelet_id()) print(cmor.wavelet) data = psi_fluctuations(ds, dbg) # data = psi_clean(ds, dbg) coeffs, freqs = cmor.generate_coefficients(data) amp = np.abs(coeffs) # new_shape = [48, 64] new_shape = [48, 64] amp_p_value = p_value_transformation_local(rebin(amp, new_shape), new_shape) fig, ax = plt.subplots(figsize=(12, 12)) img = ax.imshow(rebin(amp, new_shape), extent=(dbg.min_bg, dbg.max_bg, cmor.max_scales, cmor.min_scales), interpolation='sinc', aspect='auto', cmap='bwr') ax.set_ylim(cmor.min_scales, cmor.max_scales) fig.colorbar(img, ax=ax) # plt.title('CWT - scales range: (%s, %s)' % (cmor.min_scales, cmor.max_scales)) plt.title('CWT of Background + Signal w/ Fluctuations', fontsize=18) plt.ylabel('Scales', fontsize=16) plt.xlabel('Mass', fontsize=16) plt.show()
def save_clean_plot(path, s_id, bg_id): ds = DefaultSignal(id=s_id) dbg = DefaultBackground(id=bg_id) x = dbg.background_range() plt.plot(x, psi_clean(ds, dbg)) plt.title(r"Signal + Background") plt.ylabel("Amplitude") plt.xlabel("Mass") if os.path.isfile(path): os.remove(path) plt.savefig(path) plt.close('all')
def main(): ds = DefaultSignal(id=signal_id()) dbg = DefaultBackground(id=background_id()) x = dbg.background_range() fig, ax = plt.subplots(figsize=(9, 7)) plt.plot(x, psi_clean(ds, dbg)) plt.title(r"Background + Signal", fontsize=20) plt.ylabel("Events/Mass Unit", fontsize=18) plt.xlabel("Mass", fontsize=18) plt.xticks(fontsize=18) plt.yticks(fontsize=18) path = 'docs/output/cwt/clean_bg_signal.jpeg' plt.savefig(path) plt.close('all')
def generate_cwt_fluctuations(signal_id=0, bg_id=0, wavelet_id=0): ds = DefaultSignal(signal_id) dbg = DefaultBackground(bg_id) cmor = DefaultCWTClean(wavelet_id) data = psi_fluctuations(ds, dbg) [coeffs, freqs] = cmor.generate_coefficients(data) amp = np.abs(coeffs) return amp
def main(): ds = DefaultSignal(id=signal_id()) dbg = DefaultBackground(id=background_id()) cmor = DefaultCWTFluctuations(id=wavelet_id()) print(cmor.wavelet) x = dbg.background_range() data = psi_fluctuations(ds, dbg) # data = psi_clean(ds, dbg) coeffs, freqs = cmor.generate_coefficients(data) amp = np.abs(coeffs) new_shape = [48, 64] amp_rebinned = rebin(amp, new_shape) amp_p_value = p_value_transformation_local(amp_rebinned, new_shape) plot_bg_signal_fluc(x, data) plot_bg_signal_og(amp, dbg, cmor) plot_bg_signal_rebinned(amp_rebinned, dbg, cmor) plot_bg_signal_rebinned_p_value(amp_p_value, dbg, cmor)
def generate_rebined_sample_fluctuations(rebined_shape, signal_id=0, bg_id=0, wavelet_id=0): ds = DefaultSignal(signal_id) dbg = DefaultBackground(bg_id) cmor = DefaultCWTClean(wavelet_id) data = psi_fluctuations(ds, dbg) [coeffs, freqs] = cmor.generate_coefficients(data) amp = np.abs(coeffs) rebined_amp = rebin(amp, rebined_shape) return rebined_amp
def main(): ds = DefaultSignal(id=signal_id()) dbg = DefaultBackground(id=background_id()) cmor = DefaultCWTClean(id=wavelet_id()) print(cmor.wavelet) data = psi_clean(ds, dbg) coeffs, freqs = cmor.generate_coefficients(data) amp = np.abs(coeffs) fig, ax = plt.subplots(figsize=(9, 7)) img = ax.imshow(amp, extent=(dbg.min_bg, dbg.max_bg, cmor.max_scales, cmor.min_scales), interpolation='sinc', aspect='auto', cmap='bwr') ax.set_ylim(cmor.min_scales, cmor.max_scales) cbar = fig.colorbar(img, ax=ax) cbar.ax.tick_params(labelsize=18) plt.title('CWT w/o noise - scales range: (%s, %s)' % (cmor.min_scales, cmor.max_scales)) plt.title('CWT Background + Signal', fontsize=20) plt.ylabel('Scales', fontsize=18) plt.xlabel('Mass', fontsize=18) plt.xticks(fontsize=18) plt.yticks(fontsize=18) path = 'docs/output/cwt/cwt_bg_signal_clean.jpeg' plt.savefig(path) plt.close('all')