NICER data reduction and Spectral fitting#

contact: menglei.zhou<at>astro.uni-tuebingen.de, honghui.liu<at>uni-tuebingen.de

0. Prerequisites#

0.1. Setting up the $CALDB environment:

  1. cd $CALDB

  2. wget https://heasarc.gsfc.nasa.gov/FTP/caldb/data/nicer/xti/goodfiles_nicer_xti_20240206.tar.gz

  3. tar -zxf goodfiles_nicer_xti_20240206.tar.gz

0.2. Geomagnetic Data (specifically relevant for NICER background assessment)

  1. add export GEOMAG_PATH=/opt/geomag in your environmental variables in e.g., “~/.bashrc”

  2. run nigeodown (this command should be executed each time before data processing to keep the geomagnetic data updated)

  3. see https://heasarc.gsfc.nasa.gov/docs/nicer/analysis_threads/nicer-setup/ for more information

1. Find the simultaneous NICER observations of Cyg X-1 corresponding to the NuSTAR data we have analyzed#

Go to https://heasarc.gsfc.nasa.gov/cgi-bin/W3Browse/w3browse.pl to search for data.

Click the magnifier icon on the left to view detailed information about each observation.

Unfortunately, the three observations from 2024-07-09 to 2024-07-11 contain no GTIs. Instead, we can examine the observation from 2024-06-14 (which is also an observation in the hard state).

You can download the data using the following command: wget -q -nH --no-check-certificate --cut-dirs=5 -r -l0 -w1 -c -N -np -R 'index*' -erobots=off https://heasarc.gsfc.nasa.gov/FTP/nicer/data/obs/2024_06//7706010105/

2. Run nicerl2 indir=./ clobber=yes to produce the level 2 data#

The output will be saved in the xti/event_cl directory.

See https://heasarc.gsfc.nasa.gov/docs/nicer/analysis_threads/nicerl2/ for more details.

3. Produce level 3 data#

Please refer to https://heasarc.gsfc.nasa.gov/docs/nicer/analysis_threads/nicerl3-spect/ and https://heasarc.gsfc.nasa.gov/docs/nicer/analysis_threads/nicerl3-lc/ for more information.

I also recommend reviewing all analysis threads at https://heasarc.gsfc.nasa.gov/docs/nicer/analysis_threads/.

3.1. Spectra#

Run nicerl3-spect indir=./ bkgmodeltype=scorpeon clobber=yes

and the task will generate a script with an adjustable background model.

Alternatively, if you prefer a simpler case—similar to NuSTAR, where the background is provided as a FITS file

—use nicerl3-spect indir=./ bkgmodeltype=scorpeon bkgformat=file clobber=yes

By default, NICER spectra are grouped according to the optimal binning scheme (see Kaastra & Bleeker 2016), so no additional grouping is required.

Notes:

In many cases, you can simply run the following command before extracting NICER spectra or light curves to exclude most background effects:

nimaketime auxil/niXXXXXX.mkf good.gti cor_range="1.5-" underonly_range="-200" overonly_range="-10" clobber=yes

Then, run the Level 3 tasks, for example:

nicerl3-spect indir=./ suffix=_spec gtifile=good.gti bkgmodeltype=scorpeon bkgformat=file clobber=yes

This resolves most issues.

Notes:

It is always important to inspect NICER light curves to minimize the impact of background. If you are unsure about the cleanliness of your science products, you can always contact the NICER team—for example, Jack Steiner (jsteiner@cfa.harvard.edu), who is very nice and helpful.

3.2. Light curves#

nicerl3-lc indir=./ pirange=100-1000 timebin=1.0 clobber=YES

PI \(\approx\) Energy (keV) * 100

In next week’s session, we will discuss generating light curves directly from event files, which I personally find more convenient.

Here are two examples:

Source: 2S 1417–624 (X-ray pulsar)

OBSID: 8205540110

You can download the data using:

wget -q -nH --no-check-certificate --cut-dirs=5 -r -l0 -w1 -c -N -np -R 'index*' -erobots=off https://heasarc.gsfc.nasa.gov/FTP/nicer/data/obs/2025_05/8205540110/

I encourage you to explore the data on your own. (First nicerl2, then nimaketime + nicerl3-lc)

If we do not apply the GTI criteria, the 1–10 keV light curve would look like this:

If we apply the GTI criteria, the light curve in 1-10 keV becomes:

Always be cautious when you encounter features like this!

4. Fit NICER data with NuSTAR data simutaneously#

data 1:1 NICER_data.pha (or XSPEC12>@xti/event_cl/niXXXXXXXmpu7_load.xcm)

data 2:2 NuSTAR_data.pha

data 3:3 NuSTAR_data.pha

ignore 1: **-0.4 10.0-** 2-3: **-3.0 79.0-**

model constant*TBabs*nthcomp

5. Simulate a spectrum with XSPEC#

If you have an observation, the workflow is typically:

\[ \text{Photon counts in channels} \Leftarrow \text{Instrumental Response} \Leftarrow \text{Model evaluation} \]

Simulation works in the opposite direction. If you have a model that describes the source, you can generate a synthetic (fake) observation using a given instrumental response:

\[ \text{Prior knowledge of model parameters} \Rightarrow \text{Instrumental Response} \Rightarrow \text{Photon counts in channels} \]

5.1. Set the modeling parameters that depict the source#

  1. Define a model in XSPEC, e.g., model tbabs*(cutoffpl + relline)

  2. Check the energy range used for model evaluation (default: 0.1–50.0 keV with 5000 logarithmically spaced bins). To modify the energy grid, use for example: energies 1.0 100.0 1000 log/linear

  3. Check the source flux (which is intrinsic and instrument-independent) using flux Emin Emax, e.g., flux 1.0 10.0. XSPEC will return both the photon flux and the energy flux. You can adjust the model flux by modifying the normalization of additive components.

  4. When you have emission lines or absorption lines, you can check the relative strengths between the continuum and the line by the equivalent width eqwidth [#line model No.] (a typical value of iron K\(\alpha\) line from a BH source is ~200 eV). Here the line model relline is at position 3. Just type eqwidth 3 or eq 3 to get the equivalent width value. You can adjust the equivalent width by modifying the normalization of line components.

5.2. Simulate spectra#

Once the model is defined, run fakeit (+ bkg_file) to simulate a spectrum. The argument bkg_file is optional.

XSPEC12>fakeit ni7706010105mpu7_bg.pha
For fake spectrum #1 response file is needed: ni7706010105mpu7.rmf
   ...and ancillary file: ni7706010105mpu7.arf
 Use appropriate probability distribution to randomize fake data? (y): y
 Input optional fake file prefix: 
 Fake data file name (ni7706010105mpu7_bg.fak): fake.fak
 Exposure time, correction norm, bkg exposure time (1.00000e+09, 1.00000, 1.00000e+09): 10000 1 10000

This generates a simulated spectrum with an exposure time of 10,000 seconds. Be sure to select “y” for “Use appropriate probability distribution to randomize fake data?” Otherwise, Poisson noise will not be applied.