coolest.api.analysis#
Classes#
Handles computation of model-independent quantities |
Module Contents#
- class Analysis(coolest_object, coolest_directory, supersampling=1)[source]#
Handles computation of model-independent quantities and other analysis computations.
NOTE: Except for methods that do have a coordinates keyword argument, the grid used to performed the computations will always be the one corresponding to the instrument / observation field-of-view, with resolution controlled by the supersampling keyword argument below.
- Parameters:
coolest_object (COOLEST) – COOLEST instance
coolest_directory (str) – Directory which contains the COOLEST template and other data files
supersampling (int, optional) – Supersampling factor (relative to the instrument pixel size) that defines the grid on which computations are performed, by default 1.
- effective_einstein_radius(center=None, initial_guess=1, initial_delta_pix=10, n_iter=5, return_accuracy=False, max_loopcount=100, **kwargs_selection)[source]#
Calculates Einstein radius for a kappa grid starting from an initial guess with large step size and zeroing in from there. Uses the grid from the create_kappa_image which is built from the coolest file.
- Parameters:
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate Einstein radius; if None, use the value from create_kappa_image, by default None
initial_guess (int, optional) – initial guess for Einstein radius, by default 1
initial_delta_pix (int, optional) – initial step size before shrinking in future iterations, by default 10
n_iter (int, optional) – number of iterations, by default 5
return_accuracy (bool, optional) – if True, return estimate of accuracy as well as R_Ein value, by default False
- Returns:
Effective Einstein radius
- Return type:
float, or (float, float) if return_accuracy is True
- Raises:
RuntimeError – If the algorithm is running for more than 100 loops.
- kappa_1d_profile(center=None, r_vec=np.linspace(0, 10, 100), **kwargs_selection)[source]#
Calculates 1D profile using the kappa grid.
- Parameters:
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate; if None, use the value from , by default None
r_vec (_type_, optional) – range of radii over which to calculate the 1D profile, by default np.linspace(0, 10, 100)
- Returns:
kappa values and associated radius values
- Return type:
(array, array)
- effective_radial_slope(r_eval=None, center=None, r_vec=np.linspace(0, 10, 100), **kwargs_selection)[source]#
Numerically calculates slope of the kappa profile. Because this is defined on a grid, it is not as accurate or robust as an analytical calculation.
- Parameters:
r_eval (float, optional) – radius at which to return a single value of the slope (e.g. Einstein radius). If None (default), returns slope for all values in r_vec, by default None
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate; if None, use the value from create_kappa_image, by default None
r_vec (array-like, optional) – range of radii over which to calculate the 1D profile, by default np.linspace(0, 10, 100)
- Returns:
Effective slope
- Return type:
float
- effective_radius_light(outer_radius=10, center=None, coordinates=None, no_re_eval=False, initial_guess=1, initial_delta_pix=10, n_iter=10, return_model=False, return_accuracy=False, circular_mask_radius=None, **kwargs_selection)[source]#
Computes the effective radius of the 2D surface brightness profile, based on a definition similar to the half-light radius.
- Parameters:
outer_radius (int, optional) – outer limit of integration within which half the light is calculated to estimate the effective radius, by default 10
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate Einstein radius; if None, use the value from create_kappa_image, by default None
coordinates (Coordinates, optional) – Instance of a Coordinates object to be used for the computation. If None, will use an instance based on the Instrument, by default None
no_re_eval (bool, option) – If True, do re-evaluate the light profile (only relevant for pixelated profiles). Default is False.
initial_guess (int, optional) – Initial guess for effective radius in arcsecond, by default 1
initial_delta_pix (int, optional) – Initial step size in pixels before shrinking in future iterations, by default 10
n_iter (int, optional) – Number of iterations, by default 5
circular_mask_radius (float, optional) – If not None, multiply the flux by a circular mask with radius circular_mask_radius to force to zero any flux outside of it.
return_model (bool, optional) – If True, also returns the surface brightness map used to comouted the radius. By default False.
return_accuracy (bool, optional) – if True, return a rough estimate of accuracy as well, by default False
- Returns:
Effective radius
- Return type:
float
- Raises:
Warning – If integration loop exceeds outer bound before convergence.
- two_point_correlation(Nbins=100, rmax=None, normalize=False, use_profile_coordinates=True, coordinates=None, min_flux=None, min_flux_frac=None, return_cov=False, return_map=False, **kwargs_selection)[source]#
The two point correlation function can be obtained from the covariance matrix of an image and the distances between its pixels. By binning the covariance matrix entries in distance (or radial) bins, one can obtain the 1D correlation function. There are two ways to obtain the covariance matrix: 1) it is equivalent to the inverse Fourier transform of the power spectrum, and 2) by calculating explicitly the covariance between any two pixels Here we use the first way.
- Parameters:
Nbins (int, optional) – The number of radial bins to use for converting the 2D covariance matrix into a 1D correlation function.
rmax (float, optional) – A value for the maximum extent of the radial bins. If none is given then it is equal to half the diagonal of the provided image.
normalize (bool, optional) – Normalize the given image by its maximum. Default is False.
coordinates (Coordinates, optional) – Instance of a Coordinates object to be used for the computation. If None, will use an instance based on the Instrument, by default None
use_profile_coordinates (bool, optional) – If True and coordinates=None, uses the coordinates attached to the light profile, if available. Default is True.
min_flux (float, optional) – Minimum flux value considered in the computation of the correlation function. Default is None (i.e., no thresholding).
min_flux_frac (float, optional) – Same as min_flux, but given as a fraction of the maximum flux value. If min_flux is not None, min_flux_frac is ignored. Default is None (i.e., no thresholding).
return_cov (bool, optional) – If True, also returns the full covariance matrix. Default is False.
return_cov – If True, also returns the full covariance matrix. Default is False.
- Returns:
The location, value, and uncertainty of the 1D bins of the two-point correlation function. The location (radius/distance) is in the same units as the coordinates.
- Return type:
(array, array, array)
- total_magnitude(outer_radius=10, center=None, coordinates=None, no_re_eval=False, flux_factor=None, mag_zero_point=None, **kwargs_selection)[source]#
Computes the effective radius of the 2D surface brightness profile, based on a definition similar to the half-light radius.
- Parameters:
outer_radius (int, optional) – outer limit of integration within which half the light is calculated to integrate the flux, by default 10
no_re_eval (bool, option) – If True, do re-evaluate the light profile (only relevant for pixelated profiles). Default is False.
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate Einstein radius; if None, use the value from create_kappa_image, by default None
coordinates (Coordinates, optional) – Instance of a Coordinates object to be used for the computation. If None, will use an instance based on the Instrument, by default None
mag_zero_point (float, optional) – Magnitude zero-point corresponding to 1 electron per second. Must be given when no mag_zero_point has been found in the self.coolest object.
TODO (flux_factor is temporary, this will be removed in the future.)
- Returns:
Total magnitude from the flux integrated over the field of view.
- Return type:
float
- ellipticity_from_moments(center=None, coordinates=None, **kwargs_selection)[source]#
Estimates the axis ratio and position angle of the model map based on central moments of the image.
- Parameters:
center ((float, float), optional) – (x, y)-coordinates of the center from which to calculate Einstein radius; if None, use the value from create_kappa_image, by default None
coordinates (Coordinates, optional) – Instance of a Coordinates object to be used for the computation. If None, will use an instance based on the Instrument, by default None
- Returns:
Ellipticity measurement (axis)
- Return type:
float
- Raises:
Warning – If integration loop exceeds outer bound before convergence.
- lensing_information(a=16, b=0, noise_map=None, arc_mask=None, theta_E=None, entity_idx_theta_E=0, profile_idx_theta_E=0)[source]#
Computes the ‘lensing information’ defined in Yi Tan et al. 2023, Equations (8) and (9). https://ui.adsabs.harvard.edu/abs/2023arXiv231109307T/abstract