Pipelines and data selection
Scripts that screen NICER observations, make GTIs and quick-look plots, and prepare event files for analysis. See Selecting good data for an overview.
psrpipe.py
The main processing pipeline. See Selecting good data for what it does.
Pipeline process NICER data.
Output will be written in current working directory in directories that end in ‘_pipe’.
Several diagnostic plots are produced, and the following data processing steps are run:
Select good times according to customizable criteria, including:
(ANG_DIST.lt.0.015).and.(ELV>20.0)
(MODE.eq.1).and.(SUBMODE_AZ.eq.2).and.(SUBMODE_EL.eq.2)
If --dark is specified then also filter on SUNSHINE.eq.0
Optionally, you can filter on overshoot rate or rate of bad ratio events
Select events according to:
EVENT_FLAGS=bx1x000 (SLOW-only or SLOW+FAST events)
PI in the specified range (default is 0.25-15.0 keV)
Remove events from any DET_ID specified by the --mask parameter
The final output is ‘cleanfilt.evt’ and extracted PHA and lightcurve FITS files produced by extractor. The event file will have a PULSE_PHASE column computed using PINT if the --par file is specified on the command line.
usage: psrpipe.py [-h] [--emin EMIN] [--emax EMAX] [--mask [MASK ...]]
[--filtpolar] [--cormin CORMIN] [--kpmax KPMAX]
[--minfpm MINFPM] [--mingti MINGTI]
[--maxovershoot MAXOVERSHOOT] [--badcut BADCUT]
[--angdist ANGDIST] [--obsid OBSID] [--dark]
[--maxundershoot MAXUNDERSHOOT]
[--medianundershoot MEDIANUNDERSHOOT] [--nounderfilt]
[--minsun MINSUN] [--day] [--daynight] [--par PAR]
[--ephem EPHEM] [--outdir OUTDIR] [--polycos] [--merge]
[--crcut] [--lcbinsize LCBINSIZE]
[--filterbinsize FILTERBINSIZE] [--overonlyexpr] [--tidy]
[--nomap] [--copymkf]
[--log-level {TRACE,DEBUG,INFO,WARNING,ERROR}]
indirs [indirs ...]
Positional Arguments
- indirs
Input directories to process
Named Arguments
- --emin
Minimum energy to include (keV, default=0.25)
Default:
0.25- --emax
Maximum energy to include (kev, default=15.0)
Default:
15.0- --mask
Mask these IDS
- --filtpolar
Turn on filtering polar horn regions from data
Default:
False- --cormin
Set minimum cutoff rigidity (COR_SAX) for nimaketime filtering (default=no COR filtering, typical value = 1.5 or 2)
- --kpmax
Set maximum KP value for nimaketime filtering (default=no KP filtering, typical value = 5)
- --minfpm
Set minimum of FPMs active for nimaketime filtering (default=7)
Default:
7- --mingti
Set minimum duration (in seconds) of a GTI to be kept (default=16)
Default:
16- --maxovershoot
Select data where overshoot rate (per FPM) is below this limit (default: 1.5)
Default:
1.5- --badcut
Select data where bad ratio event rate is below this limit (default: no filter)
Default:
-1- --angdist
Set threshold for ANG_DIST in call to nimaketime (degrees, default=0.015)
Default:
0.015- --obsid
Use this as OBSID for directory and filenames
- --dark
Apply SUNSHINE=0 filter to get only data in Earth shadow
Default:
False- --maxundershoot
Select data where undershoot rate is below this limit (default: 500)
Default:
500- --medianundershoot
Select data where MEDIAN undershoot rate is below this limit
- --nounderfilt
Don’t filter good times based on UNDERONLY rate
Default:
False- --minsun
Set minimum sun angle (SUN_ANGLE) for nimaketime filtering (default=no SUN_ANGLE filtering, typical values = 60, 70, 80, 90 deg). Note: Allows dark time at any Sun angle!
- --day
Tell psrpipe to grab the _DAY.evt file that was produced by a nicerl2 run with threshfilter=DAY
Default:
False- --daynight
Tell psrpipe to grab the both normal and _DAY.evt files to include all data post light-leak
Default:
False- --par
Par file to use for phases
- --ephem
Ephem to use with photonphase
Default:
'DE421'- --outdir
Add name to output directories (by default: directories end in ‘_pipe’)
Default:
'pipe'- --polycos
Use polycos when computing photon phases (massive speedup for large numbers of events)
Default:
False- --merge
Merge all ObsIDs provided into single event list, lightcurve and spectrum (outputdir called ‘merged’)
Default:
False- --crcut
perform count rate cut on merged event file (only if --merge)
Default:
False- --lcbinsize
Lightcurve bin size (sec, default=4.0)
Default:
4.0- --filterbinsize
Bin size for Count rate and Overshoot rate filtering (sec, default=16.0)
Default:
16.0- --overonlyexpr
Turn on the expression to filter on overshoot rate based on COR_SAX
Default:
False- --tidy
Make fewer plots and remove some intermediate files, to run faster and save disk space
Default:
False- --nomap
Don’t make maps (for use if cartopy is not working)
Default:
False- --copymkf
Copy ni*.mkf into the _pipe output directory, for convenience. Warning, mkf files are large!
Default:
False- --log-level
Possible choices: TRACE, DEBUG, INFO, WARNING, ERROR
Logging level
Default:
'INFO'
nicerql.py
Quick-look science, engineering, background and map plots for one ObsID. psrpipe.py runs it automatically.
Plot the NICER data nicely.
usage: nicerql.py [-h] [--obsdir OBSDIR] [--object OBJECT] [--useftools]
[--mask [MASK ...]] [-s] [--sci] [--eng] [--bkg]
[--filtswtrig] [--filtovershoot] [--filtundershoot]
[--filtratio] [--filtall] [--emin EMIN] [--emax EMAX]
[--tskip TSKIP] [--lcbinsize LCBINSIZE]
[--filterbinsize FILTERBINSIZE] [--pi] [--basename BASENAME]
[--lclog] [--foldfreq FOLDFREQ] [--nyquist NYQUIST] [--map]
[--orb ORB] [--par PAR] [--sps SPS] [--mkf MKF] [--powspec]
[--pslog] [--writeps] [--writebkf] [--applygti APPLYGTI]
[--extraphkshootrate] [--eventshootrate] [--interactive]
[--gtirows [GTIROWS ...]] [--merge] [--allspec] [--alllc]
[--keith] [--log-level {TRACE,DEBUG,INFO,WARNING,ERROR}]
[infiles ...]
Positional Arguments
- infiles
Input files
Named Arguments
- --obsdir
Find alllllllll the files!
- --object
Override object name
- --useftools
Use FTOOLS for filter and merge
Default:
False- --mask
Mask these IDS
- -s, --save
Save plots to file
Default:
False- --sci
Makes some nice science plots
Default:
False- --eng
Makes some nice engineering plots
Default:
False- --bkg
Display background diagnostic plots
Default:
False- --filtswtrig
Filter SW TRIG events
Default:
False- --filtovershoot
Filter OVERSHOOT events
Default:
False- --filtundershoot
Filter UNDERSHOOT events
Default:
False- --filtratio
Filter PI/PI_FAST ratio using trumpet cut
Default:
False- --filtall
Filter SWTRIG, UNDERSHOOT and OVERSHOOT events
Default:
False- --emin
Minimum energy (keV) to keep
Default:
-1.0- --emax
Minimum energy (keV) to keep
Default:
-1.0- --tskip
Seconds to skip at beginning of data
Default:
0.0- --lcbinsize
Light curve bin size (s)
Default:
1.0- --filterbinsize
Bin size for Count rate and Overshoot rate filtering (s)
Default:
16.0- --pi
Force use of internal PHA to PI conversion
Default:
False- --basename
Basename for output plots
- --lclog
make light curve log axis
Default:
False- --foldfreq
Make pulse profile by folding at a fixed freq (Hz)
Default:
0.0- --nyquist
Nyquist freq for power spectrum (Hz)
Default:
100.0- --map
Creates a map with overshoots and undershoots
Default:
False- --orb
Path to orbit FITS files
- --par
Path to par file
- --sps
Path to SPS HK file (_apid0260.hk)
- --mkf
Path to MKF file
- --powspec
Display power spectrum (replaces ratio plot)
Default:
False- --pslog
make power spectrum log axis
Default:
False- --writeps
write out power spectrum
Default:
False- --writebkf
Write useful rates for background filtering to FITS file
Default:
False- --applygti
Read GTI from provided FITS file
- --extraphkshootrate
Compute HK shoot rates from a single MPU
Default:
False- --eventshootrate
Gets over/undershoot rates from the events
Default:
False- --interactive
TEST FOR INTERACTIVE LC
Default:
False- --gtirows
Select GTI rows
- --merge
when using a merged file, the OBSID keyword in header is updated (for plotting purposes)
Default:
False- --allspec
Makes a figure will a spectrum for each DET_ID
Default:
False- --alllc
Makes a figure will a lightcurve for each DET_ID
Default:
False- --keith
Standard filters used by Keith Gendreau for Space-Weather backgrounds
Default:
False- --log-level
Possible choices: TRACE, DEBUG, INFO, WARNING, ERROR
Logging level
Default:
'INFO'
bkgpipe.py
Process NICER background data. Output will be written in current working directory.
usage: bkgpipe.py [-h] [--emin EMIN] [--emax EMAX] [--filtpolar]
[--cormin CORMIN] [--dark] [--mask [MASK ...]]
[--obsid OBSID]
indirs [indirs ...]
Positional Arguments
- indirs
Input directories to process
Named Arguments
- --emin
Minimum energy to include (keV, default=0.5)
Default:
0.5- --emax
Maximum energy to include (kev, default=8.0)
Default:
8.0- --filtpolar
Filter polar horn regions from data
Default:
False- --cormin
Set minimum cutoff rigidity (COR_SAX) for nimaketime filtering (typical value = 4)
- --dark
Apply SUNSHINE=0 filter to get only data in Earth shadow
Default:
False- --mask
Mask these IDS
- --obsid
Use this as OBSID for directory and filenames
merge.py
Merging NICER ObsID or event files.
Output will be written in merged directory. This script assumes that all filtering has been done.
Output files include:
merged event file with it science plot (nicerql.py)
merged lightcurve produced by extractor
merged spectrum PHA produced by extractor
The PULSE_PHASE column will be ignored for the nicerql.py plot, since it requires a merged orbit file -- not implemented yet.
usage: merge.py [-h] [--par PAR] [--ephem EPHEM] [--orb ORB] [--cut]
[--lcbinsize LCBINSIZE] [--filterbinsize FILTERBINSIZE]
[--clobber]
infile [infile ...] outroot outdir
Positional Arguments
- infile
list of event files or text file with list
- outroot
root of the output filenames
- outdir
Name of output directory
Named Arguments
- --par
Par file to use for phases (in nicerql.py)
- --ephem
Ephem to use with photonphase
Default:
'DE421'- --orb
text file containing the paths to all orbits files
- --cut
perform count rate cut at the end
Default:
False- --lcbinsize
Lightcurve bin size (sec, default=4.0)
Default:
4.0- --filterbinsize
Bin size for Count rate filtering (sec, default=16.0)
Default:
16.0- --clobber
replace existing merged files
Default:
False
cr_cut.py
Count rate cut on event file, using ftools (following method by S. Bogdanov). Automatic if count rate cut is provided, ortherwise interactive (calling sci_plot)
usage: cr_cut.py [-h] [--lcfile LCFILE] [--cut CUT] [--invert]
[--filterbinsize FILTERBINSIZE] [--plotfilt]
[--outname OUTNAME]
[--log-level {TRACE,DEBUG,INFO,WARNING,ERROR}]
evfile
Positional Arguments
- evfile
event file
Named Arguments
- --lcfile
Light curve file (optional)
- --cut
Count rate cut in cts/sec (optional)
- --invert
Invert cut to only data data ABOVE the specified cut
Default:
False- --filterbinsize
Bin size in sec (default = 16 sec)
Default:
16.0- --plotfilt
Ploting filtered lightcurve at the end
Default:
False- --outname
Name for output event file (default=<inname>_cut.evt)
- --log-level
Possible choices: TRACE, DEBUG, INFO, WARNING, ERROR
Logging level
Default:
'INFO'
mkgti.py
Create a simple GTI file from a pair of NICER METs. This is handy as an input file to niextract-events timefile=xxx.gti
usage: mkgti.py [-h] [--gtiname GTINAME] startmet stopmet
Positional Arguments
- startmet
Starting MET for GTI
- stopmet
Ending MET for GTI
Named Arguments
- --gtiname
Name of output GTI FITS file (default gti.fits)
Default:
'gti.fits'
splitevt.py
Read NICER evt file (often a merged one from many ObsIDs) and split into shorter chunks of a specified length.
usage: splitevt.py [-h] [--outbase OUTBASE] [--minspan MINSPAN]
[--maxspan MAXSPAN] [--maxgap MAXGAP] [--minexp MINEXP]
[--fpmsel]
eventname
Positional Arguments
- eventname
FITS file to read events from
Named Arguments
- --outbase
Base name of output file
Default:
'split'- --minspan
Minimum span of each chunk (s) to not be discarded.
Default:
0.0- --maxspan
Maximum span of each chunk (s).
Default:
86400.0- --maxgap
Maximum gap to allow in a chunk (s, -1 for don’t enforce)
Default:
-1.0- --minexp
Minimum exposure for each chunk to not be discarded (s).
Default:
0.0- --fpmsel
Include FPM_SEL extension in output files
Default:
False
remove_empty_evtfiles.py
Read through list of EVENT fits files and remove any that have no events (0 rows in the EVENTS extension)
usage: remove_empty_evtfiles.py [-h] infile outfile
Positional Arguments
- infile
Text file containing list of event file names
- outfile
Output text file containing filtered list of event file names
add_kp.py
Adds a KP column to .mkf files, which psrpipe.py --kpmax uses.
Add Kp values as a column to an existing MKF file
usage: add_kp.py [-h] [--potsdam] [--nearest] [--kp KP] mkf [mkf ...]
Positional Arguments
- mkf
Input MKF file process (will be modified)
Named Arguments
- --potsdam
Use Potsdam Kp values from NICERsoft data (default is NOA data from NICER GOF)
Default:
False- --nearest
Use nearest Kp value, instead of the default linear interpolation
Default:
False- --kp
Path to NICER GOF kp.fits file (default $CALDB/data/gen/pcf/kp.fits). Only used if not --potsdam.
calcdeadtime.py
Compute deadtime correction to an EXPOSURE defined by a GTI extension, for a single OBSID.
usage: calcdeadtime.py [-h] [--mask MASK [MASK ...]] [--plot] obsdir gtifile
Positional Arguments
- obsdir
Directory containing the raw data for this OBSID
- gtifile
FITS file containing a GTI extension to be used. Can be an event file, PHA file or any FITS file with a ‘GTI’ extension.
Named Arguments
- --mask
Mask particular FPMs
Default:
[]- --plot
Plot deadtime per FPM
Default:
False