SkillAgentSearch skills...

BADASS3

Bayesian AGN Decomposition Analysis for SDSS Spectra

Install / Use

/learn @remingtonsexton/BADASS3
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

BADASS logo

New in Version 10.2.0

  • New line and configuration testing framework. See Line Testing and Options.
  • Line component options. See Line Component Options.
  • Improvements in autocorrelation calculations.
  • W80 now a standard output parameter for all lines.
  • Outputs line widths that are both corrected and uncorrected for input resolution
  • BADASS now normalizes the spectrum internally for fitting purposes.
  • Various improvements to global optimizer used in initial fit.
  • Note: The algorithm used for scaling the noise to achieve a $\Chi_\nu^2=1$ was found to be numerically unstable and users should use fit_stat='ML' instead.
<hr>

Ridiculous acronyms are a long-running joke in astronomy, but here, spectral fitting ain't no joke!

BADASS is an open-source spectral analysis tool designed for detailed decomposition of Sloan Digital Sky Survey (SDSS) spectra, and specifically designed for the fitting of Type 1 ("broad line") Active Galactic Nuclei (AGN) in the optical. The fitting process utilizes the Bayesian affine-invariant Markov-Chain Monte Carlo sampler emcee for robust parameter and uncertainty estimation, as well as autocorrelation analysis to access parameter chain convergence. BADASS can fit the following spectral features:

A more-detailed summary of BADASS, as well as a case-study of ionized gas outflows, is given in Sexton et al. (2021).

All spectral components can be turned off and on via the Jupyter Notebook interface, from which all fitting options can be easily changed to fit non-AGN-host galaxies (or even stars!). BADASS uses multiprocessing to fit multiple spectra simultaneously depending on your hardware configuration. The code was originally written in Python 2.7 to fit Keck Low-Resolution Imaging Spectrometer (LRIS) data (Sexton et al. (2019)), but because BADASS is open-source and not written in an expensive proprietary language, one can easily contribute to or modify the code to fit data from other instruments. Out of the box, BADASS fits SDSS spectra, MANGA IFU cube data, and examples are provided for fitting user-input spectra of any instrument.

Before getting started you should read the readme below.

Table of Contents

Installation

The easiest way to get started is to simply clone the repository.

As of the most recent version, the following packages are required (Python 3.8.12):

<!-- - [`astro-bifrost 2.0.3`](https://pypi.org/project/astro-bifrost/) -->

The code is run entirely through the Jupyter Notebook interface, and is set up to run on the included spectrum files in the ".../examples/" folder. If one wants to fit multiple spectra consecutively, simply add folders for each spectrum to the folder. This is the recommended directory structure:

directory structure

Simply create a folder containing the SDSS FITS format spectrum, and BADASS will generate a working folder for each fit titled "MCMC_output_#" inside each spectrum folder. BADASS automatically generates a new output folder if the same object is fit again (it does not delete previous fits).

Usage

Fitting Options

################################## Fit Options #################################
# Fitting Parameters
fit_options={
fit_options={
"fit_reg"    : (4400,5500),# Fitting region; Note: Indo-US Library=(3460,9464)
"good_thresh": 0.0, # percentage of "good" pixels required in fig_reg for fit.
"mask_bad_pix": False, # mask pixels SDSS flagged as 'bad' (careful!)
"mask_emline" : False, # automatically mask lines for continuum fitting.
"mask_metal": False, # interpolate over metal absorption lines for high-z spectra
"fit_stat": "RCHI2", # fit statistic; ML = Max. Like. , OLS = Ordinary Least Squares, RCHI2 = reduced chi2
"n_basinhop": 15, # Number of consecutive basinhopping thresholds before solution achieved
"test_lines": False, # Perform line/configuration testing for multiple components
"max_like_niter": 10, # number of maximum likelihood iterations
"output_pars": False, # only output free parameters of fit and stop code (diagnostic)
"cosmology": {"H0":70.0, "Om0": 0.30}, # Flat Lam-CDM Cosmology
}
################################################################################

fit_reg: (tuple/list of length (2,); Default: (4400,5500))<br/> the minimum and maximum desired fitting wavelength in angstroms, for example (4400,7000). This is passed to the determine_fit_reg() function to check if this region is valid and and which emission lines to fit.

good_thresh: (float [0.0,1.0]; Default: 0.0)<br/> the cutoff for minimum fraction of "good" pixels (determined by SDSS) within the fitting range to allow for fitting of a given spectrum. If the spectrum has fewer good pixels than this value, BADASS skips over it and moves onto the next spectrum.

mask_bad_pix: (bool; Default: False)<br/> Mask pixels which SDSS flagged as bad due to sky line subtraction or cosmic rays. Warning: if large portions of the fitting region are marked as bad pixels, this can cause BADASS to crash. One should only use this if only a few pixels are affected by contamination.

mask_emline: (bool; Default: False)<br/> Mask any

View on GitHub
GitHub Stars59
CategoryProduct
Updated6d ago
Forks9

Languages

HTML

Security Score

95/100

Audited on Mar 28, 2026

No findings