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

ColDescr

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).

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.

get_hdu_names()[source]

Parse outmaps to get a list of HDU names.

__init__()[source]

Constructor.

get_last_line()[source]

Get last line of a text file.

get_time_consump()[source]

Parse terminal output to get time consumption.

_load_or_save_hdu_list()[source]

Load data from or save data to FITS file.

get_coadded_layer()[source]

Extract a coadded layer from the primary HDU.

get_T_weightmap()[source]

Extract T_weightmap from an additional HDU.

get_mean_coverage()[source]

Compute mean coverage based on T_weightmap.

get_output_map()[source]

Extract an output map from the additional HDUs.

_update_hdu_data()[source]

Update data using data provided by a neighbor.

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

fpath = ''[source]
cfg = None[source]
hdu_names = None[source]
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() None[source]

Parse terminal output to get time consumption.

Return type:

None

_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.

__init__()[source]

Constructor.

get_norm()[source]

Get norm for 2D noise power spectrum (classmethod).

azimuthal_average()[source]

Compute radial profile of image (staticmethod)).

_get_wavenumbers()[source]

Calculate wavenumbers for the input image (staticmethod).

__call__()[source]

Analyze specified noise frame of given output image.

clear()[source]

Free up memory space.

AREA[source]
tfr = 3.08[source]
gain = 1.458[source]
ABstd = 3.631e-20[source]
h[source]
m_ab = 23.9[source]
s_in = 0.11[source]
PS1D_COLORS = ['orange', 'darksalmon', 'palevioletred', 'mediumvioletred', 'darkviolet'][source]
PS1D_STYLES = ['solid', 'dotted', 'dashed', 'solid', 'dashdot'][source]
outim[source]
layer[source]
cfg[source]
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

clear() None[source]

Free up memory space.

ColDescr[source]
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.

__init__()[source]

Constructor.

__call__()[source]

Analyze given point source frame of given output image.

clear()[source]

Free up memory space.

bd = 40[source]
bd2 = 8[source]
ncol[source]
outim[source]
layer = 'gsstar14'[source]
cfg[source]
__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

clear() None[source]

Free up memory space.

Return type:

None.

class _BlkGrp[source]

Abstract base class for groups of blocks (mosiacs or suites).

__call__()[source]

Run all the analyses below.

get_consump_map()[source]

Get map of time consumption.

get_coverage_map()[source]

Get map of mean coverages.

get_noise_power_spectra()[source]

Analyze noise power spectra of this mosaic.

get_star_catalog()[source]

Analyze injected point sources of this mosaic.

clear()[source]

Free up memory space.

__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.

Parameters:
  • bins (int, optional) – Number of bins for 1D power spectra.

  • overwrite (bool, optional) – Whether to overwrite existing results.

Return type:

None

get_star_catalog(layer: str = 'gsstar14', overwrite: bool = False) None[source]

Analyze injected point sources of this mosaic.

Parameters:
  • layer (str, optional) – Layer name of injected stars to analyze.

  • overwrite (bool, optional) – Whether to overwrite existing results.

Return type:

None

clear() None[source]

Free up memory space.

class Mosaic(cfg: pyimcom.config.Config)[source]

Bases: _BlkGrp

Wrapper for coadded mosaics (2D arrays of blocks).

Parameters:

cfg (Config) – Configuration used for this output mosaic.

__init__()[source]

Constructor.

share_padding_stamps()[source]

Share padding postage stamps between adjacent blocks.

ndim = 2[source]
padding = False[source]
cfg[source]
hdu_names = ['PRIMARY', 'CONFIG', 'INDATA', 'INWEIGHT', 'INWTFLAT'][source]
outimages[source]
share_padding_stamps() None[source]

Share padding postage stamps between adjacent blocks.

Return type:

None

class Suite(cfg: pyimcom.config.Config, prime: int = 691, nrun: int = 16)[source]

Bases: _BlkGrp

Wrapper 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).

__init__()[source]

Constructor.

ndim = 1[source]
padding = True[source]
cfg[source]
hdu_names = ['PRIMARY', 'CONFIG', 'INDATA', 'INWEIGHT', 'INWTFLAT'][source]
prime = 691[source]
nrun = 16[source]
outimages[source]