Scanning Utilities

Voigt profile fitting

llabs.plots.voigt. voigtslow ( a , u ) [source]

Calculate the voigt function H(a,u).

Uses numerical integration, so is slow. Answer is correct to 20 significant figures.

llabs.plots.voigt. voigt ( a , u ) [source]

Compute the Voigt function.

a: float

The lorentzian FWHM divided by the gaussian FWHM of the line.

u: array of floats

The frequency offsets from the frequency at the line centre, in units of the FWHM frequency of the doppler broadening.

Returns voigt function H(a,u).

Notes

This is a Taylor approximation to the Voigt function valid for 0 < a < 0.1. (Harris 1948, ApJ, 108, 112). Relative error with respect to voigt_de is < 10^-4.9 for a < 0.1, gets worse for larger a (since it’s an expansion in a).

Examples

>>> uvals = numpy.arange(-25, 25, 1./100)
>>> a = 0.01
>>> y1 = voigt(a, uvals)
>>> y2 = numpy.fromfile('data/idl_voigt.txt', sep=' ')
>>> numpy.allclose(y1, y2, rtol=1e-8)
True
>>> uvals = numpy.linspace(-25, 25, 40)
>>> a = 1e-5
>>> y1 = voigt(a, uvals)
>>> y2 = [voigtslow(a,u) for u in uvals]
>>> all(mp.almosteq(i, j, 1e-5) for i,j in zip(y1,y2))
True
>>> a = 0.1
>>> y1 = voigt(a, uvals)
>>> y2 = [voigtslow(a,u) for u in uvals]
>>> all(mp.almosteq(i, j, 1e-5) for i,j, in zip(y1,y2))
True
llabs.plots.voigt. p_voigt ( n , b , wave , lambdao , gamma , f ) [source]

fitting

llabs.plots.fitting. maskdef ( data , zalpha , zmin , zmax , nleftHI , nrightHI , irange , stdev , maskwidth = 0.5 , ** kwargs ) [source]
llabs.plots.fitting. fitHI ( data , zalpha , dlawidth , nleftHI , nrightHI , llhard , lldla , N , b , ** kwargs ) [source]

Using lmfit to fit a one component model to the absorber

llabs.plots.fitting. read_atom_dat ( ) [source]

Reads atom.dat file from VPfit into numpy array of strings.

llabs.plots.fitting. get_transition_info ( transition = 'Halpha' ) [source]

Collects info on the transition. At later stage may read info from VPfit atom.dat and/or my own version of the galaxy lines thingie. NB: if the atom.dat file doesn’t exist, will fall back on Halpha…

llabs.plots.fitting. residual ( voigtparams , wavelengths , flux = None , error = None ) [source]

Function to use with lmfit. Calculates the weighted residuals of flux-voigtprofile/error. voigtparams: A parameter class defining the variables wavelengths: An array of wavelengths to fit over flux: Corresponding flux values. If absent, the model (and not the residuals) is returned. Useful for plotting. error: Corresponding error values. If absent, the residuals are unweighted

utilities

llabs.utils. readspec ( filename , resolution ) [source]

Read quasar spectrum.

llabs.utils. equiwidth ( data , zalpha , dlawidth , stdev , ** kwargs ) [source]

Determine the absorption equivalent width around metal lines within the DLA velocity dispersion. Determine the fraction of pixels with absorption around metal lines CHECK OUT THE DEFINITION OF DELTAV in http://arxiv.org/pdf/astro-ph/0606185v1.pdf,better described here http://arxiv.org/pdf/1303.7239v3.pdf . Not sure it’s possible to use here, since they visually inspect to require the lines aren’t saturated…

llabs.utils. snrestimator ( data , llhard , lldla , waalpha , ** kwargs ) [source]

Estimate signal-to-noise ratio from spectrum.

llabs.utils. best ( filename , output = 'llabs.csv' , ** kwargs ) [source]