_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q257800 | bin_up_mask_2d | validation | def bin_up_mask_2d(mask_2d, bin_up_factor):
"""Bin up an array to coarser resolution, by binning up groups of pixels and using their sum 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) where \
every pixel was the sum of each collection of 2x2 pixels on the (8,8) array.
If binning up the array leads to an edge being cut (e.g. a (9,9) array binned up by 2), an array is first \
extracted around the centre of that array.
Parameters
----------
mask_2d : ndarray
The 2D array that is resized.
new_shape : (int, int)
The (y,x) new pixel dimension of the trimmed array.
origin : (int, int)
The oigin of the resized array, e.g. the central pixel around which the array is extracted.
Returns
-------
ndarray
The resized 2D array from the input 2D array.
Examples
--------
array_2d = np.ones((5,5))
resize_array | python | {
"resource": ""
} |
q257801 | setup_figure | validation | def setup_figure(figsize, as_subplot):
"""Setup a figure for plotting an image.
Parameters
-----------
figsize : (int, int)
The size of the figure in (rows, columns).
as_subplot : bool
If the figure is a subplot, the setup_figure function is omitted to ensure that each subplot does not create a \
| python | {
"resource": ""
} |
q257802 | output_figure | validation | def output_figure(array, as_subplot, output_path, output_filename, output_format):
"""Output the figure, either as an image on the screen or to the hard-disk as a .png or .fits file.
Parameters
-----------
array : ndarray
The 2D array of image to be output, required for outputting the image as a fits file.
as_subplot : bool
Whether the figure is part of subplot, in which case the figure is not output so that the entire subplot can \
be output instead using the *output_subplot_array* function.
output_path : str
| python | {
"resource": ""
} |
q257803 | output_subplot_array | validation | def output_subplot_array(output_path, output_filename, output_format):
"""Output a figure which consists of a set of subplot,, either as an image on the screen or to the hard-disk as a \
.png file.
Parameters
-----------
output_path : str
The path on the hard-disk where the figure is output.
output_filename : str
The filename of the figure that is output.
output_format : str
The format the figue is output:
'show' - display on computer screen.
'png' - output to hard-disk as a png.
| python | {
"resource": ""
} |
q257804 | image_psf_shape_tag_from_image_psf_shape | validation | def image_psf_shape_tag_from_image_psf_shape(image_psf_shape):
"""Generate an image psf shape tag, to customize phase names based on size of the image PSF that the original PSF \
is trimmed to for faster run times.
This changes the phase name 'phase_name' | python | {
"resource": ""
} |
q257805 | inversion_psf_shape_tag_from_inversion_psf_shape | validation | def inversion_psf_shape_tag_from_inversion_psf_shape(inversion_psf_shape):
"""Generate an inversion psf shape tag, to customize phase names based on size of the inversion PSF that the \
original PSF is trimmed to for faster run times.
This changes the phase name 'phase_name' | python | {
"resource": ""
} |
q257806 | bulge_disk_tag_from_align_bulge_disks | validation | def bulge_disk_tag_from_align_bulge_disks(align_bulge_disk_centre, align_bulge_disk_axis_ratio, align_bulge_disk_phi):
"""Generate a tag for the alignment of the geometry of the bulge and disk of a bulge-disk system, to customize \
phase names based on the bulge-disk model. This adds together the bulge_disk tags generated in the 3 functions
above
"""
| python | {
"resource": ""
} |
q257807 | compute_deflections_at_next_plane | validation | def compute_deflections_at_next_plane(plane_index, total_planes):
"""This function determines whether the tracer should compute the deflections at the next plane.
This is True if there is another plane after this plane, else it is False..
Parameters
-----------
plane_index : int
The index of the plane we are deciding if we should compute its deflections.
total_planes : int | python | {
"resource": ""
} |
q257808 | scaled_deflection_stack_from_plane_and_scaling_factor | validation | def scaled_deflection_stack_from_plane_and_scaling_factor(plane, scaling_factor):
"""Given a plane and scaling factor, compute a set of scaled deflections.
Parameters
-----------
plane : plane.Plane
The plane whose deflection stack is scaled.
scaling_factor : float
The factor the deflection angles are scaled by, which is typically the scaling factor between redshifts for \
| python | {
"resource": ""
} |
q257809 | grid_stack_from_deflection_stack | validation | def grid_stack_from_deflection_stack(grid_stack, deflection_stack):
"""For a deflection stack, comput a new grid stack but subtracting the deflections"""
if deflection_stack is not None:
| python | {
"resource": ""
} |
q257810 | constant_regularization_matrix_from_pixel_neighbors | validation | def constant_regularization_matrix_from_pixel_neighbors(coefficients, pixel_neighbors, pixel_neighbors_size):
"""From the pixel-neighbors, setup the regularization matrix using the constant regularization scheme.
Parameters
----------
coefficients : tuple
The regularization coefficients which controls the degree of smoothing of the inversion reconstruction.
pixel_neighbors : ndarray
An array of length (total_pixels) which provides the index of all neighbors of every pixel in \
the Voronoi grid (entries of -1 correspond to no neighbor).
pixel_neighbors_size : ndarrayy
An array of length (total_pixels) which gives the number of neighbors of every pixel in the \
Voronoi grid.
"""
| python | {
"resource": ""
} |
q257811 | weighted_regularization_matrix_from_pixel_neighbors | validation | def weighted_regularization_matrix_from_pixel_neighbors(regularization_weights, pixel_neighbors,
pixel_neighbors_size):
"""From the pixel-neighbors, setup the regularization matrix using the weighted regularization scheme.
Parameters
----------
regularization_weights : ndarray
The regularization_ weight of each pixel, which governs how much smoothing is applied to that individual pixel.
pixel_neighbors : ndarray
An array of length (total_pixels) which provides the index of all neighbors of every pixel in \
the Voronoi grid (entries of -1 correspond to no neighbor).
pixel_neighbors_size : ndarrayy
An array of length (total_pixels) which gives the number of neighbors of every pixel in the \
Voronoi grid.
"""
pixels = len(regularization_weights)
regularization_matrix = np.zeros(shape=(pixels, pixels)) | python | {
"resource": ""
} |
q257812 | plot_figure | validation | def plot_figure(array, as_subplot, units, kpc_per_arcsec, figsize, aspect, cmap, norm, norm_min, norm_max,
linthresh, linscale, xticks_manual, yticks_manual):
"""Open a matplotlib figure and plot the array of data on it.
Parameters
-----------
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
as_subplot : bool
Whether the array is plotted as part of a subplot, in which case the grid figure is not opened / closed.
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float or None
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
figsize : (int, int)
The size of the figure in (rows, columns).
aspect : str
The aspect ratio of the array, specifically whether it is forced to be square ('equal') or adapts its size to \
the figure size ('auto').
cmap : str
The colormap the array is plotted using, which may be chosen from the standard matplotlib colormaps.
norm : str
The normalization of the colormap used to plot the image, specifically whether it is linear ('linear'), log \
('log') or a symmetric log normalization ('symmetric_log').
norm_min : float or None
The minimum array value the colormap map spans (all values below this value are plotted the same color).
norm_max : float or None
The maximum array value the colormap map spans (all values above this value are plotted the same color).
linthresh : float
For the 'symmetric_log' colormap normalization ,this specifies the range of values within which the colormap \
| python | {
"resource": ""
} |
q257813 | get_normalization_min_max | validation | def get_normalization_min_max(array, norm_min, norm_max):
"""Get the minimum and maximum of the normalization of the array, which sets the lower and upper limits of the \
colormap.
If norm_min / norm_max are not supplied, the minimum / maximum values of the array of data are used.
Parameters
-----------
array : data.array.scaled_array.ScaledArray
| python | {
"resource": ""
} |
q257814 | set_colorbar | validation | def set_colorbar(cb_ticksize, cb_fraction, cb_pad, cb_tick_values, cb_tick_labels):
"""Setup the colorbar of the figure, specifically its ticksize and the size is appears relative to the figure.
Parameters
-----------
cb_ticksize : int
The size of the tick labels on the colorbar.
cb_fraction : float
The fraction of the figure that the colorbar takes up, which resizes the colorbar relative to the figure.
cb_pad : float
Pads the color bar in the figure, which resizes the colorbar relative to the figure.
cb_tick_values : [float]
Manually specified values of where the colorbar tick labels appear on the colorbar.
cb_tick_labels : [float]
Manually specified labels of the color bar tick labels, which appear where specified by cb_tick_values.
"""
if cb_tick_values is None and cb_tick_labels is None: | python | {
"resource": ""
} |
q257815 | plot_mask | validation | def plot_mask(mask, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
"""Plot the mask of the array on the figure.
Parameters
-----------
mask : ndarray of data.array.mask.Mask
The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float or None
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
pointsize : int
The size of the points plotted to show the mask.
"""
if mask is not None:
plt.gca()
edge_pixels = | python | {
"resource": ""
} |
q257816 | plot_border | validation | def plot_border(mask, should_plot_border, units, kpc_per_arcsec, pointsize, zoom_offset_pixels):
"""Plot the borders of the mask or the array on the figure.
Parameters
-----------t.
mask : ndarray of data.array.mask.Mask
The mask applied to the array, the edge of which is plotted as a set of points over the plotted array.
should_plot_border : bool
If a mask is supplied, its borders pixels (e.g. the exterior edge) is plotted if this is *True*.
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float or None
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
border_pointsize : int
The size of the points plotted to show the borders.
"""
if should_plot_border and mask | python | {
"resource": ""
} |
q257817 | plot_points | validation | def plot_points(points_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):
"""Plot a set of points over the array of data on the figure.
Parameters
-----------
positions : [[]]
Lists of (y,x) coordinates on the image which are plotted as colored dots, to highlight specific pixels.
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float or None
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
pointsize : int
The size of the points plotted to show the input positions.
"""
if points_arcsec is not None:
points_arcsec = list(map(lambda | python | {
"resource": ""
} |
q257818 | plot_grid | validation | def plot_grid(grid_arcsec, array, units, kpc_per_arcsec, pointsize, zoom_offset_arcsec):
"""Plot a grid of points over the array of data on the figure.
Parameters
-----------.
grid_arcsec : ndarray or data.array.grids.RegularGrid
A grid of (y,x) coordinates in arc-seconds which may be plotted over the array.
array : data.array.scaled_array.ScaledArray
The 2D array of data which is plotted.
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float or None
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
grid_pointsize : int
The size of the points plotted to show | python | {
"resource": ""
} |
q257819 | Mapper.mapping_matrix | validation | def mapping_matrix(self):
"""The mapping matrix is a matrix representing the mapping between every unmasked pixel of a grid and \
the pixels of a pixelization. Non-zero entries signify a mapping, whereas zeros signify no mapping.
For example, if the regular grid has 5 pixels and the pixelization 3 pixels, with the following mappings:
regular pixel 0 -> pixelization pixel 0
regular pixel 1 -> pixelization pixel 0
regular pixel 2 -> pixelization pixel 1
regular pixel 3 -> pixelization pixel 1
regular pixel 4 -> pixelization pixel 2
The mapping matrix (which is of dimensions regular_pixels x pixelization_pixels) would appear as follows:
[1, 0, 0] [0->0]
[1, 0, 0] [1->0]
[0, 1, 0] [2->1]
[0, 1, 0] [3->1]
[0, 0, 1] [4->2]
The mapping matrix is in fact built using the sub-grid of the grid-stack, whereby each regular-pixel is \
divided into a regular grid of sub-pixels which are all paired to pixels in the pixelization. The entires \
in the mapping matrix now become fractional values dependent on the sub-grid size. For example, for a 2x2 \
sub-grid in each pixel (which means the fraction value is 1.0/(2.0^2) = 0.25, if we have the following mappings:
regular pixel 0 -> sub pixel 0 -> pixelization pixel 0
regular pixel 0 -> sub pixel 1 -> pixelization pixel 1
regular pixel 0 -> sub pixel 2 -> pixelization pixel 1
regular pixel 0 -> sub pixel 3 -> pixelization pixel 1
regular pixel 1 -> sub pixel 0 -> pixelization pixel 1
regular pixel 1 -> sub | python | {
"resource": ""
} |
q257820 | Mapper.pix_to_regular | validation | def pix_to_regular(self):
"""Compute the mappings between a pixelization's pixels and the unmasked regular-grid pixels. These mappings \
are determined after the regular-grid is used to determine the pixelization.
The pixelization's pixels map to different number of regular-grid pixels, thus a list of lists is used to \
represent these mappings"""
| python | {
"resource": ""
} |
q257821 | Mapper.pix_to_sub | validation | def pix_to_sub(self):
"""Compute the mappings between a pixelization's pixels and the unmasked sub-grid pixels. These mappings \
are determined after the regular-grid is used to determine the pixelization.
The pixelization's pixels map to different number of sub-grid pixels, thus a list of lists is used to \
represent these mappings"""
| python | {
"resource": ""
} |
q257822 | VoronoiMapper.regular_to_pix | validation | def regular_to_pix(self):
"""The 1D index mappings between the regular pixels and Voronoi pixelization pixels."""
return mapper_util.voronoi_regular_to_pix_from_grids_and_geometry(regular_grid=self.grid_stack.regular,
| python | {
"resource": ""
} |
q257823 | VoronoiMapper.sub_to_pix | validation | def sub_to_pix(self):
""" The 1D index mappings between the sub pixels and Voronoi pixelization pixels. """
return mapper_util.voronoi_sub_to_pix_from_grids_and_geometry(sub_grid=self.grid_stack.sub,
regular_to_nearest_pix=self.grid_stack.pix.regular_to_nearest_pix,
| python | {
"resource": ""
} |
q257824 | setup_random_seed | validation | def setup_random_seed(seed):
"""Setup the random seed. If the input seed is -1, the code will use a random seed for every run. If it is \
positive, that seed is used for all runs, thereby giving reproducible results.
Parameters
----------
seed : int
The seed of the random number generator.
| python | {
"resource": ""
} |
q257825 | generate_poisson_noise | validation | def generate_poisson_noise(image, exposure_time_map, seed=-1):
"""
Generate a two-dimensional poisson noise_maps-mappers from an image.
Values are computed from a Poisson distribution using the image's input values in units of counts.
Parameters
----------
image : ndarray
The 2D image, whose values in counts are used to draw Poisson noise_maps values.
exposure_time_map : Union(ndarray, int)
2D array of the exposure time in each pixel used to convert to / from counts and electrons per second.
seed : int
The seed of the random number generator, used for the random noise_maps maps.
Returns
| python | {
"resource": ""
} |
q257826 | load_ccd_data_from_fits | validation | 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,
noise_map_path=None, noise_map_hdu=0,
noise_map_from_image_and_background_noise_map=False,
convert_noise_map_from_weight_map=False,
convert_noise_map_from_inverse_noise_map=False,
background_noise_map_path=None, background_noise_map_hdu=0,
convert_background_noise_map_from_weight_map=False,
convert_background_noise_map_from_inverse_noise_map=False,
poisson_noise_map_path=None, poisson_noise_map_hdu=0,
poisson_noise_map_from_image=False,
convert_poisson_noise_map_from_weight_map=False,
convert_poisson_noise_map_from_inverse_noise_map=False,
exposure_time_map_path=None, exposure_time_map_hdu=0,
exposure_time_map_from_single_value=None,
exposure_time_map_from_inverse_noise_map=False,
background_sky_map_path=None, background_sky_map_hdu=0,
convert_from_electrons=False,
gain=None, convert_from_adus=False, lens_name=None):
"""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.
This factory also includes a number of routines for converting the ccd-data from units not supported by PyAutoLens \
(e.g. adus, electrons) to electrons per second.
Parameters
----------
lens_name
image_path : str
The path to the image .fits file containing the image (e.g. '/path/to/image.fits')
pixel_scale : float
The size of each pixel in arc seconds.
image_hdu : int
The hdu the image is contained in the .fits file specified by *image_path*.
image_hdu : int
The hdu the image is contained in the .fits file that *image_path* points too.
resized_ccd_shape : (int, int) | None
If input, the ccd arrays that are image sized, e.g. the image, noise-maps) are resized to these dimensions.
resized_ccd_origin_pixels : (int, int) | None
If the ccd arrays are resized, this defines a new origin (in pixels) around which recentering occurs.
resized_ccd_origin_arcsec : (float, float) | None
If the ccd arrays are resized, this defines a new origin (in arc-seconds) around which recentering occurs.
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 .fits file specified by *psf_path*.
resized_psf_shape : (int, int) | None
If input, the psf is resized to these dimensions.
renormalize_psf : bool
If True, the PSF is renoralized such that all elements sum to 1.0.
noise_map_path : str
The path to the noise_map .fits file containing the noise_map (e.g. '/path/to/noise_map.fits')
noise_map_hdu : int
The hdu the noise_map is contained in the .fits file specified by *noise_map_path*.
noise_map_from_image_and_background_noise_map : bool
If True, the noise-map is computed from the observed image and background noise-map \
(see NoiseMap.from_image_and_background_noise_map).
convert_noise_map_from_weight_map : bool
If True, the noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_noise_map_from_inverse_noise_map : bool
If True, the noise-map loaded from the .fits file is converted from an inverse noise-map to a noise-map (see \
*NoiseMap.from_inverse_noise_map).
background_noise_map_path : str
The path to the background_noise_map .fits file containing the background noise-map \
(e.g. '/path/to/background_noise_map.fits')
background_noise_map_hdu : int
The hdu the background_noise_map is contained in the .fits file specified by *background_noise_map_path*.
convert_background_noise_map_from_weight_map : bool
If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_background_noise_map_from_inverse_noise_map : bool
If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
noise-map (see *NoiseMap.from_inverse_noise_map).
poisson_noise_map_path : str
The path to the poisson_noise_map .fits file containing the Poisson noise-map \
(e.g. '/path/to/poisson_noise_map.fits')
poisson_noise_map_hdu : int
The hdu the poisson_noise_map is contained in the .fits file specified by *poisson_noise_map_path*.
poisson_noise_map_from_image : bool
If True, the Poisson noise-map is estimated using the image.
convert_poisson_noise_map_from_weight_map : bool
If True, the Poisson noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_poisson_noise_map_from_inverse_noise_map : bool
If True, the Poisson noise-map loaded from the .fits file is converted from an inverse noise-map to a \
noise-map (see *NoiseMap.from_inverse_noise_map).
exposure_time_map_path : str
The path to the exposure_time_map .fits file containing the exposure time map \
(e.g. '/path/to/exposure_time_map.fits')
exposure_time_map_hdu : int
The hdu the exposure_time_map is contained in the .fits file specified by *exposure_time_map_path*.
exposure_time_map_from_single_value : float
The exposure time of the ccd imaging, which is used to compute the exposure-time map as a single value \
(see *ExposureTimeMap.from_single_value*).
exposure_time_map_from_inverse_noise_map : bool
If True, the exposure-time map is computed from the background noise_map map \
(see *ExposureTimeMap.from_background_noise_map*)
background_sky_map_path : str
The path to the background_sky_map .fits file containing the background sky map \
(e.g. '/path/to/background_sky_map.fits').
background_sky_map_hdu : int
The hdu the background_sky_map is contained in the .fits file specified by *background_sky_map_path*.
convert_from_electrons : bool
If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
time map.
gain : float
The image gain, used for convert from ADUs.
convert_from_adus : bool
If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
time map and gain.
"""
image | python | {
"resource": ""
} |
q257827 | load_image | validation | 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 .fits file specified by *image_path*.
pixel_scale : float
| python | {
"resource": ""
} |
q257828 | load_noise_map | validation | 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 noise-map from a .fits file.
This factory also includes a number of routines for converting the noise-map from from other units (e.g. \
a weight map) or computing the noise-map from other unblurred_image_1d (e.g. the ccd image and background noise-map).
Parameters
----------
noise_map_path : str
The path to the noise_map .fits file containing the noise_map (e.g. '/path/to/noise_map.fits')
noise_map_hdu : int
The hdu the noise_map is contained in the .fits file specified by *noise_map_path*.
pixel_scale : float
The size of each pixel in arc seconds.
image : ndarray
The image-image, which the noise-map can be calculated using.
background_noise_map : ndarray
The background noise-map, which the noise-map can be calculated using.
exposure_time_map : ndarray
The exposure-time map, which the noise-map can be calculated using.
convert_noise_map_from_weight_map : bool
If True, the noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_noise_map_from_inverse_noise_map : bool
If True, the noise-map loaded from the .fits file is converted from an inverse noise-map to a noise-map (see \
*NoiseMap.from_inverse_noise_map).
background_noise_map_path : str
The path and filename of the .fits image containing the background noise-map.
background_noise_map_hdu : int
The hdu the background noise-map is contained in the .fits file that *background_noise_map_path* points too.
convert_background_noise_map_from_weight_map : bool
If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_background_noise_map_from_inverse_noise_map : bool
If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
noise-map (see *NoiseMap.from_inverse_noise_map).
noise_map_from_image_and_background_noise_map : bool
If True, the noise-map is computed from the observed image and background noise-map \
(see NoiseMap.from_image_and_background_noise_map).
convert_from_electrons : bool
If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
time map.
gain : float
The image gain, used for convert from ADUs.
convert_from_adus : bool
If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
time map and gain.
"""
noise_map_options = sum([convert_noise_map_from_weight_map,
convert_noise_map_from_inverse_noise_map,
noise_map_from_image_and_background_noise_map])
if noise_map_options > 1:
raise exc.DataException('You have specified more than one method to load the noise_map map, e.g.:'
| python | {
"resource": ""
} |
q257829 | load_background_noise_map | validation | 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 file.
This factory also includes a number of routines for converting the background noise-map from from other units (e.g. \
a weight map).
Parameters
----------
background_noise_map_path : str
The path to the background_noise_map .fits file containing the background noise-map \
(e.g. '/path/to/background_noise_map.fits')
background_noise_map_hdu : int
The hdu the background_noise_map is contained in the .fits file specified by *background_noise_map_path*.
pixel_scale : float
The size of each pixel in arc seconds.
convert_background_noise_map_from_weight_map : bool
If True, the bacground noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_background_noise_map_from_inverse_noise_map : bool
If True, the background noise-map loaded from the .fits file is converted from an inverse noise-map to a \
noise-map (see *NoiseMap.from_inverse_noise_map).
"""
background_noise_map_options = sum([convert_background_noise_map_from_weight_map,
convert_background_noise_map_from_inverse_noise_map])
if background_noise_map_options == 0 and background_noise_map_path is not None:
return | python | {
"resource": ""
} |
q257830 | load_poisson_noise_map | validation | 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,
image, exposure_time_map, convert_from_electrons, gain, convert_from_adus):
"""Factory for loading the Poisson noise-map from a .fits file.
This factory also includes a number of routines for converting the Poisson noise-map from from other units (e.g. \
a weight map) or computing the Poisson noise_map from other unblurred_image_1d (e.g. the ccd image).
Parameters
----------
poisson_noise_map_path : str
The path to the poisson_noise_map .fits file containing the Poisson noise-map \
(e.g. '/path/to/poisson_noise_map.fits')
poisson_noise_map_hdu : int
The hdu the poisson_noise_map is contained in the .fits file specified by *poisson_noise_map_path*.
pixel_scale : float
The size of each pixel in arc seconds.
convert_poisson_noise_map_from_weight_map : bool
If True, the Poisson noise-map loaded from the .fits file is converted from a weight-map to a noise-map (see \
*NoiseMap.from_weight_map).
convert_poisson_noise_map_from_inverse_noise_map : bool
If True, the Poisson noise-map loaded from the .fits file is converted from an inverse noise-map to a \
noise-map (see *NoiseMap.from_inverse_noise_map).
poisson_noise_map_from_image : bool
If True, the Poisson noise-map is estimated using the image.
image : ndarray
The image, which the Poisson noise-map can be calculated using.
background_noise_map : ndarray
The background noise-map, which the Poisson noise-map can be calculated using.
exposure_time_map : ndarray
The exposure-time map, which the Poisson noise-map can be calculated using.
convert_from_electrons : bool
If True, the input unblurred_image_1d are in units of electrons and all converted to electrons / second using the exposure \
time map.
gain : float
The image gain, used for convert from ADUs.
convert_from_adus : bool
If True, the input unblurred_image_1d are in units of adus and all converted to electrons / second using the exposure \
time map and gain.
"""
poisson_noise_map_options = sum([convert_poisson_noise_map_from_weight_map,
convert_poisson_noise_map_from_inverse_noise_map,
poisson_noise_map_from_image])
if poisson_noise_map_options == 0 and poisson_noise_map_path is not None:
return PoissonNoiseMap.from_fits_with_pixel_scale(file_path=poisson_noise_map_path, hdu=poisson_noise_map_hdu,
| python | {
"resource": ""
} |
q257831 | load_psf | validation | 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 .fits file | python | {
"resource": ""
} |
q257832 | load_exposure_time_map | validation | 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 for computing the exposure-time map from other unblurred_image_1d \
(e.g. the background noise-map).
Parameters
----------
exposure_time_map_path : str
The path to the exposure_time_map .fits file containing the exposure time map \
(e.g. '/path/to/exposure_time_map.fits')
exposure_time_map_hdu : int
The hdu the exposure_time_map is contained in the .fits file specified by *exposure_time_map_path*.
pixel_scale : float
The size of each pixel in arc seconds.
shape : (int, int)
The shape of the image, required if a single value is used to calculate the exposure time map.
exposure_time : float
The exposure-time used to compute the expsure-time map if only a single value is used.
exposure_time_map_from_inverse_noise_map : bool
If True, the exposure-time map is computed from the background noise_map map \
(see *ExposureTimeMap.from_background_noise_map*)
inverse_noise_map : ndarray
The background noise-map, which the Poisson noise-map can be calculated using.
"""
exposure_time_map_options = sum([exposure_time_map_from_inverse_noise_map])
if exposure_time is not None and exposure_time_map_path is not None:
raise exc.DataException(
'You have supplied both a exposure_time_map_path to an exposure time map and an exposure time. Only'
| python | {
"resource": ""
} |
q257833 | load_background_sky_map | validation | 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 \
(e.g. '/path/to/background_sky_map.fits').
background_sky_map_hdu : int
The hdu the background_sky_map is contained in the .fits file specified by *background_sky_map_path*.
pixel_scale : float
| python | {
"resource": ""
} |
q257834 | load_positions | validation | 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 another are resampled during the non-linear search.
Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
lines of the same positions file.
Parameters
----------
positions_path : str
| python | {
"resource": ""
} |
q257835 | output_positions | validation | 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 pixels within a threshold value of \
one another are resampled during the non-linear search.
Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
lines of the same positions file.
Parameters
----------
positions : [[[]]]
| python | {
"resource": ""
} |
q257836 | CCDData.signal_to_noise_map | validation | def signal_to_noise_map(self):
"""The estimated signal-to-noise_maps mappers of the image."""
| python | {
"resource": ""
} |
q257837 | CCDData.absolute_signal_to_noise_map | validation | def absolute_signal_to_noise_map(self):
"""The estimated absolute_signal-to-noise_maps mappers of the image."""
| python | {
"resource": ""
} |
q257838 | NoiseMap.from_weight_map | validation | 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).
The weight map may contain zeros, in which cause the variances are converted to large values to omit them from \
the analysis.
Parameters
-----------
pixel_scale : float
The size of each pixel in arc | python | {
"resource": ""
} |
q257839 | NoiseMap.from_inverse_noise_map | validation | 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:
Variance = 1.0 / inverse_std_map.
The weight map may contain zeros, in which cause the variances are converted to large values to omit them from \
the analysis.
Parameters
-----------
pixel_scale : float
| python | {
"resource": ""
} |
q257840 | PSF.simulate_as_gaussian | validation | 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, phi=phi, intensity=1.0, sigma=sigma)
grid_1d = grid_util.regular_grid_1d_masked_from_mask_pixel_scales_and_origin(mask=np.full(shape, False),
pixel_scales=(
| python | {
"resource": ""
} |
q257841 | PSF.from_fits_renormalized | validation | 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 file.
Returns
-------
psf: PSF
| python | {
"resource": ""
} |
q257842 | PSF.from_fits_with_scale | validation | 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 : | python | {
"resource": ""
} |
q257843 | PSF.new_psf_with_renormalized_array | validation | def new_psf_with_renormalized_array(self):
"""Renormalize the PSF such that its | python | {
"resource": ""
} |
q257844 | PSF.convolve | validation | 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
| python | {
"resource": ""
} |
q257845 | Rectangular.geometry_from_grid | validation | 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 : ndarray
The (y,x) grid of coordinates over which the rectangular pixelization is placed to determine its geometry.
buffer : float
The size the pixelization is buffered relative to the grid.
"""
y_min = np.min(grid[:, 0]) - buffer
y_max = np.max(grid[:, 0]) + buffer
x_min = np.min(grid[:, 1]) - buffer
| python | {
"resource": ""
} |
q257846 | Voronoi.geometry_from_grid | validation | 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
The (y,x) grid of coordinates which determine the Voronoi pixelization's geometry.
pixel_centres : ndarray
The (y,x) centre of every Voronoi pixel in arc-seconds.
origin : (float, float)
The arc-second origin of the Voronoi pixelization's coordinate system.
| python | {
"resource": ""
} |
q257847 | Voronoi.voronoi_from_pixel_centers | validation | 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.
""" | python | {
"resource": ""
} |
q257848 | Voronoi.neighbors_from_pixelization | validation | 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.
| python | {
"resource": ""
} |
q257849 | set_xy_labels | validation | 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.
Parameters
-----------
units : str
The units of the y / x axis of the plots, in arc-seconds ('arcsec') or kiloparsecs ('kpc').
kpc_per_arcsec : float
The conversion factor between arc-seconds and kiloparsecs, required to plot the units in kpc.
xlabelsize : int
The fontsize of the x axes label.
ylabelsize : int
The fontsize of the y axes label.
xyticksize : int
The font size of | python | {
"resource": ""
} |
q257850 | grid_interpolate | validation | 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 the function.
If no interpolator attribute is associated with the input grid then the function is called as normal.
Parameters
----------
func
Some method that accepts a grid
Returns
-------
decorated_function
The function with optional interpolation
""" | python | {
"resource": ""
} |
q257851 | GridStack.unmasked_blurred_image_from_psf_and_unmasked_image | validation | 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 \
entire image as opposed to just the masked region.
Parameters
----------
psf : ccd.PSF
The PSF of the image used for convolution.
unmasked_image_1d : ndarray
| python | {
"resource": ""
} |
q257852 | GridStack.grid_stack_from_mask_sub_grid_size_and_psf_shape | validation | 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-stack's grid_stack.
sub_grid_size : int
The size of a sub-pixel's sub-grid (sub_grid_size x sub_grid_size).
psf_shape : (int, int)
the shape of the PSF used in the analysis, which defines the mask's blurring-region.
"""
| python | {
"resource": ""
} |
q257853 | GridStack.from_shape_pixel_scale_and_sub_grid_size | validation | 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, int)
The 2D shape of the array, where all pixels are used to generate the grid-stack's grid_stack.
pixel_scale : float
The size of each pixel in arc seconds.
sub_grid_size : int
The size of a sub-pixel's sub-grid (sub_grid_size | python | {
"resource": ""
} |
q257854 | GridStack.padded_grid_stack_from_mask_sub_grid_size_and_psf_shape | validation | 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 using.
sub_grid_size : int
The size of a sub-pixels sub-grid (sub_grid_size x sub_grid_size).
psf_shape : (int, int)
The shape of the PSF used in the analysis, which defines the mask's blurring-region.
"""
regular_padded_grid = PaddedRegularGrid.padded_grid_from_shape_psf_shape_and_pixel_scale(
shape=mask.shape,
psf_shape=psf_shape,
pixel_scale=mask.pixel_scale)
sub_padded_grid = PaddedSubGrid.padded_grid_from_mask_sub_grid_size_and_psf_shape(mask=mask,
| python | {
"resource": ""
} |
q257855 | GridStack.map_function | validation | def map_function(self, func, *arg_lists):
"""Map a function to all grid_stack in a grid-stack"""
| python | {
"resource": ""
} |
q257856 | RegularGrid.array_2d_from_array_1d | validation | 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.
"""
| python | {
"resource": ""
} |
q257857 | RegularGrid.scaled_array_2d_from_array_1d | validation | 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.
"""
| python | {
"resource": ""
} |
q257858 | RegularGrid.yticks | validation | def yticks(self):
"""Compute the yticks labels of this grid, used for plotting the | python | {
"resource": ""
} |
q257859 | RegularGrid.xticks | validation | def xticks(self):
"""Compute the xticks labels of this grid, used for plotting the | python | {
"resource": ""
} |
q257860 | SubGrid.regular_data_1d_from_sub_data_1d | validation | 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
-----------
sub_array_1d : ndarray | python | {
"resource": ""
} |
q257861 | SparseToRegularGrid.unmasked_sparse_to_sparse | validation | 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,
| python | {
"resource": ""
} |
q257862 | SparseToRegularGrid.sparse_to_unmasked_sparse | validation | 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(
| python | {
"resource": ""
} |
q257863 | SparseToRegularGrid.regular_to_sparse | validation | 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(
| python | {
"resource": ""
} |
q257864 | PaddedRegularGrid.padded_grid_from_shape_psf_shape_and_pixel_scale | validation | 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 beyond the input shape but will blurred light into the 2D array's shape due to the psf.
Parameters
----------
shape : (int, int)
The (y,x) shape of the masked-grid's 2D image in units of pixels.
psf_shape : (int, int)
The shape of the psf which defines the blurring region and therefore size of padding.
pixel_scale : float
The scale of | python | {
"resource": ""
} |
q257865 | PaddedRegularGrid.padded_blurred_image_2d_from_padded_image_1d_and_psf | validation | 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
| python | {
"resource": ""
} |
q257866 | PaddedRegularGrid.array_2d_from_array_1d | validation | 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*.
"""
padded_array_2d = self.map_to_2d_keep_padded(padded_array_1d)
pad_size_0 = self.mask.shape[0] - self.image_shape[0] | python | {
"resource": ""
} |
q257867 | PaddedRegularGrid.map_to_2d_keep_padded | validation | 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*.
| python | {
"resource": ""
} |
q257868 | RegularGridBorder.relocated_grid_stack_from_grid_stack | validation | 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 \
light-profiles and not inversion-grid_stack.
Parameters
| python | {
"resource": ""
} |
q257869 | set_defaults | validation | 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
"""
def decorator(func):
@functools.wraps(func)
def wrapper(phase, new_value):
new_value = new_value or []
for item in new_value:
| python | {
"resource": ""
} |
q257870 | HyperGalaxyPhase.run | validation | 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
positions
Returns
-------
results: HyperGalaxyResults
A collection of results, with one item per a galaxy
"""
model_image = results.last.unmasked_model_image
galaxy_tuples = results.last.constant.name_instance_tuples_for_class(g.Galaxy)
results_copy = copy.copy(results.last)
for name, galaxy in galaxy_tuples:
optimizer = self.optimizer.copy_with_name_extension(name)
optimizer.variable.hyper_galaxy = g.HyperGalaxy
| python | {
"resource": ""
} |
q257871 | map_2d_array_to_masked_1d_array_from_array_2d_and_mask | validation | 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 all pixels are unmasked:
- pixel [0,0] of the 2D array will correspond to index 0 of the 1D array.
- pixel [0,1] of the 2D array will correspond to index 1 of the 1D array.
- pixel [1,0] of the 2D array will correspond to index 4 of the 1D array.
Parameters
----------
mask : ndarray
A 2D array of bools, where *False* values mean unmasked and are included in the mapping.
array_2d : ndarray
The 2D array of values which are mapped to a 1D array.
Returns
--------
ndarray
A 1D array of values mapped from the 2D array with dimensions (total_unmasked_pixels).
Examples
--------
mask = np.array([[True, False, True],
[False, False, False]
[True, False, True]])
| python | {
"resource": ""
} |
q257872 | sparse_to_unmasked_sparse_from_mask_and_pixel_centres | validation | 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 whether each pixelization-grid pixel is within the regular-masks, and mapping the indexes.
Parameters
-----------
total_sparse_pixels : int
The total number of pixels in the pixelization grid which fall within the regular-masks.
mask : ccd.masks.Mask
The regular-masks within which pixelization pixels must be inside
unmasked_sparse_grid_pixel_centres : ndarray
The centres of the unmasked pixelization grid pixels.
"""
pix_to_full_pix = np.zeros(total_sparse_pixels)
| python | {
"resource": ""
} |
q257873 | unmasked_sparse_to_sparse_from_mask_and_pixel_centres | validation | 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 whether each pixelization-grid pixel is within the regular-masks, and mapping the indexes.
Pixelization pixels are paired with the next masked pixel index. This may mean that a pixel is not paired with a
pixel near it, if the next pixel is on the next row of the grid. This is not a problem, as it is only
unmasked pixels that are referened when computing image_to_pix, which is what this array is used for.
Parameters
-----------
total_sparse_pixels : int
The total number of pixels in the pixelization grid which fall within the regular-masks.
mask : ccd.masks.Mask
The regular-masks within which pixelization pixels must be inside
| python | {
"resource": ""
} |
q257874 | regular_to_sparse_from_sparse_mappings | validation | 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_unmasked_sparse : ndarray
The index mapping between every regular-pixel and masked pixelization pixel.
unmasked_sparse_to_sparse : ndarray
The index mapping between every masked pixelization pixel and unmasked pixelization pixel.
"""
| python | {
"resource": ""
} |
q257875 | sparse_grid_from_unmasked_sparse_grid | validation | 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 masked
pixelization grid pixel.
Parameters
-----------
unmasked_sparse_grid : ndarray
| python | {
"resource": ""
} |
q257876 | extracted_array_2d_from_array_2d_and_coordinates | validation | 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 the example below, an array of size (5,5) is extracted using the coordinates y0=1, y1=4, x0=1, x1=4. This
extracts an array of dimensions (2,2) and is equivalent to array_2d[1:4, 1:4]
Parameters
----------
array_2d : ndarray
The 2D array that is an array is extracted from.
y0 : int
The lower row number (e.g. the higher y-coodinate) of the array that is extracted for the resize.
y1 : int
The upper row number (e.g. the lower y-coodinate) of the array that is extracted for the resize.
x0 : int
The lower column number (e.g. the lower x-coodinate) of the array | python | {
"resource": ""
} |
q257877 | resized_array_2d_from_array_2d_and_resized_shape | validation | 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. For example, a (5,5) array's central pixel is (2,2). For even dimensions the central \
pixel is assumed to be the lower indexed value, e.g. a (6,4) array's central pixel is calculated as (2,1).
The default origin is (-1, -1) because numba requires that the function input is the same type throughout the \
function, thus a default 'None' value cannot be used.
Parameters
----------
array_2d : ndarray
The 2D array that is resized.
resized_shape : (int, int)
The (y,x) new pixel dimension of the trimmed array.
origin : (int, int)
The oigin of the resized array, e.g. the central pixel around which the array is extracted.
Returns
-------
ndarray
The resized 2D array from the input 2D array.
Examples
--------
array_2d = np.ones((5,5))
resize_array = resize_array_2d(array_2d=array_2d, new_shape=(2,2), origin=(2, 2))
"""
y_is_even = int(array_2d.shape[0]) | python | {
"resource": ""
} |
q257878 | bin_up_array_2d_using_mean | validation | 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) where \
every pixel was the mean of each collection of 2x2 pixels on the (8,8) array.
If binning up the array leads to an edge being cut (e.g. a (9,9) array binned up by 2), an array is first \
extracted around the centre of that array.
Parameters
----------
array_2d : ndarray
The 2D array that is resized.
new_shape : (int, int)
The (y,x) new pixel dimension of the trimmed array.
origin : (int, int)
The oigin of the resized array, e.g. the central pixel around which the array is extracted.
Returns
-------
ndarray
The resized 2D array from the input 2D array.
Examples
| python | {
"resource": ""
} |
q257879 | numpy_array_2d_to_fits | validation | 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
----------
array_2d : ndarray
The 2D array that is written to fits.
file_path : str
The full path of the file that is output, including the file name and '.fits' extension.
overwrite : bool
If True and a file already exists with the input file_path the .fits file is overwritten. If False, an error \
will be raised.
Returns
------- | python | {
"resource": ""
} |
q257880 | numpy_array_2d_from_fits | validation | 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
The full path of the file that is loaded, including the file name and '.fits' extension.
hdu : int
The HDU extension of the array that is loaded from the .fits file.
Returns
-------
ndarray
The | python | {
"resource": ""
} |
q257881 | ConvolverMappingMatrix.convolve_mapping_matrix | validation | 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, lets take an regular which is masked using a 'cross' of 5 pixels:
[[ True, False, True]],
[[False, False, False]],
[[ True, False, True]]
As example mapping matrix of this cross is as follows (5 regular pixels x 3 source pixels):
[1, 0, 0] [0->0]
[1, 0, 0] [1->0]
[0, 1, 0] [2->1]
[0, 1, 0] [3->1]
[0, 0, 1] [4->2]
For each source-pixel, we can create an regular of its unit-surface brightnesses by mapping the non-zero
entries back to masks. For example, doing this for source pixel 1 gives:
[[0.0, 1.0, 0.0]],
[[1.0, 0.0, 0.0]]
[[0.0, 0.0, 0.0]]
And source pixel 2:
| python | {
"resource": ""
} |
q257882 | EllipticalMassProfile.mass_within_circle_in_units | validation | def mass_within_circle_in_units(self, radius: dim.Length, unit_mass='angular', kpc_per_arcsec=None,
critical_surface_density=None):
""" Integrate the mass profiles's convergence profile to compute the total mass within a circle of \
specified radius. This is centred on the mass profile.
The following units for mass can be specified and output:
- Dimensionless angular units (default) - 'angular'.
- Solar masses - 'angular' (multiplies the angular mass by the critical surface mass density).
Parameters
----------
radius : dim.Length
The radius of the circle to compute the dimensionless | python | {
"resource": ""
} |
q257883 | EllipticalMassProfile.mass_within_ellipse_in_units | validation | def mass_within_ellipse_in_units(self, major_axis, unit_mass='angular', kpc_per_arcsec=None,
critical_surface_density=None):
""" Integrate the mass profiles's convergence profile to compute the total angular mass within an ellipse of \
specified major axis. This is centred on the mass profile.
The following units for mass can be specified and output:
- Dimensionless angular units (default) - 'angular'.
- Solar masses - 'angular' (multiplies the angular mass by the critical surface mass density)
Parameters
----------
major_axis : float
The major-axis radius of the ellipse.
| python | {
"resource": ""
} |
q257884 | EllipticalMassProfile.mass_integral | validation | def mass_integral(self, x, axis_ratio):
"""Routine to integrate an elliptical light profiles - set axis ratio to 1 to compute the luminosity within a \
| python | {
"resource": ""
} |
q257885 | EllipticalMassProfile.density_between_circular_annuli_in_angular_units | validation | def density_between_circular_annuli_in_angular_units(self, inner_annuli_radius, outer_annuli_radius):
"""Calculate the mass between two circular annuli and compute the density by dividing by the annuli surface
area.
The value returned by the mass integral is dimensionless, therefore the density between annuli is returned in \
units of inverse radius squared. A conversion factor can be specified to convert this to a physical value \
(e.g. the critical surface mass density).
Parameters
-----------
inner_annuli_radius : float
The radius of the inner annulus outside of which the density | python | {
"resource": ""
} |
q257886 | EllipticalCoredPowerLaw.einstein_radius_rescaled | validation | def einstein_radius_rescaled(self):
"""Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles
parameters"""
| python | {
"resource": ""
} |
q257887 | EllipticalCoredPowerLaw.convergence_from_grid | validation | def convergence_from_grid(self, grid):
""" Calculate the projected convergence at a given set of arc-second gridded coordinates.
Parameters
----------
grid : grids.RegularGrid
The grid of (y,x) arc-second coordinates the surface density is computed on.
"""
surface_density_grid = np.zeros(grid.shape[0])
| python | {
"resource": ""
} |
q257888 | AbstractEllipticalGeneralizedNFW.tabulate_integral | validation | def tabulate_integral(self, grid, tabulate_bins):
"""Tabulate an integral over the surface density of deflection potential of a mass profile. This is used in \
the GeneralizedNFW profile classes to speed up the integration procedure.
Parameters
-----------
grid : grids.RegularGrid
The grid of (y,x) arc-second coordinates the potential / deflection_stacks are computed on.
tabulate_bins : int
The number of bins to tabulate the inner integral of this profile.
"""
eta_min = 1.0e-4
eta_max | python | {
"resource": ""
} |
q257889 | AbstractEllipticalSersic.intensity_at_radius | validation | def intensity_at_radius(self, radius):
""" Compute the intensity of the profile at a given radius.
Parameters
----------
radius : float
The distance from the centre of the profile.
"""
| python | {
"resource": ""
} |
q257890 | AbstractEllipticalSersic.sersic_constant | validation | def sersic_constant(self):
""" A parameter derived from Sersic index which ensures that effective radius contains 50% of the profile's
total integrated light.
"""
return (2 * self.sersic_index) - (1. / 3.) + (4. / (405. * self.sersic_index)) + (
| python | {
"resource": ""
} |
q257891 | Galaxy.luminosity_within_circle_in_units | validation | def luminosity_within_circle_in_units(self, radius : dim.Length, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None):
"""Compute the total luminosity of the galaxy's light profiles within a circle of specified radius.
See *light_profiles.luminosity_within_circle* for details of how this is performed.
Parameters
----------
radius : float
The radius of the circle to compute the dimensionless mass within.
unit_luminosity : str
The units the luminosity is returned in (eps | counts).
exposure_time : float
The exposure time of the observation, which converts luminosity from electrons per second units | python | {
"resource": ""
} |
q257892 | Galaxy.luminosity_within_ellipse_in_units | validation | def luminosity_within_ellipse_in_units(self, major_axis : dim.Length, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None):
"""Compute the total luminosity of the galaxy's light profiles, within an ellipse of specified major axis. This
is performed via integration of each light profile and is centred, oriented and aligned with each light
model's individual geometry.
See *light_profiles.luminosity_within_ellipse* for details of how this is performed.
Parameters
| python | {
"resource": ""
} |
q257893 | Galaxy.mass_within_circle_in_units | validation | def mass_within_circle_in_units(self, radius, unit_mass='angular', kpc_per_arcsec=None, critical_surface_density=None):
"""Compute the total angular mass of the galaxy's mass profiles within a circle of specified radius.
See *profiles.mass_profiles.mass_within_circle* for details of how this is performed.
Parameters
----------
radius : float
The radius of the circle to compute the dimensionless mass within.
unit_mass : str
The units the mass is returned in (angular | solMass).
critical_surface_density : float
The critical surface mass density of the strong lens configuration, which converts mass from angulalr \
| python | {
"resource": ""
} |
q257894 | Galaxy.mass_within_ellipse_in_units | validation | def mass_within_ellipse_in_units(self, major_axis, unit_mass='angular', kpc_per_arcsec=None, critical_surface_density=None):
"""Compute the total angular mass of the galaxy's mass profiles within an ellipse of specified major_axis.
See *profiles.mass_profiles.angualr_mass_within_ellipse* for details of how this is performed.
Parameters
----------
major_axis : float
The major-axis radius of the ellipse.
units_luminosity : str
The units the luminosity is returned in (eps | counts).
exposure_time : float
The exposure time of the observation, which converts luminosity from electrons per second units to counts.
"""
| python | {
"resource": ""
} |
q257895 | Galaxy.einstein_radius_in_units | validation | def einstein_radius_in_units(self, unit_length='arcsec', kpc_per_arcsec=None):
"""The Einstein Radius of this galaxy, which is the sum of Einstein Radii of its mass profiles.
If the galaxy is composed of multiple ellipitcal profiles with different axis-ratios, this Einstein Radius \
may be inaccurate. This is because the differently oriented ellipses of each mass profile """
| python | {
"resource": ""
} |
q257896 | Galaxy.einstein_mass_in_units | validation | def einstein_mass_in_units(self, unit_mass='angular', critical_surface_density=None):
"""The Einstein Mass of this galaxy, which is the sum of Einstein Radii of its mass profiles.
If the galaxy is composed of multiple ellipitcal profiles with different axis-ratios, this Einstein Mass \
| python | {
"resource": ""
} |
q257897 | HyperGalaxy.hyper_noise_from_contributions | validation | def hyper_noise_from_contributions(self, noise_map, contributions):
"""Compute a scaled galaxy hyper noise-map from a baseline noise-map.
This uses the galaxy contribution map and the *noise_factor* and *noise_power* hyper-parameters.
Parameters
-----------
noise_map : ndarray
| python | {
"resource": ""
} |
q257898 | ConvolverImage.convolve_image | validation | def convolve_image(self, image_array, blurring_array):
"""For a given 1D regular array and blurring array, convolve the two using this convolver.
Parameters
-----------
image_array : ndarray
1D array of the regular values which are to be blurred with the convolver's PSF.
blurring_array : ndarray
1D array of the blurring regular values which blur into the regular-array | python | {
"resource": ""
} |
q257899 | intensities_of_galaxies_from_grid | validation | def intensities_of_galaxies_from_grid(grid, galaxies):
"""Compute the intensities of a list of galaxies from an input grid, by summing the individual intensities \
of each galaxy's light profile.
If the input grid is a *grids.SubGrid*, the intensites is calculated on the sub-grid and binned-up to the \
original regular grid by taking the mean value of every set of sub-pixels.
If no galaxies are entered into the function, an array of all zeros is returned.
Parameters
-----------
grid : RegularGrid
The grid (regular or sub) of (y,x) arc-second coordinates at the centre of every unmasked pixel which the \
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.