starred.procedures package
Submodules
starred.procedures.psf_routines module
- starred.procedures.psf_routines.build_psf(image, noisemap, subsampling_factor, masks=None, n_iter_analytic=40, n_iter_adabelief=2000, guess_method_star_position='barycenter', guess_fwhm_pixels=3.0, field_distortion=False, stamp_coordinates=None, adjust_sky=False)[source]
Routine taking in cutouts of stars (shape (N, nx, ny), with N the number of star cutouts, and nx,ny the shape of each cutout) and their noisemaps (same shape), producing a narrow PSF with pixel grid of the given subsampling_factor
- Parameters:
image (array, shape (imageno, nx, ny)) – array containing the data
noisemap (array, shape (imageno, nx, ny)) – array containing the noisemaps.
subsampling_factor (int) – by how much we supersample the PSF pixel grid compare to data.
masks (optional, array of same shape as image and noisemap containing 1 for pixels to be used, 0 for pixels to be ignored.)
n_iter_analytic (int, optional, number of iterations for fitting the moffat in the first step)
n_iter_adabelief (int, optional, number of iterations for fitting the background in the second step)
guess_method_star_position (str, optional, one of 'barycenter', 'max' or 'center')
guess_fwhm_pixels (float, the estimated FWHM of the PSF, is used to initialize the moffat. Default 3.)
field_distortion (whether we allow the psf to vary across the field. If yes, 'stamp_coordinates' must be supplied.)
stamp_coordinates (array of shape (imageno, 2), the pixel coordinates of the different stars in data.)
adjust_sky (bool, optional, if True, the sky level is adjusted for each PSF star. Default False.)
- Returns:
result – dictionary containing the narrow PSF (key narrow_psf) and other useful things.
- Return type:
dictionary.
- starred.procedures.psf_routines.narrow_psf_from_model(full_psf_model, subsampling_factor_in, subsampling_factor_out, mode='fourier_division')[source]
Compute the narrow PSF from a full PSF model.
- Parameters:
full_psf_model – array containing the full PSF model
subsampling_factor_in – int, subsampling factor of the provided full PSF model
subsampling_factor_out – int, subsampling factor of the desired narrow PSF
- Return narrow_psf:
array containing the narrow PSF
- starred.procedures.psf_routines.run_multi_steps_PSF_reconstruction(data, model, parameters, sigma_2, masks=None, star_positions=None, lambda_scales=1.0, lambda_hf=1.0, lambda_positivity=0.0, fitting_sequence=[['background'], ['moffat']], optim_list=['l-bfgs-b', 'adabelief'], kwargs_optim_list=None, method_noise='MC', regularize_full_psf=False, adjust_sky=False, verbose=True)[source]
A high level function for a custom fitting sequence. Similar to build_psf() but with more options.
- Parameters:
data – array containing the observations
model – Point Spread Function (PSF) class from
starred.psf.psfparameters – parameters class from
starred.psf.parameterssigma_2 – array containing the square of the noise maps
star_positions – default None, array of shape (N, 2) containing pixel coordinates of the stars (center of the image: (0,0)).
lambda_scales – Lagrange parameter that weights intermediate scales in the transformed domain.
lambda_hf – Lagrange parameter weighting the highest frequency scale
lambda_positivity – Lagrange parameter weighting the positivity of the full PSF. 0 means no positivity constraint (recommended).
fitting_sequence – list, List of lists, containing the element of the model to keep fixed. Example : [[‘pts-source-astrometry’,’pts-source-photometry’,’background’],[‘pts-source-astrometry’,’pts-source-photometry’], …]
optim_list – List of optimiser. Recommended if background is kept constant : ‘l-bfgs-b’, ‘adabelief’ otherwise.
kwargs_optim_list – List of dictionary, containing the setting for the different optimiser.
method_noise – method for noise propagation. Choose ‘MC’ for an empirical propagation of the noise or ‘SLIT’ for analytical propagation.
regularize_full_psf – True if you want to regularize the Moffat and the background. False regularizes only the background (recommended)
masks – array containing the masks for the PSF (if given)
adjust_sky – bool, if True, the sky level is adjusted for each PSF star. Default False
:return model, parameters, loss, kwargs_partial_list, LogL_list, loss_history_list
- starred.procedures.psf_routines.sanitize_inputs(image, noisemap, masks)[source]
Sanitizes input arrays by masking NaN values and updating masks, image, and noisemap accordingly.
- Parameters:
image (array (numpy.ndarray or jax.numpy.ndarray)) – The input image array of shape (N, nx, ny) where N is the number of stamps.
noisemap (array (numpy.ndarray or jax.numpy.ndarray)) – The noise map array of shape (N, nx, ny) where N is the number of stamps.
masks (array (numpy.ndarray or jax.numpy.ndarray)) – The mask array of shape (N, nx, ny) where N is the number of stamps.
- Returns:
image (array (numpy.ndarray or jax.numpy.ndarray)) – The sanitized image array with NaN values replaced by 0.
noisemap (array (numpy.ndarray or jax.numpy.ndarray)) – The sanitized noisemap array with NaN values replaced by 1.
masks (array (numpy.ndarray or jax.numpy.ndarray)) – The updated mask array where positions with NaN in image or noisemap are set to False.
- starred.procedures.psf_routines.update_PSF(kernel_old, data, sigma_2, masks=None, lambda_scales=2.0, lambda_hf=2.0, lambda_positivity=0.0, subsampling_factor=2.0, optim_list=None, kwargs_optim_list=None, method_noise='MC', verbose=True, normalise_data=True, show_plots=False)[source]
Update the PSF model from a provided kernel. It will not use the Moffat and the PSF will entirely be described by the grid of pixel.
- Parameters:
kernel_old – array containing the first guess of the kernel (should be the narrow PSF ideally…)
data – arrays containing the observations. Dimension (Nstar x Npix x Npix)
sigma_2 – arrays containing the noise maps. Dimension (Nstar x Npix x Npix)
masks – array containing the masks for the PSF (if given)
lambda_scales – Lagrange parameter that weights intermediate scales in the transformed domain.
lambda_hf – Lagrange parameter weighting the highest frequency scale
lambda_positivity – Lagrange parameter weighting the positivity of the full PSF. 0 means no positivity constraint (recommended).
subsampling_factor – int, by how much we supersample the PSF pixel grid compare to data.
optim_list – List of 3 optimisers, one for each step of the fit. Default: [‘l-bfgd-b’, ‘adabelief’, ‘adabelief’]
kwargs_optim_list – List of 3 dictionaries, containing the setting for the different optimiser. Default: None
method_noise – method for noise propagation. Choose ‘MC’ for an empirical propagation of the noise or ‘SLIT’ for analytical propagation. Default: ‘MC’
verbose – bool, if True, print the progress of the fit. Default: True
normalise_data – bool, if True, renormalise the data before running the fit. Default: True
show_plots – bool, if True, show the plots of the fit. Default: False
- Return kernel_new:
array containing the new full PSF
- Return narrow_psf:
array containing the narrow PSF
- Return psf_kernel_list:
list of arrays containing the PSF kernels fitted to the data
- Return starred_output:
list containing the model, parameters, loss, kwargs_partial_list, LogL_list, loss_history_list, norm
starred.procedures.deconvolution_routines module
- starred.procedures.deconvolution_routines.multi_steps_deconvolution(data, model, parameters, sigma_2, s, subsampling_factor, fitting_sequence=[['background'], ['pts-source-astrometry'], []], optim_list=['l-bfgs-b', 'adabelief', 'adabelief'], kwargs_optim_list=None, lambda_scales=1.0, lambda_hf=1000.0, lambda_positivity_bkg=100, lambda_positivity_ps=100, lambda_pts_source=0.0, prior_list=None, regularize_full_model=False, update_lambda_pts_source=False, adjust_sky=False, noise_propagation='MC', regularization_terms='l1_starlet', verbose=True)[source]
A high-level function to run several time the optimization algorithms and ensure to find the optimal solution.
- Parameters:
data – 3D array containing the images, one per epoch. shape (epochs, im_size, im_size)
model – Deconv class, deconvolution model
parameters – ParametersDeconv class
sigma_2 – 3D array containing the noisemaps, one per epoch. shape (epochs, im_size, im_size)
s – 3D array containing the narrow PSFs, one per epoch. shape (epochs, im_size_up, im_size_up) where im_size_up needs be a multiple of im_size.
subsampling_factor – integer, ratio of the size of the data pixels to that of the PSF pixels.
fitting_sequence – list, List of lists, containing the element of the model to keep fixed. Example : [[‘pts-source-astrometry’,’pts-source-photometry’,’background’],[‘pts-source-astrometry’,’pts-source-photometry’], …]
optim_list – List of optimiser. Recommended if background is kept constant : ‘l-bfgs-b’, ‘adabelief’ otherwise.
kwargs_optim_list – List of dictionary, containing the setting for the different optimiser.
lambda_scales – Lagrange parameter that weights intermediate scales in the transformed domain
lambda_hf – Lagrange parameter weighting the highest frequency scale
lambda_pts_source – Lagrange parameter regularising the pts source channel
lambda_positivity_bkg – Lagrange parameter weighting the positivity of the background. 0 means no positivity constraint.
lambda_positivity_ps – Lagrange parameter weighting the positivity of the point sources. 0 means no positivity constraint.
regularize_full_model – option to regularise just the background (False, recommended) or background + point source channel (True)
:param update_lambda_pts_source : bool, option to refine the points channel regularization strength at every iteration :param prior_list: list of Prior object, Gaussian prior on parameters to be applied at each step :param adjust_sky: bool, True if you want to fit some sky subtraction :param noise_propagation: ‘MC’ or ‘SLIT’, method to compute the noise propagation in wavelet space. Default: ‘MC’. :param verbose: bool. Verbosity.
Return model, parameters, loss, kwargs_partial_list, fig_list, LogL_list, loss_history_list
Module contents
This subpackage contains procedures / routines built on top of the main package classes.