1. acx2 module class reference¶
- class acx2.ACXDonorModel(donor, donor_linefile=None, donor_contfile=None, donor_crosssectionfile=None, abundset='AG89', elements=None, acxmodel=8, recombtype=1, collisiontype=1)¶
A model of the ACX Donor
- Parameters:
donor (string) – The donor symbol (e.g. “H”)
donor_linefile (string) – The file with the donor line emision
donor_contfile (string) – The file with the donor continuum emision
donor_crosssectionfile (string) – The cross section file for donor
abundset (optional, {"AG89"}) – The abundance set. Only AG89 works currently
elements (optional, array-like int) – The recombining element atomic numbers. Default is all.
acxmodel (optional, int, default=8) – The acx model l, n distribution to fall back on.
- linedata¶
The data in the donor_linefile
- Type:
HDUList
- contdata¶
The data in the donor_contfile
- Type:
HDUList
- crosssectiondata¶
The data in the donor_crosssectionfile
- Type:
HDUList
- donorAbundance¶
The donor abundance. Defaults to 1.0. Intended for correctly mixing donors, e.g. in 10%He, 90%H donor plasma, set to 0.1 and 0.9 respectively, though no normalization is checked for.
- Type:
float
- donormass¶
mass of the donor in a.m.u.
- Type:
float
- abund¶
abundance of each element, relative to abundset. e.g. abund[6] = 2.0 means 2x solar C
- Type:
dict of float
- ionfrac_from_temperature¶
was the ionfracance calculated from the temperature
- Type:
bool
- temperature¶
the temperature in keV
- Type:
float
- ionfrac¶
the ionization fraction, normalized to 1 for each element, e.g. ionfrac[2] = ndarray([0.01,0.1,0.89])
- Type:
dict of arrays of float
- calc_crosssection(collparam)¶
Calculate the total and partial cross sections by n, l, S.
- Parameters:
collparam (float) – Collision energy, or velocity, as determined by set_collisiontype, in kev/u, cm/s or km/s
- Return type:
TBD
- calc_line_emissivity(Z, z1_in, up, lo, collvalue=None)¶
Calculate the emissivity of a specific line.
- Parameters:
collvalue (float) – The collision parameter (kev/u or cm/s, depending) to calculate the spectrum
Z (int) – element charge
z1 (int) – recombining ion charge +1.
up (int) – upper level of transition
lo (int) – lower level of transition
- Returns:
ret – The spectrum, in ph cm^3 s-1 bin-1
- Return type:
array(float)
- calc_linelist(collparam, specrange, specunit='A', redshift=0.0)¶
Calculate the spectrum we want
- Parameters:
collparam (float) – Collision energy, or velocity, as determined by set_collisiontype, in kev/u, cm/s or km/s
specrange ([float, float]) – Minimum and maximum values for interval in which to search
specunit ({'Angstrom','keV'}) – Units for specrange (default A)
- Returns:
linelist – Numpy array of lines and emissivity, custom dtype
- Return type:
numpy.array
- calc_spectrum(collparam, Tbroaden, vbroaden, ebroaden)¶
Calculate the spectrum we want
- Parameters:
collparam (float) – Collision energy, or velocity, as determined by set_collisiontype, in kev/u, cm/s or km/s
- Returns:
self.emiss – The emissivity in photons cm^3 bin-1 s-1
- Return type:
array(float)
- find_crosssection_type(Z, z1)¶
Find the cross section type, to assign correct CXIonSpectrum type
- Parameters:
Z (int) – element charge
z1 (int) – recombining ion charge +1.
- Returns:
resolution (string) – The coupling, currently N, NLS or ACX1 (returned in upper case)
ihdu (int) – The HDU with the cross section data for the ion. Set to -1 for none.
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- initialize_CXIonspectrum()¶
Called to ensure that all the ion spectra exist and are ready to use
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- set_abund(abund, elements=None)¶
Set the elemental abundance, also in each donor model
- Parameters:
abund (array(float)) – Abundances, relative to defulat
- Return type:
None
- set_abundset(abundstring)¶
Set the abundance set.
- Parameters:
abundstring (string) – The abundance string (e.g. “AG89”, “uniform”). Case insensitive. See atomdb.get_abundance for list of possible abundances
- Returns:
updates self.abundset and self.abundsetvector.
- Return type:
none
- set_acxmodel(acxmodel)¶
Set the ACX spectrum type
- Parameters:
acxmodel (int) – The acxmodel (between 1 and 8)
- set_collisionparam(collisionparam)¶
Set the collision velocity or energy
- Parameters:
collisionparam (float) – The collision velocity or energy. Units and parameter type are set in ACXModel.set_collisiontype
- Return type:
None
- set_collisiontype(colltype, collunits='default')¶
Set the collision type and units
- Parameters:
colltype (int) – Parameter for provided collision type Collision type - 1=energy/mass of center of mass Collision type - 2=velocity of center of mass Collision type - 3=velocity of donor Collision type - 4=velocity of receiver
collunits (string, optional) – Units of collision paramter. Defaults to “kev/u” for colltype=1, “cm/s” for others
- Return type:
None
- set_donorabund(abund)¶
Set the donor abundance
- Parameters:
abund (float) – The abundance of the donor.
- set_ebins(ebins, ebins_checksum=False)¶
Set the energy bins for the spectrum being returned.
- Parameters:
ebins (array(float)) – Energy bin edges (keV)
ebins_checksum (string, optional) – The hex digest of the md5 sum of ebins. Used to check for changes.
- set_ionfrac(ionfrac)¶
Recalculate the ionization balance based on equilibrium electron temperature
- Parameters:
ionfrac (dict of arrays) – ionization fraction, e.g. ionfrac[8]=numpy.array([0.0, 0.0, 0.0, 0.0, 0.1, 0.3, 0.4, 0.2, 0.0])
- Return type:
None
- set_recombtype(recombtype)¶
Set the recombination type
- Parameters:
recombtype (int) – The type of recombination (1=single, 2=all the way to neutral, 3 = same as 2, but renomalized by total cross section)
- set_temperature(temperature)¶
Recalculate the ionization balance based on equilibrium electron temperature
- Parameters:
temperature (float) – electron temperature in keV
- Return type:
None
- class acx2.CXIonSpectrum(Z, z1, ebins, crosssectiondata, linedata, contdata, cxdata)¶
Class to store and prepare each ion’s spectrum. Will have a subset of CXShellSpectrum for each shell. Can provide it a set of energy bins and get a spectrum back. This will store all the emissivity data.
- expand_E_grid(eedges, Econt_in_full, cont_in_full)¶
Code to expand the compressed continuum onto a series of bins.
- Parameters:
eedges (float(array)) – The bin edges for the spectrum to be calculated on, in units of keV
Econt_in_full (float(array)) – The compressed continuum energies (keV)
cont_in_full (float(array)) – The compressed continuum emissivities (ph cm3 s-1 keV-1)
- Returns:
len(bins)-1 array of continuum emission, in units of photons cm^3 s^-1 bin^-1
- Return type:
float(array)
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- set_acxmodel(acxmodel)¶
Set the ACX spectrum type
- Parameters:
acxmodel (int) – The acxmodel (between 1 and 8)
- set_ebins(ebins, ebins_checksum=False)¶
Set the energy bins for the spectrum being returned.
- Parameters:
ebins (array(float)) – Energy bin edges (keV)
ebins_checksum (string, optional) – The hex digest of the md5 sum of ebins. Used to check for changes.
- set_recombtype(recombtype)¶
Set the energy bins, also in each donor model
- Parameters:
ebins (array(float)) – The energy bins in keV for the spectrum
- Return type:
None
- class acx2.CXIonSpectrum_ACX1(Z, z1, crosssectionhdu, linedata, contdata, acxmodel=8, donor=False, receivermass=False, donormass=False)¶
This is a class for ACX1 model data
- ebins¶
The energy bin in keV
- Type:
array(float)
- ebins_m5sum¶
hex digest of ebins
- Type:
md5hash
- calc_crosssection(collenergy)¶
Calculate cross sections
- calc_linelist(collenergy, collvelocity, specrange, specunit='A', redshift=0.0)¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
specrange ([float, float]) – Minimum and maximum values for interval in which to search
specunit ({'Angstrom','keV'}) – Units for specrange (default A)
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- calc_spectrum(collenergy, collvelocity, Tbroaden, vbroaden, ebroaden)¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
linedata (hdulist) – The line emissivity data
contdata (hdulist) – The continuum emissivity data
acxmodel (int) – n, l shell distribution, between 1 and 8:
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- set_ebins(ebins, ebins_checksum=False)¶
Set the energy bins, also in each donor model
- Parameters:
ebins (array(float)) – The energy bins in keV for the spectrum
- Return type:
None
- class acx2.CXIonSpectrum_N(Z, z1, crosssectiondata, linedata, contdata, acxmodel=8, donor=False, receivermass=False, donormass=False)¶
This is a class for n resolved Kronos data
- calc_linelist(collenergy, collvelocity, specrange, specunit='A')¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
specrange ([float, float]) – Minimum and maximum values for interval in which to search
specunit ({'Angstrom','keV'}) – Units for specrange (default A)
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- calc_spectrum(collenergy, collvelocity, Tbroaden, vbroaden, ebroaden)¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
linedata (hdulist) – The line emissivity data
contdata (hdulist) – The continuum emissivity data
acxmodel (int) – n, l shell distribution, between 1 and 8
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- set_ebins(ebins, ebins_checksum=False)¶
Set the energy bins, also in each donor model
- Parameters:
ebins (array(float)) – The energy bins in keV for the spectrum
- Return type:
None
- class acx2.CXIonSpectrum_NLS(Z, z1, crosssectiondata, linedata, contdata, donor=False, receivermass=False, donormass=False)¶
This is a class for nls resolved Kronos data
- calc_linelist(collenergy, collvelocity, specrange, specunit='A')¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
specrange ([float, float]) – Minimum and maximum values for interval in which to search
specunit ({'Angstrom','keV'}) – Units for specrange (default A)
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- calc_spectrum(collenergy, collvelocity, Tbroaden, vbroaden, ebroaden)¶
Calculate the spectrum of the data
- Parameters:
ebins (array(float)) – The energy bins (in keV) to calcualte the spectrum on
collenergy (flaot) – The collision energy (keV/amu)
collvelocity (float) – The velocity of the center of mass (cm/s)
linedata (hdulist) – The line emissivity data
contdata (hdulist) – The continuum emissivity data
acxmodel (int) – n, l shell distribution, between 1 and 8
- Returns:
emissivity – Emissivity * velocity in photons cm4 s-2
- Return type:
array(float)
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- set_ebins(ebins, ebins_checksum=False)¶
Set the energy bins, also in each donor model
- Parameters:
ebins (array(float)) – The energy bins in keV for the spectrum
- Return type:
None
- class acx2.CXShellSpectrum(Z, z1, n, l, linedata, contdata, s=False)¶
Holds a single n, l, shell spectrum
- expand_E_grid(eedges, Econt_in_full, cont_in_full)¶
Code to expand the compressed continuum onto a series of bins.
- Parameters:
eedges (float(array)) – The bin edges for the spectrum to be calculated on, in units of keV
Econt_in_full (float(array)) – The compressed continuum energies (keV)
cont_in_full (float(array)) – The compressed continuum emissivities (ph cm3 s-1 keV-1)
- Returns:
len(bins)-1 array of continuum emission, in units of photons cm^3 s^-1 bin^-1
- Return type:
float(array)
- hashlib = <module 'hashlib' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/hashlib.py'>¶
- numpy = <module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>¶
- os = <module 'os' (frozen)>¶
- scipy = <module 'scipy' from '/home/docs/checkouts/readthedocs.org/user_builds/acx2/envs/latest/lib/python3.11/site-packages/scipy/__init__.py'>¶
- set_ebins(ebins, ebins_checksum)¶
Set the energy bins, also in each donor model
- Parameters:
ebins (array(float)) – The energy bins in keV for the spectrum
- Return type:
None
- class acx2.DummyCXShellSpectrum(Z, z1, n, l, s=False)¶
Placeholder for a blank spectrum
- calc_spectrum(ebins, ebins_checksum, Tbroaden, vbroaden, ebroaden)¶
Return zeros
- Parameters:
ebinshash (string) – md5 sum of ebins
ebins (array(float)) – array of floats
- Returns:
0.0
- Return type:
there is no data here, so return zero.
- set_ebins(ebins, ebins_checksum=False)¶
Dummy
- Parameters:
ebinshash (string) – md5 sum of ebins
ebins (array(float)) – array of floats
- Return type:
None
- acx2.download_acx_emissivity_files(adbroot, userid, version, donor)¶
Download the AtomDB CX model emissivity files for AtomDB”
This code will go to the AtomDB FTP site and download the necessary files. It will then unpack them into a directory adbroot. It will not overwrite existing files with the same md5sum (to avoid pointless updates) but it will not know this until it has downloaded and unzipped the main file.
- Parameters:
adbroot (string) – The location to install the data. Typically should match $ATOMDB
userid (string) – An 8 digit ID number. Usually passed as a string, but integer is also fine (provided it is all numbers)
version (string) – The version string, including donors for the release, e.g. “2_1_0-h_he”
- Return type:
None
- acx2.get_full_line_info(linelist, filemap='$ATOMDB/filemap_acx', atomdbroot='$ATOMDB')¶
Gets the data for the full linelist
- acx2.loginterp(newx, x, y, offset=1e-40)¶
Interpolation helper function. Interpolates linearly on a log-log grid If newx < x[0], return x[0]. If newx > x[-1], extrapolate slope of last 2 points, unless y[-1] ==0 in which case return 0.
- Parameters:
newx (float) – The new X parameters (energy, kev/amu)
x (array(float)) – The x parameters (energy, kev/amu)
y (array(float)) – The y parameters (cross section, cm2)
offset (float (optional)) – An offset to apply before interpolation. Prevents log(0) issues.
- Returns:
newy – The interpolated cross section. Minimum of 0 in case of numerical issues.
- Return type:
float