Top-level Functions

spike.psf is the primarily user-facing portion of the code. In most cases, you will only interact with spike.psf.hst, spike.psf.jwst, or spike.psf.roman.

The quickstart guide and examples (for ACS, WFC3, and NIRCam) offer a sense of the required inputs. See below for details of individual functions.

spike.psf.hst(img_dir, obj, img_type, inst, camera=None, method='TinyTim', usermethod=None, savedir='psfs', drizzleimgs=False, objonly=True, pretweaked=False, keeporig=True, plot=False, verbose=False, parallel=False, out='fits', tweakparams={'threshold': 6.0, 'searchrad': 3.0, 'dqbits': -16, 'configobj': None, 'interactive': False, 'shiftfile': True, 'expand_refcat': True, 'outshifts': 'shift_searchrad.txt', 'updatehdr': True, 'wcsname': 'TWEAK'}, drizzleparams={'preserve': False, 'driz_cr_corr': False, 'clean': False, 'configobj': None, 'final_pixfrac': 1.0, 'build': True, 'combine_type': 'imedian', 'static': False, 'driz_sep_rot': None, 'final_rot': None}, returnpsf='full', cutout_fov=151, savecutout=True, finalonly=False, removedir='toremove', clobber=False, usename=False, **kwargs)

Generate drizzled HST PSFs.

Parameters:
  • img_dir (str) – Path to directory containing calibrated files for which model PSF will be generated. If using the tweakreg step, best to include a drizzled file, as well, which can be used as a reference.

  • obj (str, arr-like) – Name or coordinates of object of interest in HH:MM:DD DD:MM:SS or degree format.

  • img_type (str) – e.g, ‘flc’, ‘flt’, ‘cal’, ‘c0m’ – specifies which file-type to include. spike currently only works with MEF files (since astrodrizzle only works with MEF files).

  • inst (str) – ‘ACS’, ‘WFC3’, ‘WFPC’, ‘WFPC2’, NICMOS’

  • camera (str) – ‘WFC’, ‘HRC’ (ACS), ‘UVIS’, ‘IR’ (WFC3) – MUST BE SPECIFIED FOR ACS, WFC3 (if not specified, will ask for input)

  • method (str) – ‘TinyTim’, ‘TinyTim_Gillis’, ‘STDPSF’ (empirical), ‘epsf’ (empirical), ‘ACS_ePSF’ (empirical), ‘PSFEx’ (empirical) – see spike.psfgen for details – or ‘USER’; if ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_topsf.fits, e.g., imgprefix_23.31+30.12_F814W_topsf.fits or imgprefix_195.78-46.52_F555W_topsf.fits

  • usermethod (func or str) – If method = ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_psf.fits, e.g., imgprefix_23.31+30.12_F814W_psf.fits or imgprefix_195.78-46.52_F555W_psf.fits, where the imgprefix corresponds to the name of the relevant flt/flc/c0f/c1f/… files in the directory and the headers are from the original images (see spike.tools.rewrite_fits, which can be used to this end).

  • savedir (str) – Where the PSF models and drizzled PSF will be saved. Defaults to ‘psfs’.

  • drizzleimgs (bool) – If True, will drizzle the input images at the same time as creating a drizzled psf.

  • objonly (bool) – If True, only drizzles input images that cover the selected obj.

  • pretweaked (bool) – If True, skips TweakReg steps to include fine WCS corrections.

  • keeporig (bool) – If True (and pretweaked = False), create copy of img_dir before TweakReg.

  • plot (bool) – If True, saves .pngs of the model PSFs. (Not affected by clobber; images with the same name are overwritten by default.)

  • verbose (bool) – If True, prints progress messages.

  • parallel (bool) – If True, runs PSF generation in parallel.

  • out (str) – ‘fits’ or ‘asdf’. Output for the drizzled PSF. If ‘asdf’, .asdf AND .fits are saved.

  • tweakparams (dict) – Dictionary of keyword arguments for drizzlepac.tweakreg. See the drizzlepac documentation for a full list.

  • drizzleparams (dict) – Dictionary of keyword arguments for drizzlepac.astrodrizzle. See the drizzlepac documentation for a full list.

  • returnpsf (str) – ‘full’, ‘crop’, or None. If None, spike.psf.hst does not return anything. If ‘full’ (default), returns the PSF in the full spatial context of the processed image. If ‘crop’, returns the region immediately around the PSF (size of cutout set by cutout_fov).

  • cutout_fov (int) – Side length in pixels of square cutout region centered on PSF. Used if returnpsf = ‘crop’.

  • savecutout (bool) – If True, save a .fits file with the cutout region, including WCS. Only used if returnpsf = ‘crop’.

  • finalonly (bool) – If True, only retains final drizzled/resampled data products in savedir and deletes intermediate products.

  • removedir (str) – Directory (to be deleted) that stores intermediate products for removal. Default is ‘toremove’.

  • clobber (bool) – If True, will overwrite existing files with the duplicate names. (Default state – clobber = False – is recommended.)

  • usename (bool) – If True, use resolvable object name (from obj) if provided in generating output files.

  • **kwargs – Keyword arguments for PSF generation function.

Returns:

Generates model PSFs and drizzled PSF. (If drizzledimgs = True, also produces drizzled image from input files.)

If returnpsf = ‘full’, will return each of the full drizzled PSF images in an object, filter indexed dict. If returnpsf = ‘crop’, will return a cutout region of the drizzled PSF images (around the PSF) in an obj, filt indexed dict.

spike.psf.jwst(img_dir, obj, inst, img_type='cal', camera=None, method='WebbPSF', usermethod=None, savedir='psfs', drizzleimgs=False, objonly=True, pretweaked=False, usecrds=False, keeporig=True, plot=False, verbose=False, parallel=False, out='fits', returnpsf='full', cutout_fov=151, savecutout=True, finalonly=False, removedir='toremove', clobber=False, usename=False, shortcoord_style={'style': 'hmsdms', 'sep': ':'}, tweakparams={}, drizzleparams={'allowed_memory': 0.5}, usest=True, **kwargs)

Generate drizzled James Webb Space Telescope PSFs.

Parameters:
  • img_dir (str) – Path to directory containing calibrated files for which model PSF will be generated. If using the tweakreg step, best to include a drizzled file, as well, which can be used as a reference.

  • obj (str, arr-like) – Name or coordinates of object of interest in HH:MM:DD DD:MM:SS or degree format.

  • img_type (str) – e.g, ‘cal’, ‘calints’, ‘crf’, ‘crfints’ – specifies which file-type to include.

  • inst (str) – ‘MIRI’, ‘NIRCAM’, ‘NIRISS’

  • camera (str) – ‘Imaging’, ‘AMI’ – MUST BE SPECIFIED FOR NIRISS

  • method (str) – ‘WebbPSF’, ‘STDPSF’ (empirical), ‘epsf’ (empirical), ‘PSFEx’ (empirical) – see spike.psfgen for details – or ‘USER’; if ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_psf.fits, e.g., imgprefix_23.31+30.12_F814W_psf.fits or imgprefix_195.78-46.52_F555W_psf.fits. Note: the WebbPSF name is maintained here in lieu of STPSF to avoid confusion with the generation of empirical STDPSFs.

  • usermethod (func or str) – If method = ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_psf.fits, e.g., imgprefix_23.31+30.12_F814W_psf.fits or imgprefix_195.78-46.52_F555W_psf.fits, where the imgprefix corresponds to the name of the relevant flt/flc/c0f/c1f/… files in the directory and the headers are from the original images (see spike.tools.rewrite_fits, which can be used to this end).

  • savedir (str) – Where the PSF models and drizzled PSF will be saved. Defaults to ‘psfs’.

  • drizzleimgs (bool) – If True, will drizzle the input images at the same time as creating a drizzled psf.

  • objonly (bool) – If True, only drizzles input images that cover the selected obj.

  • pretweaked (bool) – If True, skips tweak step to include fine WCS corrections.

  • usecrds (bool) – If True, use CRDS config settings as defaults.

  • keeporig (bool) – If True (and pretweaked = False), create copy of img_dir before tweak.

  • plot (bool) – If True, saves .pngs of the model PSFs. (Not affected by clobber; images with the same name are overwritten by default.)

  • verbose (bool) – If True, prints progress messages.

  • parallel (bool) – If True, runs PSF generation in parallel.

  • out (str) – ‘fits’ or ‘asdf’. Output for the drizzled PSF. If ‘asdf’, .asdf AND .fits are saved.

  • returnpsf (str) – ‘full’, ‘crop’, or None. If None, spike.psf.jwst does not return anything. If ‘full’ (default), returns the PSF in the full spatial context of the processed image. If ‘crop’, returns the region immediately around the PSF (size of cutout set by cutout_fov).

  • cutout_fov (int) – Side length in pixels of square cutout region centered on PSF. Used if returnpsf = ‘crop’.

  • savecutout (bool) – If True, save a .fits file with the cutout region, including WCS. Only used if returnpsf = ‘crop’.

  • finalonly (bool) – If True, only retains final drizzled/resampled data products in savedir and deletes intermediate products.

  • removedir (str) – Directory (to be deleted) that stores intermediate products for removal. Default is ‘toremove’.

  • clobber (bool) – If True, will overwrite existing files with the duplicate names. (Default state – clobber = False – is recommended.)

  • usename (bool) – If True, use resolvable object name (from obj) if provided in generating output files.

  • shortcoord_style (dict) – If usename False and object positions are input as resolvable names, shortcoord_style sets the coordinate style in output files. Style is one of ‘decimal’ (deg), ‘dms’ (degree, minute, second), or ‘hmsdms’ (sexagecimal) + kwargs.

  • tweakparams (dict) – Dictionary of keyword arguments for the tweakreg step. See the JWST pipeline documentation for a full list. See here: https://jwst-pipeline.readthedocs.io/en/latest/jwst/tweakreg/README.html#step-arguments

  • drizzleparams (dict) – Dictionary of keyword arguments for the resample step. See the JWST pipeline documentation for a full list.

  • usest (bool) – If True, will import jwst pipeline if available rather than using spike.jwst.

  • **kwargs – Keyword arguments for PSF generation function.

Returns:

Generates model PSFs and drizzled PSF. (If drizzledimgs = True, also produces drizzled image from input files.)

If returnpsf = ‘full’, will return each of the full drizzled PSF images in an object, filter indexed dict. If returnpsf = ‘crop’, will return a cutout region of the drizzled PSF images (around the PSF) in an obj, filt indexed dict.

spike.psf.roman(img_dir, obj, inst, img_type='cal', file_type='fits', camera=None, method='WebbPSF', usermethod=None, savedir='psfs', drizzleimgs=False, objonly=True, pretweaked=False, usecrds=False, keeporig=True, plot=False, verbose=False, parallel=False, out='fits', returnpsf='full', cutout_fov=151, savecutout=True, finalonly=False, removedir='toremove', clobber=False, usename=False, shortcoord_style={'style': 'hmsdms', 'sep': ':'}, tweakparams={}, drizzleparams={}, usest=True, **kwargs)

Generate drizzled Roman Space Telescope PSFs.

Parameters:
  • img_dir (str) – Path to directory containing calibrated files for which model PSF will be generated. If using the tweakreg step, best to include a drizzled file, as well, which can be used as a reference.

  • obj (str, arr-like) – Name or coordinates of object of interest in HH:MM:DD DD:MM:SS or degree format.

  • img_type (str) – e.g, ‘cal’ – specifies which file-type to include.

  • file_type (str) – ‘fits’ or ‘asdf’ – format to use for reading and manipulating data files.

  • inst (str) – ‘WFI’, ‘CGI’

  • camera (str) – None

  • method (str) – ‘WebbPSF’, ‘epsf’ (empirical), ‘PSFEx’ (empirical) – see spike.psfgen for details – or ‘USER’; if ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_psf.fits, e.g., imgprefix_23.31+30.12_F814W_psf.fits or imgprefix_195.78-46.52_F555W_psf.fits. Note: the WebbPSF name is maintained here in lieu of STPSF to avoid confusion with the generation of empirical STDPSFs.

  • usermethod (func or str) – If method = ‘USER’, usermethod should be a function that generates, or path to a directory of user-generated, PSFs named [imgprefix]_[obj]_[band]_psf.fits, e.g., imgprefix_23.31+30.12_F814W_psf.fits or imgprefix_195.78-46.52_F555W_psf.fits, where the imgprefix corresponds to the name of the relevant cal/calints… files in the directory and the headers are from the original images (see spike.tools.rewrite_fits, which can be used to this end).

  • savedir (str) – Where the PSF models and drizzled PSF will be saved. Defaults to ‘psfs’.

  • drizzleimgs (bool) – If True, will drizzle the input images at the same time as creating a drizzled psf.

  • objonly (bool) – If True, only drizzles input images that cover the selected obj.

  • pretweaked (bool) – If True, skips tweak step to include fine WCS corrections.

  • usecrds (bool) – If True, use CRDS config settings as defaults.

  • keeporig (bool) – If True (and pretweaked = False), create copy of img_dir before tweak.

  • plot (bool) – If True, saves .pngs of the model PSFs. (Not affected by clobber; images with the same name are overwritten by default.)

  • verbose (bool) – If True, prints progress messages.

  • parallel (bool) – If True, runs PSF generation in parallel.

  • out (str) – ‘fits’ or ‘asdf’. Output for the drizzled PSF. If ‘asdf’, .asdf AND .fits are saved.

  • returnpsf (str) – ‘full’, ‘crop’, or None. If None, spike.psf.roman does not return anything. If ‘full’ (default), returns the PSF in the full spatial context of the processed image. If ‘crop’, returns the region immediately around the PSF (size of cutout set by cutout_fov).

  • cutout_fov (int) – Side length in pixels of square cutout region centered on PSF. Used if returnpsf = ‘crop’.

  • savecutout (bool) – If True, save a .fits file with the cutout region, including WCS.

  • finalonly (bool) – If True, only retains final drizzled/resampled data products in savedir and deletes intermediate products.

  • removedir (str) – Directory (to be deleted) that stores intermediate products for removal. Default is ‘toremove’.

  • clobber (bool) – If True, will overwrite existing files with the duplicate names. (Default state – clobber = False – is recommended.)

  • usename (bool) – If True, use resolvable object name (from obj) if provided in generating output files.

  • shortcoord_style (dict) – If usename False and object positions are input as resolvable names, shortcoord_style sets the coordinate style in output files. Style is one of ‘decimal’ (deg), ‘dms’ (degree, minute, second), or ‘hmsdms’ (sexagecimal) + kwargs.

  • tweakparams (dict) – Dictionary of keyword arguments for the tweakreg step. See the Roman pipeline documentation for a full list.

  • drizzleparams (dict) – Dictionary of keyword arguments for resample step. See the Roman pipeline documentation for a full list.

  • usest (bool) – If True, will import romancal pipeline if available rather than using spike.romancal.

  • **kwargs – Keyword arguments for PSF generation function.

Returns:

Generates model PSFs and drizzled PSF. (If drizzledimgs = True, also produces drizzled image from input files.)

If returnpsf = ‘full’, will return each of the full drizzled PSF images in an object, filter indexed dict. If returnpsf = ‘crop’, will return a cutout region of the drizzled PSF images (around the PSF) in an obj, filt indexed dict.