.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/calc_hitran_full_range.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Run this example online : - Click :ref:`here ` to download the full example code - Then start `Radis-Lab `__, upload the Jupyter notebook, and run it from there. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_calc_hitran_full_range.py: .. _example_hitran_full_range: =============================== Calculate a full range spectrum =============================== We compute the transmittance of an homogeneous, 1-km atmosphere layer at 300 K and 1 atm, with 420 ppm CO2 and 2% H2O. This example makes use of a lot of the RADIS optimization and convenience functions : - The database is retrieved from the latest HITRAN data using [HAPI]_, parsed with RADIS and stored to memory-mapping formats. After the first calls, retrieving the database will be very fast - The RADIS algorithm includes a sparse wavenumber implementation, which is activated by default in the following example where the waverange is very large. This behavior can be changed by setting the `SPARSE_WAVENUMBER` key of the :py:attr:`radis.config` dictionary, or of the ~/radis.json user file. - The wavenumber grid is automatically computed using the `wstep='auto'` parameter. - A linestrength cutoff reduces the initial number of lines. Eventually, the full-range spectrum (about 4.8M points) is computed within a minute, with about 140k lines resolved, i.e. a performance of about 1e10 gridpoints*lines/s. Extra optimization could be achieved by cutting the spectrum in small intervals, but requires an a-priori knowledge of the absorption & emission ranges of the spectrum. See the :ref:`Calculate a large spectrum by part ` .. GENERATED FROM PYTHON SOURCE LINES 39-58 .. code-block:: default import astropy.units as u from radis import calc_spectrum s = calc_spectrum( wmin=0.5 * u.um, wmax=15 * u.um, # cm-1 mole_fraction={"CO2": 420e-6, "H2O": 0.02}, isotope="1,2,3", pressure=1.01325, # bar Tgas=300, # K path_length=1e5, # 1 km in cm verbose=2, databank="hitran", wstep="auto", ) .. GENERATED FROM PYTHON SOURCE LINES 59-61 Plot low and high resolution spectra on the same graph : .. GENERATED FROM PYTHON SOURCE LINES 61-69 .. code-block:: default s.apply_slit(10, "nm") import matplotlib.pyplot as plt plt.figure(figsize=(16, 6)) s.plot("transmittance_noslit", wunit="nm", color="k", alpha=0.1, nfig="same") s.plot("transmittance", wunit="nm", color="k", nfig="same") .. GENERATED FROM PYTHON SOURCE LINES 70-72 Print some details about the computed spectrum : We could also simply use `print(s)` .. GENERATED FROM PYTHON SOURCE LINES 72-84 .. code-block:: default print("Number of grid points: ", len(s)) print( "Number of lines: ", s.c["total_lines"] ) # some are discarded by linestrength cutoff print("Number of lines: ", s.c["lines_calculated"]) print("Whether the sparse wavenumber algorithm was activated: ", s.c["sparse_ldm"]) print(f"Lineshape truncation used: {s.c['truncation']:.1f}cm-1") print(f"Total calculation time: {s.c['calculation_time']:.1f}s") print( f"Gridpoints * lines/s : {len(s)*s.c['lines_calculated']/s.c['calculation_time']:.1e}" ) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_calc_hitran_full_range.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: calc_hitran_full_range.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: calc_hitran_full_range.ipynb `