Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new GauntFactor class and add Itoh integrated Gaunt factors to f-f radiative loss #293

Merged
merged 69 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
8b36d16
add parsers for itoh_integrated_gaunt files
Aug 15, 2024
92853a7
fix coefficient labels -- wrong order
Aug 15, 2024
a1b7e1f
Merge branch 'wtbarnes:main' into itoh
jwreep Aug 31, 2024
d35c670
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 4, 2024
51075d8
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 10, 2024
cb32bfe
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 11, 2024
8b84276
add parsed data to ContinuumBase
Sep 11, 2024
241f9d8
start implementing new GauntFactor class
Sep 12, 2024
c26a273
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 13, 2024
2402ffb
integrate GauntFactor class into radiation calculations
Sep 13, 2024
9c74997
fix f-f rad loss
Sep 13, 2024
73a498f
update Gaunt factor tests
Sep 13, 2024
aa42780
start refactoring GauntFactor
Sep 13, 2024
f0f07f0
move _itoh dataset to GauntFactor
jwreep Sep 13, 2024
922ef13
tidy up calls to GF
jwreep Sep 13, 2024
83a6854
fix tests + pre-commit
jwreep Sep 13, 2024
4bf791c
fix last two tests
jwreep Sep 14, 2024
c09ed43
Update fiasco/ions.py
jwreep Sep 14, 2024
a0bf0c5
add functions for new Itoh Gaunt factors
Sep 14, 2024
7933c3c
move free-bound and klgfb to GauntFactor
jwreep Sep 16, 2024
001edc5
fix issues with parser preprocessors
jwreep Sep 17, 2024
052fd71
fix new itoh functions
jwreep Sep 17, 2024
7f48cdc
fix up integrated f-f Gaunt factors
jwreep Sep 18, 2024
7f17671
rearrange if-else logic to be more readable
jwreep Sep 18, 2024
2e5fcde
add itoh options to radiative loss calculations
jwreep Sep 18, 2024
0841440
fix docstring error?
jwreep Sep 18, 2024
1366833
add test_gaunt + move GF tests to this file
jwreep Sep 18, 2024
628ecc8
small changes to gaunt tests
Sep 18, 2024
4adf993
fix initialization in test
Sep 18, 2024
7f4b612
add test for new data sources
Sep 18, 2024
b79455b
use Einstein summation to speed up integrated Itoh gf
Sep 19, 2024
c46bae1
dat -> txt
jwreep Sep 20, 2024
8675be0
rename datasets
jwreep Sep 20, 2024
bf42522
Merge branch 'wtbarnes:main' into itoh
jwreep Sep 20, 2024
3c06523
replace total gaunt factor with integrated gaunt factor
Sep 20, 2024
7cf93ea
update the logic of Itoh integrated f-f gf
Sep 20, 2024
af55bc0
import missingdatasetexception
jwreep Sep 21, 2024
97c2b19
add some small tests
jwreep Sep 21, 2024
f5c0d53
test the existence of the datasets for gaunt factors
jwreep Sep 21, 2024
306de75
fix test
Sep 21, 2024
c601e84
first attempt to generalize building the test file list for a new ver…
Sep 21, 2024
8bbb6d7
fix docs issue with change to test_file_test
Sep 21, 2024
a3c90c8
use test file list iff the file list has length 0
Sep 21, 2024
eb1fe59
add a few more tests for itoh gf
Sep 21, 2024
88d75c1
two more tests + try to fix docs build
Sep 22, 2024
6d01f04
make changes to test_gaunt
Sep 23, 2024
d14ada0
make changes to collections
Sep 23, 2024
f0462c7
one more update to collections
Sep 23, 2024
6d4ecea
update ions.py
Sep 23, 2024
2939ba6
Update fiasco/io/sources/continuum_sources.py
jwreep Sep 23, 2024
fff7d4a
Update fiasco/gaunt.py
jwreep Sep 23, 2024
ce92ba5
Update fiasco/gaunt.py
jwreep Sep 23, 2024
fbbd3cc
fix summations for itoh integrated gf
jwreep Sep 24, 2024
d1b69c0
Update fiasco/gaunt.py
jwreep Sep 24, 2024
ef03339
atleast_1d(E_scaled)
jwreep Sep 24, 2024
6334924
remove gf from top level namespace
jwreep Sep 24, 2024
2bd1ccb
update docstring of f-f integrated
jwreep Sep 24, 2024
db0ecaf
remove GauntFactor from init attributes
jwreep Sep 24, 2024
5bccf76
fix docs issue related to change in __init__ file
jwreep Sep 24, 2024
0bdd2f1
how do you revert?
Sep 24, 2024
7fb7d39
minor docstring changes
Sep 25, 2024
b5d103f
add hash table v9.0.1; revert setup_db changes
Sep 25, 2024
aa20621
restore test_file_list
Sep 25, 2024
fb4e2c1
slight docstring change
jwreep Sep 26, 2024
a31457b
fix docstring
jwreep Sep 26, 2024
fb8a1ae
fix indentation -- please build docs
jwreep Sep 26, 2024
1ef87c6
more consistency in docstrings
wtbarnes Sep 26, 2024
7145d47
simplify bibtex entry
wtbarnes Sep 26, 2024
ee77037
more docstring consistency
wtbarnes Sep 26, 2024
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
2 changes: 2 additions & 0 deletions fiasco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from fiasco.collections import IonCollection
from fiasco.elements import Element
from fiasco.fiasco import list_elements, list_ions, proton_electron_ratio
from fiasco.gaunt import GauntFactor
jwreep marked this conversation as resolved.
Show resolved Hide resolved
from fiasco.ions import Ion
from fiasco.levels import Level, Transitions
from fiasco.util.util import setup_paths
Expand Down Expand Up @@ -51,6 +52,7 @@ def _get_bibtex():
"Ion",
"Level",
"Transitions",
"GauntFactor",
"defaults",
"log",
"__version__",
Expand Down
11 changes: 0 additions & 11 deletions fiasco/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ class ContinuumBase(Base):
.. note:: This is not meant to be instantiated directly by the user
and primarily serves as a base class for `~fiasco.Ion`.
"""

@property
def _gffgu(self):
data_path = '/'.join(['continuum', 'gffgu'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _gffint(self):
data_path = '/'.join(['continuum', 'gffint'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

@property
def _klgfb(self):
data_path = '/'.join(['continuum', 'klgfb'])
Expand Down
231 changes: 231 additions & 0 deletions fiasco/gaunt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
"""
Gaunt factor object.
"""
import astropy.constants as const
import astropy.units as u
import numpy as np

from scipy.ndimage import map_coordinates
from scipy.special import polygamma

import fiasco

from fiasco.io.datalayer import DataIndexer
from fiasco.util import check_database, needs_dataset

__all__ = ['GauntFactor']

class GauntFactor():
"""
Class for calculating the Gaunt factor for various continuum processes.
"""
def __init__(self, ion, wavelength=None, freefree=False, freebound=False,
wavelength_integrated=False,
hdf5_dbase_root=None, *args, **kwargs):
jwreep marked this conversation as resolved.
Show resolved Hide resolved
if hdf5_dbase_root is None:
self.hdf5_dbase_root = fiasco.defaults['hdf5_dbase_root']
else:
self.hdf5_dbase_root = hdf5_dbase_root

Check warning on line 28 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L28

Added line #L28 was not covered by tests
check_database(self.hdf5_dbase_root, **kwargs)

self.freefree = freefree
self.freebound = freebound
self.wavelength_integrated = wavelength_integrated

Check warning on line 33 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L31-L33

Added lines #L31 - L33 were not covered by tests

self.gf = None
if freefree and wavelength is not None and not wavelength_integrated:
self.gf = self.free_free(ion, wavelength)
elif freefree and wavelength_integrated:
self.gf = self.free_free_total(ion)
elif freebound and wavelength_integrated:
self.gf = self.free_bound_total(ion, **kwargs)

Check warning on line 41 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L35-L41

Added lines #L35 - L41 were not covered by tests
jwreep marked this conversation as resolved.
Show resolved Hide resolved

def __str__(self):
return f"{self.gf}"

Check warning on line 44 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L44

Added line #L44 was not covered by tests

def __repr__(self):
if self.freefree:
gaunt_type = "Free-free"
elif self.freebound:
gaunt_type = "Free-bound"

Check warning on line 50 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L48-L50

Added lines #L48 - L50 were not covered by tests

if self.wavelength_integrated:
wavelength_type = ", wavelength-integrated"

Check warning on line 53 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L52-L53

Added lines #L52 - L53 were not covered by tests
else:
wavelength_type = " as a function of wavelength"

Check warning on line 55 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L55

Added line #L55 was not covered by tests

return f"{gaunt_type} Gaunt Factor{wavelength_type}"

Check warning on line 57 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L57

Added line #L57 was not covered by tests

@property
def _gffgu(self):
data_path = '/'.join(['continuum', 'gffgu'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

Check warning on line 62 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L61-L62

Added lines #L61 - L62 were not covered by tests

@property
def _gffint(self):
data_path = '/'.join(['continuum', 'gffint'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

Check warning on line 67 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L66-L67

Added lines #L66 - L67 were not covered by tests

@property
def _itohintrel(self):
data_path = '/'.join(['continuum', 'itohintrel'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

Check warning on line 72 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L71-L72

Added lines #L71 - L72 were not covered by tests

@property
def _itohintnonrel(self):
data_path = '/'.join(['continuum', 'itohintnonrel'])
return DataIndexer.create_indexer(self.hdf5_dbase_root, data_path)

Check warning on line 77 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L76-L77

Added lines #L76 - L77 were not covered by tests

jwreep marked this conversation as resolved.
Show resolved Hide resolved
@u.quantity_input
def free_free(self, ion, wavelength: u.angstrom) -> u.dimensionless_unscaled:
r"""
Free-free Gaunt factor as a function of wavelength.

The free-free Gaunt factor is calculated from a lookup table of temperature averaged
free-free Gaunt factors from Table 2 of :cite:t:`sutherland_accurate_1998` as a function
of :math:`\log{\gamma^2},\log{u}`, where :math:`\gamma^2=Z^2\mathrm{Ry}/k_BT`
and :math:`u=hc/\lambda k_BT`.

For the regime, :math:`6<\log_{10}(T)< 8.5` and :math:`-4<\log_{10}(u)<1`, the above
prescription is replaced with the fitting formula of :cite:t:`itoh_relativistic_2000`
for the relativistic free-free Gaunt factor. This is given by Eq. 4 of
:cite:t:`itoh_relativistic_2000`,

.. math::

g_{ff} = \sum_{i,j=0}^{10} a_{ij}t^iU^j,

where :math:`t=(\log{T} - 7.25)/1.25` and :math:`U=(\log{u} + 1.5)/2.5`.
"""
gf_itoh = self._free_free_itoh(ion, wavelength)
gf_sutherland = self._free_free_sutherland(ion, wavelength)
gf = np.where(np.isnan(gf_itoh), gf_sutherland, gf_itoh)

Check warning on line 102 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L100-L102

Added lines #L100 - L102 were not covered by tests

return gf

Check warning on line 104 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L104

Added line #L104 was not covered by tests
jwreep marked this conversation as resolved.
Show resolved Hide resolved

@u.quantity_input
def _free_free_itoh(self, ion, wavelength: u.angstrom) -> u.dimensionless_unscaled:
jwreep marked this conversation as resolved.
Show resolved Hide resolved
log10_temperature = np.log10(ion.temperature.to(u.K).value)

Check warning on line 108 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L108

Added line #L108 was not covered by tests
# calculate scaled energy and temperature
tmp = np.outer(ion.temperature, wavelength)
lower_u = const.h * const.c / const.k_B / tmp
upper_u = 1. / 2.5 * (np.log10(lower_u) + 1.5)
t = 1. / 1.25 * (log10_temperature - 7.25)
itoh_coefficients = ion._itoh['a']

Check warning on line 114 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L110-L114

Added lines #L110 - L114 were not covered by tests
# calculate Gaunt factor
gf = u.Quantity(np.zeros(upper_u.shape))
for j in range(11):
for i in range(11):
gf += (itoh_coefficients[i, j] * (t**i))[:, np.newaxis] * (upper_u**j)

Check warning on line 119 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L116-L119

Added lines #L116 - L119 were not covered by tests
# apply NaNs where Itoh approximation is not valid
gf = np.where(np.logical_and(np.log10(lower_u) >= -4., np.log10(lower_u) <= 1.0),

Check warning on line 121 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L121

Added line #L121 was not covered by tests
gf, np.nan)
gf[np.where(np.logical_or(log10_temperature <= 6.0, log10_temperature >= 8.5)), :] = np.nan

Check warning on line 123 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L123

Added line #L123 was not covered by tests

return gf

Check warning on line 125 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L125

Added line #L125 was not covered by tests

@needs_dataset('gffgu')
@u.quantity_input
def _free_free_sutherland(self, ion, wavelength: u.angstrom) -> u.dimensionless_unscaled:
jwreep marked this conversation as resolved.
Show resolved Hide resolved
Ry = const.h * const.c * const.Ryd
tmp = np.outer(ion.temperature, wavelength)
lower_u = const.h * const.c / const.k_B / tmp
gamma_squared = ((ion.charge_state**2) * Ry / const.k_B / ion.temperature[:, np.newaxis]

Check warning on line 133 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L130-L133

Added lines #L130 - L133 were not covered by tests
* np.ones(lower_u.shape))
# NOTE: This escape hatch avoids a divide-by-zero warning as we cannot take log10
# of 0. This does not matter as the free-free continuum will be 0 for zero charge
# state anyway.
if ion.charge_state == 0:
return u.Quantity(np.zeros(lower_u.shape))

Check warning on line 139 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L138-L139

Added lines #L138 - L139 were not covered by tests
# convert to index coordinates
i_lower_u = (np.log10(lower_u) + 4.) * 10.
i_gamma_squared = (np.log10(gamma_squared) + 4.) * 5.
indices = [i_gamma_squared.flatten(), i_lower_u.flatten()]

Check warning on line 143 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L141-L143

Added lines #L141 - L143 were not covered by tests
# interpolate data to scaled quantities
# FIXME: interpolate without reshaping?
gf_data = self._gffgu['gaunt_factor'].reshape(

Check warning on line 146 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L146

Added line #L146 was not covered by tests
np.unique(self._gffgu['u']).shape[0],
np.unique(self._gffgu['gamma_squared']).shape[0],
)
gf = map_coordinates(gf_data, indices, order=1, mode='nearest').reshape(lower_u.shape)

Check warning on line 150 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L150

Added line #L150 was not covered by tests

return u.Quantity(np.where(gf < 0., 0., gf))

Check warning on line 152 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L152

Added line #L152 was not covered by tests

@needs_dataset('gffint')
@u.quantity_input
def free_free_total(self, ion) -> u.dimensionless_unscaled:
jwreep marked this conversation as resolved.
Show resolved Hide resolved
"""
The total (wavelength-averaged) free-free Gaunt factor, used for calculating
the total radiative losses from free-free emission.
"""
if ion.charge_state == 0:
return u.Quantity(np.zeros(ion.temperature.shape))

Check warning on line 162 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L161-L162

Added lines #L161 - L162 were not covered by tests
else:
Ry = const.h * const.c * const.Ryd
log_gamma_squared = np.log10((ion.charge_state**2 * Ry) / (const.k_B * ion.temperature))
index = [np.abs(self._gffint['log_gamma_squared'] - x).argmin() for x in log_gamma_squared]
delta = log_gamma_squared - self._gffint['log_gamma_squared'][index]

Check warning on line 167 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L164-L167

Added lines #L164 - L167 were not covered by tests
# The spline fit was pre-calculated by Sutherland 1998:
return self._gffint['gaunt_factor'][index] + delta * (self._gffint['s1'][index] + delta * (self._gffint['s2'][index] + delta * self._gffint['s3'][index]))

Check warning on line 169 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L169

Added line #L169 was not covered by tests

@u.quantity_input
def free_bound_total(self, ion, ground_state=True) -> u.dimensionless_unscaled:
r"""
The total Gaunt factor for free-bound emission, using the expressions from :cite:t:`mewe_calculated_1986`.

The Gaunt factor is not calculated for individual levels, except that the ground state has
been specified to be :math: `g_{fb}(n_{0}) = 0.9` following :cite:t:`mewe_calculated_1986`.

Parameters
----------
ground_state : `bool`, optional
If True (default), calculate the Gaunt factor for recombination onto the ground state :math: `n = 0`.
Otherwise, calculate for recombination onto higher levels with :math: `n > 1`. See Equation 16 of
:cite:t:`mewe_calculated_1986`.

Notes
-----
Equation 14 of :cite:t:`mewe_calculated_1986` has a simple
analytic solution. They approximate
.. math::
f_{1}(Z, n, n_{0} ) = \sum_{1}^{\infty} n^{-3} - \sum_{1}^{n_{0}} n^{-3} = \zeta(3) - \sum_{1}^{n_{0}} n^{-3} \approx 0.21 n_{0}^{-1.5}

where :math: `\zeta(x)` is the Riemann zeta function.

However, the second sum is analytic, :math: `\sum_{1}^{n_{0}} n^{-3} = \zeta(3) + \frac{1}{2}\psi^{(2)}(n_{0}+1)`
where :math: `\psi^{n}(x)` is the n-th derivative of the digamma function (a.k.a. the polygamma function).
So, we can write the full solution as:
.. math::
f_{1}(Z, n, n_{0}) = \zeta(3) - \sum_{1}^{n_{0}} n^{-3} = - \frac{1}{2}\psi^{(2)}(n_{0}+1)

The final expression is therefore simplified and more accurate than :cite:t:`mewe_calculated_1986`.
"""
z = ion.charge_state
if z == 0:
return u.Quantity(np.zeros(ion.temperature.shape))

Check warning on line 205 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L203-L205

Added lines #L203 - L205 were not covered by tests
else:
recombined = ion.previous_ion()
if not recombined._has_dataset('fblvl'):
return u.Quantity(np.zeros(ion.temperature.shape))
Ry = const.h * const.c * const.Ryd
prefactor = (Ry / (const.k_B * ion.temperature)).decompose()
n_0 = recombined._fblvl['n'][0]
if ground_state:
g_n_0 = 0.9 # The ground state Gaunt factor, g_fb(n_0), prescribed by Mewe et al 1986
z_0 = n_0 * np.sqrt(recombined.ip / Ry).decompose()

Check warning on line 215 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L207-L215

Added lines #L207 - L215 were not covered by tests
jwreep marked this conversation as resolved.
Show resolved Hide resolved
# NOTE: Low temperatures can lead to very large terms in the exponential and in some
# cases, the exponential term can exceed the maximum number expressible in double precision.
# These terms are eventually set to zero anyway since the ionization fraction is so small
# at these temperatures.
with np.errstate(over='ignore'):
f_2 = g_n_0 * ion._zeta_0 * (z_0**4 / n_0**5) * np.exp((prefactor * z_0**2)/(n_0**2))

Check warning on line 221 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L220-L221

Added lines #L220 - L221 were not covered by tests
jwreep marked this conversation as resolved.
Show resolved Hide resolved
else:
f_1 = -0.5 * polygamma(2, n_0 + 1)
with np.errstate(over='ignore'):
f_2 = 2.0 * f_1 * z**4 * np.exp((prefactor * z**2)/((n_0+1)**2))

Check warning on line 225 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L223-L225

Added lines #L223 - L225 were not covered by tests
# Large terms in the exponential can lead to infs in the f_2 term. These will be zero'd
# out when multiplied by the ionization equilibrium anyway
f_2 = np.where(np.isinf(f_2), 0.0, f_2)

Check warning on line 228 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L228

Added line #L228 was not covered by tests

return (prefactor * f_2)

Check warning on line 230 in fiasco/gaunt.py

View check run for this annotation

Codecov / codecov/patch

fiasco/gaunt.py#L230

Added line #L230 was not covered by tests

54 changes: 52 additions & 2 deletions fiasco/io/sources/continuum_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

from fiasco.io.generic import GenericParser

__all__ = ['GffguParser', 'GffintParser', 'KlgfbParser', 'VernerParser', 'ItohParser',
'HSeqParser', 'HeSeqParser']
__all__ = ['GffguParser', 'GffintParser', 'ItohIntegratedGauntParser',
'ItohIntegratedGauntNonrelParser', 'KlgfbParser', 'VernerParser',
'ItohParser', 'HSeqParser', 'HeSeqParser']


class GffguParser(GenericParser):
Expand Down Expand Up @@ -93,6 +94,55 @@
super().__init__(filename, **kwargs)
self.body_index = 4

class ItohIntegratedGauntParser(GenericParser):
"""
Total (frequency-integrated) relativistic free-free Gaunt factor as a
function of a scaled temperature and scaled atomic number.
"""
filetype='itoh_integrated_gaunt'
dtypes=[float, float, float, float, float, float, float, float, float, float, float]
units = [u.dimensionless_unscaled, u.dimensionless_unscaled, u.dimensionless_unscaled,
u.dimensionless_unscaled, u.dimensionless_unscaled, u.dimensionless_unscaled,
u.dimensionless_unscaled, u.dimensionless_unscaled, u.dimensionless_unscaled,
u.dimensionless_unscaled, u.dimensionless_unscaled]
headings = ['a_i0','a_i1','a_i2','a_i3','a_i4','a_i5','a_i6','a_i7','a_i8','a_i9', 'a_i10']
descriptions = ['fitting coefficient','fitting coefficient', 'fitting coefficient',
'fitting coefficient', 'fitting coefficient', 'fitting coefficient',
'fitting coefficient', 'fitting coefficient', 'fitting coefficient',
'fitting coefficient', 'fitting coefficient']

def __init__(self, filename, **kwargs):
super().__init__(filename, **kwargs)
self.full_path = pathlib.Path(kwargs.get('full_path',

Check warning on line 116 in fiasco/io/sources/continuum_sources.py

View check run for this annotation

Codecov / codecov/patch

fiasco/io/sources/continuum_sources.py#L115-L116

Added lines #L115 - L116 were not covered by tests
self.ascii_dbase_root / 'continuum' / filename))
jwreep marked this conversation as resolved.
Show resolved Hide resolved

def extract_footer(self, *args):
return """Fit parameters for relativistic free-free Gaunt factors integrated over frequency.

Check warning on line 120 in fiasco/io/sources/continuum_sources.py

View check run for this annotation

Codecov / codecov/patch

fiasco/io/sources/continuum_sources.py#L120

Added line #L120 was not covered by tests
Itoh et al., 2002, A&A, 382, 722
comment: These are the coefficients a_ik tabulated in Table 1."""


class ItohIntegratedGauntNonrelParser(GenericParser):
"""
Total (frequency-integrated) non-relativistic free-free Gaunt factor as a
function of a scaled temperature.
"""
filetype='itoh_integrated_gaunt_nonrel'
dtypes=[float]
units = [u.dimensionless_unscaled]
headings = ['b_i']
descriptions = ['fitting coefficient']

def __init__(self, filename, **kwargs):
super().__init__(filename, **kwargs)
self.full_path = pathlib.Path(kwargs.get('full_path',

Check warning on line 138 in fiasco/io/sources/continuum_sources.py

View check run for this annotation

Codecov / codecov/patch

fiasco/io/sources/continuum_sources.py#L137-L138

Added lines #L137 - L138 were not covered by tests
self.ascii_dbase_root / 'continuum' / filename))
jwreep marked this conversation as resolved.
Show resolved Hide resolved

def extract_footer(self, *args):
return """Fit coefficients for non-relativistic, frequency integrated free-free Gaunt factor

Check warning on line 142 in fiasco/io/sources/continuum_sources.py

View check run for this annotation

Codecov / codecov/patch

fiasco/io/sources/continuum_sources.py#L142

Added line #L142 was not covered by tests
Itoh et al. (2002, A&A, 382, 722)
Comment: Data taken from Table 2 of this work."""


class KlgfbParser(GenericParser):
"""
Expand Down
Loading
Loading