Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .editorconfig

This file was deleted.

26 changes: 19 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
version: 2
version: 2

build:
os: ubuntu-22.04
os: ubuntu-lts-latest
tools:
python: "3.10"
python: "mambaforge-latest"
jobs:
post_checkout:
- git fetch --unshallow || true
pre_install:
- git update-index --assume-unchanged .rtd-environment.yml docs/source/conf.py

conda:
environment: .rtd-environment.yml

sphinx:
configuration: docs/source/conf.py
builder: html
configuration: docs/source/conf.py
fail_on_warning: false

formats:
- htmlzip

# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
- requirements: requirements.txt
- method: setuptools
7 changes: 7 additions & 0 deletions .rtd-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: rtd_chiantipy
channels:
- conda-forge
dependencies:
- python=3.12
- pip
- graphviz!=2.42.*,!=2.43.*
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

24 changes: 11 additions & 13 deletions ChiantiPy/base/_IonTrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def argCheck(self, temperature=None, eDensity=None, pDensity='default', em = Non

def intensityList(self, index=None, wvlRange=None, wvlRanges=None, top=10, integrated=False,
relative=0, outFile=0, rightDigits=4):
"""
r"""
List the line intensities. Checks to see if there is an existing Intensity attribute.
If it exists, then those values are used.
Otherwise, the `intensity` method is called.
Expand All @@ -104,30 +104,28 @@ def intensityList(self, index=None, wvlRange=None, wvlRanges=None, top=10, integ
to 'energy', the intensity is given by,

.. math::
I = \\Delta E_{ij}n_jA_{ij}\\mathrm{Ab}\\frac{1}{N_e}
\\frac{N(X^{+m})}{N(X)}\\mathrm{EM},
I = \Delta E_{ij}n_jA_{ij}\mathrm{Ab}\frac{1}{N_e}\frac{N(X^{+m})}{N(X)}\mathrm{EM},

in units of ergs cm\\ :sup:`-2` s\\ :sup:`-1` sr \\ :sup:`-1`. If 'flux' is set to 'photon',
in units of ergs cm\ :sup:`-2` s\ :sup:`-1` sr \ :sup:`-1`. If 'flux' is set to 'photon',

.. math::
I = n_jA_{ij}\\mathrm{Ab}\\frac{1}{N_e}\\frac{N(X^{+m})}{N(X)}
\\mathrm{EM},
I = n_jA_{ij}\mathrm{Ab}\frac{1}{N_e}\frac{N(X^{+m})}{N(X)}\mathrm{EM},

where,

- :math:`\\Delta E_{ij}` is the transition energy (ergs)
- :math:`\Delta E_{ij}` is the transition energy (ergs)
- :math:`n_j` is the fractions of ions in level :math:`j`
- :math:`A_{ij}` is the Einstein coefficient for spontaneous emission
from level :math:`j` to level :math:`i` (in s\\ :sup:`-1`)
- :math:`\\mathrm{Ab}` is the abundance of the specified element
from level :math:`j` to level :math:`i` (in s\ :sup:`-1`)
- :math:`\mathrm{Ab}` is the abundance of the specified element
relative to hydrogen
- :math:`N_e` is the electron density (in cm\\ :sup:`-3`)
- :math:`N_e` is the electron density (in cm\ :sup:`-3`)
- :math:`N(X^{+m})/N(X)` is the fractional ionization of ion as a
function of temperature
- :math:`\\mathrm{EM}` is the emission measure integrated along the
line-of-sight, :math:`\\int\\mathrm{d}l\\,N_eN_H` (cm\\ :sup:`-5`) where
- :math:`\mathrm{EM}` is the emission measure integrated along the
line-of-sight, :math:`\int\mathrm{d}l\,N_eN_H` (cm\ :sup:`-5`) where
:math:`N_H` is the density of hydrogen (neutral + ionized)
(cm\\ :sup:`-3`)
(cm\ :sup:`-3`)

Note that if `relative` is set, the line intensity is relative to the
strongest line and so the output will be unitless.
Expand Down
4 changes: 2 additions & 2 deletions ChiantiPy/core/Bunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class bunch(ionTrails, specTrails):
'''
r'''
Calculate the emission line spectrum as a function of temperature and density.

'bunch' is very similar to 'spectrum' except that continuum is not calculated and
Expand Down Expand Up @@ -67,7 +67,7 @@ class instance of ChiantiPy.core.ion for 'mg_7'. All its methods and attributes
the temperature(s) in K

eDensity: float, ndarray
eDensity: electron density in :math:`\\mathrm{cm^{-3}}`
eDensity: electron density in :math:`\mathrm{cm^{-3}}`

wvlRange: 2 element `list` or `ndarray`
wvlRange: range of wavelengths to consider, generally in angstroms
Expand Down
28 changes: 14 additions & 14 deletions ChiantiPy/core/Continuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class continuum(ionTrails):
"""
r"""
The top level class for continuum calculations. Includes methods for the calculation of the
free-free and free-bound continua.

Expand All @@ -38,9 +38,9 @@ class continuum(ionTrails):
Elemental abundance relative to Hydrogen or name of CHIANTI abundance file,
without the '.abund' suffix, e.g. 'sun_photospheric_1998_grevesse'.
em : array-like, optional
Line-of-sight emission measure (:math:`\\int\\mathrm{d}l\\,n_en_H`), in units of
:math:`\\mathrm{cm}^{-5}`, or the volumetric emission measure (:math:`\\int\\mathrm{d}V\\,n_en_H`)
in units of :math:`\\mathrm{cm}^{-3}`.
Line-of-sight emission measure (:math:`\int\mathrm{d}l\,n_en_H`), in units of
:math:`\mathrm{cm}^{-5}`, or the volumetric emission measure (:math:`\int\mathrm{d}V\,n_en_H`)
in units of :math:`\mathrm{cm}^{-3}`.
verbose : `bool`
if True, prints additional info to the console

Expand Down Expand Up @@ -123,21 +123,21 @@ def __init__(self, ionStr, temperature, abundance=None, em=None, verbose=0):
self.ioneqOne()

def free_free_loss(self, includeAbund=True, includeIoneq=True, **kwargs):
"""
r"""
Calculate the free-free energy loss rate of an ion. The result is returned to the
`free_free_loss` attribute.

The free-free radiative loss rate is given by Eq. 5.15a of [107]_. Writing the numerical
constant in terms of the fine structure constant :math:`\\alpha`,
constant in terms of the fine structure constant :math:`\alpha`,

.. math::
\\frac{dW}{dtdV} = \\frac{4\\alpha^3h^2}{3\\pi^2m_e}\\left(\\frac{2\\pi k_B}{3m_e}\\right)^{1/2}Z^2T^{1/2}\\bar{g}_B
\frac{dW}{dtdV} = \frac{4\alpha^3h^2}{3\pi^2m_e}\left(\frac{2\pi k_B}{3m_e}\right)^{1/2}Z^2T^{1/2}\bar{g}_B

where where :math:`Z` is the nuclear charge, :math:`T` is the electron temperature, and
:math:`\\bar{g}_{B}` is the wavelength-averaged and velocity-averaged Gaunt factor. The
Gaunt factor is calculated using the methods of [103]_. Note that this expression for the
loss rate is just the integral over wavelength of Eq. 5.14a of [107]_, the free-free emission, and
is expressed in units of erg :math:`\\mathrm{cm}^3\\,\\mathrm{s}^{-1}`.
is expressed in units of erg :math:`\mathrm{cm}^3\,\mathrm{s}^{-1}`.

"""
# interpolate wavelength-averaged K&L gaunt factors
Expand All @@ -159,7 +159,7 @@ def free_free_loss(self, includeAbund=True, includeIoneq=True, **kwargs):
self.FreeFreeLoss = prefactor*(self.Zion**2)*np.sqrt(self.Temperature)*gaunt_factor

def freeFree(self, wavelength, includeAbund=True, includeIoneq=True, **kwargs):
"""
r"""
Calculates the free-free emission for a single ion. The result is returned as a dict to
the `FreeFree` attribute. The dict has the keywords `intensity`, `wvl`, `temperature`, `em`.

Expand All @@ -168,17 +168,17 @@ def freeFree(self, wavelength, includeAbund=True, includeIoneq=True, **kwargs):
constant in terms of the fine structure constant :math:`\\alpha`,

.. math::
\\frac{dW}{dtdVd\\lambda} = \\frac{c}{3m_e}\\left(\\frac{\\alpha h}{\\pi}\\right)^3\\left(\\frac{2\\pi}{3m_ek_B}\\right)^{1/2}\\frac{Z^2}{\\lambda^2T^{1/2}}\\exp{\\left(-\\frac{hc}{\\lambda k_BT}\\right)}\\bar{g}_{ff},
\frac{dW}{dtdVd\\lambda} = \frac{c}{3m_e}\left(\frac{\alpha h}{\pi}\right)^3\left(\frac{2\pi}{3m_ek_B}\right)^{1/2}\frac{Z^2}{\lambda^2T^{1/2}}\exp{\left(-\frac{hc}{\lambda k_BT}\right)}\bar{g}_{ff},

where :math:`Z` is the nuclear charge, :math:`T` is the electron temperature in K, and
:math:`\\bar{g}_{ff}` is the velocity-averaged Gaunt factor. The Gaunt factor is estimated
:math:`\bar{g}_{ff}` is the velocity-averaged Gaunt factor. The Gaunt factor is estimated
using the methods of [104]_ and [101]_, depending on the temperature and energy regime. See
`itoh_gaunt_factor` and `sutherland_gaunt_factor` for more details.

The free-free emission is in units of erg
:math:`\\mathrm{cm}^3\\mathrm{s}^{-1}\\mathrm{\\mathring{A}}^{-1}\\mathrm{str}^{-1}`. If the emission
measure has been set, the units will be multiplied by :math:`\\mathrm{cm}^{-5}` or
:math:`\\mathrm{cm}^{-3}`, depending on whether it is the line-of-sight or volumetric
:math:`\mathrm{cm}^3\mathrm{s}^{-1}\mathrm{\mathring{A}}^{-1}\mathrm{str}^{-1}`. If the emission
measure has been set, the units will be multiplied by :math:`\mathrm{cm}^{-5}` or
:math:`\mathrm{cm}^{-3}`, depending on whether it is the line-of-sight or volumetric
emission measure, respectively.

Parameters
Expand Down
12 changes: 6 additions & 6 deletions ChiantiPy/core/Ion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class ion(ioneqOne, ionTrails, specTrails):
"""
r"""
The top level class for performing spectral calculations for an ion in the
CHIANTI database.

Expand All @@ -37,9 +37,9 @@ class ion(ioneqOne, ionTrails, specTrails):
temperature : `float` , `tuple`, `list`, `~numpy.ndarray`, optional
Temperature array (Kelvin)
eDensity : `float` , `tuple`, `list`, or `~numpy.ndarray`, optional
Electron density array (:math:r`\\mathrm{cm^{-3}}` )
Electron density array (:math:`\mathrm{cm^{-3}}` )
pDensity : `float`, `tuple`, `list` or `~numpy.ndarray`, optional
Proton density (:math:r`\\mathrm{cm}^{-3}` )
Proton density (:math:`\mathrm{cm}^{-3}` )
radTemperature : `float` or `~numpy.ndarray`, optional
Radiation black-body temperature (in Kelvin)
rStar : `float` or `~numpy.ndarray`, optional
Expand All @@ -52,9 +52,9 @@ class ion(ioneqOne, ionTrails, specTrails):
attributes of the selected ion
em : `float` or `~numpy.ndarray`, optional
Emission Measure, for the line-of-sight emission measure
(:math:r`\\mathrm{\\int \\, n_e \\, n_H \\, dl}`)
(:math:r`\\mathrm{cm}^{-5}`.), for the volumetric emission measure
:math:r`\\mathrm{\\int \\, n_e \\, n_H \\, dV}` (:math:r`\\mathrm{cm^{-3}}`).
(:math:`\mathrm{\int \, n_e \, n_H \, dl}`)
(:math:`\mathrm{cm}^{-5}`.), for the volumetric emission measure
:math:`\mathrm{\int \, n_e \, n_H \, dV}` (:math:`\mathrm{cm^{-3}}`).

Attributes
----------
Expand Down
9 changes: 3 additions & 6 deletions ChiantiPy/core/Ioneq.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@
from .Ion import ion

def ioneqMake(filename, directory = None, temperature = None, reference = None, verbose = False):
"""a function to create a chianit .ioneq style ionization equilibrium
"""
A function to create a chianti .ioneq style ionization equilibrium

Parameters
----------

filename: `str`
the name of the file to be created - should end in .ioneq

directory: `str`
the directory where the file will be placed. If it is None, the the file
will be placed in the uses home directory.

temperature: `array-like`
the temperatures at which the ionization equilibrium will be calculated
the default value is None and the temperature will be 101 values exponentially
spaced between 10^4 and 10^9 K

reference: `list` of `str`
a list of references to be added to tail of file.
such as ['file created by me', 'today']

verbose: `bool`
if True, prints out information, the default is False
"""
Expand Down
2 changes: 1 addition & 1 deletion ChiantiPy/core/IpyMspectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussian
ylabel = self.Labels['spectrumYlabel']

if np.array_equal(self.Em, np.ones_like(self.Em)):
ylabel += '($\int\,$ N$_e\,$N$_H\,$d${\it l}$)$^{-1}$'
ylabel += r'($\int\,$ N$_e\,$N$_H\,$d${\it l}$)$^{-1}$'
#
self.AllLines = allLines
#
Expand Down
71 changes: 24 additions & 47 deletions ChiantiPy/core/MradLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,70 +16,47 @@


class mradLoss(ionTrails, specTrails):
""" Calculate the radiative emission loss rate as a function of temperature and density.
r"""
Calculate the radiative emission loss rate as a function of temperature and density.

this is the multiprocessing version of radloss
This is the multiprocessing version of radloss. It includes elemental abundances or
ionization equilibria. Temperature and density can be arrays but, unless the size of
either is one (1), the two must have the same size

includes elemental abundances or ionization equilibria

temperature and density can be arrays but, unless the size of either is one (1),
the two must have the same size


A selection of ions can be make with ionList containing the names of
the desired lines in Chianti notation,
i.e. C VI = c_6

a minimum abundance can be specified so that the calculation can be speeded up by excluding
A minimum abundance can be specified so that the calculation can be speeded up by excluding
elements with a low abundance. With solar photospheric abundances

setting minAbund = 1.e-4 will include H, He, C, O, Ne
setting minAbund = 2.e-5 adds N, Mg, Si, S, Fe
setting minAbund = 1.e-6 adds Na, Al, Ar, Ca, Ni

Setting em will multiply the spectrum at each temperature by the value of em.

em (for emission measure), can be a float or an array of the same length as the
temperature/density.

abundance: to select a particular set of abundances, set abundance to the name of a
CHIANTI abundance file, without the '.abund' suffix, e.g. 'sun_photospheric_1998_grevesse'
If set to a blank (''), a gui selection menu will popup and allow the
selection of an set of abundances
- setting minAbund = 1.e-4 will include H, He, C, O, Ne
- setting minAbund = 2.e-5 adds N, Mg, Si, S, Fe
- setting minAbund = 1.e-6 adds Na, Al, Ar, Ca, Ni

Parameters
--------------

temperature: `float`, `list`, `ndarray`
the temperature(s) in K

eDensity: float, ndarray
eDensity: electron density in :math:`\mathrm{cm^{-3}}`

electron density in :math:`\mathrm{cm^{-3}}`
elementList: `list`
elementList: list of elements to include, such as 'fe', 'ne', 's'

list of elements to include, such as 'fe', 'ne', 's'
ionList: `list`
ionList: list of ions to include, such as 'fe_16', 'ne_10'

list of ions to include, such as 'fe_16', 'ne_10'
minAbund: `float`
minAbund: minimum abundance (relative to H) to include

doLines: `bool1
doLines: if true, line intensities are calculated

minimum abundance (relative to H) to include
doLines: `bool`
if true, line intensities are calculated
doContinuum: `bool`
doContinuum: if true, continuum intensities are calculated only if wavelengths are in angstroms

if true, continuum intensities are calculated only if wavelengths are in angstroms
abundance: `str`
abuncance: the file name of the abuncance set to be used
must be one in the $XUVTOP/abund directory

the file name of the abuncance set to be used
must be one in the $XUVTOP/abund directory
to select a particular set of abundances, set abundance to the name of a
CHIANTI abundance file, without the '.abund' suffix, e.g. 'sun_photospheric_1998_grevesse'
If set to a blank (''), a gui selection menu will popup and allow the
selection of an set of abundances
allLInes: `bool`
allLines: whether or not to include unobserved lines

whether or not to include unobserved lines
verbose: `bool`
verbose: whether to allow certain print statements
whether to allow certain print statements

"""
def __init__(self, temperature, eDensity, elementList=None, ionList = None, minAbund=None,
Expand Down
Loading