diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index bae652c7..00000000 --- a/.editorconfig +++ /dev/null @@ -1,18 +0,0 @@ -# http://editorconfig.org - -root = true - -# utf, UNIX-style new line -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.{py,rst,md}] -indent_style = space -indent_size = 4 - -[*.yml] -indent_style = space -indent_size = 2 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 188122fd..4b80683b 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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 diff --git a/.rtd-environment.yml b/.rtd-environment.yml new file mode 100644 index 00000000..b92f46df --- /dev/null +++ b/.rtd-environment.yml @@ -0,0 +1,7 @@ +name: rtd_chiantipy +channels: + - conda-forge +dependencies: + - python=3.12 + - pip + - graphviz!=2.42.*,!=2.43.* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bce2b8bb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: python - -python: - - "3.6" - -install: - - pip install -e . - - pip install -r requirements.txt - -script: pytest - diff --git a/ChiantiPy/base/_IonTrails.py b/ChiantiPy/base/_IonTrails.py index 9eb90191..9f46f43e 100644 --- a/ChiantiPy/base/_IonTrails.py +++ b/ChiantiPy/base/_IonTrails.py @@ -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. @@ -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. diff --git a/ChiantiPy/core/Bunch.py b/ChiantiPy/core/Bunch.py index d89cc8a8..d8d874e1 100644 --- a/ChiantiPy/core/Bunch.py +++ b/ChiantiPy/core/Bunch.py @@ -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 @@ -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 diff --git a/ChiantiPy/core/Continuum.py b/ChiantiPy/core/Continuum.py index e72e8d55..098db463 100644 --- a/ChiantiPy/core/Continuum.py +++ b/ChiantiPy/core/Continuum.py @@ -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. @@ -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 @@ -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 @@ -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`. @@ -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 diff --git a/ChiantiPy/core/Ion.py b/ChiantiPy/core/Ion.py index b65c5d70..6ed5d501 100644 --- a/ChiantiPy/core/Ion.py +++ b/ChiantiPy/core/Ion.py @@ -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. @@ -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 @@ -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 ---------- diff --git a/ChiantiPy/core/Ioneq.py b/ChiantiPy/core/Ioneq.py index 12711300..66d61a6e 100644 --- a/ChiantiPy/core/Ioneq.py +++ b/ChiantiPy/core/Ioneq.py @@ -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 """ diff --git a/ChiantiPy/core/IpyMspectrum.py b/ChiantiPy/core/IpyMspectrum.py index 0014a18b..5e7bb4d3 100644 --- a/ChiantiPy/core/IpyMspectrum.py +++ b/ChiantiPy/core/IpyMspectrum.py @@ -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 # diff --git a/ChiantiPy/core/MradLoss.py b/ChiantiPy/core/MradLoss.py index c5470dce..3c4909c6 100644 --- a/ChiantiPy/core/MradLoss.py +++ b/ChiantiPy/core/MradLoss.py @@ -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, diff --git a/ChiantiPy/core/Mspectrum.py b/ChiantiPy/core/Mspectrum.py index 5e30442a..2706cd2c 100644 --- a/ChiantiPy/core/Mspectrum.py +++ b/ChiantiPy/core/Mspectrum.py @@ -14,102 +14,68 @@ class mspectrum(ionTrails, specTrails): - ''' this is the multiprocessing version of spectrum - set proc to the desired number of processors, default=3 + r''' + Calculate the emission spectrum as a function of temperature and density in parallel. - Calculate the emission spectrum as a function of temperature and density. - - temperature and density can be arrays but, unless the size of either is one (1), - the two must have the same size - - the returned spectrum will be convolved with a filter of the specified width on the - specified wavelength array - - the default filter is gaussianR with a resolving power of 100. Other filters, - such as gaussian, box and lorentz, are available in chianti.filters. When using the box filter, - the width should equal the wavelength interval to keep the units of the continuum and line - spectrum the same. - - A selection of elements can be make with elementList a list containing the names of elements - that are desired to be included, e.g., ['fe','ni'] - - 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 - - Both elementList and ionList can not be specified at the same time - - 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. - - allLines = 1 will include lines with either theoretical or observed wavelengths. allLines=0 will - include only those lines with observed wavelengths - - proc, the number of processors to use - - timeout, a small but non-zero value seems to be necessary - keepIons: set this to keep the ion instances that have been calculated in a dictionary - self.IonInstances with the keywords being the CHIANTI-style ion names - - 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' + - 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 - If set to a blank (''), a gui selection menu will popup and allow the selection of an - set of abundances + When using the box filter, the width should equal the wavelength interval to keep the units + of the continuum and line spectrum the same. Parameters -------------- - temperature: `float`, `list`, `ndarray` - the temperature(s) in K - - eDensity: float, ndarray - eDensity: electron density in :math:`\mathrm{cm^{-3}}` - + the temperature(s) in K. Must have the same size as ``eDensity`` unless it is a scalar. + eDensity: `float`, ndarray + electron density in :math:`\mathrm{cm^{-3}}`. Must have the same size as + ``temperature`` unless it is a scalar. wavelength: `list` or `ndarray` - wavelength: array of wavelengths, generally in Angstroms - + array of wavelengths, generally in Angstroms + filter: `tuple` + The filter to convolve the spectrum with and the resolving power. + The returned spectrum will be convolved with a filter of the specified width on the + specified wavelength array the default filter is gaussianR with a resolving power of 100. + Other filters, such as gaussian, box and lorentz, are available in `ChiantiPy.tools.filters`. elementList: `list` - elementList: list of elements to include, such as 'fe', 'ne', 's' - + list of elements to include, such as 'fe', 'ne', 's' + Cannot be specified at the same time as ``ionList`` 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' + Cannot be specified at the same time as ``elementList`` 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 keepIons: `bool` - keepIons: keep the ion instances used in the calculation - should be used with caution otherwise the bunch instance - can become quite large - + keep the ion instances used in the calculation should be used with caution otherwise + the bunch instance can become quite large. set this to keep the ion instances that have + been calculated in a dictionary self.IonInstances with the keywords being the CHIANTI-style ion names em: `float`, `list`, `ndarray` - em: the emission measure - the integral of the electron density times the hydrogen density - along the line of sight - + the emission measure - the integral of the electron density times the hydrogen density + along the line of sight. can be a float or an array of the same length as the + temperature/density. Setting em will multiply the spectrum at each temperature by the value of em. 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. allLines = 1 will include lines with either + theoretical or observed wavelengths. allLines=0 will include only those lines with observed wavelengths + proc: `int` + the number of processors to use. Defaults to 3. verbose: `bool` - verbose: whether to allow certain print statements + whether to allow certain print statements + timeout: `float` + A small but non-zero value seems to be necessary ''' def __init__(self, temperature, eDensity, wavelength, filter=(chfilters.gaussianR, 1000.), label=0, elementList = None, ionList = None, minAbund=None, keepIons=0, abundance=None, doLines=True, @@ -141,7 +107,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 diff --git a/ChiantiPy/core/Spectrum.py b/ChiantiPy/core/Spectrum.py index 6614a045..e76294c1 100644 --- a/ChiantiPy/core/Spectrum.py +++ b/ChiantiPy/core/Spectrum.py @@ -81,49 +81,35 @@ class spectrum(ionTrails, specTrails): 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}}` wavelength: `list` or `ndarray` - wavelength: array of wavelengths, generally in Angstroms - + array of wavelengths, generally in Angstroms 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 keepIons: `bool` - keepIons: keep the ion instances used in the calculation - should be used with caution otherwise the bunch instance - can become quite large - + keep the ion instances used in the calculation + should be used with caution otherwise the bunch instance + can become quite large em: `float`, `list`, `ndarray` - em: the emission measure - + the emission measure 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 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, wavelength, filter=(chfilters.gaussianR, 1000.), label=None, elementList = None, ionList = None, minAbund=None, doLines = True, doContinuum = True, em=None, keepIons=0, diff --git a/ChiantiPy/model/Maker.py b/ChiantiPy/model/Maker.py index 139fbc0d..478d1a2c 100644 --- a/ChiantiPy/model/Maker.py +++ b/ChiantiPy/model/Maker.py @@ -198,58 +198,35 @@ class maker(ionTrails, specTrails): ''' a class matching observed lines to lines in the CHIANTI database - Parameters ---------- - specData : dict + specData : `dict` contains the following keys intensity - a list of observed line intensities wvlObs - a list of observed wavelengths, usually in Angstroms dwvl the expected wavelength different between the observed wvl and CHIANTI - - Keyword Arguments - ----------------- - temperature: `float`, `list`, `ndarray` the temperature(s) in K, default is None - eDensity: float, ndarray eDensity: electron density in :math:`\\mathrm{cm^{-3}}`, default is None - elementList : list a list of elements, such as fe, to be searched, default = [] - ionList : list a list of ions, such as fe_14, to be searched, default = [] - allLines : bool if true, unobserved lines in CHIANTI are included in the search, default = False - abundanceName : str the name of the elemental abundance file to be used, the defaul t is None if not set, the default abundance file is used - minAbund : float sets the minimum abundance for an element to be included in the search, default = 10. to include all elements - verbose : bool if True, additional output is sent to the terminal, default is False - ''' + def __init__(self, specData, temperature=None, eDensity=None, elementList=[], ionList=[], allLines=False, abundanceName = None, minAbund=10., wghtFactor=None, verbose=False): - ''' - input a list of wavelengths and a wavelength difference - find a list of predicted spectral lines for each wavelength - all = 0 -> only previously observed wavelengths are used - dwvl = wavelength difference between CHIANTI and the observed lines - if == 0 then use use that in the observed data - - ''' - # - # -------------------------------------------------------------------------------- - # if temperature is not None: self.Temperature = np.array(temperature, np.float64) if eDensity is not None: @@ -314,16 +291,15 @@ def __init__(self, specData, temperature=None, eDensity=None, elementList=[], io # def makeMatch(self, verbose=False): - """ to match the CHIANTI lines with the input specdata - uses ionTrails.ionGate to sort through ions - - - Keyword Arguments - ----------------- + """ + Match the CHIANTI lines with the input specdata + + Uses ionTrails.ionGate to sort through ions + Parameters + ---------- verbose : `bool` if True, additional output is sent to the terminal - """ if 'intensity' in self.SpecData.keys(): @@ -416,20 +392,14 @@ def matchPrint(self, filename='matchPrint.txt', sort=None, verbose=False): sort can be 'wvl' or 'ion', otherwise, there is no sorting done does not require predicted values - - Keyword Arguments - ----------------- - - + Parameters + ---------- filename: `str` the filename where the text should be output - sort: `str`, can be `wvl`, `ion`, or None whether the output should be sorted by `wvl` or `ion` or not - verbose : `bool` if True, additional output is sent to the terminal - ''' minContribution = 0.1 @@ -517,24 +487,20 @@ def matchPrint(self, filename='matchPrint.txt', sort=None, verbose=False): outpt.write(dash +'\n') def argCheck(self, temperature=None, eDensity=None, pDensity='default', verbose=False): - ''' to check the compatibility of the three arguments + r''' + to check the compatibility of the three arguments and put them into numpy arrays of atleast_1d - Keyword Arguments - ----------------- - + 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}}` pDensity: `str`, `float`, `ndarray` - pDensity: proton density in :math:`\\mathrm{cm^{-3}}` defaults to 'default' - + proton density in :math:`\mathrm{cm^{-3}}` defaults to 'default' verbose : `bool` if True, additional output is sent to the terminal - ''' if temperature is not None: self.Temperature = np.atleast_1d(temperature) @@ -584,20 +550,16 @@ def argCheck(self, temperature=None, eDensity=None, pDensity='default', verbose= # ----------------------------------------------------------------- # def gofnt(self, temperature, density, verbose=1): - ''' + r''' calculate the gofnt function for each of the matched lines do each ion only once Parameters - ----------------- - + ---------- temperature: `float`, `list`, `ndarray` the temperature(s) in K - density: `float`, `list`, `ndarray` - density: electron density in :math:`\\mathrm{cm^{-3}}` - - + electron density in :math:`\mathrm{cm^{-3}}` ''' t1 = datetime.now() self.XUVTOP = os.environ['XUVTOP'] @@ -689,23 +651,15 @@ def mgofnt(self, temperature, density, proc=6, timeout=0.1, verbose=False): does each ion only once Parameters - ----------------- - + ---------- temperature: `float`, `list`, `ndarray` the temperature(s) in K - density: `float`, `list`, `ndarray` density: electron density in :math:`\\mathrm{cm^{-3}}` - - Keyword Arguments - ----------------- - proc: `int` the number of cores to be used - timeout: 'float' may not actually be necessary - verbose : `bool` if True, additional output is sent to the terminal @@ -843,23 +797,14 @@ def emSetIndices(self, indices, add=1., verbose=0): to set the indices of the N temperature/density EM distribution can increase the number of paramaters if additional parameters have been used - Parameters ---------- - indices: `list`, `ndarray` the indices of the temperature/density arrays for which a set of intensities will be predicted - - - Keyword Arguments - ----------------- - add: `float` to increase the number of parameters used in the calculation of the reduced chi-squared - verbose : `bool` if True, additional output is sent to the terminal - ''' if hasattr(self, 'Temperature'): self.EmIndices = np.atleast_1d(indices) @@ -877,13 +822,10 @@ def emSet(self, value): ''' sets the EM values for a N temperature EM distribution - Parameters ---------- - value: `list`, `ndarray` the values of the emission measure to be used when the intensities are predicted - ''' emValue = np.atleast_1d(value) if hasattr(self, 'EmIndices') and emValue.size == self.EmIndices.size: @@ -927,17 +869,12 @@ def emWrite(self, filename, directory, reference): outName does not need the suffix .em reference should be a list of references - Parameters ---------- - filename: `str` the name of the em file to be produced - reference: `list` a list of strings providing a reference at the end of the em file - - """ if '.em' not in filename: filename += '.em' @@ -969,44 +906,32 @@ def emPlot(self, vs='T', loc='upper right', fs=10, lw = 2, adjust=None, positio adjust is to provide an adjustment to the position of the labels position : one of 'both', 'right', 'left', or 'none' - Keyword Arguments - ----------------- - + Parameters + ---------- vs: `str`, either 'T', or 'D' whether to plot the emission measure vs temperature or density - loc: `str` matplotlib argument for plt.legend - fs: `int` the fontsize for the legend, default = 10 - lw: `int` set the line width of the plot, default = 2 - adjust: `list` a list of multiplicative adjustments to the labels to the plot lines must be the same length as the number of lines, default = None - position: `str` where the labels to the lines should be placed, `both` for both ends, `left` for the left size only, 'right' for the right side only, or None for no labels, default is 'both' - label: `bool` whether to apply, default = True - legend: `bool` whether to include a matplotlib legend, default =True - fontsize: `int` fontsize for the matplotlib xlabel and ylabel, default=16 - tscale: `float` scale the temperature by dividing by tscale, default = 1. - verbose : `bool` if True, additional output is sent to the terminal, default = True - ''' match = self.Match temp = self.Temperature @@ -1134,47 +1059,34 @@ def emPlotObj(self, vs='T', loc='upper right', fs=10, lw=2, adjust=None, positio this uses the modern object interface fig, ax = plt.subplots(figsize=figsize) fig, ax are in returned in the self.EmPlotOjb dict - Keyword Arguments - ----------------- - + Parameters + ---------- vs: `str`, either 'T', or 'D' whether to plot the emission measure vs temperature or density - loc: `str` matplotlib argument for plt.legend, default = 'upper right' - fs: `int` the fontsize for the legend, default = 10 - lw: `int` set the line width of the plot, default = 2 - adjust: `list` a list of multiplicative adjustments to the labels to the plot lines must be the same length as the number of lines, default = None - position: `str` where the labels to the lines should be placed, `both` for both ends, `left` for the left size only, 'right' for the right side only, or None for no labels, default = 'both' - label: `bool` whether to apply, default = True - legend: `bool` whether to include a matplotlib legend, default = True - fontsize: `int` fontsize for the matplotlib xlabel and ylabel, default = 16 - figsize: two element `list` or `ndarray` sets the figure size when using matplotlib subplots to initiate the object style plotting, default = [7., 5.] - tscale: `float` scale the temperature by dividing by tscale, default = 1. - verbose : `bool` if True, additional output is sent to the terminal, default = True - ''' match = self.Match temp = self.Temperature @@ -2204,30 +2116,21 @@ def search1tEmSpace(self, verbose=False): #----------------------------------------------------- # def search1tSpace(self, initialEM, indexLimits=None, logname=None, verbose=False, maxfev=0): - '''conduct a brute force search of 2 temperature space and find the - best fit + ''' + conduct a brute force search of 2 temperature space and find the best fit Parameters ---------- - initialEm: `float` the initial trial value for the log10 emission measure - - - Keyword Arguments - ----------------- - - indexLimits: 2 dimensional array type + indexLimits: 2 dimensional array type the lower an upper limits of the temperature to be searched the default is None and them the whole temperature array is searched - logname: `str` the name of the file were the search log is written the default is None and no log will be written - verbose: `bool` if True, additional output is sent to the terminal - ''' self.Nparams = 2. + 1. # if not hasattr(self, 'SearchData'): diff --git a/ChiantiPy/tools/sources.py b/ChiantiPy/tools/sources.py index 714a5374..140db933 100644 --- a/ChiantiPy/tools/sources.py +++ b/ChiantiPy/tools/sources.py @@ -54,7 +54,7 @@ def incident(self, distance, energy): def blackbody(temperature, variable, hnu=1): - """ + r""" Calculate the blackbody photon distribution as a function of energy (`hnu` = 1) or\ as a function of wavelength (`hnu` = 0) in units of :math:`\mathrm{photons}\,\mathrm{cm}^{-2}\,\mathrm{s}^{-1}\,\mathrm{str}^{-1}\,\mathrm{erg}^{-1}` diff --git a/ChiantiPy/tools/util.py b/ChiantiPy/tools/util.py index c696b38c..49ec5754 100644 --- a/ChiantiPy/tools/util.py +++ b/ChiantiPy/tools/util.py @@ -363,7 +363,7 @@ def el2z(els): def qrp(z,u): - """ + r""" Calculate :math:`Q_R^{\prime}(Z,u)`, where :math:`u=\epsilon/I` is the impact electron energy in threshold units, from Eq. 2.12 of [4]_. Parameters diff --git a/rtd_environment.yml b/rtd_environment.yml deleted file mode 100644 index 2a51342c..00000000 --- a/rtd_environment.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: chiantipy -dependencies: - - python=3.6 - - astropy - - numpy=1.14 - - scipy - - matplotlib - - ipython - - ipyparallel - - sphinx_rtd_theme