StrayLight Wrapper Scripts¶
- nustar_gen.wrappers.make_det1_image(infile, elow=3, ehigh=20, clobber=True, outpath=False)¶
Spawn an xselect instance that produces a DET1 image in the energy range.
- Parameters:
infile (str) – Full path tot eh file that you want to process
elow (float) – Low-energy band for the image. Default is 3 keV.
ehigh (float) – High-energy band for the image. Default is 20 keV.
clobber (boolean, optional, default=True) – Overwrite existing files?
outpath (str, optional, default=os.path.dirname(infile)) – Set the destination for output. Defaults to same location as infile.
- Returns:
outfile – The full path to the output image.
- Return type:
str
- nustar_gen.wrappers.make_det1_lightcurve(infile, mod, obs, time_bin=<Quantity 100. s>, mode='01', elow=3, ehigh=20, stemout=False, gtifile=False)¶
Generate a script to run nuproducts to make a lightcurve using the whole FoV and turning off all vignetting and PSF effects. Assumes that infile has already been filtered using extract_det1_events().
- Parameters:
infile (str) – Full path to the input event file. This should be pre-filtered by by extract_det1_events
mod (str) – ‘A’ or ‘B’
obs (nustar_gen.info.Observation) – Observation meta data
elow (float, optional, default = 3 keV) – Low-energy bound
ehigh (float, optional, default is 20 keV) – High-energy bound
time_bin (astropy unit) – Length of the time bin. Default is 100*u.s
mode (str, optional, default is '01') – Optional. Used to specify stemout if you’re doing mode06 analysis and want to specify output names that are more complicated.
gtifile (str) – Path to a GTI file. If this is set, then this is passed to nuproducts.
stemout (str, optional) – Use the specified stemout string when calling nuproducts. Otherwise uses the default value.
- nustar_gen.wrappers.make_det1_spectra(infile, mod, obs, stemout=False, gtifile=False)¶
Generate a script to run nuproducts to extract a source spectrum along with the associated RMF.
Assumes that infile has already been filtered using extract_det1_events().
Always runs numkrmf, never runs numkarf. Never extract background.
- Parameters:
infile (str) – Full path to the input event file. This should be pre-filtered by by extract_det1_events
mod (str) – ‘A’ or ‘B’
obs (nustar_gen.info.Observation) – Observation meta data
stemout (str) – Optional. Use the specified stemout string when calling nuproducts. Otherwise uses the default value.
gtifile (str) – Path to a GTI file. If this is set, then this is passed to nuproducts. NOTE As of now proper treatment of this being barycenter corrected (or not) is not supported. If you’re doing pulsar analysis, please write your own version.
- nustar_gen.wrappers.extract_det1_events(infile, regfile, elow=1.6, ehigh=165.0, clobber=True, outpath=False)¶
Spawn an xselect instance that produces a new event file screened using a det1 region file.
- Parameters:
infile (str) – Full path to the event file that you want to process
regfile (str) – Full path to a ds9 region file (in physical coordinates) to be used to filter the events.
elow (float) – Lowest energy to use (default is 1.6 keV)
ehigh (float) – Highest energy to use (default is 165 keV)
clobber (boolean, optional, default=True) – Overwrite existing files?
outpath (str, optional, default=os.path.dirname(infile)) – Set the destination for output. Defaults to same location as infile.
- Returns:
outfile – The full path to the output image.
- Return type:
str
StrayLight Utility Scripts¶
- nustar_gen.utils.straylight_area(det1im, regfile, evf)¶
Utility script to compute the area for a given region file. Uses the astropy.regions module to compute the mask. Allows for overlapping include/reject regions and multiple source regions
- Parameters:
det1im (str) – Full path to the DET1 exposure image file.
regfil (str) – Full path to the region file, assumed to be a ds9 region file in “IMAGE” coordinates
evf (str) – Full path to the event file. Only used for pulling down the base exposure in the FITS header.
- Returns:
area – Illuminated detector area with units of cm2.
- Return type:
astropy-units float
- nustar_gen.utils.straylight_background(det1im_file='None', sky2det_file='None', reg_file='None', det1_expo_file='None', diag=False, src_rad=None)¶
Computes the average background rate in an input energy band.
- Parameters:
detim_file (str) – Path to the input DET1 image file. This should be the output of of wrappers.make_det1_image
sky2det_file (str) – Path to the sky2det file. This is generated by nusky2det and traces the source location as a function of time in DET1 and DET2 coordinates. Used for removing the primary source
reg_file (str) – Region file for the image. Can have both source and exclusion regions. All regions listed will be treated as “exclusions” assuming that they contain all of the non-background counts in the image.
det1_expo_file (str) – Path to the DET1 effective area file. Should be the DET1 output of wrappers.make_exposure_map
diag (bool) – Show diagnostic information and make some plots showing what is happening. Default is False
src_rad (astropy.units) – Radius to exclude around the source region. Default is 2-arcmin.
- nustar_gen.utils.make_straylight_arf(det1im, regfile, filt_file, mod, obs)¶
- Produces an ARF for a given observation. Currently uses counts-weighting to
determine the contribution of the detabs parameters for each detector.
- Parameters:
det1im (str) – Full path to the DET1 exposure image file.
regfil (str) – Full path to the region file, assumed to be a ds9 region file in “IMAGE” coordinates
filt_file (str) – Full path to the DET1 screened event file (i.e. output of nustar_gen.wrappers.extract_det1_events() ). This used to scale the ARF by the number of 3–10 keV counts on each detector.
mod (str) – ‘A’ or ‘B’
obs (nustar_gen.info.Observation) – Observation meta data
- Returns:
out_arf – Full path to the new arf file
- Return type:
string
- nustar_gen.utils.validate_det1_region(regfile)¶
Code for making sure that region files that you’re trying to use on the DET1 analysis code are in “image” coordinates
- Parameters:
regfile (str) – Full path to a ds9 region file
- Return type:
None