def single_molecule_inject(self, d_path, molecule, component, gamma, cross, P_grid, T_grid):
     
     
     
     Timer = simple_timer()
     table_name = molecule
     columns = [("nu","real"),("coef","real"),("P","real"),("T","real"),("Resolution","real"),("Method","text"),("Source","text")]
     
     if self.cross_db.check_table_exist(table_name) == False:
         print "table created for {}".format(molecule)
         self.cross_db.create_table(table_name, *columns)
     else:
         self.cross_db.delete_table(table_name)
         self.cross_db.create_table(table_name, *columns)
         
     # convert to csc in the future
     molecule_data = l2x.read_data(d_path,molecule,self.numin,self.numax,-1,-1)
     
 
     for P in P_grid:
         for T in T_grid:
             # huge room for multiprocessing here....
             print "Generating cross section for {},{} at P: {}pa and T: {}K".format(molecule,component,P,T),
             
             nu,coef = l2x.absorption_Voigt_calculation(molecule_data, component, gamma, P, T, self.numin, self.numax, self.step, cross)
             
             data = [x+(P,T,self.step,self.method,self.source) for x in zip(nu,coef)]        
             print "Generation_Time:", Timer.elapse(),
     
             for i in data:
                 self.cross_db._insert_data_single_dev(table_name, i)
                 
             self.cross_db.conn.commit()                        
             print "Injection_Time:", Timer.elapse()
     print "Total_Time:",Timer.total()
Exemplo n.º 2
0
def main():

    inputfilename = os.path.join(molecule_info, "ASM4.3_Lite.xlsx")
    inputsheetname = "Database"

    WBI = load_workbook(inputfilename)
    data_sheet_ranges = WBI[inputsheetname]

    Data = []
    Timer = simple_timer(4)
    num = 2
    total = 16420
    while True:

        Smile = utils.to_str(data_sheet_ranges['A%d' % num].value)
        if Smile == None:
            break

        if num % 100 == 0:
            print Timer.progress(num, total)
            WBI.save(inputfilename)

        inchikey = utils.to_str(data_sheet_ranges['J%d' %
                                                  num].value).split("=")[-1]

        link = "http://webbook.nist.gov/cgi/cbook.cgi?InChI=%s&Units=SI" % inchikey

        result = get_cas(link)

        data_sheet_ranges['M%d' % num].value = str(result)

        num += 1

    WBI.save(inputfilename)
Exemplo n.º 3
0
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 download_NIST2():

    inputfilename = os.path.join(molecule_info, "ASM4.3_Lite.xlsx")
    inputsheetname = "Database"

    WBI = load_workbook(inputfilename)
    data_sheet_ranges = WBI[inputsheetname]

    Data = []
    Timer = simple_timer(4)
    num = 2
    total = 16420
    while True:

        Smile = utils.to_str(data_sheet_ranges['A%d' % num].value)
        if Smile == None:
            break

        cas = utils.to_str(data_sheet_ranges['M%d' % num].value)
        if cas == None:
            num += 1
            continue

        num += 1
        print num,

        for i in range(4):
            Index = i

            data_link = "http://webbook.nist.gov/cgi/cbook.cgi?JCAMP=%s&Index=%s&Type=IR" % (
                cas, Index)

            result, spectra_data = get_spectra(data_link)

            if Index == 0:
                data_sheet_ranges['N%d' % num].value = result

            if result == "N":
                print ""
                break
            else:
                name = "%s_%s.jdx" % (cas, Index)
                path = os.path.join(NIST_Spectra, cas)
                print "Saving %s" % name
                save_txt(path,
                         name,
                         spectra_data,
                         extension=".jdx",
                         check=True)

    WBI.save(inputfilename)
Exemplo n.º 5
0
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 download_NIST():

    kwargs = {
        "dir": molecule_info,
        "db_name": "Molecule_DB2.db",
        "user": "******",
        "DEBUG": False,
        "REMOVE": True,
        "BACKUP": False,
        "OVERWRITE": True
    }

    cross_db = dbm.database(**kwargs)
    cross_db.access_db()
    table_name = "ID"

    #cmd = "SELECT InChIKey from %s WHERE Formula='C2H2'"%table_name
    cmd = "SELECT InChIKey,Formula from %s" % table_name

    cross_db.c.execute(cmd)
    data = np.array(cross_db.c.fetchall()).T

    inchikey_list = data[0]
    formula_list = data[1]

    print inchikey_list
    print formula_list

    Timer = simple_timer(4)
    counter = 0
    total = len(inchikey_list)
    print total
    sys.exit()
    for inchikey in inchikey_list:

        if counter % 100 == 0:
            print Timer.progress(counter, total)

        link = "http://webbook.nist.gov/cgi/cbook.cgi?InChI=%s&Units=SI" % inchikey

        #data_link = "http://webbook.nist.gov/cgi/cbook.cgi?JCAMP=C74862&Index=0&Type=IR"

        #print inchikey, get_cas(link)

        counter += 1
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()

    # calculate theoretical transmission spectra
    s.Reference_Transit_Signal = s.load_atmosphere_geometry_model()

    # calculate observed transmission spectra
    nu, ref_trans = o.calculate_convolve(s.nu, s.Reference_Transit_Signal)

    return nu, ref_trans
 def exomol_inject2(self, d_path, molecule, Pgrid, Tgrid):
     
     Timer = simple_timer()
     
 
     # convert to csc in the future
 
     for i,T in enumerate(Tgrid):
         for j,P in enumerate(Pgrid):
             # huge room for multiprocessing here....
             print "Generating cross section for {} at P: {}pa and T: {}K".format(molecule,P,T),
             
             table_name = "T%sP%s"%(i,j)
             columns = [("nu","real"),("coef","real"),("P","real"),("T","real"),("Resolution","real"),("Method","text"),("Source","text")]
             
             if self.cross_db.check_table_exist(table_name) == False:
                 print "table created for {}".format(table_name)
                 self.cross_db.create_table(table_name, *columns)
             else:
                 self.cross_db.delete_table(table_name)
                 self.cross_db.create_table(table_name, *columns)
             
             
             name = "_".join([d_path.split("/")[-1], 
                              "-".join([str(self.numin), str(self.numax)]), 
                              "".join([str(T),"K"]),
                              "".join([str(self.step),".000000.npy"])])
             print name                                    
             nu,coef = load_npy(d_path,name)
             
             data = [x+(P,T,self.step,self.method,self.source) for x in zip(nu,coef)]        
             print "Generation_Time:", Timer.elapse(),
     
             for k in data:
                 self.cross_db._insert_data_single_dev(table_name, k)
                 
             self.cross_db.conn.commit()                        
             print "Injection_Time:", Timer.elapse()
     print "Total_Time:",Timer.total()
Exemplo n.º 9
0
def simplist_test():

    d_path = HITRAN_Water_Lines
    r_path = Temp_DIR
    molecule = "H2O"
    component = [1, 1, 1]
    numin = 3000
    numax = 40000
    step = 0.1
    P = 100000.
    T = 300.

    calc = csc.cross_section_calculator(d_path, r_path, molecule, component,
                                        numin, numax, step, P, T)

    Timer = simple_timer()

    data = calc.read_data()

    nu, coef = calc.personal_calculator(data)

    plt.simple_plot(nu, coef)
        s.user_input["Atmosphere_Effects"]["Rayleigh"]["enable"])
    if s.Rayleigh_enable:
        s.normalized_rayleigh = s.load_rayleigh_scattering()

    # calculate theoretical transmission spectra
    s.Reference_Transit_Signal = s.load_atmosphere_geometry_model()

    # calculate observed transmission spectra
    nu, ref_trans = o.calculate_convolve(s.nu, s.Reference_Transit_Signal)

    return nu, ref_trans


if __name__ == "__main__":

    Timer = simple_timer()

    user_input = config.Configuration(
        "../../bin_stable/a.Main/user_input_dev.cfg")

    Filename = "Test_Earth"
    Filename1 = "Test_Earth_with_biosig"

    user_input["Simulation_Control"]["DB_DIR"] = "Simulation_Band"
    user_input["Simulation_Control"]["DB_Name"] = None  #"cross_sec_Example.db"
    user_input["Simulation_Control"]["TP_Profile_Name"] = "earth.txt"
    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"][
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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_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()
        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)
    
    
    return nu, ref_trans, bio_trans
Exemplo n.º 14
0
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()