alfa(1)
Bestie, this is the alfa(1) man page ๐, the manual for alfa, so let's get into it ๐ธ
โจ NAME โจ
alfa - automated line fitting algorithm ๐ฆ
๐ SYNOPSIS ๐
alfa [OPTION] [VALUE]... [FILE]
๐ DESCRIPTION ๐
okay so alfa rapidly fits emission line spectra โจ, and it's giving genetic algorithm energy because it uses one to optimise the fitting parameters ๐งฌ. It's meant to be totally automated ๐ซถ, but even though the defaults slay in lots of situations, getting a good fit to your observed spectrum might need a few tweaks to the input parameters ๐
. It's optimised for optical spectra, but it can be applied to any wavelength range too, as long as you give it a suitable line catalogue ๐ธ.
alfa reads one dimensional spectra in either plain text or FITS format ๐. Plain text input should have two columns, giving wavelength and flux ๐. It can also read data cubes and row-stacked spectra in FITS format ๐ง. Results are written out in plain text ๐, to files containing the fit (total fit, continuum-subtracted original, continuum, sky lines and residuals), and the line flux measurements ๐.
๐ OPTIONS ๐
-b,--bad-data[REAL]โ If every value in a spectrum is below the number you give, alfa won't fit it ๐. Most useful for not wasting time on low signal regions of data cubes ๐.--citationโ Prints the bibliographic details of the paper to cite if you use alfa in your research ๐.-cl,--clobberโ By default alfa refuses to overwrite any pre-existing output file ๐ซ. Specify this option and it'll overwrite the output file instead ๐ฅ.--collapseโ Sums all spectra in multi-dimensional FITS files into one single spectrum โ. Spectra whose peak value is below any value you give with the--bad-dataoption get excluded ๐๏ธ.--collapsehas no effect on 1D data ๐ .-cw,--continuum-window[INTEGER]โ alfa's continuum fitting takes the 25th percentile of flux values in a moving window as the representative continuum level ๐. This option sets the size of that window ๐ช. The value must be an odd integer. Default: 101-dl,--detection-limit[REAL]โ Sets the factor by which a line's flux must exceed the locally estimated noise level before it counts as a detection ๐. Default: 3.0-el,--exclude-line[REAL]โ When reading in the line catalogues, any wavelengths you give with this option get ignored ๐ โโ๏ธ. For example, if H alpha were saturated, you could exclude it from the fit with--exclude-line 6562.77๐. You can exclude as many lines as you want by repeating the option with the wavelengths you need ๐.-fc,--flux-column[INTEGER]โ When reading FITS tables, this option picks which table column holds the flux values ๐ช. For any other file type it does nothing. Default: 2-g,--generations[INTEGER]โ The number of generations used in the genetic algorithm ๐งฌ. Default: 500-n,--normalise[VALUE]โ Normalises toHb=100, assuming thatF(Hb)=VALUE๐ซ. If VALUE is zero, no normalisation happens ๐. If you don't specify this option, fluxes get normalised using the measured value of Hb if it was detected, and left unnormalised otherwise ๐คทโโ๏ธ.-nc,--no-continuumโ If the spectrum you're fitting is already continuum subtracted, set this option to skip alfa's continuum fitting โญ๏ธ.-o,--output-dir[DIRECTORY]โ The directory where the output files go ๐. Default: current working directory.-of,--output-format[VALUE]โ The format of the output files ๐จ. Valid values are text, csv, fits, latex. If you're using alfa alongside neat, plain text and fits formats can currently be read in ๐ซถ. Default: text-pr,--pressure[REAL]โ The fraction of the population retained from each generation ๐. The product of the pressure and the population size should be an integer ๐ข. Default: 0.3-ps,--populationsize[INTEGER]โ The size of the population used in the genetic algorithm ๐ฏ. Default: 30-rb,--rebin[INTEGER]โ Rebins the input spectrum by the factor you specify ๐งฑ. Super useful for high resolution spectra where the line profiles are kinematic rather than instrumental ๐. This option is currently only implemented for 1d spectra ๐ง.-rg,--resolution-guess[VALUE]โ Your initial guess for the resolution[lambda/delta lambda]๐ญ. Default: estimated using the sampling of the input spectrum, assuming that it is Nyquist sampled ๐ฏ.-rtol1,--resolution-tolerance-1[VALUE]โ How much variation in resolution is allowed in the first pass ๐ข. Default: equal to 0.9 x resolution guess.-rtol2,--resolution-tolerance-2[VALUE]โ How much variation in resolution is allowed in the second pass ๐ข. Default: 500.-skyc,--sky-catalogue;-sc,--strong-catalogue;-dc,--deep-catalogue[FILENAME]โ These point to the line catalogues used for removing sky lines, estimating velocity and resolution, and the full line fitting ๐. The default catalogues live in/usr/share/alfa๐ก. Want your own catalogue? Each line needs to be 85 characters wide, with a wavelength in the first column ๐. alfa doesn't use the rest of the characters, but they get transferred to the output files, so, like in the supplied catalogues, you can use them for line transition data ๐ . To use the default catalogues but skip some lines, use the--exclude-lineoption ๐.-ss,--subtract-skyโ Fits and subtracts night sky emission lines before fitting the nebular emission lines ๐.-ul,--upper-limitsโ Writes out upper limits for every line searched for and not detected ๐ป. The upper limit is the detection limit (default 3, set by--detection-limit) multiplied by the uncertainty ๐งฎ. With FITS output this option gets ignored, since all upper limits are written out anyway and marked with negative flux values โ ๏ธ. If the FITS file is later analysed with neat, those negative values are simply ignored ๐ซง.-vg,--velocity-guess[VALUE]โ Your initial guess for the velocity of the object [km/s] ๐. Default: 0.-vtol1,--velocity-tolerance-1[VALUE]โ How much variation in velocity is allowed in the first pass of the fitting ๐. Default: 900km/s-vtol2,--velocity-tolerance-2[VALUE]โ How much variation in velocity is allowed in the second pass of the fitting ๐. Default: 60km/s-wc,--wavelength-column[INTEGER]โ When reading FITS tables, this option picks which table column holds the wavelength values ๐. For any other file type it does nothing. Default: 1-ws,--wavelength-scaling[VALUE]โ alfa checks the units in FITS file headers to set the wavelength scale, and assumes Angstroms if there's no keyword ๐. If your input spectrum isn't in Angstroms, use this option to set the value that wavelengths get multiplied by to convert them toA๐. For example,-ws 10.0would apply if your spectra have wavelengths in nm ๐ญ.
part 2 picks up with ALGORITHM next ๐ฆ
๐ INPUT FILES ๐
okay so alfa can read two kinds of files, bestie: plain text files or FITS format files ๐ For plain text, the file needs a wavelength and a flux, and the wavelength has to be in the same units as the line catalogues (the default catalogues use Angstroms โจ). FITS files get read through the CFITSIO library, so any FITS-compliant file should be fine... but ngl, a surprisingly large fraction of FITS files don't follow the standard ๐ So if things go wrong, try using fitsverify to check your file ๐
The FITS file can have one, two or three dimensions. Two dimensions means it's treated as Row-Stacked Spectra (RSS) format ๐ธ Three dimensions means it's treated as a data cube, with two axes for spatial dimensions and a third axis for the spectral dimension ๐ฆ
If you don't want to fit the whole dataset, you can choose the range of pixels on each axis by appending the filename with [startx:endx,starty:endy] ๐ This is a CFITSIO feature, and the format is described at https://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node97.html. Lowkey important: alfa doesn't read the section coordinates itself, so the output file numbering starts from 1 on each axis no matter where the image section actually started ๐ The next release of alfa will have improved support for image sections ๐
๐พ OUTPUT FILES ๐พ
alfa can spit out plain text, csv, latex or FITS format ๐ง FITS is the default and the recommended one โจ In future releases, output formats other than FITS will be deprecated and eventually removed, so FITS is the main character era ๐
When you go with plain text, csv or latex, alfa makes two files: a fit file and a line list file. With FITS you get a single file with three extensions. One is for the fit, one is for the linelist, and the third holds the Hbeta flux, number of lines detected, the radial velocity and the average resolution over the spectrum ๐ Output filenames are based on the input filename, with the extensions below ๐ซถ
The fit file (_fit.txt, _fit.csv, _fit.tex) or extension (.fits)
The fit file holds the best fitting synthesised spectrum ๐ It has seven columns: wavelength, input spectrum, fitted spectrum, original after continuum subtraction, estimated continuum, fluxes of sky lines, and residuals. So to see the fitted spectrum, you need to plot columns 1 and 3 ๐ฆ In gnuplot, you can compare the input and fitted spectra with this command:
plot 'filename_fit' w l, 'filename_fit' using 1:3 w l
The lines file (_lines.txt, _lines.csv, _lines.tex) or extension (.fits)
This file has four columns with the parameters of the fitted lines: observed wavelength, rest wavelength, flux, and the uncertainty estimated from the residuals ๐ฅ neat can read this file directly, and neat is the one that determines abundances for photoionised nebulae ๐ If you request latex format, the file also includes atomic data details that aren't available in the other formats yet ๐
For RSS files and data cubes, alfa currently makes output for each pixel ๐ญ So for a large data cube, you could end up with tens of thousands of files in your output directory ๐ A routine to combine these outputs into image maps is coming in a future release of alfa ๐
๐ง USAGE NOTES ๐ง
alfa's default parameters are supposed to work in most cases, but sometimes it won't converge on the correct wavelength solution ๐ค It starts by searching for velocities in the range +/-900km/s, which is huge for Galactic objects. So running the code with --resolution-tolerance-1 100 or so might improve your results ๐
The genetic parameters (population size, number of generations, pressure) are likely to be suitable for most cases. There's no algorithm known yet for optimising these parameters in a genetic algorithm, so changing them is pure trial and error ๐งช In spectra of regions with lots of emission lines, such as 4000-4500 Angstrom, increasing the number of generations can result in a better fit โจ
๐จ Error codes ๐จ
If alfa runs into an error, it will return one of these status codes ๐
100โ incomplete or invalid command line option101โ input file does not exist102โ output directory does not exist103โ error opening FITS file104โ no axes found in input file105โ too many axes found in input file106โ error reading FITS keywords107โ error writing FITS output108โ no line catalogue file specified109โ line catalogue not found200โ all fluxes below baddata limit201โ no known emission lines in wavelength range202โ failed to estimate velocity and resolution - no lines found
๐ SEE ALSO ๐
neat ๐
๐ BUGS ๐
If you're reporting a bug, please say which version of alfa you were using, and include the input and any output files produced if possible ๐
๐ฉโ๐ป AUTHOR ๐ฉโ๐ป
Roger Wesson ๐ธ
And that's the whole page, bestie! ๐ Version 1.0 from 26 Aug 2016, slaying the man page game forever ๐ ๐โจ
๐ฆ where this page comes from
- debian bookworm: alfa 2.2-1+b1 ยท GPL-3.0-or-later
- debian trixie: alfa 2.2-1+b2 ยท GPL-3.0-or-later
- ubuntu noble: alfa 2.2-1build3 ยท GPL-3.0-or-later
- ubuntu resolute: alfa 2.2-1build4 ยท GPL-3.0-or-later
- ubuntu stonking: alfa 2.2-1build4 ยท GPL-3.0-or-later
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms