.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/0_Database_handling/plot_custom_abundances.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note You can download :ref:`below ` the full example code and run it with 🔬 `Radis-Lab `__, .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_0_Database_handling_plot_custom_abundances.py: .. _example_custom_abundances: ===================== Use Custom Abundances ===================== Custom isotopologue abundances can be defined, to model non-terrestrial atmospheres. Abundances are read and set directly in the :py:class:`~radis.lbl.factory.SpectrumFactory` using the :py:meth:`~radis.lbl.loader.DatabankLoader.get_abundance` and :py:meth:`~radis.lbl.loader.DatabankLoader.set_abundance` methods. Below, we compute a CO2 spectrum with custom abundances for the two main terrestrial isotopes (12C-16O2 ; 13C-16O2) See Also -------- :py:class:`~radis.db.molparam.MolParams` .. GENERATED FROM PYTHON SOURCE LINES 24-42 .. code-block:: Python from radis.test.utils import setup_test_line_databases setup_test_line_databases() # creates "HITEMP-CO2-TEST" for this example from radis import SpectrumFactory sf = SpectrumFactory( 2284.2, 2284.6, wstep=0.001, # cm-1 pressure=20 * 1e-3, # bar mole_fraction=400e-6, molecule="CO2", isotope="1,2", verbose=False, ) sf.load_databank("HITEMP-CO2-TEST") .. rst-class:: sphx-glr-script-out .. code-block:: none Added HITRAN-CO2-TEST database in /home/docs/radis.json Added HITRAN-CO-TEST database in /home/docs/radis.json Added HITEMP-CO2-TEST database in /home/docs/radis.json Added HITEMP-CO2-HAMIL-TEST database in /home/docs/radis.json /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/db/molparam.py:252: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use ``sep='\s+'`` instead df = pd.read_csv(file, comment="#", delim_whitespace=True) /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/warning.py:427: MissingReferenceWarning: Missing doi for CDSD-HITEMP. Use HITEMP-2010? warnings.warn(WarningType(message)) /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/api/tools.py:280: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)` new_col = df["branch"].replace(mapping) .. GENERATED FROM PYTHON SOURCE LINES 43-44 To explicitly identify the isotopes we can use the molparam attribute the Factory .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python print(sf.molparam.get("CO2", 1, "isotope_name")) # >> (12C)(16O)2 print(sf.molparam.get("CO2", 2, "isotope_name")) # >> (13C)(16O)2 .. rst-class:: sphx-glr-script-out .. code-block:: none (12C)(16O)2 (13C)(16O)2 .. GENERATED FROM PYTHON SOURCE LINES 49-50 Print the default abundance of the CO2 isotopes, compute a spectrum .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python print("Abundance of CO2[1,2]", sf.get_abundance("CO2", [1, 2])) sf.eq_spectrum(2000).plot("abscoeff") .. image-sg:: /auto_examples/0_Database_handling/images/sphx_glr_plot_custom_abundances_001.png :alt: plot custom abundances :srcset: /auto_examples/0_Database_handling/images/sphx_glr_plot_custom_abundances_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Abundance of CO2[1,2] [[0.984204 ] [0.0110574]] /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/warning.py:427: PerformanceWarning: 'object' type column found in database, calculations and memory usage would be faster with a numeric type. Possible solution is to not use 'save_memory' and convert the columns to dtype. warnings.warn(WarningType(message)) .. GENERATED FROM PYTHON SOURCE LINES 54-55 Set the abundance of CO2(626) to 0.8; and the abundance of CO2(636) to 0.2 (arbitrary): .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python sf.set_abundance("CO2", [1, 2], [0.8, 0.2]) print("New abundance of CO2[1,2]", sf.get_abundance("CO2", [1, 2])) sf.eq_spectrum(2000).plot("abscoeff", nfig="same") .. image-sg:: /auto_examples/0_Database_handling/images/sphx_glr_plot_custom_abundances_002.png :alt: plot custom abundances :srcset: /auto_examples/0_Database_handling/images/sphx_glr_plot_custom_abundances_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none New abundance of CO2[1,2] [[0.8] [0.2]] /home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/latest/radis/misc/warning.py:427: PerformanceWarning: 'object' type column found in database, calculations and memory usage would be faster with a numeric type. Possible solution is to not use 'save_memory' and convert the columns to dtype. warnings.warn(WarningType(message)) findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans. findfont: Generic family 'sans-serif' not found because none of the following families were found: Helvetica, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Avant Garde, sans-serif .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.189 seconds) .. _sphx_glr_download_auto_examples_0_Database_handling_plot_custom_abundances.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_custom_abundances.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_custom_abundances.py `