def simulate_noise(user_input): observer = observe.OS_Simulator(user_input) analyzer = analyze.Spectra_Analyzer(user_input) sim_plot = plotter.Simulation_Plotter(user_input) nu, ref_trans, bio_trans = load_npy(user_input["Save"]["Spectra"]["path"], user_input["Save"]["Spectra"]["name"]) wav = (10000. / nu) rbin_centers, rbin_mean_I = observer.calculate_bin(wav, ref_trans) rbin_mean_error_I, rbin_mean_error_bar = observer.add_noise(rbin_mean_I) bbin_centers, bbin_mean_I = observer.calculate_bin(wav, bio_trans) bbin_mean_error_I, bbin_mean_error_bar = observer.add_noise(bbin_mean_I) signal_diff = np.array(bbin_mean_I - rbin_mean_I) signal_diff2 = np.array(bbin_mean_error_I - rbin_mean_I) x, SNR = analyzer.spectra_SNR(bbin_centers, signal_diff2) maxSNR = max(SNR) print "Feature Max SNR: %s. " % maxSNR, if maxSNR > 9: print "Over 9 sigma" elif maxSNR > 6: print "Over 6 sigma" elif maxSNR > 3: print "Over 3 sigma" else: print "Not Detected"
plt_ref_2 = sim_plot.plot_xy( s.nu, s.normalized_stellar_spectra * s.Reference_Reflect_Signal, "Reflection Spectra") sim_plot.set_legend([plt_ref_1, plt_ref_2]) if utils.to_bool(user_input["Save"]["Plot"]["save"]): sim_plot.save_plot() else: sim_plot.show_plot() if __name__ == "__main__": user_input = config.Configuration( "../../bin_stable/a.Main/user_input_dev.cfg") user_input["Simulation_Control"]["DB_DIR"] = "Example" user_input["Simulation_Control"]["DB_Name"] = "cross_sec_Example.db" user_input["Simulation_Control"]["TP_Profile_Name"] = "isothermal_300K.txt" user_input["Simulation_Control"]["Mixing_Ratio_Name"] = "H2O_only.txt" user_input["Save"]["Plot"]["save"] = False user_input["Save"]["Intermediate_Data"][ "cross_section_savename"] = "Temp_H2O_Cross_Section.npy" simulation = theory.RS_Simulator(user_input) observer = observe.OS_Simulator(user_input) analyzer = analyze.Spectra_Analyzer(user_input) simulate(simulation, observer, analyzer)