pyimcom.meta.distortimage
Metadetection mosaic class and associated functions.
Classes
- MetaMosaic
A (sub-)mosaic that can be sheared.
Functions
- shearimage_to_fits
Writes a sheared image to a FITS file.
Classes
Contains mosaic information for use in meta operations. |
Functions
|
Utility to save a shearimage dictionary a FITS file. |
Module Contents
- class MetaMosaic(fname, bbox=None, extpix=None, verbose=False)[source]
Contains mosaic information for use in meta operations.
- Parameters:
fname (str) – File name of block to build (sub-mosaic will be a 3x3 block region centered on this).
bbox (list of int, optional) – Boundaries [xmin, xmax, ymin, ymax]: accept only blocks with xmin<=x<xmax, ymin<=y<ymax. Default is to read the whole mosaic. This feature is useful if you haven’t run the whole mosaic or pulled it to your disk.
extpix (int, optional) – Number of pixels to extend beyond the block boundary. Uses full 3x3 submosaic if not given.
verbose (bool, optional) – Whether to print diagnostics.
- origimage()[source]
Same format as shearimage, but doesn’t do shear/reconvolution (just extracts subarrays).
- maskpix(extramask)[source]
Provide additional masking beyond the default.
Pixels that are True in extramask are masked out.
- Parameters:
extramask (np.array of bool) – 2D array of pixels to mask out.
- Return type:
None
- mask_fidelity_cut(fidelitymin)[source]
Masks pixels with fidelity below the cut.
For example,
mosaic.mask_fidelity_cut(40)will cut pixels with leakage worse than 40 dB (i.e. U/C>1e-4).- Parameters:
fidelitymin (float) – The fidelity cut in dB.
- Return type:
None
- mask_noise_cut(noisemax)[source]
Masks pixels with noise metric worse than the cut.
For example,
mosaic.mask_noise_cut(3)will cut pixels whose noise suppression is less than 3 dB relative to input (i.e., Sigma>10**(-0.3)).- Parameters:
noisemax (float) – The noise cut in dB.
- Return type:
None
- mask_caps(ra, dec, radius)[source]
Masks circular regions around an input catalog.
Each of ra, dec, and radius should be an array-like object of the same length N (radius is permitted to be a scalar).
- Parameters:
ra (np.array of float) – The right ascensions of the objects to mask (in degrees).
dec (np.array of float) – The declinations of the objects to mask (in degrees).
radius (float or np.array of float) – The radius to mask around each object (in degrees). If a scalar value is given, uses the same radius for all objects.
- Return type:
None
- to_file(fname)[source]
Writes the input mosaic images to a FITS file.
- Parameters:
fname (str) – File name for the output FITS file.
- Return type:
None
- shearimage(N, jac=None, psfgrow=1.0, oversamp=1.0, fidelity_min=None, Rsearch=6.0, select_layers=None, verbose=False)[source]
Generates a sheared image and its WCS.
- Parameters:
N (int) – Size of the output image (shape will be (N, N)).
jac (np.array or None, optional) – 2x2 Jacobian for transformation (None defaults to the identity).
psfgrow (float, optional) – Factor (in linear scale) by which to grow the PSF.
oversamp (float, optional) – Up-sampling factor (e.g., 1 = preserve pixel scale).
fidelity_min (float or None, optional) – Fidelity cut (in dB) for which pixels to use.
Rsearch (float, optional) – Search radius in interpolation, in units of coadded pixels.
select_layers (np.array of int or None, optional) – If given, only process these layers.
stest (int, optional) – Computes test diagnostics (leakage & noise for interpolation) every this many output pixels. Set to 1 to do every output pixel (but this may be slower).
verbose (bool, optional) – Print diagnostics to terminal.
- Returns:
im – Image dictionary containing ‘image’, ‘mask’, ‘wcs’, ‘pars’, ‘layers’, ‘psf_fwhm’, and ‘ref’.
- Return type:
dict
Notes
The output image contains: *
im['image']: np.array, image cube (3D) *im['mask']: np.array, image mask (2D, Boolean, True=masked) *im['wcs']: astropy.wcs.WCS, world coordinate system object (appropriate for a FITS file) *im['pars']: dict, parameter dictionary (can be turned into a FITS header) *im['layers']: list of str, names of layers *im['psf_fwhm']: float, 1 sigma width of output PSF in arcsec *im['ref']: (int, int), projection center (x,y), 0-offset conventionThe sense of jac is that the output is related to the input by: d{input coords[i]} = sum_j jac[i,j] d{output coords[j]}
Assumes a Gaussian PSF, returns an error if something else is used.
- origimage(N=None, select_layers=None)[source]
Like shearimage, but without applying the deconvolution/shear/reconvolution (so is faster).
- Parameters:
N (int, optional) – Size of the output image (shape will be (N, N)). Default is one block.
select_layers (np.array of int or None, optional) – If given, only process these layers.
- Returns:
im – Image dictionary
- Return type:
dict
See also
shearimageCarries out a shear, same output format.
- shearimage_to_fits(im, fname, layers=None, overwrite=False)[source]
Utility to save a shearimage dictionary a FITS file.
- Parameters:
im (dict) – Image dictionary from MetaMosaic.shearimage or MetaMosaic.origimage.
fname (str) – File name for output.
layers (np.array of int, optional) – Which layers to include.
overwrite (bool, optional) – Whether to overwrite an existing file.
- Return type:
None