fit_spec

pyplatefit.fit_spec(spec, z, fit_all=False, ziter=False, fitcont=True, fitlines=True, lines=None, major_lines=False, fitabs=False, vdisp=80, use_line_ratios=False, find_lya_vel_offset=False, dble_lyafit=False, mcmc_lya=False, mcmc_all=False, lsf=<function muse_lsf>, eqw=True, trimm_spec=True, contpars={}, linepars={}, mcmcpars={'nwalkers': 0, 'progress': True, 'run_mcmc_kwargs': {'skip_initial_state_check': False}, 'save_proba': False, 'steps': 0}, minpars={'method': 'least_square', 'xtol': 0.001})

perform platefit cont and line fitting on a spectra

Parameters:
specMPDAF spectrum or str

Input spectrum either as a string or a MPDAF spectrum object

zfloat

redshift (in vacuum)

fit_allbool

If True, fit all lines except Lya together with the same velocity and velocity dispersion (default False)

ziterbool

if True, a first emission line fit is performed to refine the redshift before a new continuum subtraction and a complete line fit is performed (to save computation time, eemce option is disactivated for the first fit), default false

fitcontbool

If True, fit and subtract the continuum before performing an emission or absorption line fit (default: True)

fitlinesbool

If True, perform an emission line fit

lines: list or astropy table

the list specify the MPDAF lines to use in the fit, while the astropy table is a replacement of the MPDAF line list table (see Linefit.fit_lines for more info)

major_linesbool

if true, use only major lines as defined in MPDAF line list (default False).

fitabsbool

if True, fit also absorption lines after the emission line fit

vdispfloat

fixed velocity dispersion in km/s (default 80 km/s) used in the continuum fit.

use_line_ratiosbool

if True, use constrain line ratios in fit (default False)

find_lya_vel_offsetbool

if True, perform an initial search for the lya velocity offset [deactivated for dble lya fit]

dble_lyafitbool

if True, use a double asymetric gaussian model for the lya line fit

mcmc_lyabool

if True, perform an MCMC LYALPHA fit after the first fit (default False)

mcmc_allbool

if True, perform an MCMC fit after the first fit for all lines (default False)

lsffunction

LSF model to take into account the instrumental LSF (default to muse_lsf).

eqwbool

if True compute equivalent widths (default True).

trimm_specbool

if True, trimmed spec around selected emission lines (default True).

contparsdictionary

Input parameters to pass to Contfit (default {})

lineparsdictionary

Input parameters to pass to Linefit (default {})

  • vel : (min,init,max), emi lines, bounds and init value for velocity offset (km/s), default (-500,0,500)

  • vdisp : (min,init,max), emi lines, bounds and init value for velocity dispersion (km/s), default (5,50,300)

  • velabs : (min,init,max), abs lines, bounds and init value for velocity offset (km/s), default (-500,0,500)

  • vdispabs : (min,init,max), abs lines, bounds and init value for velocity dispersion (km/s), default (5,50,300)

  • vdisp_lya : (min,init,max), bounds and init value for lya velocity dispersion (km/s), default (50,150,700)

  • gamma_lya : (min,init,max), bounds and init value for lya skewness parameter, default (-1,0,10)

  • gamma_2lya1 : (min,init,max), bounds and init value for lya left line skewness parameter, default (-10,-2,0)

  • gamma_2lya2 : (min,init,max), bounds and init value for lya right line skewness parameter, default (0,2,10)

  • sep_2lya : (min,init,max), bounds and init value for the 2 peak lya line separation (rest frame, km/s), default (80,500,1000)

  • windmax : float, maximum half size window in A to find peak values around initial wavelength value (default 10)

  • nstd_relsize : float, relative size (wrt to FWHM) of the wavelength window used for CHI2 line estimation (used in bootstrap only), default: 3.0

  • minsnr : float, minimum SNR to display line ID in plots (default 3.0)

  • line_ratios : list of tuples, list of line_ratios (see text), defaulted to [(“CIII1907”, “CIII1909”, 0.6, 1.2), (“OII3726”, “OII3729”, 1.0, 2.0)]

minparsdictionary

Input parameters to pass to minimize (lmfit) exemple:

mcmcparsdictionary

Input parameters to pass to emcee via minimize (lmfit)

  • steps : (default 0 = 10000 except for dble_lya 15000)

  • nwalkers : (default 0 = 25*npars)

  • save_proba: if True add P95 and P99 limits to fitted parameters (default False)

  • progress : if True display progress bar (default True)

Returns:
resultdict
  • result[‘lines’]: astropy line table (see fit_lines)

  • result[‘ztable’]; astropy z table (see fit_lines)

  • result[‘spec’]: MPDAF original spectrum

  • result[‘cont_spec’]: MPDAF spectrum, estimated continuum in observed frame (cont_fit + smooth residuals)

  • result[‘cont_fit’]: MPDAF spectrum, fitted continuum in observed frame

  • result[‘line_spec’]: MPDAF spectrum, continnum removed spectrum in observed frame

  • result[‘line_fit’]: MPDAF spectrum, fitted emission lines in observed frame

  • result[‘line_initfit’]: MPDAF spectrum, starting solution for emission line fit in observed frame

  • result[‘spec_fit’]: MPDAF spectrum, fitted line+continuum in observed frame

  • result[‘dcont’]: return dictionary from fit_cont (see fit_cont)

  • result[‘dline’]: returned dictionary from fit_lines (see fit_lines)

Lines table:

The table of the lines found in the spectrum are given in the table lines. The columns are:

  • FAMILY: the line family name (eg balmer)

  • LINE: The name of the line

  • ISBLEND: True if this line is a blend

  • LBDA_REST: The rest-frame position of the line in vacuum

  • DNAME: The display name for the line (set to None for close doublets)

  • VEL: The velocity offset in km/s with respect to the initial redshift (rest frame)

  • VEL_ERR: The error in velocity offset in km/s

  • Z: The fitted redshift in vacuum of the line (note for lyman-alpha the line peak is used)

  • Z_ERR: The error in fitted redshift of the line.

  • Z_INIT: The initial redshift

  • VDISP: The fitted velocity dispersion in km/s (rest frame)

  • VDISP_ERR: The error in fitted velocity dispersion

  • VDINST: The instrumental velocity dispersion in km/s

  • FLUX: Flux in the line. The unit depends on the units of the spectrum.

  • FLUX_ERR: The fitting uncertainty on the flux value.

  • SNR: the SNR of the line

  • SKEW: The skewness parameter of the asymetric line (for Lyman-alpha line only).

  • SKEW_ERR: The uncertainty on the skewness (for Lyman-alpha line only).

  • SEP: The fitted lya rest frame peak separation (in km/s) (for the double lyman-alpha fit only)

  • SEP_ERR: The error in fitted lya rest frame peak separation (in km/s) (for the double lyman-alpha fit only)

  • LBDA_OBS: The fitted position the line peak in the observed frame

  • PEAK_OBS: The fitted peak of the line in the observed frame

  • LBDA_LEFT: The wavelength at the left of the peak with 0.5*peak value

  • LBDA_RIGHT: The wavelength at the rigth of the peak with 0.5*peak value

  • FWHM_OBS: The full width at half maximum of the line in the observed frame

  • NSTD: The log10 of the normalized standard deviation of the line fit

  • LBDA_LNSTD: The wavelength at the left of the range used for NSTD estimation

  • LBDA_RNSTD: The wavelength at the right of the range used for NSTD estimation

  • EQW: The restframe line equivalent width

  • EQW_ERR: The error in EQW

  • CONT_OBS: The continuum mean value in Observed frame

  • CONT: the continuum mean value in rest frame

  • CONT_ERR: the error in rest frame continuum

When the options mcmc_lya or mcmc_all are active, additional columns are produced:

  • VEL_RTAU, VDISP_RTAU, FLUX_RTAU, SEP_RTAU, SKEW_RTAU: give the ratio of the mcmc chain length to 50 times the autocorrelation time

  • par_MIN99, par_MIN95, par_MAX95, par_MAX99: give the 95 and 99% quantile of the estimated probability distribution,

with par = VEL, Z, VDISP, FLUX, SEP, SKEW. This is computed only if save_proba = True is set in the mcmcpars dictionary

Redshift table:

The redshift table is saved in the table ztable The columns are:

  • FAMILY: the line family name

  • VEL: the velocity offset with respect to the original z in km/s

  • VEL_ERR: the error in velocity offset

  • Z: the fitted redshift (in vacuum)

  • Z_ERR: the error in redshift

  • Z_INIT: The initial redshift

  • VDISP: The fitted velocity dispersion in km/s (rest frame)

  • VDISP_ERR: The error in fitted velocity dispersion

  • LINE: the emission line name with maximum SNR

  • SNRMAX: the maximum SNR

  • SNRSUM: the sum of SNR (all lines)

  • SNRSUM_CLIPPED: the sum of SNR (only lines above a MIN SNR (default 3))

  • NL: number of fitted lines

  • NL_CLIPPED: number of lines with SNR>SNR_MIN

  • NFEV: the number of function evaluation

  • RCHI2: the reduced Chi2 of the family lines fit

  • STATUS: return status from minimization

  • METHOD: minimization method

  • NSTEPS: length of the mcmc chain (mcmc only)

  • RCHAIN: minimum value of the mcmc chain length divided by 50 times the autocorrelation time (mcmc only)

  • NBAD: number of lines with a parameter RTAU < 1 (mcmc only)

  • RCHAIN_CLIP: RCHAIN after clipping of lines with SNR < snr_min (mcmc only)

  • NBAD_CLIP: number of clipped lines with a parameter RTAU < 1 (mcmc only)