Spectrum Database

RADIS has SpecDatabase feature used to store and retrieve calculated Spectrums. A path can be specified for SpecDatabase all Spectrums are stored as .spec files which can be loaded from the SpecDatabase object itself. A csv file is generated which contains all input and conditional parameters of Spectrum.

RADIS also has init_database() feature which initializes the SpecDatabase for the SpectrumFactory and every Spectrum generated from it will be stored in the SpecDatabase automatically.

You can use plot_cond() to make a 2D plot using the conditions of the Spectrums in the SpecDatabase and use a z_label to plot a heat map based on it.

SpecDatabase_Test

Out:

parse_local_quanta not implemented for molecules of HITRAN group 6
parse_global_quanta not implemented for molecules of HITRAN class 3
Database SpecDatabase_Test initialised in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples
*** Loading the database with 1 processor (0 files)***
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715.spec (0.1Mb)
loaded 20210715.spec
Loading database SpecDatabase_Test
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib1200K_Trot1200K.spec (0.1Mb)
loaded 20210715_Tvib1200K_Trot1200K.spec
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib2100K_Trot2100K.spec (0.1Mb)
loaded 20210715_Tvib2100K_Trot2100K.spec
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib3000K_Trot3000K.spec (0.1Mb)
loaded 20210715_Tvib3000K_Trot3000K.spec
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib300K_Trot300K.spec (0.2Mb)
loaded 20210715_Tvib300K_Trot300K.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib1200K_Trot1200K_1.spec (0.2Mb)
loaded 20210715_Tvib1200K_Trot1200K_1.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib2100K_Trot2100K_1.spec (0.2Mb)
loaded 20210715_Tvib2100K_Trot2100K_1.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib3000K_Trot3000K_1.spec (0.2Mb)
loaded 20210715_Tvib3000K_Trot3000K_1.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib300K_Trot300K_1.spec (0.4Mb)
loaded 20210715_Tvib300K_Trot300K_1.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib1200K_Trot1200K_2.spec (0.4Mb)
loaded 20210715_Tvib1200K_Trot1200K_2.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib2100K_Trot2100K_2.spec (0.4Mb)
loaded 20210715_Tvib2100K_Trot2100K_2.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib3000K_Trot3000K_2.spec (0.4Mb)
loaded 20210715_Tvib3000K_Trot3000K_2.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib300K_Trot300K_2.spec (11.5Mb)
loaded 20210715_Tvib300K_Trot300K_2.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib1200K_Trot1200K_3.spec (12.3Mb)
loaded 20210715_Tvib1200K_Trot1200K_3.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib2100K_Trot2100K_3.spec (12.4Mb)
loaded 20210715_Tvib2100K_Trot2100K_3.spec
Warning. File already exists. Filename is incremented
Spectrum stored in /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/examples/SpecDatabase_Test/20210715_Tvib3000K_Trot3000K_3.spec (12.4Mb)
loaded 20210715_Tvib3000K_Trot3000K_3.spec
Loading database SpecDatabase_Test

import os

import numpy as np

from radis import SpectrumFactory
from radis.tools import SpecDatabase

sf = SpectrumFactory(
    wavenum_min=2900,
    wavenum_max=3200,
    molecule="OH",
    broadening_max_width=10,  # cm-1
    medium="vacuum",
    verbose=0,  # more for more details
    pressure=10,
    wstep=0.1,
)
sf.warnings = {"AccuracyError": "ignore"}
sf.fetch_databank("hitemp")

# Generating a Spectrum
s1 = sf.eq_spectrum(Tgas=300, path_length=1)

# Creating SpecDatabase
my_folder = os.getcwd() + "/SpecDatabase_Test"
db = SpecDatabase(my_folder)

# Method 1: Creating .spec file and adding manually to SpecDatabase
db.add(s1)

# Method 2: Using init_database()
# Generated Spectrum are added to SpecDatabase automatically
sf.init_database(my_folder)

wstep = np.linspace(0.1, 0.001, 4)
Tgas = np.linspace(300, 3000, 4)


# Multiple Spectrum calculation based on different values of Tgas and wstep
for i in wstep:
    sf.wstep = i
    sf.params.wstep = i
    for j in Tgas:
        sf.eq_spectrum(Tgas=j, path_length=1)


# Loading SpecDatabase
db_new = SpecDatabase(my_folder)

# Plot Tgas vs wstep for all Spectrums, heatmap based on calculation_time
db_new.plot_cond("Tgas", "wstep", "calculation_time")

Total running time of the script: ( 0 minutes 7.600 seconds)

Gallery generated by Sphinx-Gallery