Welcome to the nDspec documentation!¶
This is the intial repository for the nDspec Python-based X-ray astronomy modeling software. nDspec is designed to allow users to model spectral, spectral timing and (in the future) spectral polarimetry and polarimetry timing X-ray data. The software allows users to fit power-spectra as a function of Fourier frequency, time-averaged spectra as a function of photon energy (channel), as well as cross spectra (and their related products, such as lag spectra) as a function of both Fourier frequency and energy. Bayesian sampling using the common package emcee is fully supported. The software comes with a small library of phenomenological models; alternatively, users can use their own Python-based models. Currently, nDspec does not support joint fitting multiple datasets together.
Currently, the software is built on two core functionalities which users can use in their own code, outside of the fitting environment. The ResponseMatrix class allows user to fold one- and two-dimensional models through the response matrix of modern X-ray instruments - formally these would either be spectral-timing or spectral-polarimetry models, although the second dimension beyond photon energy does not matter. The observatories/instruments explicitely supported are RXTE/PCA, Swift/XRT, XMM-Newton, NuSTAR and NICER. The PowerSpectrum and CrossSpectrum classes can compute standard Fourier products like lag spectra from time- and/or energy- dependent, user-defined models. It is possible to input models defined in both the time and Fourier domains, as well as to combine multiple components.
Along with these two core functionalities, the current release of nDspec provides classes for modelling time-averaged spectra, power spectra, and cross-spectra as a function of both energy and frequency (or both). In the latter case, users can fit lags alone (in units of time), or jointly model the real and imaginary, or modulus and phase, as a unique dataset, without the need to instatiate multiple models and/or tie or define multiple parameters. nDspec provides classes for handling model and parameter management, chi-squared optimization and plotting, and to interface with the emcee Python package for performing Bayesian inference. Finally, a small library of one and two dimensional phenomenological models is included. Alternatively, users can implement their own models, either by writing them in Python directly, or interfacing Python with their own compiled code (e.g. through the use of pybind or f2py).
Installation and testing¶
The alpha release of the software can only be installed from the repository.
Unit tests utilize py-test. Running the unit tests simply requires opening the folder in which users downloaded the repository, and running the command pytest in the command line.
Table of contents¶
Data fitting tutorials:
nDspec core functionality:
- X-ray instrument response basics
- X-ray instrument response optimization
- Spectral timing products
- Defining a power spectrum from a model time series
- Defining a power spectrum model in the Fourier domain
- Setting up a 2d model for a cross spectrum
- Retrieving 1d timing products from a cross spectrum
- Calculating a cross spectrum from an impulse response function
- Combining models for the cross spectrum
- Folding a cross spectrum through an instrument response
- Numerical considerations for spectral timing models
References and tables¶
- nDspec API
- Operator Class
- Response Matrix Class
ResponseMatrixResponseMatrix.convolve_response()ResponseMatrix.diagonal_matrix()ResponseMatrix.load_arf()ResponseMatrix.load_rmf()ResponseMatrix.plot_arf()ResponseMatrix.plot_response()ResponseMatrix.rebin_channels()ResponseMatrix.rebin_energies()ResponseMatrix.set_exposure_time()ResponseMatrix.unfold_response()
- Timing Classes
FourierProductPowerSpectrumCrossSpectrumCrossSpectrum.cross_from_irf()CrossSpectrum.cross_from_transfer()CrossSpectrum.imag()CrossSpectrum.imag_energy()CrossSpectrum.imag_frequency()CrossSpectrum.lag()CrossSpectrum.lag_energy()CrossSpectrum.lag_frequency()CrossSpectrum.mod()CrossSpectrum.mod_energy()CrossSpectrum.mod_frequency()CrossSpectrum.phase()CrossSpectrum.phase_energy()CrossSpectrum.phase_frequency()CrossSpectrum.plot_cross_1d()CrossSpectrum.plot_cross_2d()CrossSpectrum.real()CrossSpectrum.real_energy()CrossSpectrum.real_frequency()CrossSpectrum.rebin_frequency()CrossSpectrum.set_impulse()CrossSpectrum.set_psd_weights()CrossSpectrum.set_reference_energ()CrossSpectrum.set_reference_lc()CrossSpectrum.set_transfer()CrossSpectrum.transfer_from_irf()
- SimpleFit Classes
- Data loading utilities
- FitPowerSpectrum Class
- FitTimeAvgSpectrum Class
- FitCrossSpectrum Class
FitCrossSpectrumFitCrossSpectrum.eval_model()FitCrossSpectrum.plot_data_1d()FitCrossSpectrum.plot_data_2d()FitCrossSpectrum.plot_model_1d()FitCrossSpectrum.plot_model_2d()FitCrossSpectrum.renorm_mods()FitCrossSpectrum.renorm_phases()FitCrossSpectrum.set_coordinates()FitCrossSpectrum.set_data()FitCrossSpectrum.set_model()FitCrossSpectrum.set_product_dependence()FitCrossSpectrum.set_psd_weights()
- Emcee sampling functions
- Model library