skip to content

HEASARC support for unencrypted FTP access ended on September 20, 2019. Please see this notice for details.

XMM-Newton Guest Observer Facility


Fit an EPIC Spectrum with Xspec (Locally Installed)

We will do some simple spectral fitting, using as an example the source and background that was extracted from the Lockman Hole observation (Obs ID 0123700101) and its RMF and ARF files. All tasks will be called from the command line.

Nearly all spectra will need to be binned for statistical purposes. The procedure grppha from FTOOL provides an excellent mechanism to do just that. The following commands not only group the source spectrum for Xspec but also associate the appropriate background and response files for the source. This is done simply by calling the task and editting parameters as is appropriate:

      Please enter PHA filename[] mos1_pi.fits      ! input spectrum file name
      Please enter output filename[] mos1_grp.fits  ! output grouped spectrum
      GRPPHA[] chkey BACKFILE back_pi.fits          ! include the background spectrum
      GRPPHA[] chkey RESPFILE mos1_rmf.fits         ! include the RMF
      GRPPHA[] chkey ANCRFILE mos1_arf.fits         ! include the ARF
      GRPPHA[] group min 25                         ! group the data by 25 counts/bin
      GRPPHA[] exit
Next, use Xspec to fit the spectrum, editting the parameters as needed.
      XSPEC> data mos1_grp.fits      ! input data
      XSPEC> ignore 0.0-0.2,6.6-**   ! ignore unusable energy ranges, in keV
                                     ! set a range appropriate for the data
      XSPEC> model wabs(pow+pow)     ! set spectral model to two absorbed power laws
      1:wabs:nH> 0.01                ! set model absorption column density to 1.e20
      2:powerlaw:PhoIndex> 2.0       ! set the first model power law index to 2.0
      3:powerlaw:norm>               ! default model normalization
      4:powerlaw:PhoIndex> 1.0       ! set the second model power law index to 1.0
      5:powerlaw:norm>               ! default model normalization
      wabs:nH> 0.01                  ! set model absorption column density to 1.e20
      XSPEC> renorm                  ! renormalize the model spectrum
      XSPEC> fit                     ! fit the model to the data
      XSPEC> setplot device /xw      ! set the plot device
      XSPEC> setplot energy          ! plot energy along the X axis
      XSPEC> plot ldata ratio        ! plot two panels with the log of the data and
                                        !     the data/model ratio values along the Y axes
      XSPEC> exit                    ! exit Xspec
      Do you really want to exit? (y) y
The spectrum is shown in Figure 1.
Figure 5: The spectrum fitted in Xspec.

If you have any questions concerning XMM-Newton send e-mail to

This file was last modified on Tuesday, 19-Nov-2013 17:08:40 EST
Curator:Michael Arida (ADNET);

NASA Astrophysics

  • FAQ/Comments/Feedback
  • Education Resources
  • Download Adobe Acrobat
  • A service of the Astrophysics Science Division (ASD) at NASA/ GSFC

    XMM-Newton Project Scientist: Dr. Steve Snowden

    Responsible NASA Official: Phil Newman

    Privacy Policy and Important Notices.