shapepipe.modules.ngmix_package.ngmix

shapepipe.modules.ngmix_package.ngmix

NGMIX.

This module contains a class for ngmix shape measurement.

Author

Axel Guinot

class Ngmix(input_file_list, output_dir, file_number_string, zero_point, pixel_scale, f_wcs_path, w_log, id_obj_min=- 1, id_obj_max=- 1)[source]

Bases: object

Ngmix.

Class to handle NGMIX shapepe measurement.

Parameters
  • input_file_list (list) – Input files

  • output_dir (str) – Output directory

  • file_number_string (str) – File numbering scheme

  • zero_point (float) – Photometric zero point

  • pixel_scale (float) – Pixel scale in arcsec

  • f_wcs_path (str) – Path to merged single-exposure single-HDU headers

  • w_log (logging.Logger) – Logging instance

  • id_obj_min (int, optional) – First galaxy ID to process, not used if the value is set to -1; the default is -1

  • id_obj_max (int, optional) – Last galaxy ID to process, not used if the value is set to -1; the default is -1

Raises

IndexError – If the length of the input file list is incorrect

classmethod MegaCamFlip(vign, ccd_nb)[source]

Flip for MegaCam.

MegaCam has CCDs that are upside down. This function flips the postage stamps in these CCDs.

Parameters
  • vign (numpy.ndarray) – Array containing the postage stamp to flip

  • ccd_nb (int) – ID of the CCD containing the postage stamp

Returns

The flipped postage stamp

Return type

numpy.ndarray

get_prior()[source]

Get Prior.

Return prior for the different parameters.

Returns

Priors for the different parameters

Return type

ngmix.priors

compile_results(results)[source]

Compile Results.

Prepare the results of NGMIX before saving.

Parameters

results (dict) – Results of NGMIX metacal

Returns

Compiled results ready to be written to a file

Return type

dict

Raises

KeyError – If SNR key not found

save_results(output_dict)[source]

Save Results.

Save the results into a FITS file.

Parameters

output_dict – Dictionary containing the results

process()[source]

Process.

Funcion to processs NGMIX.

Returns

Dictionary containing the NGMIX metacal results

Return type

dict

get_guess(img, pixel_scale, guess_flux_unit='img', guess_size_type='T', guess_size_unit='sky', guess_centroid=True, guess_centroid_unit='sky')[source]

Get Guess.

Get the guess vector for the NGMIX shape measurement [center_x, center_y, g1, g2, size_T, flux]. No guesses are given for the ellipticity (0, 0).

Parameters
  • img (numpy.ndarray) – Array containing the image

  • pixel_scale (float) – Approximation of the pixel scale

  • guess_flux_unit (str) – If img returns the flux in pixel units, otherwise if sky returns the flux in \({\rm arcsec}^{-2}\)

  • guess_size_type (str) – If T returns the size in quadrupole moments definition \(2\sigma^2\), otherwise if sigma returns the moments \(\sigma\)

  • guess_size_unit (str) – If img returns the size in pixel units, otherwise if sky returns the size in arcsec

  • guess_centroid (bool) – If True, will return a guess on the object centroid, otherwise if False, will return the image centre

  • guess_centroid_unit (str) – If img returns the centroid in pixel unit, otherwise if sky returns the centroid in arcsec

Returns

Return the guess array [center_x, center_y, g1, g2, size_T, flux]

Return type

numpy.ndarray

Raises
  • GalSimHSMError – For an error in the computation of adaptive moments

  • ValueError – For invalid unit guess types

make_galsimfit(obs, model, guess0, prior=None, ntry=5)[source]

Make GalSim Fit.

Fit image using simple GalSim model.

Parameters
  • obs (ngmix.observation.Observation) – Image to fit

  • model (str) – Model for fit

  • guess0 (numpy.ndarray) – Parameters of first model guess

  • prior (ngmix.prior, optional) – Prior for fit paraemeters

  • ntry (int, optional) – Number of tries for fit, the default is 5

Returns

Results

Return type

dict

Raises

ngmix.BootGalFailure – Failure to bootstrap galaxy

get_jacob(wcs, ra, dec)[source]

Get Jacobian.

Return the Jacobian of the WCS at the required position.

Parameters
  • wcs (astropy.wcs.WCS) – WCS object for which we want the Jacobian

  • ra (float) – RA position of the center of the vignet (in degrees)

  • dec (float) – Dec position of the center of the vignet (in degress)

Returns

Jacobian of the WCS at the required position

Return type

galsim.wcs.BaseWCS.jacobian

get_noise(gal, weight, guess, pixel_scale, thresh=1.2)[source]

Get Noise.

Compute the sigma of the noise from an object postage stamp. Use a guess on the object size, ellipticity and flux to create a window function.

Parameters
  • gal (numpy.ndarray) – Galaxy image

  • weight (numpy.ndarray) – Weight image

  • guess (list) – Gaussian parameters fot the window function [x0, y0, g1, g2, T, flux]

  • pixel_scale (float) – Pixel scale of the galaxy image

  • thresh (float, optional) – Threshold to cut the window function, cut = thresh * \(\sigma_{\rm noise}\); the default is 1.2

Returns

Sigma of the noise on the galaxy image

Return type

float

do_ngmix_metacal(gals, psfs, psfs_sigma, weights, flags, jacob_list, prior, pixel_scale)[source]

Do Ngmix Metacal.

Perform the metacalibration on a multi-epoch object and return the joint shape measurement with NGMIX.

Parameters
  • gals (list) – List of the galaxy vignets

  • psfs (list) – List of the PSF vignets

  • psfs_sigma (list) – List of the sigma PSFs

  • weights (list) – List of the weight vignets

  • flags (list) – List of the flag vignets

  • jacob_list (list) – List of the Jacobians

  • prior (ngmix.priors) – Priors for the fitting parameters

  • pixel_scale (float) – pixel scale in arcsec

Returns

Dictionary containing the results of NGMIX metacal

Return type

dict