Manually Extracting a NICER Spectrum


One of the basic operations of any NICER scientific analysis is extracting a spectrum. This thread describes how to extract a basic NICER spectrum, without any corrections or adjustments.

Read this thread if you want to: Extract a NICER spectrum.

Last update: 2022-10-26


Spectroscopy is a fundamental pillar of most X-ray data analysis projects An X-ray spectrum provides information about the X-ray target that usually cannot be found by any other means. Thus, extracting a spectrum is a fundamental task that almost all NICER users will need to do.

This thread describes how to extract a basic NICER spectrum from a NICER event file.

Please beware that this task is a basic building block and does NOT perform most of the recommended steps for spectral analysis, including response generation, and various corrections and adjustments to NICER spectral data.

The NICER team highly recommends that the high level product task nicerl3-spect be used to extract spectra since generates all auxiliary products such as responses and backgrounds.


Here is what is needed:

  • NICER clean event file (obsid/event_cl/niNNNNNNNNNN_0mpu7_cl.evt)

Extract a Spectrum

Extract a spectrum with the following command.

niextspect infile=ni1234567890_0mpu7_cl.evt \ outfile=myspectrum.pha


  • infile is the NICER cleaned event file name
  • outfile is the name of the output spectrum (myspectrum.pha in this case)

Upon completion, niextspect will produce the named spectrum. However, no auxiliary files are produced.

Specifying Additional Time Filtering (GTI)

If you have an existing cleaned event file but want to specify additional temporal filtering using a GTI file, you can specify a temporal filter on the command line using the timefile parameter. For example, niextspect infile=ni1234567890_0mpu7_cl.evt \ outfile=myspectrum.pha timefile=myfilter.gti where myfilter.gti is the GTI file. Note that the GTI file myfilter.gti will only be used to make more restrictive temporal filtering. The specified GTI file will be intersected with the existing GTI of the event file.

Using XSELECT to Extract Spectrum

Previously, the NICER team recommended that scientists use XSELECT to extract spectra. This method is still supported, although it is not the first recommendation. Please see the Creating NICER Spectra with XSELECT thread for more information.

Next Steps: Loading Data into XSPEC

We can load our spectrum into XSPEC to see what it looks like. Here is a sample command session history: bash$ xspec XSPEC version: 12.12.1c_d Build Date/Time: Thu Sep 29 14:49:44 2022 XSPEC12>data myspectrum.pha 1 spectrum in use Spectral Data File: myspectrum.pha Spectrum 1 Net count rate (cts/s) for Spectrum:1 5.297e+01 +/- 2.448e-01 Assigned to Data Group 1 and Plot Group 1 Noticed Channels: 1-1479 Telescope: NICER Instrument: XTI Channel Type: PI Exposure Time: 1277 sec Using fit statistic: chi No response loaded. ***Warning! One or more spectra are missing responses, and are not suitable for fit. XSPEC12>cpd /xs XSPEC12>plot ldata

The result is a plot like the following.

Please note that since no responses are loaded, it is not possible to display an energy scale.

Next Steps

Although we have presented this step here, please consider using the nicerl3-spect high level spectral pipeline task, which does all NICER-recommended steps.

In addition to extracting a spectrum, one will have to consider response generation, background generation; and applying systematic error, quality flags and bin grouping


  • 2022-10-20 - initial draft