### Spectral fitting

#### Overview

At this website it is possible to model X-ray spectra of a large subset of XMM-Newton detections for which SAS based pipeline has extracted necessary data products. For the 4XMM-DR10 catalog, out of 849 991 detections 303 023 (or 35.6%) have spectra. Note that they were extracted in an automated regime so in complex cases such as highly variable / diffuse background, aperture centering and background extraction algorithms work imperfectly. In other words, these spectra and present spectral analysis tool are provided for quick-look purposes only.

If you want to try the spectral fitting but are not sure which source to take, just type `has_spectrum = true`

in the search field at the top and pick any item from the list of results. Then click any of the *Fit spectrum* links in the table at the bottom of the page.

#### Data

The XMM-Newton pipeline produces the following spectral data products for sources which are used at the core of the spectral fitting functionality:

*SRSPEC*— EPIC source spectrum.- A source spectrum is generated for each EPIC source which is found to be sufficiently bright to yield a useful spectrum. Spectra are considered for extraction for point sources in the EPIC field where the EPIC band-8 count rate is > 100 cts/s — where the detection comes from only one or two of the cameras, this initial filtering is by equivalent EPIC counts, which are derived adopting a PN to MOS count ratio of 3.5:1. Spectra are subsequently delivered where the extracted spectrum has > 100 "good" (in XSPEC terminology) counts.
- A source spectrum is accumulated by use of a spatial filter (a circular aperture whose radius is determined by a S/N optimisation algorithm) on valid events in an exposure from CCDs operating in IMAGING mode.
- Currently the extraction aperture is of fixed (28”) radius for all sources.
- For each candidate source a spectrum is produced for each EPIC camera (2 MOS and 1 pn), where available.
- No systematic error is included in the spectrum file. The statistical error is defined by Poisson errors on the counts in the channel.

*BGSPEC*— EPIC background spectrum.- It is generated for each detected EPIC source for which a source spectrum is generated.
- The background spectrum is generated by accumulation of detected events from a source- free region of the field-of-view (contaminating source regions having been masked out in the process).
- For each candidate source a background spectrum is produced for each EPIC camera (2 MOS and 1 pn) where available.
- No systematic error is included in the spectrum file. The statistical error is defined by Poisson errors on the counts in the channel.
- The data are stored as counts, not count rate.

*SRCARF*— ancillary response function file.- This is the file providing the effective area of the instrument as a function of energy (channel).
- A file is produced for each source and exposure for which spectral products have been extracted and is for use with those spectral products.

The fitting application uses most recent version of canned response matrices.

More details on these and other science ready data products from the XMM-Newton are available in the Specifications for individual SSC data products document.

Please note that *SRSPEC*, *BGSPEC*, *SRCARF* data products are available for direct download from this website for further analysis in any OGIP-compatible software package such as XSPEC, Sherpa or ISIS. To find direct download links one needs to fetch exported detections table in FITS, VOTable or CSV formats from any query results and check columns *url_data_spectrum_PN*, *url_data_bckgrnd_PN*, *url_data_arf_PN* (replace 'PN' to 'M1' or 'M2' in column names if you are interested in MOS data).

#### Software

Under the hood the spectral fitting engine is essentially a wrapper over Sherpa modelling and fitting application and at the time of writing we use its version 4.5. The flexible interface between the web application and the Sherpa engine allows rapid development of new features, so if you miss any functionality (e.g. specific model from this list) that exists in the Sherpa, let us know and there is a fair chance we implement it here.

#### Spectral fitting interface

**Instrument**— selection of spectrum for particular source coming from any of the three EPIC detectors: PN, M1, M2. If a particular selection is disabled, it means that source spectrum from this instrument has not been produced as it does not meet spectral extraction criteria (see above). Default value: whichever instrument available first in the order PN, M1, M2.**Energy range min**and**Energy range min**— minimum and maximum energy of the spectral range to consider, in keV. Equivalent of XSPEC's*ignore min-max*command. Default value: 0.2 to 10 keV range.**Group counts**— group counts before fitting, in counts per bin. Default value: group to 20 counts per bin.**Optimization**— method for finding a minimum of the statistics function, see Sherpa documentation. Presently Levenberg-Marquardt (*levmar*choice) and Simplex (*neldermead*choice) local optimization methods are supported. Shout if you need Monte-Carlo global optimization. Default value:*levmar*.**Statistics**— statistics function. Presently χ2 statistic with variance computed from data amplitudes (*chi2xspecvar*), χ2 statistic with constant variance computed from the counts data (*chi2constvar*), and χ2 statistic with the Gehrels variance function (*chi2gehrels*) are supported. See details in the Sherpa documentation. Default value:*chi2xspecvar*.**Model**— model function. Presently a (random) predefined set of frequently used simple models is supported. Model names in the dropdown list are just abbreviated XSPEC model specifications, for example*phabs_pl*corresponds to*phabs(powerlaw)*,*phabs_pl_nsatm*is*phabs(powerlaw + nsatm)*, etc. Detailed model descriptions are available from Sherpa documentation. Default value:*phabs_pl*.

##### Model parameters options

**value**— initial value for each model parameter. Default value: as in Sherpa model, or at the best fit values if this source spectrum has already been fit by other users.**min**— hard minimum limit for the interval where to look for optimal parameter value in Sherpa/XSPEC model units. Default value: as in Sherpa model.**max**— hard maximum limit for the interval where to look for optimal parameter value in Sherpa/XSPEC model units. Default value: as in Sherpa model.**freeze**— check this box to freeze the parameter at its initial value during the fit. Uncheck the box to thaw. Default value: as in Sherpa model.

If the fit is successful, the X-ray spectrum plot is updated with fitted model and its residuals plotted. The text output of the Sherpa *fit()* function is shown with reduced χ2 value and the total model flux within the specified energy range.