pyimcom.splitpsf.imsubtract
Routines for implementing the image subtraction step in PSF wing removal.
Functions
- pltshow
Helper to determine where to save a plot.
- get_wcs
Extracts the World Coordinate System from a cached file.
- run_imsubtract
Main workflow for image subtraction step.
Attributes
Functions
|
Convolve two N-dimensional arrays using FFT. |
|
Where to save a plot. |
|
Gets the WCS from a cached FITS file. |
|
Gets the "sub-WCS" from the FITS file. Using SlicedLowLevelWCS avoids extra axes |
|
Main routine to run imsubtract on a single image. |
|
Main routine to run imsubtract. |
Module Contents
- fftconvolve_multi(in1, in2, out, mode='full', nb=4, workers=None, verbose=False)[source]
Convolve two N-dimensional arrays using FFT.
This is almost a drop-in replacement for
scipy.signal.fftconvolve. The big difference is that the convolution is directly added to out, rather than being a return value.For the 2D mode = “valid” case, this splits up the data into nb blocks for the convolution. It is designed to be efficient when in1 is much smaller than in2.
- Parameters:
in1 (np.ndarray) – First input.
in2 (np.ndarray) – Second input. Should have the same number of dimensions as in1.
out (np.ndarray) – Location to add to the output image. Must have the right dimensions.
mode (str, optional) – Mode; options are “full”, “valid”, and “same” (just as for the scipy functions).
nb (int, optional) – Number of blocks to use.
workers (int, optional) – Number of workers for the FFTs if requesting parallelism.
verbose (bool, optional) – Whether to print the intermediate steps.
- Return type:
None
- pltshow(plt, display, pars={})[source]
Where to save a plot.
- Parameters:
plt (matplotlib.pyplot) – The pyplot module to use for plotting.
display (str or None) – Sends to file (if string), screen (None), or nowhere (if ‘/dev/null’)
pars (dict, optional) – Parameters for saving the file. Must be provided if a file is requested.
- Return type:
None
Notes
The pars dictionary contains the keys: * ‘type’ : str, currently only supports ‘window’ * ‘obsid’ : int, observation ID * ‘sca’ : int, SCA number * ‘ix’ : int, x block index * ‘iy’ : int, y block index
- get_wcs(cachefile)[source]
Gets the WCS from a cached FITS file.
If a gwcs is used, finds the attached ASDF file and reads that.
- Parameters:
cachefile (str) – Name of the cached file.
- Returns:
The World Coordinate System of the cached file.
- Return type:
pyimcom.wcsutils.PyIMCOM_WCS
- get_wcs_from_infile(infile)[source]
Gets the “sub-WCS” from the FITS file. Using SlicedLowLevelWCS avoids extra axes which create additional complications in the WCS.
- Parameters:
infile (str) – Name of the file.
- Returns:
The World Coordinate System of the file with only the necessary axes.
- Return type:
sub-WCS
- run_imsubtract_single(cfgdata, scaid, obsid, path, expname, display=None, local_output=False, fft_workers=None, wcs_shortcut=True, max_layers=None, mmap=None)[source]
Main routine to run imsubtract on a single image.
- Parameters:
cfgdata (Config object) – a pyimcom Config object
scaid (int) – SCA ID for the image to be subtracted. Should be in range 1..18, inclusive.
obsid (int) – Observation ID for the image to be subtracted.
path (str) – Path to the directory containing the cached files.
expname (str) – Name of the cached file (will be of the form `stem_obsid_scaid.fits’).
display (str or None, optional) – Display location for intermediate steps.
local_output (bool, optional) – Whether to direct the file to local output instead of the cache directory. (This will normally be the default False; it is provided only so that if more than one user runs tests at the same time, they can use True to avoid a collision.)
fft_workers (int, optional) – Number of workers for the FFTs if requesting parallelism.
wcs_shortcut (bool, optional) – If set, allows interpolation methods to speed up WCS computations.
max_layers (int, optional) – Maximum number of layers to process. (For testing; default is None, which means no limit.)
mmap (str or str-like, optional) – Directory to put temporary mmap files.
Notes
There are several options for display:
display = None : print to screen
display = ‘/dev/null’ : don’t save
display = any other string : save to
display+f'_{obsid}_{sca}_{ix:02d}_{iy:02d}.png'
- run_imsubtract(config_file, display=None, scanum=None, local_output=False, max_img=None, workers=None, wcs_shortcut=True, max_layers=None, mmap=None)[source]
Main routine to run imsubtract.
- Parameters:
config_file (str) – Location of a configuration file.
display (str or None, optional) – Display location for intermediate steps.
scanum (int or None, optional) – If not None, only run this SCA. Should be in range 1..18, inclusive. (Mostly used for parallelization.)
local_output (bool, optional) – Whether to direct the file to local output instead of the cache directory. (This will normally be the default False; it is provided only so that if more than one user runs tests at the same time, they can use True to avoid a collision.)
max_img (int, optional) – If provided, does computations for a maximum number of SCAs. Most users will want the default of None; this is provided mainly for testing.
workers (int, optional) – Number of workers for the FFTs if requesting parallelism.
wcs_shortcut (bool, optional) – If set, allows interpolation methods to speed up WCS computations.
max_layers (int, optional) – Maximum number of layers to process. (For testing; default is None, which means no limit.)
mmap (str or str-like, optional) – Directory to put temporary mmap files.
Notes
There are several options for display:
display = None : print to screen
display = ‘/dev/null’ : don’t save
display = any other string : save to
display+f'_{obsid}_{sca}_{ix:02d}_{iy:02d}.png'