imcascade.mgm
Module Contents
Classes
A class used to generate models based series of Gaussians |
Functions
|
Experimental, do not use yet! |
|
Function to rotate image around a given point |
|
Function used to derrive the observed Gaussian Parameters for a non-circular PSF |
|
Approximate erf function for use with numba |
|
Wrapper Function used to calculate render model using the hybrid method |
- class imcascade.mgm.MultiGaussModel(shape, sig, psf_sig, psf_a, verbose=True, sky_model=True, sky_type='tilted-plane', render_mode='hybrid', log_weight_scale=True, psf_shape=None)
A class used to generate models based series of Gaussians
- Parameters
shape (2x1 array_like) – Size of model image to generate
sig (1-D array) – Widths of Gaussians used to genrate model
psf_sig (1-D array, None) – Width of Gaussians used to approximate psf
psf_a (1-D array, None) – Weights of Gaussians used to approximate psf, must be same length as ‘psf_sig’. If both psf_sig and psf_a are None then will run in Non-psf mode
verbose (bool, optional) – If true will print out errors
sky_model (bool, optional) – If True will incorperate a tilted plane sky model
render_mode ('gauss' or 'erf') – Option to decide how to render models. Default is ‘erf’ as it computes the integral over the pixel of each profile therefore is more accurate but more computationally intensive. ‘gauss’ assumes the center of a pixel provides a reasonble estimate of the average flux in that pixel. ‘gauss’ is faster but far less accurate for objects with size O(pixel size), so use with caution.
log_weight_scale (bool, optional) – Wether to treat weights as log scale, Default True
- get_gauss_stack(x0, y0, q_arr, a_arr, var_arr)
Function used to calculate render model using the ‘Gauss’ method
- Parameters
x0 (float) – x position of center
y0 (float) – y position of center
q_arr (Array) – Array of axis ratios
a_arr – Array of Gaussian Weights
var_arr – Array of Gassian widths, note this the variance so sig^2
- Returns
Gauss_model – Array representing the model image, same shape as ‘shape’
- Return type
array
- get_erf_stack(x0, y0, final_q, final_a, final_var)
Function used to calculate render model using the ‘erf’ method
- Parameters
x0 (float) – x position of center
y0 (float) – y position of the center
final_q (Array) – Array of axis ratios
final_a (Array) – Array of Gaussian Weights
final_var (Array) – Array of Gassian widths, note this the variance so sig^2
- Returns
erf_model – Array representing each rendered component
- Return type
array
- get_hybrid_stack(x0, y0, final_q, final_a, final_var)
Function used to calculate render model using the hybrid method, which uses erf where neccesary to ensure accurate integration and gauss otherwise. Also set everything >5 sigma away to 0.
- Parameters
x0 (float) – x position of center
y0 (float) – y position of the center
final_q (Array) – Array of axis ratios
final_a (Array) – Array of Gaussian Weights
final_var (Array) – Array of Gassian widths, note this the variance so sig^2
- Returns
erf_model – Array representing each rendered component
- Return type
3D array
- make_model(param, return_stack=False)
Function to generate model image based on given paramters array. This version assumaes the gaussian weights are given in linear scale
- Parameters
param (array) – 1-D array containing all the Parameters
- Returns
model_image – Generated model image as the sum of all components plus sky, if included
- Return type
2D Array
- get_sky_model_flat(args)
Function used to calculate flat sky model
- Parameters
args: (a,) (float,)
- Returns
sky_model – Model for sky background based on given parameters, same shape as ‘shape’
- Return type
2D Array
- get_sky_model_tp(args)
Function used to calculate tilted-plane sky model
- Parameters
args ((a,b,c) (float,float,float)) –
- overall normalization (a) –
- slope in x direction (b) –
- slope in y direction (c) –
- Returns
sky_model – Model for sky background based on given parameters, same shape as ‘shape’
- Return type
2D Array
- imcascade.mgm.rot_im_jax_exp(img, phi, x0, y0)
Experimental, do not use yet!
- imcascade.mgm.rot_im(img, phi, x0, y0)
Function to rotate image around a given point
- Parameters
img (2D array) – Image to be rotated
phi (Float) – angle to rotate image
x0 (Float) – x coordinate to rotate image around
y0 (Float) – y coordinate to rotate image around
- Returns
rotated image
- Return type
2D array
- imcascade.mgm.get_ellip_conv_params(var_all, q, phi, psf_var_all, psf_q, psf_phi)
Function used to derrive the observed Gaussian Parameters for a non-circular PSF
- Parameters
var (array) – Variances of Gaussian components
q (Float) – Axis ratio of Galaxy
phi (Float) – PA of galaxy
psf_var_all (array) – Variances of PSF gaussian decomposition
psf_q (float) – Axis ratio of PSF
psf_phi (PA of PSF) –
- Returns
obs_var (array) – Array of variances for the components of the convolved gaussian model
obs_phi (array) – Array of position angles for the components of the convolved gaussian model
obs_q (array) – Array of axis ratios for the components of the convolved gaussian model
- imcascade.mgm._erf_approx(x)
Approximate erf function for use with numba
- Parameters
x (scalar) – value
- Returns
- Return type
Approximation of erf(x)
- imcascade.mgm._get_hybrid_stack(x0, y0, final_q, final_a, final_var, im_args)
Wrapper Function used to calculate render model using the hybrid method
- Parameters
x0 (float) – x position of center
y0 (float) – y position of the center
final_q (Array) – Array of axis ratios
final_a – Array of Gaussian Weights
final_var – Array of Gassian widths, note this the variance so sig^2
return_stack (Bool, optional) – If True returns an image for each individual gaussian
- Returns
erf_model – Array representing the model image, same shape as ‘shape’
- Return type
array