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"
def load_single(user_input): nu, ref_trans = load_npy(user_input["Save"]["Spectra"]["path"], user_input["Save"]["Spectra"]["name"]) sim_plot = plotter.Simulation_Plotter(user_input) sim_plot.plot_xy(nu, ref_trans, "ref.") sim_plot.show_plot()
def simulate(s, o, a): s.Timer = simple_timer(4) #create a base flat spectra based on planetary parameters s.Surface_g, s.Base_TS_Value = s.load_astrophysical_properties() # normalized pressure directly correspond to atmosphere layers. s.normalized_pressure = s.load_atmosphere_pressure_layers() # load mixing ration files and determine what molecules are added to the simulation # acquire the mixing ratio at each pressure (need to be interpolated to normalized pressure) s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() # load molecular cross section for main constituent of the atmosphere # will check first to see if the molecule is in the database s.cross_db = s.check_molecules() s.nu, s.normalized_cross_section = s.load_molecule_cross_section() s.normalized_stellar_spectra = s.load_stellar_spectra() s.Reference_Reflect_Signal = s.load_atmosphere_geometry_model() s.user_input["Plotting"]["Figure"]["y_multiplier"] = 1 s.user_input["Plotting"]["Figure"][ "Title"] = "Simulated Example Reflection Spectra for Pure Water Atmosphere" s.user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' s.user_input["Plotting"]["Figure"]["y_label"] = r"Flux Density (W/m^2)" sim_plot = plotter.Simulation_Plotter(s.user_input) plt_ref_1 = sim_plot.plot_xy(s.nu, s.normalized_stellar_spectra, "Stellar Spectra") 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()
def simulate_window(s, o, a): s.Timer = simple_timer(4) #create a base flat spectra based on planetary parameters s.Surface_g, s.Base_TS_Value = s.load_astrophysical_properties() # normalized pressure directly correspond to atmosphere layers. s.normalized_pressure = s.load_atmosphere_pressure_layers() # load mixing ration files and determine what molecules are added to the simulation # acquire the mixing ratio at each pressure (need to be interpolated to normalized pressure) s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() # load molecular cross section for main constituent of the atmosphere # will check first to see if the molecule is in the database s.cross_db = s.check_molecules() s.nu, s.normalized_cross_section = s.load_molecule_cross_section() s.normalized_rayleigh = s.load_rayleigh_scattering() print "load time", s.Timer.elapse() s.Transit_Signal = s.load_atmosphere_geometry_model() nu, trans = o.calculate_convolve(s.nu, s.Transit_Signal) s.nu_window = a.spectra_window(nu, trans, "T", 0.3, 100., s.min_signal) print "calc time", s.Timer.elapse() user_input["Plotting"]["Figure"][ "Title"] = "Absorption and Atmospheric Window for Simulated Atmosphere of %s" % "_".join( s.normalized_molecules) user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' user_input["Plotting"]["Figure"]["y_label"] = r"Transit Signal (ppm)" sim_plot = plotter.Simulation_Plotter(s.user_input) sim_plot.plot_xy(nu, trans) sim_plot.plot_window(s.nu_window, "k", 0.2) sim_plot.show_plot() return s.Transit_Signal
def simulate_noise(user_input): observer = observe.OS_Simulator(user_input) sim_plot = plotter.Simulation_Plotter(user_input) nu, ref_trans = load_npy(user_input["Save"]["Spectra"]["path"], user_input["Save"]["Spectra"]["name"]) wav = (10000. / nu) trans = ref_trans bin_centers, bin_mean_I = observer.calculate_bin(wav, trans) bin_mean_error_I, bin_mean_error_bar = observer.add_noise(bin_mean_I) sim_plot.plot_xy(wav, trans, "ref.", Dtype="um") sim_plot.plot_bin(bin_centers, bin_mean_error_I, bin_mean_error_bar) sim_plot.plot_bin(bin_centers, bin_mean_I, bin_mean_error_bar * 10**-6) sim_plot.show_plot()
user_input["Simulation_Control"]["Mixing_Ratio_Name"] = "earth.txt" user_input["Save"]["Intermediate_Data"][ "cross_section_savename"] = "%s_Cross_Section.npy" % Filename user_input["Save"]["Window"][ "path"] = "../../output/Simple_Atmosphere_Window" user_input["Save"]["Window"][ "name"] = "%s_Window_A1000_S100.txt" % Filename user_input["Save"]["Plot"] = {} user_input["Save"]["Plot"]["path"] = "../../output/Plot_Result" user_input["Save"]["Plot"]["name"] = "%s_Plot.png" % Filename simulation = theory.TS_Simulator(user_input) observer = observe.OS_Simulator(user_input) Raw_nu, Raw_TS = simulation.simulate_example() nu, Trans = observer.calculate_convolve(Raw_nu, Raw_TS) user_input["Plotting"]["Figure"][ "Title"] = "Transit Signal for Simulated Earth Atmosphere" user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' user_input["Plotting"]["Figure"]["y_label"] = r"Transit Signal (ppm)" sim_plot = plotter.Simulation_Plotter(user_input) plt_ref_1 = sim_plot.plot_xy(Raw_nu, Raw_TS, "raw_spectra") plt_ref_2 = sim_plot.plot_xy(nu, Trans, "convolved_spectra") sim_plot.set_legend([plt_ref_1, plt_ref_2]) sim_plot.show_plot()
def simulate_NIST(s, o, a): s.Timer = simple_timer(4) #create a base flat spectra based on planetary parameters s.Surface_g, s.Base_TS_Value = s.load_astrophysical_properties() # normalized pressure directly correspond to atmosphere layers. s.normalized_pressure = s.load_atmosphere_pressure_layers() # load mixing ration files and determine what molecules are added to the simulation # acquire the mixing ratio at each pressure (need to be interpolated to normalized pressure) s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() # load molecular cross section for main constituent of the atmosphere # will check first to see if the molecule is in the database s.cross_db = s.check_molecules() s.nu, s.normalized_cross_section = s.load_molecule_cross_section() print "load time", s.Timer.elapse() # load rayleigh scattering s.Rayleigh_enable = utils.to_bool( s.user_input["Atmosphere_Effects"]["Rayleigh"]["enable"]) if s.Rayleigh_enable: s.normalized_rayleigh = s.load_rayleigh_scattering() user_input["Plotting"]["Figure"][ "Title"] = "Simulated Earth-like Exoplanet Atmosphere Comparison Study" user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' user_input["Plotting"]["Figure"]["y_label"] = r"Transit Signal (ppm)" sim_plot = plotter.Simulation_Plotter(s.user_input) # calculate theoretical transmission spectra s.Reference_Transit_Signal = s.load_atmosphere_geometry_model() nu, ref_trans = o.calculate_convolve(s.nu, s.Reference_Transit_Signal) # plotting plt_legend = [] plt_ref = sim_plot.plot_xy(nu, ref_trans, "ref.", "r") plt_legend.append(plt_ref) cloud_deck = 1000 # 100mbar cloud_amount = 0.5 s.Cloudy_Transit_Signal = s.load_atmosphere_geometry_model_with_cloud( cloud_deck, cloud_amount) nu, clo_trans = o.calculate_convolve(s.nu, s.Cloudy_Transit_Signal) plt_ref = sim_plot.plot_xy(nu, clo_trans, "%s" % cloud_amount) plt_legend.append(plt_ref) """ cloud_deck = 10000 # 100mbar cloud_amount = 0.1 # cloud absorption for cloud_amount in [0.01,0.02,0.05,0.1,0.2,0.5,1,2,5,10]: s.Cloudy_Transit_Signal = s.load_atmosphere_geometry_model_with_cloud(cloud_deck,cloud_amount) nu,clo_trans = o.calculate_convolve(s.nu, s.Cloudy_Transit_Signal) plt_ref = sim_plot.plot_xy(nu,clo_trans,"%s"%cloud_amount) plt_legend.append(plt_ref) """ """ # cloud deck for cloud_deck in [100000,10000,1000,100,10,1,0.1,0.01,0.001]: s.Cloudy_Transit_Signal = s.load_atmosphere_geometry_model_with_cloud(cloud_deck,cloud_amount) nu,clo_trans = o.calculate_convolve(s.nu, s.Cloudy_Transit_Signal) plt_ref = sim_plot.plot_xy(nu,clo_trans,"%s"%cloud_deck) plt_legend.append(plt_ref) """ # comparison study """ for cloud_amount in [0.01,0.1,1]: for cloud_deck in [1000,1]: s.Cloudy_Transit_Signal = s.load_atmosphere_geometry_model_with_cloud(cloud_deck,cloud_amount) nu,clo_trans = o.calculate_convolve(s.nu, s.Cloudy_Transit_Signal) plt_ref = sim_plot.plot_xy(nu,clo_trans,"D%s_A%s"%(cloud_deck,cloud_amount)) plt_legend.append(plt_ref) """ s.nu_window = a.spectra_window(nu, ref_trans, "T", 0.3, 100., s.min_signal) sim_plot.plot_window(s.nu_window, "k", 0.2) sim_plot.set_legend(plt_legend) sim_plot.show_plot() return s
def simulate_NIST(s, o, a): s.Timer = simple_timer(4) #create a base flat spectra based on planetary parameters s.Surface_g, s.Base_TS_Value = s.load_astrophysical_properties() # normalized pressure directly correspond to atmosphere layers. s.normalized_pressure = s.load_atmosphere_pressure_layers() # load mixing ration files and determine what molecules are added to the simulation # acquire the mixing ratio at each pressure (need to be interpolated to normalized pressure) s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() # load molecular cross section for main constituent of the atmosphere # will check first to see if the molecule is in the database s.cross_db = s.check_molecules() s.nu, s.normalized_cross_section = s.load_molecule_cross_section() # load biosignature molecules bio_enable = utils.to_bool( s.user_input["Atmosphere_Effects"]["Bio_Molecule"]["enable"]) if bio_enable == True: data_type = s.user_input["Atmosphere_Effects"]["Bio_Molecule"][ "data_type"] bio_molecule = s.user_input["Atmosphere_Effects"]["Bio_Molecule"][ "molecule"] bio_abundance = utils.to_float( s.user_input["Atmosphere_Effects"]["Bio_Molecule"]["abundance"]) s.is_smile = utils.to_bool( s.user_input["Atmosphere_Effects"]["Bio_Molecule"]["is_smile"]) s.nu, s.bio_cross_section = s.load_bio_molecule_cross_section( bio_molecule, data_type) s.bio_normalized_cross_section = np.concatenate( [s.normalized_cross_section, s.bio_cross_section], axis=0) # modify the molecular abundance after adding biosignatures # scale heights untouched still since effect is small s.bio_normalized_abundance = [] for i, abundance in enumerate(s.normalized_abundance): s.bio_normalized_abundance.append([]) for j in abundance: s.bio_normalized_abundance[i].append(j * (1 - bio_abundance)) s.bio_normalized_abundance[i].append(bio_abundance) s.bio_normalized_molecules = np.concatenate( [s.normalized_molecules, [bio_molecule]], axis=0) print "load time", s.Timer.elapse() # load rayleigh scattering s.Rayleigh_enable = utils.to_bool( s.user_input["Atmosphere_Effects"]["Rayleigh"]["enable"]) if s.Rayleigh_enable: s.normalized_rayleigh = s.load_rayleigh_scattering() s.Overlay_enable = utils.to_bool( s.user_input["Atmosphere_Effects"]["Overlay"]["enable"]) if s.Overlay_enable: o_nu, o_xsec = s.load_overlay_effects(dtype="HITRAN") s.normalized_overlay = s.interpolate_overlay_effects(o_nu, o_xsec) # calculate theoretical transmission spectra s.Reference_Transit_Signal = s.load_atmosphere_geometry_model() s.Bio_Transit_Signal = s.load_atmosphere_geometry_model(bio=bio_enable) # calculate observed transmission spectra nu, ref_trans = o.calculate_convolve(s.nu, s.Reference_Transit_Signal) nu, bio_trans = o.calculate_convolve(s.nu, s.Bio_Transit_Signal) # analyze the spectra s.nu_window = a.spectra_window(nu, ref_trans, "T", 0.3, 100., s.min_signal) user_input["Plotting"]["Figure"][ "Title"] = "Transit Signal and Atmospheric Window for Simulated Earth Atmosphere with traces of %s at %s ppm" % ( bio_molecule, bio_abundance * 10**6) user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' user_input["Plotting"]["Figure"]["y_label"] = r"Transit Signal (ppm)" sim_plot = plotter.Simulation_Plotter(s.user_input) plt_ref_1 = sim_plot.plot_xy(nu, bio_trans, "with_bio") plt_ref_2 = sim_plot.plot_xy(nu, ref_trans, "ref.") sim_plot.plot_window(s.nu_window, "k", 0.2) 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() return s
def simulate_CIA(s): s.Timer = simple_timer(4) #create a base flat spectra based on planetary parameters s.Surface_g, s.Base_TS_Value = s.load_astrophysical_properties() # normalized pressure directly correspond to atmosphere layers. s.normalized_pressure = s.load_atmosphere_pressure_layers() # load mixing ration files and determine what molecules are added to the simulation # acquire the mixing ratio at each pressure (need to be interpolated to normalized pressure) s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() s.normalized_molecules, s.MR_Pressure, s.molecule_MR = s.load_mixing_ratio( ) s.normalized_abundance = s.interpolate_mixing_ratio() # load temperature pressure profile s.TP_Pressure, s.TP_Temperature = s.load_TP_profile() s.normalized_temperature = s.interpolate_TP_profile() # calculate the scale height for each layer of the atmosphere s.normalized_scale_height = s.calculate_scale_height() s.cross_db = s.check_molecules() s.nu, s.normalized_cross_section = s.load_molecule_cross_section() s.normalized_rayleigh = s.load_rayleigh_scattering() CIA_Enable = utils.to_bool( s.user_input["Atmosphere_Effects"]["CIA"]["enable"]) if CIA_Enable == True: s.CIA_File, s.CIA_Data = s.load_CIA(["H2"]) s.normalized_CIA = s.interpolate_CIA() s.Transit_Signal_CIA = s.load_atmosphere_geometry_model(CIA=True) s.Transit_Signal = s.load_atmosphere_geometry_model() user_input["Plotting"]["Figure"][ "Title"] = r"Transit Signal and Atmospheric Window for Simulated Atmosphere of %s" % "_".join( s.normalized_molecules) user_input["Plotting"]["Figure"]["x_label"] = r'Wavelength ($\mu m$)' user_input["Plotting"]["Figure"]["y_label"] = r"Transit Signal (ppm)" sim_plot = plotter.Simulation_Plotter(s.user_input) plt_ref_1 = sim_plot.plot_xy(s.nu, s.Transit_Signal, "Molecular") plt_ref_2 = sim_plot.plot_xy(s.nu, s.Transit_Signal_CIA, "Molecular+CIA") sim_plot.set_legend([plt_ref_1, plt_ref_2]) sim_plot.show_plot()