INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Factory for loading the ccd data from. fits files as well as computing properties like the noise - map exposure - time map etc. from the ccd - data.
def load_ccd_data_from_fits(image_path, pixel_scale, image_hdu=0, resized_ccd_shape=None, resized_ccd_origin_pixels=None, resized_ccd_origin_arcsec=None, psf_path=None, psf_hdu=0, resized_psf_shape=None, renormalize_psf=True, ...
Factory for loading the image from a. fits file
def load_image(image_path, image_hdu, pixel_scale): """Factory for loading the image from a .fits file Parameters ---------- image_path : str The path to the image .fits file containing the image (e.g. '/path/to/image.fits') image_hdu : int The hdu the image is contained in the .fit...
Factory for loading the noise - map from a. fits file.
def load_noise_map(noise_map_path, noise_map_hdu, pixel_scale, image, background_noise_map, exposure_time_map, convert_noise_map_from_weight_map, convert_noise_map_from_inverse_noise_map, noise_map_from_image_and_background_noise_map, convert_from_electrons, gain, convert_from_adus...
Factory for loading the background noise - map from a. fits file.
def load_background_noise_map(background_noise_map_path, background_noise_map_hdu, pixel_scale, convert_background_noise_map_from_weight_map, convert_background_noise_map_from_inverse_noise_map): """Factory for loading the background noise-map from a .fits...
Factory for loading the Poisson noise - map from a. fits file.
def load_poisson_noise_map(poisson_noise_map_path, poisson_noise_map_hdu, pixel_scale, convert_poisson_noise_map_from_weight_map, convert_poisson_noise_map_from_inverse_noise_map, poisson_noise_map_from_image, im...
Factory for loading the psf from a. fits file.
def load_psf(psf_path, psf_hdu, pixel_scale, renormalize=False): """Factory for loading the psf from a .fits file. Parameters ---------- psf_path : str The path to the psf .fits file containing the psf (e.g. '/path/to/psf.fits') psf_hdu : int The hdu the psf is contained in the .fit...
Factory for loading the exposure time map from a. fits file.
def load_exposure_time_map(exposure_time_map_path, exposure_time_map_hdu, pixel_scale, shape, exposure_time, exposure_time_map_from_inverse_noise_map, inverse_noise_map): """Factory for loading the exposure time map from a .fits file. This factory also includes a number of routines f...
Factory for loading the background sky from a. fits file.
def load_background_sky_map(background_sky_map_path, background_sky_map_hdu, pixel_scale): """Factory for loading the background sky from a .fits file. Parameters ---------- background_sky_map_path : str The path to the background_sky_map .fits file containing the background sky map \ (...
Load the positions of an image.
def load_positions(positions_path): """Load the positions of an image. Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \ multiply-imaged region of the source-plane. Mass models which do not trace the pixels within a threshold value of \ one...
Output the positions of an image to a positions. dat file.
def output_positions(positions, positions_path): """Output the positions of an image to a positions.dat file. Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \ multiply-imaged region of the source-plane. Mass models which do not trace the pixel...
Create a realistic simulated image by applying effects to a plain simulated image.
def simulate_variable_arrays(cls, array, pixel_scale, exposure_time_map, psf=None, background_sky_map=None, add_noise=True, noise_if_add_noise_false=0.1, noise_seed=-1, name=None): """ Create a realistic simulated image by applying effects to a plain simulated image. ...
Create a realistic simulated image by applying effects to a plain simulated image.
def simulate_to_target_signal_to_noise(cls, array, pixel_scale, target_signal_to_noise, exposure_time_map, psf=None, background_sky_map=None, seed=-1): """ Create a realistic simulated image by applying effects to a plain simulated image. Parameters ...
The estimated signal - to - noise_maps mappers of the image.
def signal_to_noise_map(self): """The estimated signal-to-noise_maps mappers of the image.""" signal_to_noise_map = np.divide(self.image, self.noise_map) signal_to_noise_map[signal_to_noise_map < 0] = 0 return signal_to_noise_map
The estimated absolute_signal - to - noise_maps mappers of the image.
def absolute_signal_to_noise_map(self): """The estimated absolute_signal-to-noise_maps mappers of the image.""" return np.divide(np.abs(self.image), self.noise_map)
For an array ( in counts ) and an exposure time mappers convert the array to units electrons per second
def array_from_adus_to_electrons_per_second(self, array, gain): """ For an array (in counts) and an exposure time mappers, convert the array to units electrons per second Parameters ---------- array : ndarray The array the values are to be converted from counts to el...
The estimated noise_maps mappers of the image ( using its background noise_maps mappers and image values in counts ) in counts.
def estimated_noise_map_counts(self): """ The estimated noise_maps mappers of the image (using its background noise_maps mappers and image values in counts) in counts. """ return np.sqrt((np.abs(self.image_counts) + np.square(self.background_noise_map_counts)))
Estimate the background signal_to_noise_ratio by binning data_to_image located at the edge ( s ) of an image into a histogram and fitting a Gaussian profiles to this histogram. The standard deviation ( sigma ) of this Gaussian gives a signal_to_noise_ratio estimate.
def background_noise_from_edges(self, no_edges): """Estimate the background signal_to_noise_ratio by binning data_to_image located at the edge(s) of an image into a histogram and fitting a Gaussian profiles to this histogram. The standard deviation (sigma) of this Gaussian gives a signal_to_nois...
Setup the noise - map from a weight map which is a form of noise - map that comes via HST image - reduction and \ the software package MultiDrizzle.
def from_weight_map(cls, pixel_scale, weight_map): """Setup the noise-map from a weight map, which is a form of noise-map that comes via HST image-reduction and \ the software package MultiDrizzle. The variance in each pixel is computed as: Variance = 1.0 / sqrt(weight_map). T...
Setup the noise - map from an root - mean square standard deviation map which is a form of noise - map that \ comes via HST image - reduction and the software package MultiDrizzle.
def from_inverse_noise_map(cls, pixel_scale, inverse_noise_map): """Setup the noise-map from an root-mean square standard deviation map, which is a form of noise-map that \ comes via HST image-reduction and the software package MultiDrizzle. The variance in each pixel is computed as: V...
Simulate the PSF as an elliptical Gaussian profile.
def simulate_as_gaussian(cls, shape, pixel_scale, sigma, centre=(0.0, 0.0), axis_ratio=1.0, phi=0.0): """Simulate the PSF as an elliptical Gaussian profile.""" from autolens.model.profiles.light_profiles import EllipticalGaussian gaussian = EllipticalGaussian(centre=centre, axis_ratio=axis_ratio...
Loads a PSF from fits and renormalizes it
def from_fits_renormalized(cls, file_path, hdu, pixel_scale): """Loads a PSF from fits and renormalizes it Parameters ---------- pixel_scale file_path: String The path to the file containing the PSF hdu : int The HDU the PSF is stored in the .fits...
Loads the PSF from a. fits file.
def from_fits_with_scale(cls, file_path, hdu, pixel_scale): """ Loads the PSF from a .fits file. Parameters ---------- pixel_scale file_path: String The path to the file containing the PSF hdu : int The HDU the PSF is stored in the .fits f...
Renormalize the PSF such that its data_vector values sum to unity.
def new_psf_with_renormalized_array(self): """Renormalize the PSF such that its data_vector values sum to unity.""" return PSF(array=self, pixel_scale=self.pixel_scale, renormalize=True)
Convolve an array with this PSF
def convolve(self, array): """ Convolve an array with this PSF Parameters ---------- image : ndarray An array representing the image the PSF is convolved with. Returns ------- convolved_image : ndarray An array representing the im...
An image - plane pixelization is one where its pixel centres are computed by tracing a sparse grid of pixels from \ the image s regular grid to other planes ( e. g. the source - plane ).
def setup_image_plane_pixelization_grid_from_galaxies_and_grid_stack(galaxies, grid_stack): """An image-plane pixelization is one where its pixel centres are computed by tracing a sparse grid of pixels from \ the image's regular grid to other planes (e.g. the source-plane). Provided a galaxy has an image-p...
Calculate the image - plane pixelization from a regular - grid of coordinates ( and its mask ).
def image_plane_pix_grid_from_regular_grid(self, regular_grid): """Calculate the image-plane pixelization from a regular-grid of coordinates (and its mask). See *grid_stacks.SparseToRegularGrid* for details on how this grid is calculated. Parameters ----------- regular_grid : g...
Determine the geometry of the rectangular grid by overlaying it over a grid of coordinates such that its \ outer - most pixels align with the grid s outer most coordinates plus a small buffer.
def geometry_from_grid(self, grid, buffer=1e-8): """Determine the geometry of the rectangular grid, by overlaying it over a grid of coordinates such that its \ outer-most pixels align with the grid's outer most coordinates plus a small buffer. Parameters ----------- grid : ndar...
Setup a rectangular mapper from a rectangular pixelization as follows:
def mapper_from_grid_stack_and_border(self, grid_stack, border): """Setup a rectangular mapper from a rectangular pixelization, as follows: 1) If a border is supplied, relocate all of the grid-stack's regular and sub grid pixels beyond the border. 2) Determine the rectangular pixelization's geo...
Determine the geometry of the Voronoi pixelization by alligning it with the outer - most coordinates on a \ grid plus a small buffer.
def geometry_from_grid(self, grid, pixel_centres, pixel_neighbors, pixel_neighbors_size, buffer=1e-8): """Determine the geometry of the Voronoi pixelization, by alligning it with the outer-most coordinates on a \ grid plus a small buffer. Parameters ----------- grid : ndarray ...
Compute the Voronoi grid of the pixelization using the pixel centers.
def voronoi_from_pixel_centers(pixel_centers): """Compute the Voronoi grid of the pixelization, using the pixel centers. Parameters ---------- pixel_centers : ndarray The (y,x) centre of every Voronoi pixel. """ return scipy.spatial.Voronoi(np.asarray([pixel_...
Compute the neighbors of every Voronoi pixel as an ndarray of the pixel index s each pixel shares a \ vertex with.
def neighbors_from_pixelization(self, pixels, ridge_points): """Compute the neighbors of every Voronoi pixel as an ndarray of the pixel index's each pixel shares a \ vertex with. The ridge points of the Voronoi grid are used to derive this. Parameters ---------- ridge_p...
Setup a Voronoi mapper from an adaptive - magnification pixelization as follows:
def mapper_from_grid_stack_and_border(self, grid_stack, border): """Setup a Voronoi mapper from an adaptive-magnification pixelization, as follows: 1) (before this routine is called), setup the 'pix' grid as part of the grid-stack, which corresponds to a \ sparse set of pixels in the image-p...
Plot a grid of ( y x ) Cartesian coordinates as a scatter plot of points.
def plot_grid(grid, axis_limits=None, points=None, as_subplot=False, units='arcsec', kpc_per_arcsec=None, figsize=(12, 8), pointsize=5, pointcolor='k', xyticksize=16, title='Grid', titlesize=16, xlabelsize=16, ylabelsize=16, output_path=None, output_format='show',...
Convert the grid from its input units ( arc - seconds ) to the input unit ( e. g. retain arc - seconds ) or convert to \ another set of units ( kiloparsecs ).
def convert_grid_units(grid_arcsec, units, kpc_per_arcsec): """Convert the grid from its input units (arc-seconds) to the input unit (e.g. retain arc-seconds) or convert to \ another set of units (kiloparsecs). Parameters ----------- grid_arcsec : ndarray or data.array.grids.RegularGrid The...
Set the x and y labels of the figure and set the fontsize of those labels.
def set_xy_labels(units, kpc_per_arcsec, xlabelsize, ylabelsize, xyticksize): """Set the x and y labels of the figure, and set the fontsize of those labels. The x and y labels are always the distance scales, thus the labels are either arc-seconds or kpc and depend on the \ units the figure is plotted in. ...
Plot a subset of points in a different color to highlight a specifc region of the grid ( e. g. how certain \ pixels map between different planes ).
def plot_points(grid, points, pointcolor): """Plot a subset of points in a different color, to highlight a specifc region of the grid (e.g. how certain \ pixels map between different planes). Parameters ----------- grid : ndarray or data.array.grids.RegularGrid The (y,x) coordinates of the ...
Wrap the function in a function that if the grid is a sub - grid ( grids. SubGrid ) rebins the computed \ values to the sub - grids corresponding regular - grid by taking the mean of each set of sub - gridded values.
def sub_to_image_grid(func): """ Wrap the function in a function that, if the grid is a sub-grid (grids.SubGrid), rebins the computed \ values to the sub-grids corresponding regular-grid by taking the mean of each set of sub-gridded values. Parameters ---------- func : (profiles, *args, **kwarg...
Decorate a profile method that accepts a coordinate grid and returns a data grid.
def grid_interpolate(func): """ Decorate a profile method that accepts a coordinate grid and returns a data grid. If an interpolator attribute is associated with the input grid then that interpolator is used to down sample the coordinate grid prior to calling the function and up sample the result of th...
For a padded grid - stack and psf compute an unmasked blurred image from an unmasked unblurred image.
def unmasked_blurred_image_from_psf_and_unmasked_image(self, psf, unmasked_image_1d): """For a padded grid-stack and psf, compute an unmasked blurred image from an unmasked unblurred image. This relies on using the lens data's padded-grid, which is a grid of (y,x) coordinates which extends over the \ ...
Setup a grid - stack of grid_stack from a mask sub - grid size and psf - shape.
def grid_stack_from_mask_sub_grid_size_and_psf_shape(cls, mask, sub_grid_size, psf_shape): """Setup a grid-stack of grid_stack from a mask, sub-grid size and psf-shape. Parameters ----------- mask : Mask The mask whose unmasked pixels (*False*) are used to generate the grid-...
Setup a grid - stack of grid_stack from a 2D array shape a pixel scale and a sub - grid size. This grid corresponds to a fully unmasked 2D array.
def from_shape_pixel_scale_and_sub_grid_size(cls, shape, pixel_scale, sub_grid_size=2): """Setup a grid-stack of grid_stack from a 2D array shape, a pixel scale and a sub-grid size. This grid corresponds to a fully unmasked 2D array. Parameters ----------- shape : (int,...
Setup a grid - stack of masked grid_stack from a mask sub - grid size and psf - shape.
def padded_grid_stack_from_mask_sub_grid_size_and_psf_shape(cls, mask, sub_grid_size, psf_shape): """Setup a grid-stack of masked grid_stack from a mask, sub-grid size and psf-shape. Parameters ----------- mask : Mask The mask whose masked pixels the grid-stack are setup us...
Setup a grid - stack of grid_stack for simulating an image of a strong lens whereby the grid s use \ padded - grid_stack to ensure that the PSF blurring in the simulation routine ( * ccd. PrepatoryImage. simulate * ) \ is not degraded due to edge effects.
def grid_stack_for_simulation(cls, shape, pixel_scale, psf_shape, sub_grid_size=2): """Setup a grid-stack of grid_stack for simulating an image of a strong lens, whereby the grid's use \ padded-grid_stack to ensure that the PSF blurring in the simulation routine (*ccd.PrepatoryImage.simulate*) \ ...
Setup a grid - stack of grid_stack using an existing grid - stack. The new grid - stack has the same grid_stack ( regular sub blurring etc. ) as before but adds a pix - grid as a \ new attribute.
def new_grid_stack_with_pix_grid_added(self, pix_grid, regular_to_nearest_pix): """Setup a grid-stack of grid_stack using an existing grid-stack. The new grid-stack has the same grid_stack (regular, sub, blurring, etc.) as before, but adds a pix-grid as a \ new attribute. Param...
Apply a function to all grid_stack in the grid - stack. This is used by the * ray - tracing * module to easily apply tracing operations to all grid_stack.
def apply_function(self, func): """Apply a function to all grid_stack in the grid-stack. This is used by the *ray-tracing* module to easily apply tracing operations to all grid_stack.""" if self.blurring is not None and self.pix is not None: return GridStack(func(self.regula...
Map a function to all grid_stack in a grid - stack
def map_function(self, func, *arg_lists): """Map a function to all grid_stack in a grid-stack""" return GridStack(*[func(*args) for args in zip(self, *arg_lists)])
Convolve a 1d padded array of values ( e. g. intensities before PSF blurring ) with a PSF and then trim \ the convolved array to its original 2D shape.
def convolve_array_1d_with_psf(self, padded_array_1d, psf): """Convolve a 1d padded array of values (e.g. intensities before PSF blurring) with a PSF, and then trim \ the convolved array to its original 2D shape. Parameters ----------- padded_array_1d: ndarray A 1D a...
Setup a regular - grid from a mask wehere the center of every unmasked pixel gives the grid s ( y x ) \ arc - second coordinates.
def from_mask(cls, mask): """Setup a regular-grid from a mask, wehere the center of every unmasked pixel gives the grid's (y,x) \ arc-second coordinates. Parameters ----------- mask : Mask The mask whose unmasked pixels are used to setup the regular-pixel grid. ...
Setup a regular - grid from a 2D array shape and pixel scale. Here the center of every pixel on the 2D \ array gives the grid s ( y x ) arc - second coordinates. This is equivalent to using a 2D mask consisting entirely of unmasked pixels.
def from_shape_and_pixel_scale(cls, shape, pixel_scale): """Setup a regular-grid from a 2D array shape and pixel scale. Here, the center of every pixel on the 2D \ array gives the grid's (y,x) arc-second coordinates. This is equivalent to using a 2D mask consisting entirely of unmaske...
Setup a blurring - grid from a mask where a blurring grid consists of all pixels that are masked but they \ are close enough to the unmasked pixels that a fraction of their light will be blurred into those pixels \ via PSF convolution. For example if our mask is as follows: |x|x|x|x|x|x|x|x|x|x| |x|x|x|x|x|x|x|x|x|x| T...
def blurring_grid_from_mask_and_psf_shape(cls, mask, psf_shape): """Setup a blurring-grid from a mask, where a blurring grid consists of all pixels that are masked, but they \ are close enough to the unmasked pixels that a fraction of their light will be blurred into those pixels \ via PSF convo...
Map a 1D array the same dimension as the grid to its original masked 2D array.
def array_2d_from_array_1d(self, array_1d): """ Map a 1D array the same dimension as the grid to its original masked 2D array. Parameters ----------- array_1d : ndarray The 1D array which is mapped to its masked 2D array. """ return mapping_util.map_masked_1d...
Map a 1D array the same dimension as the grid to its original masked 2D array and return it as a scaled \ array.
def scaled_array_2d_from_array_1d(self, array_1d): """ Map a 1D array the same dimension as the grid to its original masked 2D array and return it as a scaled \ array. Parameters ----------- array_1d : ndarray The 1D array of which is mapped to a 2D scaled array. ...
Compute the yticks labels of this grid used for plotting the y - axis ticks when visualizing a regular
def yticks(self): """Compute the yticks labels of this grid, used for plotting the y-axis ticks when visualizing a regular""" return np.linspace(np.min(self[:, 0]), np.max(self[:, 0]), 4)
Compute the xticks labels of this grid used for plotting the x - axis ticks when visualizing a regular
def xticks(self): """Compute the xticks labels of this grid, used for plotting the x-axis ticks when visualizing a regular""" return np.linspace(np.min(self[:, 1]), np.max(self[:, 1]), 4)
Setup a sub - grid of the unmasked pixels using a mask and a specified sub - grid size. The center of \ every unmasked pixel s sub - pixels give the grid s ( y x ) arc - second coordinates.
def from_mask_and_sub_grid_size(cls, mask, sub_grid_size=1): """Setup a sub-grid of the unmasked pixels, using a mask and a specified sub-grid size. The center of \ every unmasked pixel's sub-pixels give the grid's (y,x) arc-second coordinates. Parameters ----------- mask : Mask...
Setup a sub - grid from a 2D array shape and pixel scale. Here the center of every pixel on the 2D \ array gives the grid s ( y x ) arc - second coordinates where each pixel has sub - pixels specified by the \ sub - grid size.
def from_shape_pixel_scale_and_sub_grid_size(cls, shape, pixel_scale, sub_grid_size): """Setup a sub-grid from a 2D array shape and pixel scale. Here, the center of every pixel on the 2D \ array gives the grid's (y,x) arc-second coordinates, where each pixel has sub-pixels specified by the \ sub...
Map a 1D sub - array the same dimension as the sub - grid ( e. g. including sub - pixels ) to its original masked 2D sub array.
def sub_array_2d_from_sub_array_1d(self, sub_array_1d): """ Map a 1D sub-array the same dimension as the sub-grid (e.g. including sub-pixels) to its original masked 2D sub array. Parameters ----------- sub_array_1d : ndarray The 1D sub_array which is mapped to its ma...
Map a 1D sub - array the same dimension as the sub - grid to its original masked 2D sub - array and return it as a scaled array.
def scaled_array_2d_with_sub_dimensions_from_sub_array_1d(self, sub_array_1d): """ Map a 1D sub-array the same dimension as the sub-grid to its original masked 2D sub-array and return it as a scaled array. Parameters ----------- sub_array_1d : ndarray The 1D sub-arra...
Map a 1D sub - array the same dimension as the sub - grid to its original masked 2D sub - array and return it as a scaled array.
def scaled_array_2d_with_regular_dimensions_from_binned_up_sub_array_1d(self, sub_array_1d): """ Map a 1D sub-array the same dimension as the sub-grid to its original masked 2D sub-array and return it as a scaled array. Parameters ----------- sub_array_1d : ndarray T...
For an input sub - gridded array map its hyper - values from the sub - gridded values to a 1D regular grid of \ values by summing each set of each set of sub - pixels values and dividing by the total number of sub - pixels.
def regular_data_1d_from_sub_data_1d(self, sub_array_1d): """For an input sub-gridded array, map its hyper-values from the sub-gridded values to a 1D regular grid of \ values by summing each set of each set of sub-pixels values and dividing by the total number of sub-pixels. Parameters ...
The 1D index mappings between the unmasked sparse - grid and masked sparse grid.
def unmasked_sparse_to_sparse(self): """The 1D index mappings between the unmasked sparse-grid and masked sparse grid.""" return mapping_util.unmasked_sparse_to_sparse_from_mask_and_pixel_centres( mask=self.regular_grid.mask, unmasked_sparse_grid_pixel_centres=self.unmasked_spar...
The 1D index mappings between the masked sparse - grid and unmasked sparse grid.
def sparse_to_unmasked_sparse(self): """The 1D index mappings between the masked sparse-grid and unmasked sparse grid.""" return mapping_util.sparse_to_unmasked_sparse_from_mask_and_pixel_centres( total_sparse_pixels=self.total_sparse_pixels, mask=self.regular_grid.mask, unmasked...
The 1D index mappings between the regular - grid and masked sparse - grid.
def regular_to_sparse(self): """The 1D index mappings between the regular-grid and masked sparse-grid.""" return mapping_util.regular_to_sparse_from_sparse_mappings( regular_to_unmasked_sparse=self.regular_to_unmasked_sparse, unmasked_sparse_to_sparse=self.unmasked_sparse_to_spa...
The ( y x ) arc - second coordinates of the masked sparse - grid.
def sparse_grid(self): """The (y,x) arc-second coordinates of the masked sparse-grid.""" return mapping_util.sparse_grid_from_unmasked_sparse_grid( unmasked_sparse_grid=self.unmasked_sparse_grid, sparse_to_unmasked_sparse=self.sparse_to_unmasked_sparse)
Setup a regular padded grid from a 2D array shape psf - shape and pixel - scale.
def padded_grid_from_shape_psf_shape_and_pixel_scale(cls, shape, psf_shape, pixel_scale): """Setup a regular padded grid from a 2D array shape, psf-shape and pixel-scale. The center of every pixel is used to setup the grid's (y,x) arc-second coordinates, including padded pixels \ which are beyo...
Compute a 2D padded blurred image from a 1D padded image.
def padded_blurred_image_2d_from_padded_image_1d_and_psf(self, padded_image_1d, psf): """Compute a 2D padded blurred image from a 1D padded image. Parameters ---------- padded_image_1d : ndarray A 1D unmasked image which is blurred with the PSF. psf : ndarray ...
Map a padded 1D array of values to its original 2D array trimming all edge values.
def array_2d_from_array_1d(self, padded_array_1d): """ Map a padded 1D array of values to its original 2D array, trimming all edge values. Parameters ----------- padded_array_1d : ndarray A 1D array of values which were computed using the *PaddedRegularGrid*. """ ...
Map a padded 1D array of values to its padded 2D array.
def map_to_2d_keep_padded(self, padded_array_1d): """ Map a padded 1D array of values to its padded 2D array. Parameters ----------- padded_array_1d : ndarray A 1D array of values which were computed using the *PaddedRegularGrid*. """ return mapping_util.map_...
Setup an * PaddedSubGrid * for an input mask sub - grid size and psf - shape.
def padded_grid_from_mask_sub_grid_size_and_psf_shape(cls, mask, sub_grid_size, psf_shape): """Setup an *PaddedSubGrid* for an input mask, sub-grid size and psf-shape. The center of every sub-pixel is used to setup the grid's (y,x) arc-second coordinates, including \ masked-pixels which are bey...
Determine a set of relocated grid_stack from an input set of grid_stack by relocating their pixels based on the \ borders.
def relocated_grid_stack_from_grid_stack(self, grid_stack): """Determine a set of relocated grid_stack from an input set of grid_stack, by relocating their pixels based on the \ borders. The blurring-grid does not have its coordinates relocated, as it is only used for computing analytic \ ...
Relocate the coordinates of a grid to its border if they are outside the border. This is performed as \ follows:
def relocated_grid_from_grid_jit(grid, border_grid): """ Relocate the coordinates of a grid to its border if they are outside the border. This is performed as \ follows: 1) Use the mean value of the grid's y and x coordinates to determine the origin of the grid. 2) Compute the radial di...
Load a default value for redshift from config and set it as the redshift for source or lens galaxies that have falsey redshifts
def set_defaults(key): """ Load a default value for redshift from config and set it as the redshift for source or lens galaxies that have falsey redshifts Parameters ---------- key: str Returns ------- decorator A decorator that wraps the setter function to set defaults ...
Run this phase.
def run(self, positions, pixel_scale, results=None): """ Run this phase. Parameters ---------- pixel_scale positions results: autofit.tools.pipeline.ResultsCollection An object describing the results of the last phase or None if no phase has been exec...
Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase.
def make_analysis(self, positions, pixel_scale, results=None): """ Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase. Parameters ---------- pixel_scale positions ...
Run this phase.
def run(self, data, results=None, mask=None, positions=None): """ Run this phase. Parameters ---------- positions mask: Mask The default masks passed in by the pipeline results: autofit.tools.pipeline.ResultsCollection An object describing...
Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase.
def make_analysis(self, data, results=None, mask=None, positions=None): """ Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase. Parameters ---------- positions mask: Ma...
Run this phase.
def run(self, galaxy_data, results=None, mask=None): """ Run this phase. Parameters ---------- galaxy_data mask: Mask The default masks passed in by the pipeline results: autofit.tools.pipeline.ResultsCollection An object describing the re...
Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase.
def make_analysis(self, galaxy_data, results=None, mask=None): """ Create an lens object. Also calls the prior passing and lens_data modifying functions to allow child classes to change the behaviour of the phase. Parameters ---------- galaxy_data mask: Mask ...
Run a fit for each galaxy from the previous phase.
def run(self, data, results=None, mask=None, positions=None): """ Run a fit for each galaxy from the previous phase. Parameters ---------- data: LensData results: ResultsCollection Results from all previous phases mask: Mask The mask ...
For pixels on a 2D array of shape ( rows colums ) map an array of 1D pixel indexes to 2D pixel indexes.
def map_1d_indexes_to_2d_indexes_for_shape(indexes_1d, shape): """For pixels on a 2D array of shape (rows, colums), map an array of 1D pixel indexes to 2D pixel indexes. Indexing is defined from the top-left corner rightwards and downwards, whereby the top-left pixel on the 2D array corresponds to index 0,...
For pixels on a 2D array of shape ( rows colums ) map an array of 2D pixel indexes to 1D pixel indexes.
def map_2d_indexes_to_1d_indexes_for_shape(indexes_2d, shape): """For pixels on a 2D array of shape (rows, colums), map an array of 2D pixel indexes to 1D pixel indexes. Indexing is defined from the top-left corner rightwards and downwards, whereby the top-left pixel on the 2D array corresponds to index 0,...
For pixels on a 2D array of shape ( rows colums ) compute a 1D array which for every unmasked pixel on this 2D array maps the 1D sub - pixel indexes to their 1D pixel indexes.
def sub_to_regular_from_mask(mask, sub_grid_size): """"For pixels on a 2D array of shape (rows, colums), compute a 1D array which, for every unmasked pixel on this 2D array, maps the 1D sub-pixel indexes to their 1D pixel indexes. For example, the following mappings from sub-pixels to 2D array pixels are: ...
For a 2D array and mask map the values of all unmasked pixels to a 1D array.
def map_2d_array_to_masked_1d_array_from_array_2d_and_mask(mask, array_2d): """For a 2D array and mask, map the values of all unmasked pixels to a 1D array. The pixel coordinate origin is at the top left corner of the 2D array and goes right-wards and downwards, such that for an array of shape (3,3) where ...
For a 1D array that was computed by mapping unmasked values from a 2D array of shape ( rows columns ) map its \ values back to the original 2D array where masked values are set to zero.
def map_masked_1d_array_to_2d_array_from_array_1d_shape_and_one_to_two(array_1d, shape, one_to_two): """For a 1D array that was computed by mapping unmasked values from a 2D array of shape (rows, columns), map its \ values back to the original 2D array where masked values are set to zero. This uses a 1D ar...
For a 1D array that was flattened from a 2D array of shape ( rows columns ) map its values back to the \ original 2D array.
def map_unmasked_1d_array_to_2d_array_from_array_1d_and_shape(array_1d, shape): """For a 1D array that was flattened from a 2D array of shape (rows, columns), map its values back to the \ original 2D array. The pixel coordinate origin is at the top left corner of the 2D array and goes right-wards and downw...
Determine the mapping between every masked pixelization - grid pixel and pixelization - grid pixel. This is performed by checking whether each pixelization - grid pixel is within the regular - masks and mapping the indexes.
def sparse_to_unmasked_sparse_from_mask_and_pixel_centres(total_sparse_pixels, mask, unmasked_sparse_grid_pixel_centres): """Determine the mapping between every masked pixelization-grid pixel and pixelization-grid pixel. This is performed by checking whe...
Determine the mapping between every pixelization - grid pixel and masked pixelization - grid pixel. This is performed by checking whether each pixelization - grid pixel is within the regular - masks and mapping the indexes.
def unmasked_sparse_to_sparse_from_mask_and_pixel_centres(mask, unmasked_sparse_grid_pixel_centres, total_sparse_pixels): """Determine the mapping between every pixelization-grid pixel and masked pixelization-grid pixel. This is performed by checking whe...
Using the mapping between the regular - grid and unmasked pixelization grid compute the mapping between each regular pixel and the masked pixelization grid.
def regular_to_sparse_from_sparse_mappings(regular_to_unmasked_sparse, unmasked_sparse_to_sparse): """Using the mapping between the regular-grid and unmasked pixelization grid, compute the mapping between each regular pixel and the masked pixelization grid. Parameters ----------- regular_to_unmaske...
Use the central arc - second coordinate of every unmasked pixelization grid s pixels and mapping between each pixelization pixel and unmasked pixelization pixel to compute the central arc - second coordinate of every masked pixelization grid pixel.
def sparse_grid_from_unmasked_sparse_grid(unmasked_sparse_grid, sparse_to_unmasked_sparse): """Use the central arc-second coordinate of every unmasked pixelization grid's pixels and mapping between each pixelization pixel and unmasked pixelization pixel to compute the central arc-second coordinate of every mask...
Resize an array to a new size by extracting a sub - set of the array.
def extracted_array_2d_from_array_2d_and_coordinates(array_2d, y0, y1, x0, x1): """Resize an array to a new size by extracting a sub-set of the array. The extracted input coordinates use NumPy convention, such that the upper values should be specified as +1 the \ dimensions of the extracted array. In ...
Resize an array to a new size around a central pixel.
def resized_array_2d_from_array_2d_and_resized_shape(array_2d, resized_shape, origin=(-1, -1), pad_value=0.0): """Resize an array to a new size around a central pixel. If the origin (e.g. the central pixel) of the resized array is not specified, the central pixel of the array is \ calculated automatically....
Bin up an array to coarser resolution by binning up groups of pixels and using their mean value to determine \ the value of the new pixel.
def bin_up_array_2d_using_mean(array_2d, bin_up_factor): """Bin up an array to coarser resolution, by binning up groups of pixels and using their mean value to determine \ the value of the new pixel. If an array of shape (8,8) is input and the bin up size is 2, this would return a new array of size (4,4) ...
Write a 2D NumPy array to a. fits file.
def numpy_array_2d_to_fits(array_2d, file_path, overwrite=False): """Write a 2D NumPy array to a .fits file. Before outputting a NumPy array, the array is flipped upside-down using np.flipud. This is so that the arrays \ appear the same orientation as .fits files loaded in DS9. Parameters --------...
Read a 2D NumPy array to a. fits file.
def numpy_array_2d_from_fits(file_path, hdu): """Read a 2D NumPy array to a .fits file. After loading the NumPy array, the array is flipped upside-down using np.flipud. This is so that the arrays \ appear the same orientation as .fits files loaded in DS9. Parameters ---------- file_path : str ...
Plot the model image of a specific plane of a lens fit.
def plot_lens_subtracted_image( fit, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, as_subplot=False, units='arcsec', kpc_per_arcsec=None, figsize=(7, 7), aspect='square', cmap='jet', norm='linear', norm_min=None, norm_max=None, linthresh=0.05, linscale=0.01, ...
Plot the model image of a specific plane of a lens fit.
def plot_model_image_of_planes( fit, plot_foreground=False, plot_source=False, mask=None, extract_array_from_mask=False, zoom_around_mask=False, positions=None, plot_mass_profile_centres=True, as_subplot=False, units='arcsec', kpc_per_arcsec=None, figsize=(7, 7), aspect='square', cmap='j...
If none of the tracer s galaxies have a light profile it image - plane image cannot be computed. This wrapper \ makes this property return * None *.
def check_tracer_for_light_profile(func): """If none of the tracer's galaxies have a light profile, it image-plane image cannot be computed. This wrapper \ makes this property return *None*. Parameters ---------- func : (self) -> Object A property function that requires galaxies to have a m...
If none of the tracer s galaxies have a mass profile it surface density potential and deflections cannot \ be computed. This wrapper makes these properties return * None *.
def check_tracer_for_mass_profile(func): """If none of the tracer's galaxies have a mass profile, it surface density, potential and deflections cannot \ be computed. This wrapper makes these properties return *None*. Parameters ---------- func : (self) -> Object A property function that req...
For an input grid of ( y x ) arc - second image - plane coordinates ray - trace the coordinates to any redshift in \ the strong lens configuration.
def grid_at_redshift_from_image_plane_grid_and_redshift(self, image_plane_grid, redshift): """For an input grid of (y,x) arc-second image-plane coordinates, ray-trace the coordinates to any redshift in \ the strong lens configuration. This is performed using multi-plane ray-tracing and the exis...
For a given inversion mapping matrix convolve every pixel s mapped regular with the PSF kernel.
def convolve_mapping_matrix(self, mapping_matrix): """For a given inversion mapping matrix, convolve every pixel's mapped regular with the PSF kernel. A mapping matrix provides non-zero entries in all elements which map two pixels to one another (see *inversions.mappers*). For example,...