.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/user_guide/ion_metadata.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_gallery_user_guide_ion_metadata.py: Creating an `Ion` ================== This example shows how to create a `~fiasco.Ion` object and access various pieces of metadata. .. GENERATED FROM PYTHON SOURCE LINES 8-13 .. code-block:: Python import astropy.units as u import numpy as np from fiasco import Ion .. GENERATED FROM PYTHON SOURCE LINES 14-19 The CHIANTI database is organized around individual ions, with multiple types of datafiles attached to each ion. In keeping with the organization of the database, the primary unit of the fiasco library is the `~fiasco.Ion` object which can be created in the following way, .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: Python temperature = np.logspace(5, 7, 100) * u.K ion = Ion('Fe 15', temperature) print(ion) .. rst-class:: sphx-glr-script-out .. code-block:: none CHIANTI Database Ion --------------------- Name: Fe 15 Element: iron (26) Charge: +14 Number of Levels: 283 Number of Transitions: 0 Temperature range: [0.100 MK, 10.000 MK] HDF5 Database: /home/docs/.fiasco/chianti_dbase.h5 Using Datasets: ioneq: chianti abundance: sun_coronal_1992_feldman_ext ip: chianti .. GENERATED FROM PYTHON SOURCE LINES 24-26 This creates a `~fiasco.Ion` object for the Fe XV ion. Note also the same object can also be created in the following ways, .. GENERATED FROM PYTHON SOURCE LINES 26-30 .. code-block:: Python ion = Ion('iron 15', temperature) ion = Ion('iron 14+', temperature) ion = Ion('Fe XV', temperature) .. GENERATED FROM PYTHON SOURCE LINES 31-33 The `~fiasco.Ion` object holds several basic pieces of metadata related to the particular ion, .. GENERATED FROM PYTHON SOURCE LINES 33-41 .. code-block:: Python print(ion.element_name) print(ion.atomic_symbol) print(ion.atomic_number) print(ion.ion_name) print(ion.charge_state) print(ion.ionization_stage) print(ion.abundance) .. rst-class:: sphx-glr-script-out .. code-block:: none iron Fe 26 Fe 15 14 15 0.0001258925411794166 .. GENERATED FROM PYTHON SOURCE LINES 42-44 The `~fiasco.Ion` object can also be indexed like an array in order to get information about the energy levels. .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: Python print(ion[0]) .. rst-class:: sphx-glr-script-out .. code-block:: none Level: 1 Configuration: 3s2 Orbital Angular Momentum: S Energy: 0.0 eV .. GENERATED FROM PYTHON SOURCE LINES 47-48 Each level also holds various bits of metadata .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python for i in range(5): lev = ion[i] print(f'Level {lev.level} {lev.configuration}, {lev.energy}') .. rst-class:: sphx-glr-script-out .. code-block:: none Level 1 3s2, 0.0 erg Level 2 3s.3p, 4.6451447212741975e-11 erg Level 3 3s.3p, 4.760716141243122e-11 erg Level 4 3s.3p, 5.04199687461541e-11 erg Level 5 3s.3p, 6.990521480351365e-11 erg .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.197 seconds) .. _sphx_glr_download_generated_gallery_user_guide_ion_metadata.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ion_metadata.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ion_metadata.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_