def example_db():
    """
    Simplistic database with one molecule
    with same resolution for all wavelength
    """
    data = config.Configuration("Example_db.cfg")

    molecule_data = data["Molecule"]
    outpath = Example_DB
    db_name = "cross_sec_Example.db"
    user = "******"

    db_info = [outpath, db_name, user]

    numin = 3000
    numax = 4000
    step = 10
    method = "Voigt"
    source = "HITRAN_LL"

    T_grid = [250, 300, 350]
    P_grid = [100000, 10000, 1000]
    gamma = "gamma_self"
    cross = True

    db_init = csdb.xsec_generator(db_info, numin, numax, step, method, source)

    for molecule in molecule_data:
        component = np.array(molecule_data[molecule]["component"],
                             dtype=np.int)
        d_path = os.path.join(HITRAN_Lines, molecule)
        db_init.single_molecule_inject(d_path, molecule, component, gamma,
                                       cross, P_grid, T_grid)
def exomol_db2():
    """
    Simplistic database with one molecule
    with same resolution for all wavelength
    """
    user_input = config.Configuration(
        "../../bin_stable/a.Main/user_input_dev.cfg")

    molecule = "31P-1H3"
    outpath = Exomol_DB
    db_name = "Exomol_PH3.db"
    user = "******"

    db_info = [outpath, db_name, user]

    numin = 400
    numax = 9999
    step = 1
    method = "Doppler"
    source = "Exomol"

    T_grid = user_input["Simulation_Control"]["T_Grid"]
    P_grid = user_input["Simulation_Control"]["P_Grid"]

    db_init = csdb.xsec_generator(db_info, numin, numax, step, method, source)

    d_path = os.path.join(Exomol_Xsec, molecule)
    print d_path

    db_init.exomol_inject2(d_path, "PH3", P_grid, T_grid)
예제 #3
0
def demo_db():
    
    data = config.Configuration("Demo_db.cfg")

    molecule_data   = data["Molecule"]
    outpath         = Demo_DB
    db_name         = "cross_sec_Demo.db"
    user            = "******"
    
    db_info = [outpath, db_name, user]
    
    numin       = 400
    numax       = 30000
    step        = 10
    method      = "Voigt"
    source      = "HITRAN_LL"
    
    T_grid      = [200,300,400,500,600,700,800]
    P_grid      = [100000.0, 36800.0, 13500.0, 4980.0, 1830.0, 674.0, 248.0, 91.2, 33.5, 12.3, 4.54, 1.67, 0.614, 0.226, 0.0832, 0.0306, 0.0113, 0.00414, 0.00152]
    gamma       = "gamma_self"
    cross       = True
    
    db_init = csdb.xsec_generator(db_info,numin,numax,step,method,source)
    
    for molecule in molecule_data:
        component = np.array(molecule_data[molecule]["component"],dtype=np.int)
        d_path = os.path.join(HITRAN_Lines,molecule)
        db_init.single_molecule_inject(d_path,molecule,component,gamma,cross,P_grid,T_grid)
예제 #4
0
def db_load():

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

    molecule = "PH3"

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

    cross_db = dbm.database(**kwargs)
    cross_db.access_db()

    result = cross_db.c.execute(
        "SELECT nu, coef FROM {} WHERE P={} AND T={} AND nu>={} AND nu<={} ORDER BY nu"
        .format(molecule, 13500.0, 300, 400, 9999))
    fetch = np.array(result.fetchall()).T

    nu = fetch[0]
    coef = fetch[1]
    plotter = Plotter()
    plotter.plot_xy(10000. / nu, coef)
예제 #5
0
def db_load_bulk():

    inputs = config.Configuration("../../bin_stable/a.Main/user_input_dev.cfg")
    molecule = "PH3"

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

    cross_db = dbm.database(**kwargs)
    cross_db.access_db()

    nu, data = exomol_cross_section_loader(inputs, cross_db, molecule)

    print len(nu)
예제 #6
0
    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()


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)
예제 #7
0
import os
import sys
import numpy as np

DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(DIR, '../..'))

import SEAS_Utils.common_utils.configurable as config
from SEAS_Utils.common_utils.DIRs import TP_Profile_Data
from SEAS_Utils.common_utils.data_loader import two_column_file_loader
import SEAS_Utils.common_utils.data_plotter as plt

if __name__ == "__main__":
    

    user_input = config.Configuration("user_input_dev.cfg")
    
    if user_input["Simulation_Control"]["TP_Profile"] == "File":
        filename = os.path.join(TP_Profile_Data,user_input["Simulation_Control"]["TP_Profile_Name"])
        
        x,y = two_column_file_loader(filename)
        plt.simple_plot(y,np.log10(x))








import os
import sys
import numpy as np

DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(DIR, '../..'))

import SEAS_Utils.common_utils.configurable as config
from SEAS_Utils.common_utils.DIRs import Mixing_Ratio_Data
from SEAS_Utils.common_utils.data_loader import multi_column_file_loader
import SEAS_Utils.common_utils.data_plotter as plt

if __name__ == "__main__":
    

    user_input = config.Configuration("../a.Main/user_input_dev.cfg")
    
    if user_input["Simulation_Control"]["Mixing_Ratio"] == "File":
        filename = os.path.join(Mixing_Ratio_Data,user_input["Simulation_Control"]["Mixing_Ratio_Name"])
        print filename
        
        data = multi_column_file_loader(filename,type="mixed")
        
        pressure = data[0]
        mixing_ratio = data[1:]
        print pressure
        print mixing_ratio



# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
This code test the generation of TP Profiles
"""

import os
import sys

DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(DIR, '../..'))

import SEAS_Aux.atmosphere_processes.TP_profile_generator as TPgen
import SEAS_Utils.common_utils.configurable as config

if __name__ == "__main__":

    TP_input = config.Configuration(
        "TP_selection.cfg")["Test Isothermal Atmosphere"]

    simulator = TPgen.temperature_pressure_profile_generator(
        TP_input, name="isothermal_300K.txt")
    simulator.generate()

    simulator.save()
    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


if __name__ == "__main__":

    Timer = simple_timer()

    user_input = config.Configuration(
        os.path.join(track, "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"]["path"] = os.path.join(
        track, "output/Simple_Atmosphere_Window")
    user_input["Save"]["Window"][
        "name"] = "%s_Window_A1000_S100.txt" % Filename1
def generate_water():

    ratio_input = config.Configuration("water_only_selection.cfg")
    simulator = mix.mixing_ratio_generator(ratio_input,filler=False,name="selection/water_only2.txt")
    simulator.generate()
    simulator.save()
DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(DIR, '../..'))

import SEAS_Aux.atmosphere_processes.mixing_ratio_generator as mix
import SEAS_Utils.common_utils.configurable as config

def generate_water():

    ratio_input = config.Configuration("water_only_selection.cfg")
    simulator = mix.mixing_ratio_generator(ratio_input,filler=False,name="selection/water_only2.txt")
    simulator.generate()
    simulator.save()

if __name__ == "__main__":
    
    ratio_input = config.Configuration("selection/h2_only_selection.cfg")

    simulator = mix.mixing_ratio_generator(ratio_input,
                                           filler=True,
                                           filler_molecule="He",
                                           pressures = [100000.0, 36800.0, 13500.0, 4980.0, 1830.0, 674.0, 248.0, 91.2, 33.5, 12.3, 4.54, 1.67, 0.614, 0.226, 0.0832, 0.0306, 0.0113, 0.00414, 0.00152, 0.00056, 0.000206, 7.58e-05, 2.79e-05, 1.03e-05],
                                           name="H2&He.txt",
                                           overwrite=True)
    simulator.generate()
    simulator.save()
    
    
    
    
    
    
예제 #13
0
    x1, y1 = load_NIST_spectra(smiles, ["wn", "A"], True)
    y2 = biosig_interpolate(x1, y1, nu, "A")
    leg2, = plt.plot(10000. / nu, np.array(y2), label="NIST")

    legends = [leg1, leg2]

    plt.legend(handles=legends)
    plt.xlabel("Wavenumber (cm^-1)")
    plt.ylabel("Absorption (proxy)")
    plt.title('Simulated ATMOS vs NIST Molecular Absorption for: %s' % smiles)
    plt.show()


if __name__ == "__main__":

    molecule_input = config.Configuration("atmos_data.cfg")

    window = "earth2_atmosphere"
    pressure = 10e6
    temperature = 300

    for smiles in molecule_input:

        Simulator = ATMOS_1_Simulator(smiles, window, pressure, temperature)
        nu = np.arange(400, 30000, 1)
        xsec = Simulator.get_cross_section(nu)
        leg1, = plt.plot(10000. / nu, xsec, label="ATMOS")

        x1, y1 = load_NIST_spectra(smiles, ["wn", "A"], True)
        y2 = biosig_interpolate(x1, y1, nu, "A")
        leg2, = plt.plot(10000. / nu, np.array(y2), label="NIST")