Radial Profile Scripts

High level scripts

nustar_gen.radial_profile.make_radial_profile(filename, show_image=False, filt_range=5, coordinates=False)

Makes the radial profile.

filename should show be the input image filename

If coordinates is False, then does a maximum image filter and find the source. If True, then uses those coordinates instead and the filtered image is not used.

The filtered image is NOT used for the radial profile itself, just for finding the source location.

nustar_gen.radial_profile.optimize_radius_snr(rind, rad_profile, radial_err, psf_profile, bgd_rin=200, bgd_rout=300, rlimit=300, source_ratio=0.5, show=True)

Assumes that you have already constructed the radial profile from the source location using make_radial_profile in a given energy band.

This method fits the “source” and “background” components using the profile_model method above.

Based on the relative strength of the source and the background this then computes the radius that optimizes the signal-to-noise in this band.

Returns the “best” radius in arcseconds.

If show is True, then generates diagnostic plots.

nustar_gen.radial_profile.find_source(filename, show_image=False, filt_range=10, gauss_sig=3)

Find a source in the image. Returns the location in pixel_coordiantes.

filename should point to a file produed by nustar_gen.wrappers.make_image()

Low level scripts

nustar_gen.radial_profile.load_psf(rind, energy=4, filt_range=5, show=False)

Load the PSF from the CALDB and generate a radial profile

nustar_gen.radial_profile.profile_model(rind, psf_scale, bgd_offset, bgd_slope)

Model for fitting the radial profile by scaling the PSF and then adding a background term that’s assumed to be flat in cts / area

nustar_gen.radial_profile.azimuthalAverage(image, center=None)

Calculate the azimuthally averaged radial profile.

image - The 2D image center - The [x,y] pixel coordinates used as the center. The default is

None, which then uses the center of the image (including fracitonal pixels).

Returns - the radial profile in units of cts / area.

nustar_gen.radial_profile.make_obs_psf(oaa_file, module, out_dir=None, out_prefix='obs')

Create a synthetic PSF for a source. Note that you have to run nuproducts o on the source first before you use this tool so that you know what the distribution of off-axis angles and azimuthal rotations are for the source.

Each file is based on the PSF at the correct off-axis location and with the correct azimuthal rotation applied to match the data. This varies with energy, so there will be a number of PSF files produced. The energy edges are: 3, 4, 5, 6, 8, 12, 20, and 80 keV based on the 2D CALDB PSFs

This script produces a number of files, each with a filename like: psf2d_{out_prefix}_5.5keV_A.fits …where the energy given is the mid-point of the bin and the out_prefix is an optional keyword (default is ‘obs’).

The appropriate PSF should be matched with the energy bands used to produce the image. See the example notebook for a demonstration of using this PSF.

Parameters:
  • oaa_file (str) – Path to the optical axis file from nuproducts Will have a name like this: nu60501018002A01_srcA_offaxishisto.fits

  • module (str) – ‘A’ or ‘B’

  • out_dir (str) – Output path. If not specified, assumed os.getcwd() is where you want the file

  • out_prefix (str) – Output PSF prefix. File will have a name like psf2_preix_

Return type:

None