ufig package

Subpackages

Submodules

ufig.array_util module

Created on Dec 5, 2016

author: tomaszk

ufig.array_util.check_flag_bit(flags, flagbit)[source]
ufig.array_util.check_flag_bit_single(value, bit)[source]
ufig.array_util.clear_flag_bit_single(value, bit)[source]
ufig.array_util.rec_float64_to_float32(cat)[source]
ufig.array_util.set_flag_bit(flags, select, field)[source]
ufig.array_util.set_flag_bit_single(value, bit)[source]

ufig.io_util module

Created on Nov 3, 2015

author: jakeret

ufig.io_util.get_abs_path(file_name, root_path='res/maps/', is_file=True, package_name='ufig')[source]

Resolves the absolute path for a file or a directory.

In case the input is treated as a file (is_file=True), the function tries the following steps: 1) if file_name is already an absolute path, then just return it 2) if root_path is an absolute path the path is simply concatenated 3) checking in the ufig package structure 4) using DarkSkySync

In case the input should be treated as a directory (is_file=False), the function tries the following steps: 1) if file_name is already an absolute path, then just return it 2) if root_path is an absolute path the path is simply concatenated 3) checking in the ufig package structure

Returns path:

local absolute path to the file or directory if possible

ufig.io_util.get_local_abs_path(path)[source]
ufig.io_util.load_from_hdf5(file_name, hdf5_keys, hdf5_path='', root_path='res/maps/')[source]

Load data stored in a HDF5-file. :param file_name: Name of the file. :param hdf5_keys: Keys of arrays to be loaded. :param hdf5_path: Path within HDF5-file appended to all keys. :param root_path: Relative or absolute root path. :return: Loaded arrays.

ufig.io_util.load_hpmap(file_name, root_path, ext=1)[source]

Loads a healpix map and returns it in the ring-scheme

Parameters:
  • file_name – name of the file

  • root_path – relative root path

  • ext – Extension of Healpix-maps (by default = 1)

ufig.io_util.load_image(file_name, size_x, size_y, root_path='res/maps/', ext=0, **kwargs)[source]

Loads an image from stored in a fits file :param file_name: name of the file :param size_x: max x size :param size_y: max y size :param root_path: relative root path :param ext: fits extention

ufig.io_util.load_image_chunks(file_name, ext=0, dtype=<class 'numpy.float64'>, n_pix_per_row=100)[source]
ufig.io_util.write_hpmap(maps, file_path, **kwargs)[source]

Writes Healpix maps ensuring a format that can be loaded easily with fits.getdata() and displayed properly with Aladin.

Parameters:
  • maps – 1 or 3 (given as a list) Healpix maps

  • file_path – path where maps need to be stored

ufig.mask_utils module

Created on Feb 5, 2019 author: Joerg Herbel

ufig.mask_utils.decimal_integer_to_binary(n_bits, arr_decimal, dtype_out)[source]

Transform a one-dimensional array of decimal integers into its binary representation. Returns an array with the shape (len(arr_decimal), n_bits). To reconstruct arr_decimal[i], one would perform the operation

arr_decimal[i] = np.sum(2**np.arange(n_bits) * arr_binary[i])

This means that this binary representation is reversed with respect to what is normally used. For example, normally,

1100 = 1 * 2**3 + 1 * 2**2 + 0 * 2**1 + 0 * 2**0.

However, here we have

1100 = 1 * 2**0 + 1 * 2**1 + 0 * 2**2 + 0 * 2**3.

ATTENTION: THIS FUNCTION MODIFIES ARR_DECIMAL IN PLACE!

ufig.mask_utils.get_binary_mask_dtype(n_bits)[source]
ufig.mask_utils.pixel_mask_to_catalog_mask(pixel_mask, cat, off_mask_radius)[source]
ufig.mask_utils.pixel_mask_to_ucat_catalog_mask(pixel_mask, cat, off_mask_radius, r50_offset=5)[source]
ufig.mask_utils.select_off_mask(xs, ys, rs, mask)[source]
ufig.mask_utils.set_masked_pixels(pixel_mask, maskbits_keep, n_bits)[source]

Set pixels which are masked according to input bits. This function modifies pixel_mask in-place. :param pixel_mask: mask :param maskbits_keep: mask bits to keep :param n_bits: … :return: mask with only bits to keep switched on (same shape as input mask)

ufig.rendering_util module

Created on Jul 31, 2017 @author: Joerg Herbel

ufig.rendering_util.add_photon(image, x, y, dx, dy)[source]

Add one photon to image. :param image: image :param x: centroid x-position :param y: centroid y-position :param dx: x-coordinate sampled from light profile :param dy: y-coordinate sampled from light profile :return:

ufig.rendering_util.compute_ellip_matrices(size, e1, e2)[source]

size can either be the PSF fwhm or the intrinsic galaxy r50

ufig.rendering_util.compute_flexion_tensors(fwhm, f1, f2, g1, g2)[source]
ufig.rendering_util.compute_kurtoses(fwhm, kurtoses, beta)[source]
ufig.rendering_util.distribute_photons_psf_profiles(nphot, n_profiles, flux_ratio)[source]
ufig.rendering_util.draw_photon_gal(rng_buffer, sin_table, cos_table, gammaprecision, gammaprecisionhigh, intrinsic_sersic_l, intrinsic_sersic_b, intrinsic_table, rng, ellip_matrix)[source]
ufig.rendering_util.draw_photon_psf(rng_buffer, sin_table, cos_table, alpha_by_fwhm, beta_power, rng, ellip_matrix, flexion_tensor, kurtosis, flexion_suppression, kurtosis_suppression, dx_offset, dy_offset)[source]
ufig.rendering_util.draw_photon_psf_radial(rng_buffer, sin_table, cos_table, rng, alpha_by_fwhm, beta_power)[source]
ufig.rendering_util.execute_threaded(func, n_threads, *args)[source]
ufig.rendering_util.integrate_pixel_psf(alpha_sq, beta, r50, e1, e2, dx_offset, dy_offset, nphot, min_x, max_x, min_y, max_y, offset_x, offset_y, mean)[source]
ufig.rendering_util.moffat_cdf_factors(psf_beta)[source]
ufig.rendering_util.psf_flexion_suppression(beta, flexion_suppression)[source]
ufig.rendering_util.psf_kurtosis_suppression(beta)[source]
ufig.rendering_util.rng_buffer()[source]
ufig.rendering_util.sin_cos_table()[source]
ufig.rendering_util.split_array(arr, n_split)[source]

ufig.run_util module

Created on Sep 30, 2016 @author: Joerg Herbel

ufig.run_util.run_ufig_from_config(config, **kwargs)[source]

Run UFig using an (importable) configuration file. Additional parameters can be provided as keyword arguments. :param config: Importable configuration file. :param kwargs: Additional parameter values. :return: Ivy-context created by UFig

ufig.sysmaps_util module

Created on Nov 16, 2016 author: Tomasz Kacprzak

ufig.sysmaps_util.chi_mean_combination_lowmem(par)[source]

This creates a CHI-MEAN detection image, as is done by the DES pipeline, see https://iopscience.iop.org/article/10.3847/1538-4365/aab4f5/pdf (DOI: 10.3847/1538-4365/aab4f5), appendix B.

Copy of chi_mean_combination made to run with low memory

Parameters:

images_and_weights – iterable yielding images with weights to be combined

Returns:

chi-mean detection image

ufig.sysmaps_util.chi_mean_loop(detect_image, n_contribute, arange_mu)[source]
ufig.sysmaps_util.get_detection_image(par)[source]

Constructs the detection image for SExtractor. In case of a single-band detection image, simply writes the weight map of the detection band to a fits file. For multi-band detection, the function computes the CHI-MEAN combination of the detection band images and their weights. :param par: ctx.parameters :return: path to detection image (fits), path to detection weights (fits or ‘NONE’),

weight type of detection image for SExtractor, either according to input parameters (single-band) or ‘NONE’ (multi-band detection image)

ufig.sysmaps_util.get_hdf_location_bgrms(par, band=None)[source]

Get the filename and dataset for the background noise map :param par: ctx().parameters structure :param band: which band to use (if None, use the single-band parameter values) :return: filepath, dataset: path and dataset index in hdf file

ufig.sysmaps_util.get_hdf_location_exptime(par, band=None)[source]

Get the filename and dataset for the exposure time map :param par: ctx().parameters structure :param band: which band to use (if None, use the single-band parameter values) :return: filepath, dataset: path and dataset index in hdf file

ufig.sysmaps_util.get_hdf_location_gain(par, band=None)[source]

Get the filename and dataset for the background noise map :param par: ctx().parameters structure :param band: which band to use (if None, use the single-band parameter values) :return: filepath, dataset: path and dataset index in hdf file

ufig.sysmaps_util.get_hdf_location_invvar(par, band=None)[source]

Get the filename and dataset for the inverse variance map :param par: ctx().parameters structure :param band: which band to use (if None, use the single-band parameter values) :return: filepath, dataset: path and dataset index in hdf file

ufig.sysmaps_util.get_path_temp_sextractor_weight(par, band)[source]

Constructs the path to the temporary fits-file with the weights for SExtractor :param par: ctx.parameters :param band: filter band :return: path

ufig.sysmaps_util.stack_detect_image(detect_image, n_contribute, image, weights)[source]
ufig.sysmaps_util.write_temp_sextractor_weight(par, path_out, band=None, dtype=<class 'numpy.float32'>)[source]

Reads out the weight map (inverse variance) from hdf5 and writes it to fits, s.t. it can be used by SExtractor :param par: ctx.parameters :param path_out: path where weight map will be stored :param band: filter band

ufig.sysmaps_util.write_temp_sextractor_weights(par, dirpath_temp, overwrite_photo=True, overwrite_det=True, dtype=<class 'numpy.float32'>)[source]

Write fits weight maps for SExtractor in the temp folder.

Parameters:
  • par – ctx().parameters structure

  • dirpath_temp – temp dir where to write files

  • overwrite_photo – if to overwrite photometry weight if exists

  • overwrite_det – if to overwrite detection weight if exists

Returns:

filepath_fits_photometry, filepath_fits_detection: paths to decompressed weights

ufig.workflow_util module

Created on Jun 15, 2016 author: Joerg Herbel

class ufig.workflow_util.FiltersStopCriteria[source]

Bases: StopCriteria

Stopping criteria for ivy-loops which makes the loop iterate over all filters in ctx.parameters.filters. It also sets the variable ctx.current_filter according to the current loop iteration.

is_stop()[source]

Module contents