xrb-population is a Python-based project designed to study the spatial distribution of Galactic black hole low-mass X-ray binaries (BH-LMXBs) using simulated X-ray spectral modeling. The project performs extensive simulations with XSPEC to explore how various observational and intrinsic parameters affect distance estimates from soft-state (and soft-to-hard transition) spectra. In addition, it provides a framework for bias-correcting these distance estimates and comparing the corrected spatial distribution with theoretical models of the Milky Way.
This project aims to:
- Simulate Synthetic Spectra: Generate fake X-ray spectra using XSPEC’s
fakeit
command with a model defined asTBabs*(powerlaw+ezdiskbb)
. - Investigate Observational Biases: Examine how parameters such as interstellar absorption (nH), photon index (Γ), disc temperature, black hole spin, mass, disc inclination, disc-to-total flux ratio, and exposure time affect the recovery of input distances.
- Bias Correction & Analysis: Calculate correction factors based on simulation results to mitigate systematic biases in distance estimates. The bias trends (often following an inverse-square law with distance) are then applied to correct the observed distribution.
- Compare with Galactic Models: Compare the bias-corrected radial distribution and galactic heights of BH-LMXBs with expected distributions (e.g., from Grimm et al. 2002), providing insights into observational selection effects and possible implications for natal kick velocities.
The simulation study supports the analysis presented in the paper:
-
requirements.txt
Lists the required Python packages:
h5py==3.6.0
,matplotlib==3.5.1
,numpy==1.21.5
,pandas==1.4.2
, andtqdm==4.64.0
-
xspec_simulations.py
Contains thesimulation
class that:- Initializes simulation parameters (including instrument-specific settings for MAXI or Swift/XRT).
- Uses XSPEC’s fakeit command to generate synthetic spectra.
- Bins the spectrum and performs a model fit to extract flux and spectral parameters.
-
data_read.py
Provides utility functions to:- Read date files.
- Locate product folders based on given dates and instrument.
- Search for saved XSPEC model files.
-
observational_effects.py
Implements the simulation study to quantify observational biases by:- Running simulations in parallel over a grid of distances and interstellar absorption values.
- Applying GR correction factors and normalization methods to the simulated spectra.
- Aggregating simulation results and generating CSV tables and plots for further analysis.
-
Data Files and Database:
all_data_flat_maxi.csv
andall_data_flat_xrt.csv
: CSV files containing simulation or observational data.results.db
: A database file used to store all simulation outcomes.
-
Clone the Repository:
git clone https://github.com/ysabdulghani/xrb-population.git cd xrb-population
-
Install Dependencies:
It is recommended to use a virtual environment. For example:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate pip install -r requirements.txt
-
Setup XSPEC and heasoftpy:
Ensure that you have XSPEC (part of the HEASoft package) installed and properly configured, as the simulations rely on PyXspec and heasoftpy.
The main simulation study is implemented in observational_effects.py
. You can run the script via the command line with the following arguments:
python observational_effects.py <gamma> <temp> <a> <mass> <inc> <ratio_disk_to_tot> <exposure> <instrument>
Where:
<gamma>
is the power-law photon index.<temp>
is the maximum disc temperature (in keV).<a>
is the black hole spin parameter (e.g., 0 or 0.998).<mass>
is the black hole mass (in solar masses).<inc>
is the disc inclination (in degrees).<ratio_disk_to_tot>
is the disc-to-total flux ratio.<exposure>
is the exposure time (in seconds).<instrument>
specifies the instrument (maxi
orxrt
).
The script:
- Creates a temporary directory for simulation files.
- Iterates over a grid of distances and interstellar absorption (nH) values.
- Runs multiple iterations (e.g., 300 per combination) in parallel using Python’s multiprocessing.
- Saves full and reduced result tables as CSV files in the
results/<instrument>_results/
directory.
Post-simulation, you will find CSV files summarizing:
- The fitted spectral parameters and flux estimates.
- Bias-corrected distance estimates.
- Statistical measures (e.g., red chi-squared values, fractional uncertainties).
You can then use these tables for further statistical analysis or plotting to compare with theoretical Galactic distributions.
The project is motivated by the need to understand observational biases in distance estimates to BH-LMXBs and their spatial distribution in the Milky Way. By simulating spectra over a wide parameter grid, the project investigates how systematic errors (for example, due to interstellar absorption or instrumental response) can affect the inferred distances. The bias correction approach leverages an empirical probability density function—closely resembling an inverse-square law—to de-bias the observed distribution, thereby yielding a corrected view of the Galactic population.
For more details on the methodology and scientific results, please refer to the paper.
This project makes use of:
- The Tempest High-Performance Computing Cluster at Montana State University to run the extensive multi-parameter simulations
- XSPEC
- heasoftpy for interfacing with XSPEC.
- Python libraries: NumPy, Pandas, Matplotlib, and tqdm.
- The Astropy community for numerous astronomy utilities.
For further details and discussion of the scientific results, please see the paper by Abdulghani et al 2025.