ufig.plugins package
Submodules
ufig.plugins.add_generic_stamp_flags module
Created on Aug 5, 2016 @author: Tomasz Kacprzak
- ufig.plugins.add_generic_stamp_flags.add_all_stamp_flags(filename_cat, filename_overlapblock, filename_mask, off_mask_radius)[source]
- ufig.plugins.add_generic_stamp_flags.add_edge_duplicate_flag(filename_cat, filename_overlapblock)[source]
ufig.plugins.add_generic_stamp_flags_ucat module
Created on Aug 5, 2016 @author: Tomasz Kacprzak adapted by Silvan Fischbacher, 2024
- ufig.plugins.add_generic_stamp_flags_ucat.add_all_stamp_flags(filename_cat, filename_overlapblock, filename_mask, off_mask_radius)[source]
- ufig.plugins.add_generic_stamp_flags_ucat.add_edge_duplicate_flag(filename_cat, filename_overlapblock)[source]
ufig.plugins.add_lensing module
Created on Nov 4, 2014 @author: Claudio Bruderer
- class ufig.plugins.add_lensing.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Shear and magnification are applied to the input galaxy catalog and combined into an effective ellipticity, magnitude, and size
- Parameters:
numgalaxies – number of galaxies
shear_type – whether a constant or variable shear is added
int_e1 – Intrinsic ellipticity 1-component
int_e2 – Intrinsic ellipticity 2-component
int_mag – Intrinsic magnitude
int_r50 – Intrinsic r50-radius
- Return gamma1:
Shear 1-component at every galaxy location
- Return gamma2:
Shear 2-component at every galaxy location
- Return e1:
Effective ellipticity 1-component at every galaxy location
- Return e2:
Effective ellipticity 1-component at every galaxy location
- Return kappa:
Kappa at every galaxy location
- Return mag:
Effective magnitude of every galaxy
- Return r50:
Effective size of every galaxy
- ufig.plugins.add_lensing.add_shear(int_e1, int_e2, gamma1, gamma2)[source]
Function that adds shear and the intrinsic ellipticity in the weak shear regime (small values of gamma1 and gamma2) for the ellipticity definition (a**2 - b**2) / (a**2 + b**2)
- Parameters:
int_e1 – Intrinsic ellipticity 1-component
int_e2 – Intrinsic ellipticity 2-component
gamma1 – Shear 1-component
gamma2 – Shear 1-component
- Return e1:
Effective ellipticity 1-component
- Return e2:
Effective ellipticity 2-component
- ufig.plugins.add_lensing.load_shear_skymaps(shear_maps, g1_prefactor, maps_remote_dir='')[source]
Load the map containing a realization on the whole sphere of a given input angular power spectrum for the shear
- Parameters:
shear_maps – File name of the shear maps
g1_prefactor – Prefactor to account for a potential flipping of the shear g1-map
maps_remote_dir – Root directory where maps are stored
- Return gamma1_map:
Realization of a shear-cl, 1-component
- Return gamma2_map:
Realization of a shear-cl, 2-component
- ufig.plugins.add_lensing.shear_constant(numgalaxies, par)[source]
Generates a constant shear field at the location of each galaxy
- Parameters:
numgalaxies – number of galaxies, i.e. number of samples
par – ctx.parameters; part of ctx containing parameters
- Returns:
Shear 1-component
- Returns:
Shear 2-component
- ufig.plugins.add_lensing.shear_from_sky_map(gamma1_map, gamma2_map, w, x, y)[source]
Given an input gamma1 and gamma2 map, sample it at positions (x, y) to get input shear
- Parameters:
gamma1_map – Map containing gamma1 information
gamma2_map – Map containing gamma2 information
w – wcs-object containing all the relevant wcs-transformation information
x – pixel x-coordinate
y – pixel y-coordinate
- Return gamma1:
Array containing the sampled gamma1 values
- Return gamma2:
Array containing the sampled gamma2 values
ufig.plugins.add_psf module
Created on Mar 20, 2015 @author: Claudio Bruderer adapted by Silvan Fischbacher, 2024
- class ufig.plugins.add_psf.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
The PSF is applied to the input galaxy and star catalogs by evaluating the PSF size and ellipticity fields at every objects position
- Parameters:
psf_type – whether a constant or variable psf is added
psf_beta – beta parameter for Moffat PSF profile
seeing – seeing (arcsec)
psf_e1 – e1 for the PSF
psf_e2 – e2 for the PSF
psf_maps – File name of the psf maps (0: r50-map, 1: e1-map, 2: e2-map)
maps_remote_dir – Remote directory used in case the file name of the psf maps is not absolute
pixscale – pixel scale (arcsec/pixel)
size_x – size of image in x-direction (pixel)
size_y – size of image in y-direction (pixel)
ra0 – right ascension at the center of the image in degree
dec0 – declination at the center of the image in degree
- Return psf_r50:
PSF r50 (flux radius 50%) evaluated at every object’s position
- Return psf_beta:
PSF beta parameter evaluated at every object’s position
- Return psf_e1:
PSF ellipticity 1-component evaluated at every object’s position
- Return psf_e2:
PSF ellipticity 2-component evaluated at every object’s position
- ufig.plugins.add_psf.get_moffat_maps_psf(obj_name, ctx)[source]
Set the PSF for objects (stars or galaxies) using maps of the PSF across the sky.
- Parameters:
obj_name – Name of the objects the PSF is evaluated for
ctx – Ivy-context containing the catalog of the object properties
- Return r50:
PSF r50 (flux radius 50%) evaluated at the positions of the input objects
- Return beta:
PSF beta parameter evaluated at the positions of the input objects
- Return e1:
PSF ellipticity 1-component evaluated at the positions of the input objects
- Return e2:
PSF ellipticity 2-component evaluated at the positions of the input objects
- ufig.plugins.add_psf.load_psf_skymaps(psf_maps, par)[source]
Load maps of the PSF across the sky.
- Parameters:
psf_maps – File name of the psf maps (0: r50-map, 1: e1-map, 2: e2-map)
par – ctx.parameters containing potential fudge factors for PSF maps
- Return r50_map:
r50-map containing flux radius (50%)-variations across the survey area
- Return e1_map:
Ellipticity 1-component-map containing variations across the survey area
- Return e2_map:
Ellipticity 2-component-map containing variations across the survey area
- ufig.plugins.add_psf.moffat_alpha2fwhm(psf_alpha, psf_beta)[source]
Computes the fwhm (in the units alpha is in) for a given alpha and beta parameter for a Moffat distribution
- Parameters:
psf_alpha – alpha of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
alpha of the Moffat profile in units of pixels
- ufig.plugins.add_psf.moffat_alpha2r50(psf_alpha, psf_beta)[source]
Computes the r50 (in units of alpha) for a given alpha and beta parameter for a Moffat distribution
- Parameters:
psf_alpha – alpha of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
alpha of the Moffat profile in units of pixels
- ufig.plugins.add_psf.moffat_fwhm2alpha(psf_fwhm, psf_beta)[source]
Computes the alpha parameter for a given FWHM and beta parameter for a Moffat distribution
- Parameters:
psf_fwhm – FWHM of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
alpha of the Moffat profile in units of pixels
- ufig.plugins.add_psf.moffat_fwhm2r50(psf_fwhm, psf_beta, psf_flux_ratio)[source]
Computes the r50 for a given FWHM and beta parameter for the PSF assuming a Moffat distribution
- Parameters:
psf_fwhm – FWHM of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
r50 of the PSF (assuming a Moffat distribution) in units of pixels
- ufig.plugins.add_psf.moffat_profile_integrated(r, psf_beta, psf_flux_ratio)[source]
Evaluates the integrated “1 - Moffat profile” within a radius r (in units of Moffat alpha), which potentially can consist of multiple components, and returns the flux in units of the total flux.
- Parameters:
x – Radius in units of Moffat alpha
psf_beta – Moffat beta parameter(s)
psf_flux_ratio – Fraction of flux in the first component
- Returns:
Flux within a radius r in units of the total flux
- ufig.plugins.add_psf.moffat_r502alpha(psf_r50, psf_beta)[source]
Computes the alpha parameter for a given r50 and beta parameter for a Moffat distribution
- Parameters:
psf_r50 – r50 of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
alpha of the Moffat profile in units of pixels
- ufig.plugins.add_psf.moffat_r502fwhm(psf_r50, psf_beta, psf_flux_ratio)[source]
Computes the FWHM for a given r50 and beta parameter for the PSF assuming a Moffat distribution
- Parameters:
psf_r50 – r50 of the PSF in units of pixels
psf_beta – beta parameter for a Moffat distribution
- Returns:
FWHM of the PSF (assuming a Moffat distribution) in units of pixels
- ufig.plugins.add_psf.multiple_moffat_fwhm(psf_r50, psf_beta, psf_flux_ratio)[source]
Solve the nonlinear equation to recover an effective fwhm of a PSF profile consisting of potentially multiple Moffat profiles. This function is similar to ufig.plugins.add_psf.multiple_moffat_r50().
- Parameters:
psf_fwhm – FWHM of the Moffat profile in pixels
psf_beta – Moffat beta parameter(s)
psf_flux_ratio – Fraction of flux in the first component
- Returns:
r50 of the total PSF profile
- ufig.plugins.add_psf.multiple_moffat_r50(psf_fwhm, psf_beta, psf_flux_ratio)[source]
Solve the nonlinear equation to recover an effective r50 of a PSF profile consisting of potentially multiple Moffat profiles.
- Parameters:
psf_fwhm – FWHM of the Moffat profile in pixels
psf_beta – Moffat beta parameter(s)
psf_flux_ratio – Fraction of flux in the first component
- Returns:
r50 of the total PSF profile
- ufig.plugins.add_psf.numba_min_dist(X, Y)[source]
Finds the index of the closest point in Y for each point in X
- ufig.plugins.add_psf.psf_from_sky_maps(r50_map, e1_map, e2_map, psf_beta, w, x, y, psf_flux_ratio)[source]
Evaluate PSF maps at input positions.
- Parameters:
r50_map – r50-map containing flux radius (50%)-variations across the survey area
e1_map – Ellipticity 1-component-map containing variations across the survey area
e2_map – Ellipticity 2-component-map containing variations across the survey area
psf_beta – PSF beta parameter evaluated at every object’s position
w – wcs-object containing all the relevant wcs-transformation information
x – pixel x-coordinate
y – pixel y-coordinate
psf_flux_ratio – Flux ratio of the different PSF Moffat component(s) relative to the total flux
- Return r50:
PSF r50 (flux radius 50%) evaluated at the input positions
- Return beta:
PSF beta parameter evaluated at the input positions
- Return e1:
PSF ellipticity 1-component evaluated at the input positions
- Return e2:
PSF ellipticity 2-component evaluated at the input positions
- ufig.plugins.add_psf.sample_psf_moffat_constant(obj_name, ctx)[source]
Evaluate a constant, Moffat-PSF field at the positions of different objects (stars or galaxies).
- Parameters:
obj – Name of the objects the PSF is evaluated for
ctx – Ivy-context containing the catalog of the object properties
- Return r50:
PSF r50 (flux radius 50%) evaluated at the positions of the input objects
- Return beta:
PSF beta parameter evaluated at the positions of the input objects
- Return e1:
PSF ellipticity 1-component evaluated at the positions of the input objects
- Return e2:
PSF ellipticity 2-component evaluated at the positions of the input objects
ufig.plugins.background_noise module
Created on Oct 7, 2013 @author: Lukas Gamper
- class ufig.plugins.background_noise.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Generating random Gaussian background noise for each pixel and adding the noise onto the image.
- Parameters:
background_sigma – rms spread of (zero mean) Gaussian background noise
background_seed_offset – seed of the rng used to generate the background noies (optional)
- Returns:
Image with noise added
- ufig.plugins.background_noise.add_from_chunked_map(ctx)[source]
Adds noise to the image using a rms map. The map is memmapped and only read out in quadratic chunks to reduce the memory footprint.
- Parameters:
ctx.image – Simulated image
ctx.params.maps_remote_dir – Path to fits-image containing the RMS of the noise in every pixel of the image
ctx.params.bkg_rms_file_name – Path to fits-image containing the RMS of the noise in every pixel of the image
ctx.params.bkg_noise_scale – Scale factor applied to the map
ctx.params.bkg_noise_amp – Amplitude factor applied to the map
- ufig.plugins.background_noise.add_from_gaussian(ctx)[source]
Adds noise to the image assuming a Gaussian background model. The noise in every pixel is randomly drawn from a Gaussian
- Parameters:
ctx.image – Simulated image
ctx.parameters.bkg_noise_amp – Center of the Gaussian distribution
ctx.parameters.background_sigma – RMS of the Gaussian distribution
- ufig.plugins.background_noise.add_from_map(ctx)[source]
Adds noise to the image using a rms map
- Parameters:
ctx.image – Simulated image
ctx.params.maps_remote_dir – Path to fits-image containing the RMS of the noise in every pixel of the image
ctx.params.bkg_rms_file_name – Path to fits-image containing the RMS of the noise in every pixel of the image :param ctx.params.bkg_noise_scale: Scale factor applied to the map
ctx.params.bkg_noise_amp – Amplitude factor applied to the map
ufig.plugins.background_subtract module
Created on Jan 5, 2016 @author: Tomasz Kacprzak
- ufig.plugins.background_subtract.sigma_clip(data, sig=3, iters=1, cenfunc=<function median>, varfunc=<function var>, maout=False)[source]
Perform sigma-clipping on the provided data.
This performs the sigma clipping algorithm - i.e. the data will be iterated over, each time rejecting points that are more than a specified number of standard deviations discrepant.
Note
scipy.stats.sigmaclip provides a subset of the functionality in this function.
- Parameters:
data – array-like The data to be sigma-clipped (any shape).
sig – float The number of standard deviations (not variances) to use as the clipping limit.
iters – int or NoneThe number of iterations to perform clipping for, or None to clip until convergence is achieved (i.e. continue until the last iteration clips nothing).
cenfunc – callable The technique to compute the center for the clipping. Must be a callable that takes in a 1D data array and outputs the central value. Defaults to the median.
varfunc – callable The technique to compute the variance about the center. Must be a callable that takes in a 1D data array and outputs the width estimator that will be interpreted as a variance. Defaults to the variance.
maout – bool or ‘copy’ If True, a masked array will be returned. If the special string ‘inplace’, the masked array will contain the same array as data, otherwise the array data will be copied.
- Returns:
filtereddata : numpy.ndarray or numpy.masked.MaskedArray If maout is True, this is a masked array with a shape matching the input that is masked where the algorithm has rejected those values. Otherwise, a 1D array of values including only those that are not clipped.
- Returns:
mask : boolean array Only present if maout is False. A boolean array with a shape matching the input data that is False for rejected values and True for all others.
Examples
This will generate random variates from a Gaussian distribution and return only the points that are within 2 sample standard deviation from the median:
>>> from astropy.stats import sigma_clip >>> from numpy.random import randn >>> randvar = randn(10000) >>> data,mask = sigma_clip(randvar, 2, 1)
This will clipping on a similar distribution, but for 3 sigma relative to the sample mean, will clip until converged, and produces a numpy.masked.MaskedArray:
>>> from astropy.stats import sigma_clip >>> from numpy.random import randn >>> from numpy import mean >>> randvar = randn(10000) >>> maskedarr = sigma_clip(randvar, 3, None, mean, maout=True)
ufig.plugins.cleanup_catalogs module
ufig.plugins.cleanup_memory module
ufig.plugins.compression_noise module
Created on 04/2016 @author: Tomasz Kacprzak
ufig.plugins.convert_photons_to_adu module
Created on Aug 19, 2014 @author: Chihway Chang
- class ufig.plugins.convert_photons_to_adu.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Convert integer photon counts into float ADU’s by multiplying the quantum efficiency and dividing gain.
- Parameters:
gain – gain of CCD detector (e/ADU)
- Returns:
image that is rescaled to some specified zero point
ufig.plugins.draw_stars_besancon_map module
Created on Jul 20, 2016 author: Tomasz Kacprzak
- class ufig.plugins.draw_stars_besancon_map.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Draw stars for the r-band from a catalog created using the Besancon model of the Milky Way.
- Parameters:
besancon_cat_name – Path to the catalog of stars drawn from the model stored as fits-file. The catalog must contain a column called ‘r’ giving the magnitude of the stars in the r-band. Furthermore, the header of the HDU in which the catalog is stored must contain a field labeled ‘AREA’ which states the area (in sq. deg) the catalog covers.
seed – General seed.
star_num_seed_offset – Seed offset before number of stars is drawn.
stars_mag_min – Minimum magnitude of stars in the r-band.
stars_mag_max – Maximum magnitude of stars in the r-band.
star_dist_seed_offset – Seed offset before positions of stars are drawn.
star_nphot_seed_offset – Seed offset before numbers of photons are calculated for stars.
n_exp – Number of single exposures in coadded image.
magzero – Magnitude zeropoint.
gain – Gain in electrons per ADU.
exp_time_file_name – File name of an exposure time map.
size_x – Size of the image in x-direction.
size_y – Size of the image in y-direction.
maps_remote_dir – Remote directory where maps are stored.
- ufig.plugins.draw_stars_besancon_map.get_interp_nearest(ra_new, dec_new, dict_besancon_info)[source]
- ufig.plugins.draw_stars_besancon_map.load_besancon_map(ctx)[source]
Simply load the pickle with maps, from par.besancon_map_path return pickle with the Besancon simulation map model, with fields
- dict_besancon_info = {‘simulation_area’: area_store, ‘nside’: nside,
‘healpix_list’: list_df, ‘healpix_mask’: hp_map}
simulation_area - area in sq. deg corresponding to the simulation catalog covers
nside - resolution of simulation sampling
- healpix_list - a list of numpy record arrays, each element corresponds
to a pixel on HEALPix grid with nside=nside
hp_map - HEALPix map showing the coverage of simulations, ring=False
- ufig.plugins.draw_stars_besancon_map.load_besancon_map_pixels(ctx, list_ipix)[source]
Simply load the pickle with maps, from par.besancon_map_path
return pickle with the Besancon simulation map model, with fields
- dict_besancon_info={‘simulation_area’: area_store, ‘nside’: nside,
‘healpix_list’: list_df, ‘healpix_mask’: hp_map}
simulation_area - area in sq. deg corresponding to the simulation catalog covers
nside - resolution of simulation sampling
- healpix_list - a list of numpy record arrays, each element corresponds to a pixel on
HEALPix grid with nside=nside
hp_map - HEALPix map showing the coverage of simulations, ring=False
ufig.plugins.estimate_psf module
ufig.plugins.gamma_interpolation_table module
Created on Nov 24, 2013 @author: Claudio Bruderer
- class ufig.plugins.gamma_interpolation_table.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Loads, or in case explicitly set or non-existent computes on-the-fly, the table with pre-computed values of the inverse gamma function in the range [0,1[ for different Sersic indexes in [0,10[ used in the render_galaxies.py-module to sample the radial cdf.
Optionally a new intrinsic_table can furthermore be saved. Desirably not overwriting the ones in res/intrinsictables/ unless specifically stated.
- Parameters:
sersicprecision – 2**sersicpresicion points to interpolate the Sersic range [0,10]
gammaprecision – 2*(2**gammaprecision) to interpolate the range [0,1[ where the inverse cdf is evaluated
gammaprecisionhigh – Change of point density at 1-2**(-gammaprecisionhigh) (increased precision close to 1)
compute_gamma_table_onthefly – whether or not the interpolation table is computed on the fly
- Returns:
Table containing values of the inv gamma function for different Sersic values in [0,10] and values in [0,1[
- ufig.plugins.gamma_interpolation_table.compute_intrinsictable(sersicprecision, gammaprecision, gammaprecisionhigh)[source]
Compute the table containing values of the inverse gamma function.
- Parameters:
sersicprecision – 2**sersicpresicion points to interpolate the Sersic range [0,10]
gammaprecision – 2*(2**gammaprecision) to interpolate the range [0,1[ where the inverse cdf is evaluated
gammaprecisionhigh – Change of point density at 1-2**(-gammaprecisionhigh) (increased precision close to 1)
- Return intrinsicTable:
Table containing values
- ufig.plugins.gamma_interpolation_table.load_intrinsicTable(sersicprecision, gammaprecision, gammaprecisionhigh, copy_to_cwd=False)[source]
Load the table containing values of the inverse gamma function.
- Parameters:
sersicprecision – 2**sersicpresicion points to interpolate the Sersic range [0,10]
gammaprecision – 2*(2**gammaprecision) to interpolate the range [0,1[ where the inverse cdf is evaluated
gammaprecisionhigh – Change of point density at 1-2**(-gammaprecisionhigh) (increased precision close to 1)
copy_to_cwd – Copy the table to the current working directory
- Return intrinsicTable:
Table containing values
ufig.plugins.match_sextractor_catalog_multiband_read module
Created on Apr 12, 2015 @author: Claudio Bruderer
- class ufig.plugins.match_sextractor_catalog_multiband_read.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Matches a Source Extractor catalog to the input catalogs and adds all the input columns to the Source Extractor catalog.
- ufig.plugins.match_sextractor_catalog_multiband_read.match(x_in, y_in, mag_in, x_out, y_out, mag_out, par)[source]
Match UFig input positions and magnitudes to SExtractor output positions and magnitudes.
- Parameters:
x_in – Input x-coordinates (in SExtractor convention)
y_in – Input y-coordinates (in SExtractor convention)
mag_in – Input magnitudes
x_out – Output x-coordinates
y_out – Output y-coordinates
mag_out – Output magnitudes
par.max_radius – Maximum distance between an input and a detected objects to classify as a match.
par.mag_diff – Maximum magnitude difference between an input and a detected object to classify as a match.
- Returns:
Indices linking detected to input objects.
ufig.plugins.match_sextractor_seg_catalog_multiband_read module
Created on Dec 21, 2023 @author: Beatrice Moser
- class ufig.plugins.match_sextractor_seg_catalog_multiband_read.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Matches a Source Extractor catalog to the input catalogs and adds all the input columns to the Source Extractor catalog.
- ufig.plugins.match_sextractor_seg_catalog_multiband_read.match(x_in, y_in, mag_in, segimage, mag_out, bands)[source]
Match UFig input positions and magnitudes to SExtractor output positions and magnitudes.
- Parameters:
x_in – Input x-coordinates (in SExtractor convention)
y_in – Input y-coordinates (in SExtractor convention)
mag_in – Input magnitudes
mag_out – Output magnitudes
par.mag_diff – Maximum magnitude difference between an input and a detected object to classify as a match.
- Returns:
Indices linking detected to input objects.
ufig.plugins.multi_band_setup module
Created on May 3, 2016 author: Joerg Herbel
- class ufig.plugins.multi_band_setup.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Prepare for the rendering of multiple images. This plugin essentially allows to change the names of files used in the rendering of images in different bands by providing a format for the corresponding file names. This format specifies the way file names are obtained from the name of the tile in the sky and/or the filter band names. It contains ‘{}’ where the tile name and/or the filter band name have to be inserted to obtain the correct file name(s).
- Parameters:
filters – List of names of filter bands used to render images, optional.
tile_name – Name of the tile in the sky corresponding to the images rendered in this run, optional.
image_name_dict – Dictionary of image names for each filter band used to render an image, optional.
image_name_format – Format of images names, used to obtain the image names from the name of the tile and the name(s) of the filter band(s), optional.
galaxy_catalog_name_dict – Dictionary of galaxy catalog names for each filter band used to render an image, optional.
galaxy_catalog_name_format – Format of galaxy catalog names, used to obtain the catalog names from the name of the tile and the name(s) of the filter band(s), optional.
star_catalog_name_dict – Dictionary of star catalog names for each filter band used to render an image.
star_catalog_name_format – Format of star catalog names, used to obtain the catalog names from the name of the tile and the name(s) of the filter band(s), optional.
besancon_cat_name – Name of a catalog of stars drawn from the Besancon model of the galaxy, optional.
besancon_cat_name_format – Format of the name of a catalog of stars drawn from the Besancon model, used to obtain the catalog name from the name of the tile, optional.
exp_time_file_name_dict – Dictionary of file names of maps of exposure times for each filter band used to render an image, optional.
exp_time_file_name_format – Format of file names of maps of exposure times, used to obtain the file names from the name of the tile and the name(s) of the filter band(s), optional.
bkg_rms_file_name_dict – Dictionary of file names of maps of the standard deviation of the background for each filter band used to render an image, optional.
bkg_rms_file_name_format – Format of file names of maps of the standard deviation of the background, used to obtain the file names from the name of the tile and the name(s) of the filter band(s), optional.
psf_maps_dict – Dictionary of file names of PSF maps for each filter band used to render an image, optional.
psf_maps_file_name_format – Format of file names of PSF maps, used to obtain the file names from the name of the tile and the name(s) of the filter band(s), optional.
sextractor_catalog_name_dict – Dictionary of SExtractor catalog names for each filter band used to render an image, optional.
sextractor_catalog_name_format – Format of SExtractor catalog names, used to obtain the catalog names from the name of the tile and the name(s) of the filter band(s), optional.
weight_image_dict – Dictionary of weight image names used by SExtractor for each filter band used to render an image, optional.
weight_image_format – Format of weight image names used by SExtractor, used to obtain the names from the name of the tile and the name(s) of the filter band(s), optional.
- Returns:
ctx.parameters with multi-band dictionaries modified accordingly.
ufig.plugins.read_in_catalog module
Created on May 30, 2015 @author: Claudio Bruderer, adapted by Silvan Fischbacher
- class ufig.plugins.read_in_catalog.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Write star and galaxy catalogs to fits tables. These catalogs are the ufig input catalog, ie. the parameters directly associated with the image.
- Parameters:
overwrite – whether to overwrite existing image
galaxy_catalog_name – name of output galaxy catalog
star_catalog_name – name of output star catalog
- Returns:
star and galaxy catalog
ufig.plugins.render_galaxies_flexion module
Created on Oct 7, 2013 @author: Lukas Gamper
- ufig.plugins.render_galaxies_flexion.integrate_image(buffer, gammaprecision, gammaprecisionhigh, sersicprecision, intrinsic_table, image, x, y, nphot, sersic_indices, gal_ellip_matrices, psf_betas, psf_ellip_matrices, psf_flexion_tensors, psf_kurtoses, psf_dx_offset, psf_dy_offset, psf_flexion_suppression, sort_by_y)[source]
ufig.plugins.render_stars_photon module
Created on Jul 31, 2017 @author: Joerg Herbel
- class ufig.plugins.render_stars_photon.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Render stellar profiles photon-by-photon onto a pixelated grid.
- ufig.plugins.render_stars_photon.integrate_cube(buffer, cube, x, y, nphot, psf_betas, ellip_matrices, flexion_tensors, kurtoses, dx_offset, dy_offset, flexion_suppression, q_xx, q_yy, q_xy)[source]
- ufig.plugins.render_stars_photon.integrate_image_phot(buffer, image, x, y, nphot, psf_betas, ellip_matrices, flexion_tensors, kurtoses, dx_offset, dy_offset, flexion_suppression, sort_by_y)[source]
- ufig.plugins.render_stars_photon.integrate_image_pixel(seed, image, gain, render_stars_accuracy, x, y, nphot, psf_beta, psf_flux_ratio, psf_fwhm, psf_e1, psf_e2, psf_dx_offset, psf_dy_offset)[source]
ufig.plugins.resample module
Created on Oct 7, 2013 @author: Lukas Gamper
- class ufig.plugins.resample.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Convolve the image with a Lanczos kernel to model the effect of correlated noise. The main effect of correlated noise modeled by this kernel is that coming from the coadding process.
- Parameters:
lanczos_n – the order of lanczos function used to model the resampling
- Returns:
image after the lanczos convolution
ufig.plugins.run_detection_classifier module
ufig.plugins.run_emulator module
ufig.plugins.run_nflow module
ufig.plugins.run_sextractor module
Created on Jun 3, 2014 @author: Lukas Gamper
- class ufig.plugins.run_sextractor.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Executes sextractor by spawning a subprocess.
:param image_name of image :param sextractor_binary: path to sextractor binary :param sextractor_config: c :param saturation_level: SATUR_LEVEL :param magzero_point: MAG_ZEROPOINT :param gain: GAIN :param sextractor_nnw: STARNNW_NAME :param sextractor_filter: FILTER_NAME :param sextractor_params: PARAMETERS_NAME :param sextractor_catalog_name: CATALOG_NAME :param sextractor_checkimages: CHECKIMAGE_TYPE :param sextractor_checkimages_suffixes: Suffixes to construct CHECKIMAGE_NAME from
sextractor_catalog_name
ufig.plugins.run_sextractor_forced_photometry module
Created on Jul 12, 2016 @author: Joerg Herbel
- class ufig.plugins.run_sextractor_forced_photometry.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Run SExtractor in forced-photometry mode.
- ufig.plugins.run_sextractor_forced_photometry.build_sextractor_cmd(binary_name, image_name, config_name, **kwargs)[source]
Construct a list of strings which make up a valid command line argument to call SExtractor.
- Parameters:
binary_name – Path of SExtractor executable
image_name – Path(s) of image(s) on which SExtractor will run
config_name – Path of SExtractor configuration file
kwargs – Keyword arguments that can be converted to SExtractor command line arguments
- Returns:
Command to call SExtractor as a list of strings
- ufig.plugins.run_sextractor_forced_photometry.checkimages_to_hdf(checkimage_type, checkimages_names_fits, checkimages_names_hdf5, kw_dataset=None)[source]
- ufig.plugins.run_sextractor_forced_photometry.convert_fits_to_hdf(filepath_fits, fits_ext=2)[source]
- ufig.plugins.run_sextractor_forced_photometry.enforce_abs_path(path)[source]
Build an absolute path using the path of the SExtractor directory in UFig. In case the input is already a path (and not only a filename), it is left unchanged.
- Parameters:
path – Input path
- Returns:
Absolute path
- ufig.plugins.run_sextractor_forced_photometry.get_checkimages(sextractor_catalog_name, sextractor_checkimages, sextractor_checkimages_suffixes)[source]
- ufig.plugins.run_sextractor_forced_photometry.kwarg_to_sextractor_arg(key, value)[source]
Construct a SExtractor command line argument from a keyword argument. The key of the keyword argument must be a valid SExtractor parameter (modulo upper cases). The value must convertible to a string. It can also be an iterable containing only objects that can be converted to a string.
- Parameters:
key – Key
value – Value
- Returns:
SExtractor command line argument as a list in the form [-<PARAM_NAME>, VALUE]
- ufig.plugins.run_sextractor_forced_photometry.run_sextractor(binary_name, image_name, config_name, **kwargs)[source]
Run SExtractor by spawning a subprocess.
- Parameters:
binary_name – Path of SExtractor executable
image_name – Path(s) of image(s) on which SExtractor will run
config_name – Path of SExtractor configuration file
kwargs – Keyword arguments that can be converted to SExtractor command line arguments
ufig.plugins.saturate_pixels module
Created on Oct 7, 2013 @author: Lukas Gamper
- class ufig.plugins.saturate_pixels.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
For pixels that exceed the saturation flux, leak the photons in the column direction until all pixels are under the saturation level.
- Parameters:
gain – gain of CCD detector (e/ADU)
size_x – size of image in x-direction (pixel)
size_y – size of image in y-direction (pixel)
saturation_level – saturation level in electrons
ufig.plugins.saturate_pixels_x module
Created on Oct 7, 2013 @author: Lukas Gamper
- class ufig.plugins.saturate_pixels_x.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
For pixels that exceed the saturation flux, leak the photons in the column direction until all pixels are under the saturation level.
- Parameters:
gain – gain of CCD detector (e/ADU)
size_x – size of image in x-direction (pixel)
size_y – size of image in y-direction (pixel)
saturation_level – saturation level in electrons
ufig.plugins.single_band_setup module
Created on Feb 09, 2016 author: Joerg Herbel
- class ufig.plugins.single_band_setup.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Set parameters to render an image according to the current filter band and multi-band dictionaries. The number of photons is also calculated here.
- exception ufig.plugins.single_band_setup.UFigNumPhotError[source]
Bases:
ValueError
Raised when more photons (for galaxies) than allowed by the input parameters are sampled
- ufig.plugins.single_band_setup.convert_magnitude_to_nphot_const_gain(mag, par, gain, x=None, y=None, texp_img=None, n_exp=None)[source]
Convert the magnitude into a number of photons to be sampled later on
- Parameters:
mag – magnitude of the objects
par – Container of ctx.parameters parameters (magzero & gain)
x – x-coordinate of objects (in pixels) (not used here)
y – y-coordinate of objects (in pixels) (not used here)
texp_img – Image contining the exposure times at each position (not used here)
n_exp – number of exposures
- Returns:
Number of photons
- ufig.plugins.single_band_setup.convert_magnitude_to_nphot_const_texp(mag, par, x=None, y=None, texp_img=None, n_exp=None)[source]
Convert the magnitude into a number of photons to be sampled later on
- Parameters:
mag – magnitude of the objects
par – Container of ctx.parameters parameters (magzero & gain)
x – x-coordinate of objects (in pixels) (not used here)
y – y-coordinate of objects (in pixels) (not used here)
texp_img – Image contining the exposure times at each position (not used here)
n_exp – number of exposures
- Returns:
Number of photons
- ufig.plugins.single_band_setup.convert_magnitude_to_nphot_variable_texp(mag, par, x, y, texp_img=None, n_exp=None)[source]
Convert the magnitude into a number of photons to be sampled later on
- Parameters:
mag – magnitude of the objects
par – self.ctx.parameters; must contain: magzero: magnitude zero point of target image gain: gain of the target image exp_time_file_name: file name of the exposure time image maps_remote_dir: Remote directory images and maps are stored in if not at ‘res/maps/’
x – x-coordinate of objects (in pixels)
y – y-coordinate of objects (in pixels)
texp_img – Image contining the exposure times at each position
n_exp – number of exposures (not used here)
- Returns:
Number of photons
- ufig.plugins.single_band_setup.convert_magnitude_to_nphot_with_gain_map(mag, par, x, y, **args)[source]
Convert the magnitude into a number of photons to be sampled later on
- Parameters:
mag – magnitude of the objects
par – self.ctx.parameters; must contain: magzero: magnitude zero point of target image gain: gain of the target image exp_time_file_name: file name of the exposure time image maps_remote_dir: Remote directory images and maps are stored in if not at ‘res/maps/’
x – x-coordinate of objects (in pixels)
y – y-coordinate of objects (in pixels)
texp_img – Image contining the exposure times at each position
n_exp – number of exposures (not used here)
- Returns:
Number of photons
ufig.plugins.single_band_setup_intrinsic_only module
ufig.plugins.write_catalog module
Created on Aug 2021 author: Tomasz Kacprzak
ufig.plugins.write_catalog_for_emu module
Created 2024 author: Silvan Fischbacher
- ufig.plugins.write_catalog_for_emu.add_blending_binned_integrated(cat, par)[source]
Computes the average galaxy density weighted by magnitude and sizes to estimate the blending risk. The image is divided into bins and the value is computed for each bin.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with additional column
“density_mag_weighted” and “density_size_weighted”
- ufig.plugins.write_catalog_for_emu.add_blending_full_image(cat, par)[source]
Add blending information to catalog estimating the flux at all positions.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with blending information
- ufig.plugins.write_catalog_for_emu.add_blending_integrated(cat, par)[source]
Computes the average galaxy density weighted by magnitude and sizes to estimate the blending risk. The value is the same for all objects in the image.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with additional column
“density_mag_weighted” and “density_size_weighted”
- ufig.plugins.write_catalog_for_emu.add_blending_ngal(cat, par)[source]
Computes the number of galaxies for different magnitude cuts. This can later be used to estimate the blending risk.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with additional column “ngal_{}”.format(mag_cuts)
- ufig.plugins.write_catalog_for_emu.add_blending_points(cat, par)[source]
Add blending information to catalog estimating only the flux at the position of the objects.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with blending information
- ufig.plugins.write_catalog_for_emu.add_no_blending(cat, par)[source]
Add no blending information to the catalog.
- Parameters:
cat – catalog
par – context parameters
- Returns:
catalog with no blending information
- ufig.plugins.write_catalog_for_emu.enrich_catalog(cat, par)[source]
Enrich the catalog with computed columns: absolute ellipticity, noise levels
- Parameters:
cat – catalog
par – ctx parameters
catalog_precision – precision of the catalog
- Returns:
catalog with additional columns
- ufig.plugins.write_catalog_for_emu.enrich_star_catalog(cat, par)[source]
Add additional columns to the star catalog such that it can be used the same way as the galaxy catalog
- Parameters:
cat – catalog of stars
par – ctx parameters
catalog_precision – precision of the catalog
- Returns:
catalog of stars with additional columns and a list of the new column names
- ufig.plugins.write_catalog_for_emu.estimate_flux_full_image(cat, imshape=(4200, 4200), max_mag=26, n_half_light_radius=5)[source]
Estimates the flux of the image from catalog (with magnitude cut)
- Parameters:
cat – catalog
imshape – shape of the image
max_mag – maximum magnitude that is considered for blending
n_half_light_radius – number of half light radii to consider for each galaxy
- Returns:
estimated flux of the image
- ufig.plugins.write_catalog_for_emu.estimate_flux_of_points(cat, imshape=(4200, 4200), max_mag=26, n_half_light_radius=5)[source]
Estimates the flux of the points of the image where the galaxies are located.
- Parameters:
cat – catalog
- Returns:
estimated flux at the points of the galaxies
- ufig.plugins.write_catalog_for_emu.get_elliptical_indices(x, y, r50, e1, e2, imshape=(4200, 4200), n_half_light_radius=5, pre_selected_indices=None)[source]
Get the indices of the pixels within an elliptical region and their distances from the center. The distance is normalized to true pixel distance in the elliptical coordinate system. If the radius is too small to include any pixel, the center pixel is returned.
- Parameters:
x – x coordinate of the center of the ellipse
y – y coordinate of the center of the ellipse
r50 – (half light) radius of the ellipse
e1 – ellipticity component 1
e2 – ellipticity component 2
imshape – shape of the image
n_half_light_radius – number of half light radii to consider
pre_selected_indices – pre-selected indices of the image where the distance
should be calculated, tuple of (x, y) indices :return: indices of the pixels within the elliptical region and their distances from the center
ufig.plugins.write_image module
Created on Oct 7, 2013 @author: Lukas Gamper
- class ufig.plugins.write_image.Plugin(ctx, **kwargs)[source]
Bases:
BasePlugin
Write a general ufig image into a FITS file with minimum basic header information.
- ufig.plugins.write_image.get_seeing_value(ctx)[source]
Returns the seeing value of the simulated image.
- Parameters:
ctx – Context
- Returns:
Seeing in pixels