trident.absorption_spectrum.absorption_spectrum_fit.generate_total_fit(x, fluxData, orderFits, speciesDicts, minError=0.0001, complexLim=0.995, fitLim=0.97, minLength=3, maxLength=1000, splitLim=0.99, output_file=None)[source]

Fit an absorption-line spectrum into line profiles.

Fits the spectrum into absorption complexes and iteratively adds and optimizes voigt profiles for each complex.


  1. ndarray

1d array of wavelengths

  1. ndarray

array of flux corresponding to the wavelengths given in x. (needs to be the same size as x)



list of the names of the species in the order that they should be fit. Names should correspond to the names of the species given in speciesDicts. (ex: [‘lya’,’OVI’])



Dictionary of dictionaries (I’m addicted to dictionaries, I confess). Top level keys should be the names of all the species given in orderFits. The entries should be dictionaries containing all relevant parameters needed to create an absorption line of a given species (f,Gamma,lambda0) as well as max and min values for parameters to be fit


float, optional

Maximum flux to start the edge of an absorption complex. Different from fitLim because it decides extent of a complex rather than whether or not a complex is accepted.



Maximum flux where the level of absorption will trigger identification of the region as an absorption complex. Default = .98. (ex: for a minSize=.98, a region where all the flux is between 1.0 and .99 will not be separated out to be fit as an absorbing complex, but a region that contains a point where the flux is .97 will be fit as an absorbing complex.)


int, optional

number of cells required for a complex to be included. default is 3 cells.


int, optional

number of cells required for a complex to be split up. Default is 1000 cells.


float, optional

if attempting to split a region for being larger than maxlength the point of the split must have a flux greater than splitLim (ie: absorption greater than splitLim). Default= .99.


string, optional

location to save the results of the fit.




Dictionary of dictionaries representing the fit lines. Top level keys are the species given in orderFits and the corresponding entries are dictionaries with the keys ‘N’,’b’,’z’, and ‘group#’. Each of these corresponds to a list of the parameters for every accepted fitted line. (ie: N[0],b[0],z[0] will create a line that fits some part of the absorption spectrum). ‘group#’ is a similar list but identifies which absorbing complex each line belongs to. Lines with the same group# were fit at the same time. group#’s do not correlate between species (ie: an lya line with group number 1 and an OVI line with group number 1 were not fit together and do not necessarily correspond to the same region)

  1. ndarray

array of flux corresponding to the combination of all fitted absorption profiles. Same size as x.