pyimcom.analysis
Tools to analyze coadded images.
Classes
- OutImage
Wrapper for coadded images (blocks).
- NoiseAnal
Analysis of noise frames.
- StarsAnal
Analysis of point sources.
- _BlkGrp
Abstract base class for groups of blocks (mosiacs or suites).
- Mosaic
Wrapper for coadded mosaics (2D arrays of blocks).
- Suite
Wrapper for coadded suites (hashed arrays of blocks).
Attributes
Classes
Wrapper for coadded images (blocks). |
|
Analysis of noise frames. |
|
Analysis of point sources. |
|
Abstract base class for groups of blocks (mosiacs or suites). |
|
Wrapper for coadded mosaics (2D arrays of blocks). |
|
Wrapper for coadded suites (hashed arrays of blocks). |
Module Contents
- class OutImage(fpath: str, cfg: pyimcom.config.Config = None, hdu_names: list[str] = None)[source]
Wrapper for coadded images (blocks).
- Parameters:
fpath (str or str-like) – Path to the output FITS file.
cfg (Config, optional) – Configuration used for this output image. If provided, no consistency check is performed. If None, it will be extracted from FITS file.
hdu_names (list of str, optional) – List of HDU names of this FITS file. If provided, no consistency check is performed. If None, it will be derived from cfg.
- static get_hdu_names(outmaps: str) list[str][source]
Parse outmaps to get a list of HDU names.
- Parameters:
outmaps (str) – outmaps attribute of a Config instance.
- Returns:
A list of HDU names.
- Return type:
list of str
- static get_last_line(fname: str) str[source]
Get last line of a text file.
- Parameters:
fname (str) – Path to the text file.
- Returns:
Last line of the text file.
- Return type:
str
- get_time_consump() float[source]
Parse terminal output to get time consumption.
- Returns:
Time consumption in seconds (if found), otherwise nan.
- Return type:
float
- _load_or_save_hdu_list(load_mode: bool = True, save_file: bool = False, auto_to_all: bool = False) None[source]
Load data from or save data to FITS file.
- Parameters:
load_mode (bool, optional) – If True, load data from FITS file (if not already loaded); if False, remove current data from memory (if data exist).
save_file (bool, optional) – Only used when load_mode == False. If (save_file ==) True, save current data to FITS file (overwriting the existing file).
auto_to_all (bool, optional) – Only used when load_mode == False and save_file == True. If (auto_to_all ==) True, change ‘PADSIDES’ from ‘auto’ to ‘all’ in the ‘CONFIG’ HDU of FITS file.
- Return type:
None
- get_coadded_layer(layer: str, j_out: int = 0) numpy.array[source]
Extract a coadded layer from the primary HDU.
- Parameters:
layer (str) – Name of the layer to be extracted.
j_out (int or None, optional) – Index of the output PSF. If None, return results based on all output PSFs.
- Returns:
data – Requested coadded layer. The shape is either (NsideP, NsideP) or (n_out, NsideP, NsideP) (all output PSFs)
- Return type:
np.array
- get_T_weightmap(flat: bool = False, j_out: int = 0) numpy.array[source]
Extract T_weightmap from an additional HDU.
- Parameters:
flat (bool, optional) – Whether to read the flat version of T_weightmap.
j_out (int or None, optional) – Only used when flat is False. Index of the output PSF. If None, return results based on all output PSFs.
- Returns:
data – Requested T_weightmap. Shape is either (n_inimage, n1P, n1P) (1) or (n_out, n_inimage, n1P, n1P) (all output PSFs) or (n_out*n1P, n_inimage*n1P) (flat version)
- Return type:
np.array
- get_mean_coverage(padding: bool = False) float[source]
Compute mean coverage based on T_weightmap.
We assume that mean coverage is the same for all output PSFs.
- Parameters:
padding (bool, optional) – Whether to include padding postage stamps. The default is False.
- Returns:
mean_coverage – Mean coverage based on T_weightmap.
- Return type:
float
- get_output_map(outmap: str, j_out: int = 0) numpy.array[source]
Extract an output map from the additional HDUs.
- Parameters:
outmap (str) – Name of the output map to be extracted.
j_out (int or None, optional) – Index of the output PSF. If None, return results based on all output PSFs.
- Returns:
data – Requested output map. shape is either (NsideP, NsideP) or (n_out, NsideP, NsideP) (all output PSFs).
- Return type:
np.array
- _update_hdu_data(neighbor: OutImage, direction: str, add_mode: bool = True) None[source]
Update data using data provided by a neighbor.
This method is developed for postprocessing, i.e., sharing padding postage stamps between adjacent blocks. This method neither loads nor saves hdu_list.
- Parameters:
neighbor (OutImage) – Neighboring output image (block) who shares data with “me.”
direction (str) – Which side to update. Must be ‘left’, ‘right’, ‘bottom’, or ‘top’.
add_mode (bool, optional) – If True, update “my” data by adding neighbor’s to “mine;” if False, replace “my” data with neighbor’s.
- Return type:
None
- class NoiseAnal(outim: OutImage, layer: str)[source]
Analysis of noise frames.
Largely based on diagnostics/noise/noisespecs.py.
- Parameters:
outim (OutImage) – Output image to analyze.
layer (str) – Layer name of noise frame to analyze.
- classmethod get_norm(layer: str, L: int, filtername: str, s_out: float) float[source]
Get norm for 2D noise power spectrum.
- Parameters:
layer (str) – Layer name of noise frame to analyze.
L (int) – Side length of noise frame in px.
filtername (str) – Name of filter used for this output image.
s_out (float) – Output pixel scale in arcsec.
- Returns:
Norm for 2D noise power spectrum.
- Return type:
float
Notes
For simulated noise frames, dividing by s_in**2 converts from units of S_in^2 to arcsec^2.
- static azimuthal_average(image: numpy.array, nradbins: int, rbin: numpy.array = None, ridx: numpy.array = None) numpy.array[source]
Compute radial profile of image.
- Parameters:
image (np.array) – Input image, shape (L, L).
nradbins (int) – Number of radial bins in profile.
rbin (np.array, optional) – “labels” parameter for ndimage utilities. If provided, has shape (L, L). The default is None. If not provided, derive from image.shape.
ridx (np.array, optional) – “index” parameter for ndimage utilities. If provided, has shape (nradbins,). The default is None. If not provided, derive from rbin.
- Returns:
radial_mean (np.array) – Mean intensity within each annulus. Main result. Shape is (nradbins,)
radial_err (np.array) – Standard error on the mean: sigma / sqrt(N). Shape is (nradbins,)
- static _get_wavenumbers(window_length: int, nradbins: int, rbin: numpy.array = None, ridx: numpy.array = None) numpy.array[source]
Calculate wavenumbers for the input image.
- Parameters:
window_length (int) – the length of one axis of the image.
nradbins (int) – number of radial bins the image should be averaged into
rbin (np.array, optional) – “labels” parameter for ndimage utilities. If provided, shape is (L,L). The default is None. If not provided, derive from image.shape.
ridx (np.array, optional) – “index” parameter for ndimage utilities. If provided, shape is (nradbins,). The default is None. If not provided, derive from rbin.
- Returns:
kmean – the wavenumbers for the image, shape (nradbins,)
- Return type:
np.array
- __call__(padding: bool = False, bin_: bool = True, rbin: numpy.array = None, ridx: numpy.array = None) None[source]
Analyze specified noise frame of given output image.
- Parameters:
padding (bool, optional) – Whether to include padding postage stamps. (to be implemented)
bin (bool, optional) – Whether to bin the 2D spectrum into L/8 x L/8 image. Currently this is ignored, as only bin_ == True is supported.
rbin (np.array, optional, shape : (L, L)) – “labels” parameter for ndimage utilities. The default is None. If not provided, derive from image.shape.
ridx (np.array, optional, shape : (nradbins,)) – “index” parameter for ndimage utilities. The default is None. If not provided, derive from rbin.
- Return type:
None
Notes
If the image side length is not a multiple of 8, the extra pixels (L // 8) are clipped.
- class StarsAnal(outim: OutImage, layer: str = 'gsstar14')[source]
Analysis of point sources.
Largely based on diagnostics/starcube_nonoise.py.
- Parameters:
outim (OutImage) – Output image to analyze.
layer (str, optional) – Layer name of injected stars to analyze.
- __call__(n: int = None, search_radius: float = None, forced_scale: float = None, bdpad: int = None, res: int = None) None[source]
Analyze given point source frame of given output image.
- Parameters:
n (int or None, optional) – Size of output images. If not provided, derive from self.cfg. Same for other parameters.
search_radius (float or None, optional) – Search radius for injected point sources.
forced_scale (float or None, optional) – Forced scale length for star moments.
bdpad (int or None, optional) – Padding region around the edge.
res (int or None, optional) – Resolution of HEALPix grid.
- Return type:
None
- class _BlkGrp[source]
Abstract base class for groups of blocks (mosiacs or suites).
- __call__(overwrite: bool = False) None[source]
Run all the analyses below.
- Parameters:
overwrite (bool, optional) – Whether to overwrite existing results.
- Return type:
None
- get_consump_map(overwrite: bool = False) None[source]
Get map of time consumption.
- Parameters:
overwrite (bool, optional) – Whether to overwrite existing results.
- Return type:
None
- get_coverage_map(overwrite: bool = False) None[source]
Get map of mean coverages.
- Parameters:
overwrite (bool, optional) – Whether to overwrite existing results.
- Return type:
None
- get_noise_power_spectra(bins: int = 5, overwrite: bool = False) None[source]
Analyze noise power spectra of this mosaic.
The output noise power spectra are written to
self.cfg.outstem + "_NoisePS.npz". These are in the format:ps2d_all = 2D power spectrum, [which_noise_layer, ybin, xbin]
ps1d_all = 1D power spectrum, [which_noise_layer, coverage_bin, wavenumber_bin, value_or_err]
wavenumber = 1D array of wavenumbers
- Parameters:
bins (int, optional) – Number of coverage bins for 1D power spectra.
overwrite (bool, optional) – Whether to overwrite existing results.
- Return type:
None
- class Mosaic(cfg: pyimcom.config.Config)[source]
Bases:
_BlkGrpWrapper for coadded mosaics (2D arrays of blocks).
- Parameters:
cfg (Config) – Configuration used for this output mosaic.
Share padding postage stamps between adjacent blocks.
- class Suite(cfg: pyimcom.config.Config, prime: int = 691, nrun: int = 16)[source]
Bases:
_BlkGrpWrapper for coadded suites (hashed arrays of blocks).
- Parameters:
cfg (Config) – Configuration used for this output mosaic.
prime (int, optional) – Prime number for hashing (Paper IV).
nrun (int, optional) – Number of coadded blocks (Paper IV).