Full qsoabsfind API reference
qsoabsfind.parallel_convolution module
This script contains a function that runs the absorber finder in parallel for many spectra.
- qsoabsfind.parallel_convolution.parallel_convolution_search(fits_file, spec_indices, absorber, n_jobs, warnings_file=None, **kwargs)[source]
Run convolution_method_absorber_finder_in_QSO_spectra in parallel using multiprocessing.
- Parameters:
fits_file (str) – Path to the FITS file containing Normalized QSO spectra.
spec_indices (list or numpy.ndarray) – Indices of quasars in the data matrix.
absorber (str) – Absorber name for searching doublets (MgII, CIV, OVI, NV, SiIV, AlIII, FeII).
n_jobs (int) – Number of parallel jobs to run.
warnings_file (str, optional) – Path to a file where worker-process warnings are written. Default is None.
**kwargs – Search parameters as described in qsoabsfind.constants().
- Returns:
- Combined results from all spectra, with only absorbers with z_abs > 0 retained.
Keys:
index_spec,z_abs,gauss_fit,gauss_fit_std,ew_1_mean,ew_2_mean,ew_total_mean,ew_1_error,ew_2_error,ew_total_error,z_abs_err,sn_1,sn_2,vel_disp1,vel_disp2,delta_chi2.
- Return type:
dict
qsoabsfind.absfinder module
This script contains a function to run the main convolution based absorber algorithm on a single spectrum.
- qsoabsfind.absfinder.convolution_method_absorber_finder_in_QSO_spectra(spec_index, absorber='MgII', lam_obs=None, residual=None, error=None, lam_search=None, unmsk_residual=None, ker_width_pixels=5, coeff_sigma=2.5, mult_resi=1, d_pix=0.6, pm_pixel=200, sn_line1=3, sn_line2=2, use_covariance=False, logwave=True, verbose=True, nboot=None, conf_level=0.95)[source]
Detect absorbers with doublet properties in SDSS quasar spectra using a convolution method. This function identifies potential absorbers based on user-defined threshold criteria, applies Gaussian fitting to reject false positives, and computes the equivalent widths (EWs) of the lines, returning the redshifts, EWs, and fitting parameters.
- Parameters:
spec_index (int) – Index of quasar in the spectra 2D array.
absorber (str) – Absorber name for searching doublets (MgII, CIV, OVI, NV, SiIV, AlIII, FeII, NaI). Default is ‘MgII’.
lam_obs (numpy.array) – observed wavelength array.
residual (numpy.array) – residual (i.e. flux/continuum) array
error (numpy.array) – error on residuals
lam_search (numpy.array) – search observed wavelength array (i.e. region where absorber will be looked for).
unmsk_residual (numpy.array) – search residual array (residuals at search wavelength pixels)
ker_width_pixels (int or list) – Kernel width(s) in pixels. Default is 5.
coeff_sigma (float) – Coefficient for sigma to apply threshold in the convolved array. Default is 2.5.
mult_resi (float) – Factor to shift the residual up or down. Default is 1.
d_pix (float) – Pixel distance for line separation during Gaussian fitting. Default is 0.6.
pm_pixel (int) – Pixel parameter for local noise estimation. Default is 200.
sn_line1 (float) – Signal-to-noise ratio threshold for line 1. Default is 3.
sn_line2 (float) – Signal-to-noise ratio threshold for line 2. Default is 2.
use_covariance (bool) – If True, use full covariance of scipy curve_fit for EW error calculation. Default is False.
logwave (bool) – If True, wavelength is on log scale (e.g. SDSS). Default is True.
verbose (bool) – If True, print detailed outputs for debugging. Default is True.
nboot (int, optional) – Number of bootstrap iterations for fitting. Default is None (disabled).
conf_level (float) – Minimum confidence level for chi2-based absorber selection. Default is 0.95.
- Returns:
- Contains lists of various parameters related to detected absorbers.
index_spec (list): QSO spec index searched
z_abs (list): redshifts of absorbers detected
gauss_fit (list of arrays): gaussian fit parameters for each absorber
gauss_fit_std (list of arrays): errors on gaussian fit parameters for each absorber
ew_1_mean (list): Equivalent width of line 1 for each absorber
ew_2_mean (list): Equivalent width of line 2 for each absorber
ew_total_mean (list): Total Equivalent width of line 1 and line 2 for each absorber
ew_1_error (list): errors on Equivalent width of line 1 for each absorber
ew_2_error (list): errors on Equivalent width of line 2 for each absorber
ew_total_error (list): errors on Total Equivalent width of line 1 and line 2 for each absorber
z_abs_err (list): errors on redshifts of absorbers detected
sn_1 (list): SNR of line 1 for each absorber
sn_2 (list): SNR of line 2 for each absorber
vel_disp1 (list): rest-frame velocity dispersion of line 1 for each absorber (in km/s)
vel_disp2 (list): rest-frame velocity dispersion of line 2 for each absorber (in km/s)
delta_chi2 (list): delta_chi2 between fitted model and flat continuum (null hypothesis)
- Return type:
dict
- qsoabsfind.absfinder.read_single_spectrum_and_find_absorber(fits_file, spec_index, absorber, **kwargs)[source]
This function retrieves a single QSO spectrum from a FITS file, processes the data to remove NaNs, and prepares the spectrum for absorber search within specified wavelength regions and runs the convolution based adaptive S/N method to detect absorbers in the spectrum.
- Parameters:
fits_file (str) – Path to the FITS file containing normalized QSO spectra. The file must include extensions for FLUX, ERROR, WAVELENGTH and METADATA which must contain keyword Z_QSO.
spec_index (int) – Index of the quasar spectrum to retrieve from the FITS file.
absorber (str) – Name of the absorber to search for (e.g., MgII, CIV, OVI, NV, SiIV, AlIII, FeII).
kwargs (dict) – search parameters as taken in convolution_method..()
- Returns:
- Contains lists of various parameters related to detected absorbers.
index_spec (list): QSO spec index searched
z_abs (list of floats): redshifts of absorbers detected
gauss_fit (list of arrays): gaussian fit parameters for each absorber
gauss_fit_std (list of arrays): errors on gaussian fit parameters for each absorber
ew_1_mean (list of floats): Equivalent width of line 1 for each absorber
ew_2_mean (list of floats): Equivalent width of line 2 for each absorber
ew_total_mean (list of floats): Total Equivalent width of line 1 and line 2 for each absorber
ew_1_error (list of floats): errors on Equivalent width of line 1 for each absorber
ew_2_error (list of floats): errors on Equivalent width of line 2 for each absorber
ew_total_error (list of floats): errors on Total Equivalent width of line 1 and line 2 for each absorber
z_abs_err (list): errors on redshifts of absorbers detected
sn_1 (list): SNR of line 1 for each absorber
sn_2 (list): SNR of line 2 for each absorber
vel_disp1 (list): rest-frame velocity dispersion of line 1 for each absorber (in km/s)
vel_disp2 (list): rest-frame velocity dispersion of line 2 for each absorber (in km/s)
delta_chi2 (list): delta_chi2 between fitted model and flat continuum (null hypothesis)
- Return type:
dict
- Raises:
AssertionError – If the sizes of lam_search, unmsk_residual, and unmsk_error do not match.
Note
This function assumes that the input spectra are already normalized (i.e., flux divided by continuum).
The wavelength search region is determined dynamically based on the observed wavelength range.
qsoabsfind.absorberutils module
This script contains a utility functions that are repeatedly called during the absorber search in QSO spectra.
- qsoabsfind.absorberutils.absorber_search_window(wavelength, residual, err_residual, zqso, absorber, min_wave, max_wave, start_rest_wave=None, end_rest_wave=None, dv=5000, lam_edge_sep=0, verbose=False)[source]
Wrapper function to return the most basic wavelength window for absorber search.
- Parameters:
wavelength (numpy.ndarray) – The wavelength array of the QSO spectrum.
residual (numpy.ndarray) – The residual array of the QSO spectrum.
err_residual (numpy.ndarray) – The error residual array of the QSO spectrum.
zqso (float) – The redshift of the QSO.
absorber (str) – (Options: MgII, CIV, OVI, NV, SiIV, AlIII, FeII)
min_wave (float) – minimum observed wavelength edge (in Ang)
max_wave (float) – maximum observed wavelength edge (in Ang)
start_rest_wave (float, optional) – start wave in QSO rest-frame for absorber search (default None)
end_rest_wave (float, optional) – end wave in QSO rest-frame for absorber search (default None)
dv (float) – absolute velocity offset from QSO redshift (default 5000 km/s)
lam_edge_sep (float) – separation from minimum/maximum wavelength, i.e. lam_min +/- lam_edge_sep, this is just to make sure that we avoid the very edge of the spectrum
verbose (bool, optional) – If True will print time info. Default is False.
- Returns:
A tuple containing unmasked wavelength, residual, and errors.
- Return type:
tuple
- qsoabsfind.absorberutils.calculate_doublet_ratio(ew1, ew2, ew1_error, ew2_error, f1, f2)[source]
Calculate the doublet ratio and its associated error.
- Parameters:
ew1 (float) – Equivalent width of the first line.
ew2 (float) – Equivalent width of the second line.
ew1_error (float) – Error associated with the first equivalent width.
ew2_error (float) – Error associated with the second equivalent width.
f1 (float) – oscillator strength of first line
f2 (float) – oscillator strength of second line
- Returns:
- A tuple containing:
doublet_ratio (float): The ratio of ew1 to ew2.
doublet_ratio_error (float): The propagated error for the doublet ratio.
- Return type:
tuple
- qsoabsfind.absorberutils.check_absorber_selection(qso_id, zabs, gaussian_parameters, bound, lower_del_lam, c0, c1, upper_del_lam, sn1, sn_line1, sn2, sn_line2, vel1, vel2, min_dr, dr, max_dr, ew1_snr, ew2_snr, delta_chi2, conf_level=0.95, vmax=120, verbose=False)[source]
Check absorber selection criteria, print details, and count satisfied conditions.
Evaluates whether a candidate absorber passes various selection criteria based on spectral line properties, signal-to-noise ratios, velocity constraints, and statistical significance.
- Parameters:
qso_id (str) – Unique identifier for the quasar/QSO.
zabs (float) – Absorption redshift of the candidate system.
gaussian_parameters (array-like) – Fitted parameters for the double Gaussian model, typically [amp1, center1, width1, amp2, center2, width2].
bound (bool) – Bounds for Gaussian fit parameters.
lower_del_lam (float) – Lower wavelength offset/deviation.
c0 (float) – Central wavelength or reference wavelength for line 1.
c1 (float) – Central wavelength or reference wavelength for line 2.
upper_del_lam (float) – Upper wavelength offset/deviation.
sn1 (float) – Signal-to-noise ratio near line 1.
sn_line1 (float) – Signal-to-noise ratio thresholde at line 1 center.
sn2 (float) – Signal-to-noise ratio for continuum near line 2.
sn_line2 (float) – Signal-to-noise ratio thresholde at line 2 center.
vel1 (float) – Velocity width of line 1 component in km/s.
vel2 (float) – Velocity width of line 2 component in km/s.
min_dr (float) – Minimum doublet ratio threshold.
dr (float) – Measured doublet ratio (e.g., CIV 1548/1550 ratio).
max_dr (float) – Maximum doublet ratio threshold.
ew1_snr (float) – Equivalent width signal-to-noise ratio for line 1.
ew2_snr (float) – Equivalent width signal-to-noise ratio for line 2.
delta_chi2 (float) – Chi-squared difference between flat and fitted models.
conf_level (float, optional) – Confidence level for statistical significance. Defaults to 0.95 (95% confidence).
vmax (float, optional) – Maximum allowed velocity difference between components in km/s. Defaults to 120.
- Returns:
True if the absorber passes the selection criteria, False otherwise.
- Return type:
bool
Note
The function evaluates multiple selection criteria including: - Wavelength bounds for both lines - S/N thresholds for continuum and line centers - Velocity constraints between components - Doublet ratio physical limits - Equivalent width significance - Statistical significance via delta chi-squared test
Prints detailed information about each criterion and whether it passes.
- qsoabsfind.absorberutils.contiguous_pixel_remover(abs_z, sn1_all, sn2_all, use_kernel, fitted_params)[source]
Remove contiguous or duplicate absorbers by evaluating the signal-to-noise ratio (SNR) and comparing their line centers.
- Parameters:
abs_z (list or numpy.ndarray) – List of absorber redshifts.
sn1_all (list or numpy.ndarray) – List of SNR values for the first line.
sn2_all (list or numpy.ndarray) – List of SNR values for the second line.
use_kernel (str, optional) – Kernel type (MgII, CIV, OVI, NV, SiIV, AlIII, FeII).
fitted_params (list of arrays) – corresponding gaussian fitting parameters for those redshifts
- Returns:
Updated list of indices indicating bad (1) or good (-1) absorbers.
- Return type:
list
- qsoabsfind.absorberutils.estimate_local_sigma_conv_array(conv_array, pm_pixel)[source]
Estimate the local standard deviation for each element in the convolution array over a window defined by pm_pixel.
- Parameters:
conv_array (numpy.ndarray) – Input convolution array for which local standard deviations are to be calculated.
pm_pixel (int) – Number of pixels defining the window size around each element for local standard deviation calculation.
- Returns:
Array of local standard deviations.
- Return type:
numpy.ndarray
- qsoabsfind.absorberutils.estimate_snr_for_lines(l1, l2, sig1, sig2, lam_rest, residual, error, log)[source]
Estimate S/N of the doublet lines.
- Parameters:
l1 (float) – First wavelength to check around.
l2 (float) – Second wavelength to check around.
sig1 (float) – fitted width of the first line
sig2 (float) – fitted width of second line
lam_rest (numpy.ndarray) – Rest-frame wavelengths.
residual (numpy.ndarray) – Residual flux values.
error (numpy.ndarray) – Error values corresponding to the residuals.
log (bool) – if wavelength bins are on log scale
- Returns:
- Integrated signal-to-noise ratios (SNR) around the specified wavelengths.
Returns (mean_sn1, mean_sn2).
- Return type:
tuple
- qsoabsfind.absorberutils.find_searchable_qsos(fits_file, absorber, constant_file, ncpus=4, n_qso=None, verbose=False)[source]
Run searchability checks for all QSO spectra in parallel.
For each spectrum, determines whether the given absorber can be searched based on the wavelength coverage and pixel count thresholds defined in the user constants file. Overridable package constants (
SMALL_WAVE,LARGE_WAVE,LAM_CIV_MIN,MIN_NPIXEL) are patched from the user constants file before the checks run, exactly as done in the main convolution pipeline.- Parameters:
fits_file (str) – Path to the FITS file containing normalised QSO spectra.
absorber (str) – Absorber name (e.g.
'MgII','CIV').constant_file (str) – Path to the user constants
.pyfile.ncpus (int) – Number of parallel worker processes (default 4).
n_qso (int or str, optional) – Number of spectra to check, or a range string such as
'1-1000'or'1-1000:10'. IfNone, all spectra in the file are checked.verbose (bool) – If
True, pass verbose flag to the per-spectrum check (defaultFalse).
- Returns:
Table with two columns:
QSO_INDEX(int): Spectrum index in the FITS file.IS_GOOD(bool):Trueif the absorber can be searched in that spectrum,Falseotherwise.SNR(float): SNR value in the absorber search region (if snr_cut added, otherwise snr value = -1)
- Return type:
astropy.table.Table
- qsoabsfind.absorberutils.find_valid_indices(our_z, residual_our_z, lam_search, conv_arr, sigma_cr, coeff_sigma, beta, line1, line2, logwave)[source]
Find valid indices based on thresholding in the convolved array.
- Parameters:
our_z (array) – Array of redshift values.
residual_our_z (array) – Array of residual values at the redshift positions.
lam_search (array) – Array of wavelengths.
conv_arr (array) – Convolved array.
sigma_cr (array) – Local sigma values.
coeff_sigma (float) – Coefficient for sigma.
beta (float) – Oscillator strength ratio.
line1 (float) – First line wavelength.
line2 (float) – Second line wavelength.
logwave (bool) – if wavelength pixels are on fixed log-scale (e.g. SDSS)
- Returns:
Arrays of new redshift values and new residual values.
- Return type:
Tuple
- qsoabsfind.absorberutils.find_z_from_minimum(wavelength, residual, line_rest, z_guess, window=9, log=False)[source]
Estimate absorber redshift from the minimum flux near the expected line center.
Given an initial redshift guess, this function identifies a symmetric window around the expected observed-frame line center and finds the pixel with the minimum residual (flux) within that window. The wavelength of that minimum is converted back to a refined redshift for the line.
- Parameters:
wavelength (numpy.ndarray) – Observed-frame wavelength array, monotonically increasing and aligned with residual.
residual (numpy.ndarray) – Residual/flux array aligned with wavelength. May contain NaNs; the minimum is computed with np.nanargmin.
line_rest (float) – Rest-frame wavelength (in the same units as wavelength) of the spectral line used for refinement (e.g., 1548.204 A for C IV).
z_guess (float) – Initial absorber redshift guess.
window (int, optional) – Half-window size in pixels for the local search around the expected line center. Defaults to 9. The search range is +/- window x (wavelength pixel spacing).
log (bool) – if wavelenght ins log-scale (default False)
- Returns:
Refined redshift estimate computed as (λ_min / line_rest) - 1, where λ_min is the observed-frame wavelength at the minimum residual within the search window. If no pixels fall within the window, returns z_guess.
- Return type:
float
Note
If the search window contains only NaNs, np.nanargmin will raise a ValueError. Consider pre-filtering residual or guarding with np.isfinite if this is a possibility in your data.
The window is defined in observed-frame wavelength by converting the pixel count to delta λ using the local pixel spacing.
- qsoabsfind.absorberutils.get_search_limits(absorber, zqso, min_wave, max_wave, start_rest_wave=None, end_rest_wave=None, dv=5000, lam_edge_sep=0, verbose=False)[source]
Return observed-frame wavelength range (lam_start, lam_end) to search for the given absorber.
- Parameters:
absorber (str) – Absorber name (e.g., MgII, CIV, OVI, NV, SiIV, AlIII, FeII.)
zqso (float) – Quasar emission redshift
min_wave (float) – minimum Observed wavelength
max_wave (float) – maximum Observed wavelength
start_rest_wave (float, optional) – start wave in QSO rest-frame for absorber search (default None)
end_rest_wave (float, optional) – end wave in QSO rest-frame for absorber search (default None)
dv (float) – absolute velocity offset from QSO redshift (default 5000 km/s)
lam_edge_sep (float) – Padding in angstroms to avoid edge artifacts
- Returns:
Observed-frame wavelength limits
- Return type:
lam_start, lam_end (float)
- qsoabsfind.absorberutils.group_and_select_weighted_redshift(redshifts, fluxes, residual, lam_obs, line1, line2, delta_z)[source]
Group contiguous redshifts and select the highest weighted (corresponding to minimum flux) redshift from each group.
- Parameters:
redshifts (list or numpy.ndarray) – List of candidate absorber redshifts.
fluxes (list or numpy.ndarray) – Corresponding residual fluxes near each redshift.
residual (numpy.ndarray) – Full residual flux array aligned with
lam_obs.lam_obs (numpy.ndarray) – Observed-frame wavelength array.
line1 (float) – Rest-frame wavelength of the first doublet line (Angstrom).
line2 (float) – Rest-frame wavelength of the second doublet line (Angstrom).
delta_z (float) – Maximum redshift difference to consider two candidates contiguous.
- Returns:
Best redshift from each contiguous group (minimum-flux weighted selection).
- Return type:
list
- qsoabsfind.absorberutils.group_contiguous_pixel(data, resi, avg)[source]
Arrange data into groups where successive elements differ by less than the average difference.
- Parameters:
data (np.ndarray) – List of absorbers for each spectrum.
resi (np.ndarray) – Corresponding residual.
avg (float) – Maximum allowed difference to group data.
- Returns:
Final list with contiguous pixels grouped, and corresponding residuals if provided.
- Return type:
tuple
- qsoabsfind.absorberutils.median_selection_after_combining(combined_final_our_z, lam_search, residual, d_pix, use_kernel, delta_z, window=9, gamma=4)[source]
Perform grouping and weighted mean from the list of all potentially identified absorbers after combining from all the runs with different kernel widths.
- Parameters:
combined_final_our_z (list) – List of potential absorbers identified for each spectrum.
lam_search (numpy.ndarray) – Wavelength search array.
residual (numpy.ndarray) – Residual values corresponding to the absorbers.
d_pix (float) – Pixel separation tolerance in wavelength (default 0.6 Angstrom).
use_kernel (str) – Kernel/absorber type (e.g. MgII, CIV).
delta_z (float) – Maximum redshift difference to consider two candidates contiguous.
window (int) – window size for redshift estimate (default 9)
gamma (int) – power for lambda to use in 1/lam**gamma weighting scheme (default 4)
- Returns:
List after grouping contiguous pixels for each spectrum.
- Return type:
list
- qsoabsfind.absorberutils.redshift_estimate(fitted_obs_l1, fitted_obs_l2, std_fitted_obs_l1, std_fitted_obs_l2, line1, line2)[source]
Estimate the redshift and its error from Gaussian fitting parameters for two spectral lines.
- Parameters:
fitted_obs_l1 (float) – Gaussian fitted line centre 1 (obs frame).
fitted_obs_l2 (float) – Gaussian fitted line centre 2 (obs frame).
std_fitted_obs_l1 (float) – error on Gaussian fitted line centre 1 (obs frame).
std_fitted_obs_l2 (float) – error on Gaussian fitted line centre 2 (obs frame).
line1 (float) – first line centre of metal spectral line.
line2 (float) – second line centre of metal spectral line.
- Returns:
- A tuple containing:
z_corr (float): mean redshift estimated from the Gaussian fitting parameters.
z_err (float): Estimated error in the corrected redshift.
- Return type:
tuple
- qsoabsfind.absorberutils.remove_Mg_falsely_come_from_Fe_absorber(z_after_grouping, lam_obs, residual, error, d_pix, logwave)[source]
Remove any MgII absorber that arises falsley due to Fe 2586, 2600 doublet, i.e., false positive due to Fe lines.
- Parameters:
z_after_grouping (list) – List of absorbers after grouping.
lam_obs (numpy.ndarray) – Observed wavelengths.
residual (numpy.ndarray) – Residual values.
error (numpy.ndarray) – Error values corresponding to the residuals.
d_pix (float) – Delta pixel value.
logwave (bool) – if wavelength on log scale (default True for SDSS)
- Returns:
Updated list of absorbers with false positives removed.
- Return type:
numpy.ndarray
- qsoabsfind.absorberutils.return_if_absorber_can_be_detected_in_a_spectrum(spectra, absorber, **kwargs)[source]
Check if an absorber can be searched in a given QSO spectrum.
This function loads a single QSO spectrum from a spec.QSOSpecRead object, removes NaNs, and determines if the absorber’s search window falls within the spectrum’s observed wavelength range.
- Parameters:
spectra (object) – spec.QSOSpecRead object
absorber (str) – Absorber name (e.g., ‘MgII’, ‘CIV’, ‘OVI’, etc.).
kwargs (dict) – search parameters as described in qsoabsfind.constants()
- Returns:
1 if the absorber can be searched in the spectrum, 0 otherwise and snr value (if snr cut added, otherwise snr value = -1)
- Return type:
tuple
Note
Assumes input spectra are already normalized (flux / continuum).
Checks whether enough search window pixels are available after masking NaNs.
Users can define ‘snr_cut’ in kwargs to check if the median SNR > kwargs[‘snr_cut’] in the absorber search wavelength region.
- qsoabsfind.absorberutils.return_search_window_wavelength_range(absorber, start_rest_wave=None, end_rest_wave=None, verbose=False)[source]
Return default red and blue end rest-frame quasar emission wavelength range that will be used to define the search windohe given absorber.
- Parameters:
absorber (str) – Absorber name (e.g., MgII, CIV, OVI, NV, SiIV, AlIII, FeII.)
start_rest_wave (float, optional) – start wave in QSO rest-frame for absorber search (default None)
end_rest_wave (float, optional) – end wave in QSO rest-frame for absorber search (default None)
- Returns:
(blue_end, red_end)
- qsoabsfind.absorberutils.z_abs_from_same_metal_absorber(first_list_z, lam_obs, residual, error, d_pix, use_kernel, logwave)[source]
Remove any absorber that arises due to the MgII2803 or CIV1550 line but has already been detected for the MgII2796 or CIV1548 line, exploiting the doublet property of MgII/CIV to remove false positives.
- Parameters:
first_list_z (list) – List of absorbers after grouping.
lam_obs (numpy.ndarray) – Observed wavelengths.
residual (numpy.ndarray) – Residual values.
error (numpy.ndarray) – Error values corresponding to the residuals.
d_pix (float) – Pixel distance for line separation during Gaussian fitting.
use_kernel (str, optional) – Kernel type (MgII, CIV).
logwave (bool) – if wavelength bins are on log scale
- Returns:
Updated list of absorbers with false positives removed.
- Return type:
numpy.ndarray
qsoabsfind.ew module
This script contains a function to fit a given absorption profile with a double gaussian and measure equivalent widths.
- qsoabsfind.ew.bootstrap_fitting_and_ew(index, nboot, z, wavelength, flux, error, ix0, ix1, bound, amp_ratio, line1, line2, num_iter)[source]
Perform bootstrap resampling to estimate uncertainties in fitting parameters and equivalent widths.
Conducts bootstrap analysis on spectral data to derive robust estimates of double Gaussian fitting parameters and equivalent widths with associated uncertainties for a doublet system.
- Parameters:
index (int) – Index or identifier for the current fitting process.
nboot (int) – Number of bootstrap iterations to perform.
z (float) – Redshift of the absorption system.
wavelength (array-like) – Observed Wavelength array of the spectrum.
flux (array-like) – Flux array of the spectrum.
error (array-like) – Flux uncertainty array.
ix0 (int) – Starting index of the spectral region to fit.
ix1 (int) – Ending index of the spectral region to fit.
bound (tuple or list) – Bounds for the fitting parameters.
amp_ratio (float) – Expected amplitude ratio between the two lines in the doublet.
line1 (float) – Rest wavelength of the first line in the doublet.
line2 (float) – Rest wavelength of the second line in the doublet.
num_iter (int) – Maximum number of iterations for each fitting attempt.
- Returns:
- A tuple containing:
fit_params_mean (array): Mean values of fitted parameters across bootstrap samples.
fit_param_std (array): Standard deviations of fitted parameters.
ew1_mean (float): Mean equivalent width of line 1.
ew2_mean (float): Mean equivalent width of line 2.
ew_total_mean (float): Mean total equivalent width of the doublet.
ew1_std (float): Standard deviation of line 1 equivalent width.
ew2_std (float): Standard deviation of line 2 equivalent width.
ew_total_std (float): Standard deviation of total equivalent width.
- Return type:
tuple
- qsoabsfind.ew.calculate_ew_errors(popt, perr)[source]
Calculate the errors in the equivalent widths (EW) using the errors in the optimized parameters.
- Parameters:
popt (numpy.ndarray) – Optimized parameters from the curve fitting.
perr (numpy.ndarray) – Errors of the optimized parameters from the curve fitting.
- Returns:
- Contains the following elements:
EW1_error (float): Error in the equivalent width of the first Gaussian.
EW2_error (float): Error in the equivalent width of the second Gaussian.
EW_total_error (float): Total error in the equivalent width of both Gaussians.
- Return type:
tuple
- qsoabsfind.ew.double_curve_fit(index, fun_to_run, lam_fit_range, nmf_resi_fit, error_fit, bounds, init_cond, maxefv)[source]
Fits a double Gaussian function to the provided data.
- Parameters:
index (int) – Index of the spectrum being fitted.
fun_to_run (callable) – The fitting function.
lam_fit_range (numpy.ndarray) – Wavelength range for the fitting.
nmf_resi_fit (numpy.ndarray) – Residual array for the fitting.
error_fit (numpy.ndarray) – Error array for the fitting.
bounds (tuple) – Bounds for the fitting parameters.
init_cond (list or numpy.ndarray) – Initial conditions for the fitting parameters.
maxefv (int) – Maximum number of iterations for the fitting algorithm.
- Returns:
- Contains the following elements:
save_param_array (numpy.ndarray): Fitted parameters.
save_param_error (numpy.ndarray): Errors of the fitted parameters.
EW_first (float): Equivalent width of the first Gaussian.
EW_second (float): Equivalent width of the second Gaussian.
EW_total (float): Total equivalent width of both Gaussians.
- Return type:
tuple
- qsoabsfind.ew.full_covariance_ew_errors(popt, pcov)[source]
With full covariance matrix, calculate the errors in the equivalent widths (EW) using the errors in the optimized parameters.
- Parameters:
popt (numpy.ndarray) – Optimized parameters from the curve fitting.
pcov (numpy.ndarray) – Covariance matrix from the curve fitting.
- Returns:
- Contains the following elements:
EW1_error (float): Error in the equivalent width of the first Gaussian.
EW2_error (float): Error in the equivalent width of the second Gaussian.
EW_total_error (float): Total error in the equivalent width of both Gaussians.
- Return type:
tuple
- qsoabsfind.ew.measure_absorber_properties_double_gaussian(index, wavelength, flux, error, absorber_redshift, bound, use_kernel, d_pix, num_iter=500, window=5, use_covariance=False, nboot=None)[source]
Measures the properties of each potential absorber by fitting a double Gaussian to the absorption feature and measuring the equivalent width (EW) and errors of absorption lines.
- Parameters:
index (int) – Index of the spectrum being fitted.
wavelength (numpy.ndarray) – Array containing common rest frame quasar wavelength.
flux (numpy.ndarray) – Matrix containing the residual flux.
error (numpy.ndarray) – Error array corresponding to the flux.
absorber_redshift (list) – List of potential absorbers identified previously.
bound (tuple) – Bounds for the fitting parameters.
use_kernel (str) – Kernel type (MgII, FeII, CIV, NV, OVI, SiIV, AlIII).
d_pix (float) – wavelength pixel for tolerance
window (int) – window size for redshift estimate (default 9)
use_covariance (bool) – if want to use full covariance of scipy curvey_fit for EW error calculation (default is False)
nboot (int) – if provided, will perform bootstrapping fitting (default None)
- Returns:
- Contains the following elements:
z_abs_array (numpy.ndarray): Array of absorber redshifts.
z_abs_err (numpy.ndarray): Array of redshift errors.
fitting_param_for_spectrum (numpy.ndarray): Array of fitting parameters for double Gaussian.
fitting_param_std_for_spectrum (numpy.ndarray): Array of errors for fitting parameters.
EW_first_line (numpy.ndarray): Mean equivalent width of the first line.
EW_second_line (numpy.ndarray): Mean equivalent width of the second line.
EW_total (numpy.ndarray): Mean total equivalent width of both lines.
EW_first_line_error (numpy.ndarray): Error in the equivalent width of the first line.
EW_second_line_error (numpy.ndarray): Error in the equivalent width of the second line.
EW_total_error (numpy.ndarray): Total error in the equivalent width of both lines.
delta_chi2 (numpy.ndarray): Delta chi-squared values for significance testing.
- Return type:
tuple
- qsoabsfind.ew.quick_significance_test(flux_norm, fitted_model, error, fitted_params=None, wavelength_rest=None, n_pixels=5)[source]
Significance test with simple absorption check at line centers.
- Parameters:
flux_norm – Normalized flux array
fitted_model – Fitted double Gaussian model
error – Error array
fitted_params – Fitted parameters [amp1, center1, sigma1, amp2, center2, sigma2]
wavelength_rest – Wavelength array (same frame as fitted_params)
n_pixels – Number of pixels around each line center to check
- Returns:
Delta chi-square value, or 0 if absorption criteria not met
- Return type:
delta_chi2
qsoabsfind.io module
This script contains functions to read, append and write fits files.
- qsoabsfind.io.append_table_to_fits(filename, table, hdu_name)[source]
Append an Astropy Table as a new BinTableHDU to a FITS file.
- Parameters:
filename (str) – Path to the FITS file to write to.
table (astropy.table.Table) – Table to append.
hdu_name (str) – Name of the new HDU (used for identification).
- qsoabsfind.io.read_any_fits_file(filename, hdu_name)[source]
Read any fits file given filename and hdu_name.
- Parameters:
filename (str) – fits filepath
hdu_name (str or int) – HDU extension name or number
- Returns:
Table for BinTableHDU, data array for Image/Primary HDU
- Return type:
astropy data
- qsoabsfind.io.read_fits_file(fits_file, index=None)[source]
Reads the FLUX, ERROR, WAVELENGTH, and METADATA extensions from the FITS file.
- Parameters:
fits_file (str) – Path to the FITS file containing QSO spectra.
index (int, list, or np.ndarray, optional) – Index or indices of the rows to load. Default is None.
- Returns:
A tuple containing the flux, error, wavelength, and metadata data.
- Return type:
tuple
- qsoabsfind.io.save_results_to_fits(results, input_file, output_file, headers, absorber)[source]
Save the absorber results to a FITS file along with the metadata of QSOs.
- Parameters:
results (dict) – The results dictionary from
parallel_convolution_search().input_file (str) – The path to the input spectra FITS file.
output_file (str) – The path to the output FITS file.
headers (dict) – The headers to include in the FITS file.
absorber (str) – The absorber type (e.g. MgII, CIV).
- Returns:
Writes a FITS file with an
ABSORBERBinTableHDU containing detected absorber properties and aMETADATABinTableHDU with corresponding QSO metadata.- Return type:
None
qsoabsfind.datamodel module
This module contains data model classes for reading and handling QSO spectra and absorber catalog FITS files.
- class qsoabsfind.datamodel.AbsorberData(filepath, autoload=False, verbose=True)[source]
Bases:
objectA class to read and handle Absorber table FITS file containing ABSORBER, METADATA, and optionally COLUMN_DENSITY extensions.
- class qsoabsfind.datamodel.QSOSpecRead(fits_file, index=None, autoload=False, verbose=True)[source]
Bases:
objectA class to read and handle QSO spectra from a FITS file containing FLUX, ERROR, WAVELENGTH, and METADATA extensions.
- __init__(fits_file, index=None, autoload=False, verbose=True)[source]
Initializes the QSOSpecRead class.
- Parameters:
fits_file (str) – Path to the FITS file containing QSO spectra.
index (int, list, or np.ndarray, optional) – Index or indices of the rows to load. Default is None.
autoload (bool) – if True, class itself will load the data (default=False), in True case, user does not need to use available class functions.
verbose (bool) – if want to print time info
- get_metadata(asdict=False)[source]
Returns the METADATA data with keyword handling (must be used after read_fits() option).
- Parameters:
asdict (bool) – if True, metadata will be returned as a dictionary, otherwise astropy.table
- Returns:
The metadata data with keywords (if asdict=True), otherwise a Table
- Return type:
dict or Table
qsoabsfind.utils module
This script contains some utility functions.
- qsoabsfind.utils.combine_fits_files(directory, output_file)[source]
Combines data from several FITS files in a directory into a single FITS file.
Note
This function assumes that all FITS files have the same HDU structure and that all HDUs are Tables. Any column with ‘EW’ in its name will have its unit set to Angstrom. The INDEX_SPEC column is not concatenated. The primary HDU from the first FITS file is copied to the final combined file. So make sure that directory contains only qsoabsfind output files.
- Parameters:
directory (str) – Path to the directory containing the FITS files.
output_file (str) – Path to the output FITS file.
- Returns:
The combined FITS file is saved to the specified output path.
- Return type:
None
- qsoabsfind.utils.compute_doublet_amplitudes(A1_input, f1, f2)[source]
Computes amplitudes for the first and second lines of a doublet based on the user-defined A1_input and oscillator strengths f1 and f2.
Ensures that both amplitudes remain <= 1.
- Parameters:
A1_input (float) – Desired amplitude of the stronger line (usually <= 1).
f1 (float) – Oscillator strength of the first line.
f2 (float) – Oscillator strength of the second line.
- Returns:
Tuple of amplitudes for line1 and line2
- Return type:
(A1, A2)
- qsoabsfind.utils.convolution_fun(absorber, residual_arr_after_mask, width, log, wave_res, index, f1, f2)[source]
Convolves the spectrum with a Gaussian kernel.
- Parameters:
absorber (str) – Type of absorber (e.g., MgII, CIV, OVI, NV, SiIV, AlIII, FeII).
residual_arr_after_mask (numpy.ndarray) – Final residual array after masking.
width (float) – The width of the Gaussian kernel (decide base dupon width of real absorption feature).
log (bool) – if log bins should be used for wavelength
wave_res (float) – wavelength pixel size (SDSS: 0.0001 on log scale, DESI: 0.8 on linear scale)
index (int) – QSO index
f1 (float) – Oscillator strength of the first line.
f2 (float) – Oscillator strength of the second line.
- Returns:
The convolved residual array.
- Return type:
numpy.ndarray
- qsoabsfind.utils.double_gaussian(x, amp1, mean1, sigma1, amp2, mean2, sigma2)[source]
Generates a double Gaussian function to fit absorption features in a given spectrum.
- Parameters:
x (numpy.ndarray) – Wavelength points where the model is evaluated.
amp1 (float) – Amplitude of the first Gaussian.
mean1 (float) – Mean (center) of the first Gaussian.
sigma1 (float) – Standard deviation (width) of the first Gaussian.
amp2 (float) – Amplitude of the second Gaussian.
mean2 (float) – Mean (center) of the second Gaussian.
sigma2 (float) – Standard deviation (width) of the second Gaussian.
- Returns:
The function that fits the absorption feature using curve_fit.
- Return type:
numpy.ndarray
- qsoabsfind.utils.elapsed(start, msg)[source]
Prints the elapsed time since start.
- Parameters:
start (float) – The start time.
msg (str) – The message to print with the elapsed time.
- Returns:
The current time.
- Return type:
float
- qsoabsfind.utils.gauss_two_lines_kernel(x, a)[source]
Defines the kernel function using double gaussian only.
- Parameters:
x (numpy.ndarray) – Kernel lambda array (user defined),
a (numpy.ndarray) – Kernel parameters, 6 parameters (amp, mean, and sigma for two Gaussian),
- Returns:
The kernel function (array of numbers).
- Return type:
numpy.ndarray
- qsoabsfind.utils.get_all_extnames(filename)[source]
Get list of all HDU extension names in a FITS file
- Parameters:
filename (str) – fits file
- Returns:
list containing extension names
- Return type:
list
- qsoabsfind.utils.get_package_versions()[source]
Get the versions of qsoabsfind and other relevant packages.
- Returns:
A dictionary containing the versions of the packages.
- Return type:
dict
- qsoabsfind.utils.match_order(arr1, arr2)[source]
Matching order based on match key fot given two arrays
- Parameters:
arr1 (array) – First array (will be assumed to be the reference array)
arr2 (array) – Second array (target array for which the order to be matched)
- Returns:
matching indices such that arr2[indices]=arr1
Note
Raises Assertion error if sizes do not match
- qsoabsfind.utils.modify_units(col_name, col)[source]
Modify the unit of a column based on the column name.
- Parameters:
col_name (str) – The name of the column.
col (Column) – The column object.
- Returns:
The modified unit if conditions are met, otherwise the original unit.
- Return type:
str
- qsoabsfind.utils.numeric_key(filename)[source]
Extract first integer from filename for sorting.
Extracts the first sequence of digits found in a filename to use as a numeric sorting key. Files without numbers are placed at the end of the sort order.
- Parameters:
filename (str) – Filename or path from which to extract the numeric key.
- Returns:
- First integer found in the filename, or float(‘inf’) if no
number is present (ensuring numberless files sort last).
- Return type:
int or float
Examples
>>> numeric_key("file_123_data.txt") 123 >>> numeric_key("report_42.pdf") 42 >>> numeric_key("no_numbers_here.txt") inf >>> sorted(["file3.txt", "file20.txt", "file1.txt"], key=numeric_key) ['file1.txt', 'file3.txt', 'file20.txt']
- qsoabsfind.utils.parse_qso_sequence(qso_sequence)[source]
Parse a bash-like sequence or a single integer to generate QSO indices.
- Parameters:
qso_sequence (str or int) – Bash-like sequence (e.g., ‘1-1000’, ‘1-1000:10’) or an integer.
- Returns:
Array of QSO indices.
- Return type:
numpy.array
- qsoabsfind.utils.plot_absorber(spectra, absorber, zabs, show_error=False, plot_filename=None, **kwargs)[source]
Saves a plot of spectra with absorber(s) (full spectrum + zoomed version) along with its Gaussian fit in the current working directory or in the user-defined directory.
- Parameters:
spectra (object) – spectra class, output of QSOSpecRead()
absorber (str) – Type of absorber, e.g., MgII, CIV, OVI, NV, SiIV, AlIII, FeII
zabs (Table, Row, dict, np.ndarray or float) – Must have ‘Z_ABS’ and ‘GAUSS_FIT’ columns, if not float.
show_error (bool) – if error bars should be shown (default False)
plot_filename (str) – If provided, will save the plot to the given filename.
**kwargs – Additional keyword arguments for matplotlib plot functions, such as: xlabel (str): The label for the x-axis. ylabel (str): The label for the y-axis. title (str): The super title of the plot. fontsize (int): Font size for the title and labels.
- qsoabsfind.utils.read_nqso_from_header(file_path, hdu_name='METADATA')[source]
Read the NAXIS2 value from the header of a specified HDU in a FITS file.
- Parameters:
file_path – str, path to the FITS file.
hdu_name – str, name of the HDU from which to read NAXIS1 (default: ‘METADATA’).
- Returns:
int, value of NAXIS2 from the specified HDU header.
- Return type:
naxis2_value
- qsoabsfind.utils.save_plot(x, y, plot_filename='qsoabsfind_plot.png', xlabel='X-axis', ylabel='Y-axis', title='Plot Title')[source]
Saves a plot of x vs y in the current working directory. If y is a list of arrays, each will be plotted.
- Parameters:
x (array-like) – The x data.
y (array-like or list of array-like) – The y data or list of y data arrays.
plot_filename (str) – The filename for the saved plot. Default is ‘qsoabsfind_plot.png’.
xlabel (str) – The label for the x-axis. Default is ‘X-axis’.
ylabel (str) – The label for the y-axis. Default is ‘Y-axis’.
title (str) – The title of the plot. Default is ‘Plot Title’.
- qsoabsfind.utils.single_gaussian(x, params)[source]
Defines the fitting function to fit a single absorption line with a gaussian profile.
- Parameters:
x (numpy.ndarray) – Wavelength points where the user wants to fit the model.
params (list or numpy.ndarray) – Array of parameters [amp, mean, sigma].
- Returns:
The fitting function values.
- Return type:
numpy.ndarray
- qsoabsfind.utils.update_header(args, user_constants)[source]
Add search parameters and package versions to headers.
Updates FITS header with search parameters from command-line arguments and user-defined constants, along with relevant package version information for reproducibility.
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments containing search parameters and configuration options.
user_constants (object) – Object containing user-defined constants and configuration attributes used in the search/analysis.
- Returns:
- Updated FITS header containing search parameters,
constants, and package version information.
- Return type:
astropy.io.fits.Header
- qsoabsfind.utils.validate_sizes(conv_arr, unmsk_residual, spec_index)[source]
Validate that all arrays have the same size.
- Parameters:
conv_arr (numpy.ndarray) – Convolved array.
unmsk_residual (numpy.ndarray) – Unmasked residual array.
spec_index (int) – QSO index.
- Returns:
0 if sizes match, 1 if a size mismatch is detected.
- Return type:
int
- qsoabsfind.utils.vel_dispersion(c1, c2, sigma1, sigma2, resolution, z, obs_wave)[source]
Calculates and corrects velocity dispersion using Gaussian quadrature.
- Parameters:
c1 (float) – rest-frame fitted line center 1 (in Ang).
c2 (float) – rest-frame fitted line center 2 (in Ang).
sigma1 (float) – rest-frame fitted width 1 (in Ang).
sigma2 (float) – rest-frame fitted width 2 (in Ang).
resolution (float or np.array) – instrumental true resolution (in km/s), see note.
z (float) – redshift of absorber
obs_wave (np.array) – observed wavelength in Angstroms
- Returns:
- A tuple
(vel1, vel2)where each element is a float giving the instrumental-resolution-corrected velocity dispersion (km/s) for the respective line. Returns
numpy.nanfor a line whose fitted width is smaller than the instrumental resolution.
- A tuple
- Return type:
tuple
Note
resolution must be the true one, not the FWHM, usually R = lambda/delta_lambda is in FWHM unit, so first divide by 2.355 and then provide here. This is important.
qsoabsfind.columndensity module
This script contains functions to calculate column densities for absorbers using Apparent Optical Depth Method (AODM) of Savage & Sembach 1991
Paper link: https://ui.adsabs.harvard.edu/abs/1991ApJ…379..245S/abstract.
We adopt the inverse-variance weighted column density for doublets with DR > 2 − DR_error. For systems with DR <= 2 − DR_error. We also apply the Savage & Sembach (1991) correction to the weaker line when both transitions are measured. Otherwise, we adopt the weaker column density as a lower limit, or stronger line as a fallback if weaker line is unavailable.
- qsoabsfind.columndensity.compute_single_column_density(args)[source]
Compute column density for a single absorber.
Wrapper function for parallel processing that unpacks arguments and computes the total column density for a single absorption system using the doublet method.
- Parameters:
args (tuple) –
Packed arguments in the following order:
flux (numpy.ndarray) — Continuum-normalised flux spectrum.
error (numpy.ndarray) — Flux uncertainty array.
wavelength (numpy.ndarray) — Observed wavelength array (Angstrom).
tt_row (astropy.table.Row) — Table row containing absorber properties (must include
Z_ABSand EW columns).f1 (float) — Oscillator strength of the first line.
f2 (float) — Oscillator strength of the second line.
l1 (tuple) —
(key, rest_wavelength)for the first line.l2 (tuple) —
(key, rest_wavelength)for the second line.continuum_error_frac (float) — Fractional continuum placement uncertainty.
dv (float) — Velocity range for integration (km/s).
logwave (bool) — Whether the wavelength array is log-spaced.
- Returns:
Column density measurements and uncertainties. Keys match the output of
total_column_density():N,N_err,logN,err_logN,flag, and saturation diagnostics.- Return type:
dict
- qsoabsfind.columndensity.optical_depth(F_lambda, sigma_F_lambda, continuum_error_frac)[source]
Function to calculate optical depth (tau) of absorption feature
- Parameters:
F_lambda (array) – continuum normalized flux
sigma_F_lambda (array) – errors on continuum normalized flux
continuum_error_frac (float) – assumed systematics on continuum normalized flux (default 5%)
- Returns:
apparent optical depth array and corresponding error arrays
- Return type:
tuple
- qsoabsfind.columndensity.return_total_column_density_table(spectra_fits, absorber, output, continuum_error_frac=0.05, dv=300, logwave=False, nproc=None)[source]
Function to calculate total column density of metal doublets using apparent optical depth method
- Parameters:
spectra_fits (str) – input spectra file
absorber (str) – absorber name (MgII, CIV, OVI, FeII, AlIII, SiIV, NV)
output (str) – output absorber catalog filename
continuum_error_frac (float) – systematics on continuum normalized flux (default: 0.05)
dv (float) – maximum velocity range to be considered for optical depth calculation (default 300 km/s)
logwave (bool) – If true, means wavelength pixels are on log scale (true for SDSS)
nproc (int) – number of cpus for multiprocessing
- Returns:
Appends a
COLUMN_DENSITYBinTableHDU to the absorber catalog FITS file specified byoutput.- Return type:
None
- qsoabsfind.columndensity.single_column_density(F_lambda, error, wavelength, z, f, lambda_0, continuum_error_frac, velocity_range, logwave)[source]
Function to calculate apparent column density for one line using Savage & Sembach 1991 method
- Parameters:
F_lambda (array) – continuum normalized flux
error (array) – continuum normalized errors
wavelength (array) – observed wavelength (Angstrom)
z (float) – redshift of absorber
f (float) – oscillator strength of line transition
lambda_0 (float) – rest-frame wavelength of given absorber (Angstrom)
continuum_error_frac (float) – systematics on continuum normalized flux
velocity_range (float) – +/- velocity_range will be used for column density integration (km/s)
logwave (bool) – If true, means wavelength pixels are on log scale (true for SDSS)
- Returns:
dictionary containing column density and error
- Return type:
dict
- qsoabsfind.columndensity.ss1991_correction(delta_logN)[source]
Interpolate Savage & Sembach (1991) Table 4 to get Delta_log N correction.
- Parameters:
delta_logN (float) – difference between logN of first and second lines
- Returns:
correction based on Savage & Sembach 1991 paper
- Return type:
array
- qsoabsfind.columndensity.total_column_density(F_lambda, error, wavelength, abs_cat, f1, f2, lambda1, lambda2, continuum_error_frac, velocity_range, logwave)[source]
Function to calculate total apparent column density (inverse-variance weighted) for a doublet using Savage & Sembach 1991 method
- Parameters:
F_lambda (array) – continuum normalized flux
error (array) – continuum normalized errors
wavelength (array) – observed wavelength (Angstrom)
abs_cat (table) – absorber table for the individual absorber (must contain Z_ABS, {absorber}_line12_EW, and {absorber}_line12_EW_ERROR, e.g. CIV_1548_EW)
f1 (float) – oscillator strength of first line
f2 (float) – oscillator strength of second line
lambda1 (tuple) – key and rest-frame wavelength of first line (Angstrom)
lambda2 (tuple) – key and rest-frame wavelength of second line (Angstrom)
continuum_error_frac (float) – systematics on continuum normalized flux
velocity_range (float) – +/- velocity_range will be used for column density integration (km/s)
logwave (bool) – If true, means wavelength pixels are on log scale (true for SDSS)
- Returns:
dictionary containing apparent column density and error and flag showing if its saturated
- Return type:
dict
Note
for fN flag, description: 1: WEIGHTED, 2: FIRST, 3: SECOND, 4: Corrected weak line (partial saturation), 5: Lower limit from weak line (strong saturation), 6: Lower limit from strong (strong saturation and weak line is not available) -1: FAIL’,
- qsoabsfind.columndensity.velocity_from_wavelength(lambda_array, lambda_0, z, logwave=False)[source]
Function to convert wavelength into velocity pixels
- Parameters:
lambda_array (array) – observed wavelength (Angstrom)
lambda_0 (float) – rest-frame wavelength of given absorber (Angstrom)
z (float) – redshift of absorber
logwave (bool) – If true, means wavelength pixels are on log scale (true for SDSS)
- Returns:
velocities (observed and in rest-frame, array in km/s)
- Return type:
tuple
Module contents
Qsoabsfind module initialization.