partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
EllipticalMassProfile.mass_within_circle_in_units
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 mass within. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angulalr \ units to phsical units (e.g. solar masses).
autolens/model/profiles/mass_profiles.py
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 mass within. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angulalr \ units to phsical units (e.g. solar masses). """ self.check_units_of_radius_and_critical_surface_density( radius=radius, critical_surface_density=critical_surface_density) profile = self.new_profile_with_units_converted( unit_length=radius.unit_length, unit_mass='angular', kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density) mass_angular = dim.Mass(value=quad(profile.mass_integral, a=0.0, b=radius, args=(1.0,))[0], unit_mass='angular') return mass_angular.convert(unit_mass=unit_mass, critical_surface_density=critical_surface_density)
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 mass within. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angulalr \ units to phsical units (e.g. solar masses). """ self.check_units_of_radius_and_critical_surface_density( radius=radius, critical_surface_density=critical_surface_density) profile = self.new_profile_with_units_converted( unit_length=radius.unit_length, unit_mass='angular', kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density) mass_angular = dim.Mass(value=quad(profile.mass_integral, a=0.0, b=radius, args=(1.0,))[0], unit_mass='angular') return mass_angular.convert(unit_mass=unit_mass, critical_surface_density=critical_surface_density)
[ "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", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L170-L199
[ "def", "mass_within_circle_in_units", "(", "self", ",", "radius", ":", "dim", ".", "Length", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "None", ",", "critical_surface_density", "=", "None", ")", ":", "self", ".", "check_units_of_radius_and_critical_surface_density", "(", "radius", "=", "radius", ",", "critical_surface_density", "=", "critical_surface_density", ")", "profile", "=", "self", ".", "new_profile_with_units_converted", "(", "unit_length", "=", "radius", ".", "unit_length", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", "mass_angular", "=", "dim", ".", "Mass", "(", "value", "=", "quad", "(", "profile", ".", "mass_integral", ",", "a", "=", "0.0", ",", "b", "=", "radius", ",", "args", "=", "(", "1.0", ",", ")", ")", "[", "0", "]", ",", "unit_mass", "=", "'angular'", ")", "return", "mass_angular", ".", "convert", "(", "unit_mass", "=", "unit_mass", ",", "critical_surface_density", "=", "critical_surface_density", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalMassProfile.mass_within_ellipse_in_units
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. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angular \ units to phsical units (e.g. solar masses).
autolens/model/profiles/mass_profiles.py
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. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angular \ units to phsical units (e.g. solar masses). """ self.check_units_of_radius_and_critical_surface_density( radius=major_axis, critical_surface_density=critical_surface_density) profile = self.new_profile_with_units_converted( unit_length=major_axis.unit_length, unit_mass='angular', kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density) mass_angular = dim.Mass(value=quad(profile.mass_integral, a=0.0, b=major_axis, args=(self.axis_ratio,))[0], unit_mass='angular') return mass_angular.convert(unit_mass=unit_mass, critical_surface_density=critical_surface_density)
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. unit_mass : str The units the mass is returned in (angular | angular). critical_surface_density : float or None The critical surface mass density of the strong lens configuration, which converts mass from angular \ units to phsical units (e.g. solar masses). """ self.check_units_of_radius_and_critical_surface_density( radius=major_axis, critical_surface_density=critical_surface_density) profile = self.new_profile_with_units_converted( unit_length=major_axis.unit_length, unit_mass='angular', kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density) mass_angular = dim.Mass(value=quad(profile.mass_integral, a=0.0, b=major_axis, args=(self.axis_ratio,))[0], unit_mass='angular') return mass_angular.convert(unit_mass=unit_mass, critical_surface_density=critical_surface_density)
[ "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", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L201-L231
[ "def", "mass_within_ellipse_in_units", "(", "self", ",", "major_axis", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "None", ",", "critical_surface_density", "=", "None", ")", ":", "self", ".", "check_units_of_radius_and_critical_surface_density", "(", "radius", "=", "major_axis", ",", "critical_surface_density", "=", "critical_surface_density", ")", "profile", "=", "self", ".", "new_profile_with_units_converted", "(", "unit_length", "=", "major_axis", ".", "unit_length", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", "mass_angular", "=", "dim", ".", "Mass", "(", "value", "=", "quad", "(", "profile", ".", "mass_integral", ",", "a", "=", "0.0", ",", "b", "=", "major_axis", ",", "args", "=", "(", "self", ".", "axis_ratio", ",", ")", ")", "[", "0", "]", ",", "unit_mass", "=", "'angular'", ")", "return", "mass_angular", ".", "convert", "(", "unit_mass", "=", "unit_mass", ",", "critical_surface_density", "=", "critical_surface_density", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalMassProfile.mass_integral
Routine to integrate an elliptical light profiles - set axis ratio to 1 to compute the luminosity within a \ circle
autolens/model/profiles/mass_profiles.py
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 \ circle""" r = x * axis_ratio return 2 * np.pi * r * self.convergence_func(x)
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 \ circle""" r = x * axis_ratio return 2 * np.pi * r * self.convergence_func(x)
[ "Routine", "to", "integrate", "an", "elliptical", "light", "profiles", "-", "set", "axis", "ratio", "to", "1", "to", "compute", "the", "luminosity", "within", "a", "\\", "circle" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L233-L237
[ "def", "mass_integral", "(", "self", ",", "x", ",", "axis_ratio", ")", ":", "r", "=", "x", "*", "axis_ratio", "return", "2", "*", "np", ".", "pi", "*", "r", "*", "self", ".", "convergence_func", "(", "x", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalMassProfile.density_between_circular_annuli_in_angular_units
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 are estimated. outer_annuli_radius : float The radius of the outer annulus inside of which the density is estimated.
autolens/model/profiles/mass_profiles.py
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 are estimated. outer_annuli_radius : float The radius of the outer annulus inside of which the density is estimated. """ annuli_area = (np.pi * outer_annuli_radius ** 2.0) - (np.pi * inner_annuli_radius ** 2.0) return (self.mass_within_circle_in_units(radius=outer_annuli_radius) - self.mass_within_circle_in_units(radius=inner_annuli_radius)) \ / annuli_area
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 are estimated. outer_annuli_radius : float The radius of the outer annulus inside of which the density is estimated. """ annuli_area = (np.pi * outer_annuli_radius ** 2.0) - (np.pi * inner_annuli_radius ** 2.0) return (self.mass_within_circle_in_units(radius=outer_annuli_radius) - self.mass_within_circle_in_units(radius=inner_annuli_radius)) \ / annuli_area
[ "Calculate", "the", "mass", "between", "two", "circular", "annuli", "and", "compute", "the", "density", "by", "dividing", "by", "the", "annuli", "surface", "area", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L239-L257
[ "def", "density_between_circular_annuli_in_angular_units", "(", "self", ",", "inner_annuli_radius", ",", "outer_annuli_radius", ")", ":", "annuli_area", "=", "(", "np", ".", "pi", "*", "outer_annuli_radius", "**", "2.0", ")", "-", "(", "np", ".", "pi", "*", "inner_annuli_radius", "**", "2.0", ")", "return", "(", "self", ".", "mass_within_circle_in_units", "(", "radius", "=", "outer_annuli_radius", ")", "-", "self", ".", "mass_within_circle_in_units", "(", "radius", "=", "inner_annuli_radius", ")", ")", "/", "annuli_area" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalMassProfile.average_convergence_of_1_radius_in_units
The radius a critical curve forms for this mass profile, e.g. where the mean convergence is equal to 1.0. In case of ellipitical mass profiles, the 'average' critical curve is used, whereby the convergence is \ rescaled into a circle using the axis ratio. This radius corresponds to the Einstein radius of the mass profile, and is a property of a number of \ mass profiles below.
autolens/model/profiles/mass_profiles.py
def average_convergence_of_1_radius_in_units(self, unit_length='arcsec', kpc_per_arcsec=None): """The radius a critical curve forms for this mass profile, e.g. where the mean convergence is equal to 1.0. In case of ellipitical mass profiles, the 'average' critical curve is used, whereby the convergence is \ rescaled into a circle using the axis ratio. This radius corresponds to the Einstein radius of the mass profile, and is a property of a number of \ mass profiles below. """ def func(radius): radius = dim.Length(radius, unit_length=unit_length) return self.mass_within_circle_in_units(radius=radius) - np.pi * radius ** 2.0 radius = self.ellipticity_rescale * root_scalar(func, bracket=[1e-4, 1000.0]).root radius = dim.Length(radius, unit_length) return radius.convert(unit_length=unit_length, kpc_per_arcsec=kpc_per_arcsec)
def average_convergence_of_1_radius_in_units(self, unit_length='arcsec', kpc_per_arcsec=None): """The radius a critical curve forms for this mass profile, e.g. where the mean convergence is equal to 1.0. In case of ellipitical mass profiles, the 'average' critical curve is used, whereby the convergence is \ rescaled into a circle using the axis ratio. This radius corresponds to the Einstein radius of the mass profile, and is a property of a number of \ mass profiles below. """ def func(radius): radius = dim.Length(radius, unit_length=unit_length) return self.mass_within_circle_in_units(radius=radius) - np.pi * radius ** 2.0 radius = self.ellipticity_rescale * root_scalar(func, bracket=[1e-4, 1000.0]).root radius = dim.Length(radius, unit_length) return radius.convert(unit_length=unit_length, kpc_per_arcsec=kpc_per_arcsec)
[ "The", "radius", "a", "critical", "curve", "forms", "for", "this", "mass", "profile", "e", ".", "g", ".", "where", "the", "mean", "convergence", "is", "equal", "to", "1", ".", "0", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L259-L275
[ "def", "average_convergence_of_1_radius_in_units", "(", "self", ",", "unit_length", "=", "'arcsec'", ",", "kpc_per_arcsec", "=", "None", ")", ":", "def", "func", "(", "radius", ")", ":", "radius", "=", "dim", ".", "Length", "(", "radius", ",", "unit_length", "=", "unit_length", ")", "return", "self", ".", "mass_within_circle_in_units", "(", "radius", "=", "radius", ")", "-", "np", ".", "pi", "*", "radius", "**", "2.0", "radius", "=", "self", ".", "ellipticity_rescale", "*", "root_scalar", "(", "func", ",", "bracket", "=", "[", "1e-4", ",", "1000.0", "]", ")", ".", "root", "radius", "=", "dim", ".", "Length", "(", "radius", ",", "unit_length", ")", "return", "radius", ".", "convert", "(", "unit_length", "=", "unit_length", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoredPowerLaw.einstein_radius_rescaled
Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles parameters
autolens/model/profiles/mass_profiles.py
def einstein_radius_rescaled(self): """Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles parameters""" return ((3 - self.slope) / (1 + self.axis_ratio)) * self.einstein_radius ** (self.slope - 1)
def einstein_radius_rescaled(self): """Rescale the einstein radius by slope and axis_ratio, to reduce its degeneracy with other mass-profiles parameters""" return ((3 - self.slope) / (1 + self.axis_ratio)) * self.einstein_radius ** (self.slope - 1)
[ "Rescale", "the", "einstein", "radius", "by", "slope", "and", "axis_ratio", "to", "reduce", "its", "degeneracy", "with", "other", "mass", "-", "profiles", "parameters" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L353-L356
[ "def", "einstein_radius_rescaled", "(", "self", ")", ":", "return", "(", "(", "3", "-", "self", ".", "slope", ")", "/", "(", "1", "+", "self", ".", "axis_ratio", ")", ")", "*", "self", ".", "einstein_radius", "**", "(", "self", ".", "slope", "-", "1", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoredPowerLaw.convergence_from_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.
autolens/model/profiles/mass_profiles.py
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]) grid_eta = self.grid_to_elliptical_radii(grid) for i in range(grid.shape[0]): surface_density_grid[i] = self.convergence_func(grid_eta[i]) return surface_density_grid
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]) grid_eta = self.grid_to_elliptical_radii(grid) for i in range(grid.shape[0]): surface_density_grid[i] = self.convergence_func(grid_eta[i]) return surface_density_grid
[ "Calculate", "the", "projected", "convergence", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L360-L376
[ "def", "convergence_from_grid", "(", "self", ",", "grid", ")", ":", "surface_density_grid", "=", "np", ".", "zeros", "(", "grid", ".", "shape", "[", "0", "]", ")", "grid_eta", "=", "self", ".", "grid_to_elliptical_radii", "(", "grid", ")", "for", "i", "in", "range", "(", "grid", ".", "shape", "[", "0", "]", ")", ":", "surface_density_grid", "[", "i", "]", "=", "self", ".", "convergence_func", "(", "grid_eta", "[", "i", "]", ")", "return", "surface_density_grid" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoredPowerLaw.potential_from_grid
Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ potential_grid = quad_grid(self.potential_func, 0.0, 1.0, grid, args=(self.axis_ratio, self.slope, self.core_radius))[0] return self.einstein_radius_rescaled * self.axis_ratio * potential_grid
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ potential_grid = quad_grid(self.potential_func, 0.0, 1.0, grid, args=(self.axis_ratio, self.slope, self.core_radius))[0] return self.einstein_radius_rescaled * self.axis_ratio * potential_grid
[ "Calculate", "the", "potential", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L380-L393
[ "def", "potential_from_grid", "(", "self", ",", "grid", ")", ":", "potential_grid", "=", "quad_grid", "(", "self", ".", "potential_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "self", ".", "axis_ratio", ",", "self", ".", "slope", ",", "self", ".", "core_radius", ")", ")", "[", "0", "]", "return", "self", ".", "einstein_radius_rescaled", "*", "self", ".", "axis_ratio", "*", "potential_grid" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoredPowerLaw.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): einstein_radius_rescaled = self.einstein_radius_rescaled deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, einstein_radius_rescaled, self.slope, self.core_radius))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): einstein_radius_rescaled = self.einstein_radius_rescaled deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, einstein_radius_rescaled, self.slope, self.core_radius))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L399-L423
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "def", "calculate_deflection_component", "(", "npow", ",", "index", ")", ":", "einstein_radius_rescaled", "=", "self", ".", "einstein_radius_rescaled", "deflection_grid", "=", "self", ".", "axis_ratio", "*", "grid", "[", ":", ",", "index", "]", "deflection_grid", "*=", "quad_grid", "(", "self", ".", "deflection_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "npow", ",", "self", ".", "axis_ratio", ",", "einstein_radius_rescaled", ",", "self", ".", "slope", ",", "self", ".", "core_radius", ")", ")", "[", "0", "]", "return", "deflection_grid", "deflection_y", "=", "calculate_deflection_component", "(", "1.0", ",", "0", ")", "deflection_x", "=", "calculate_deflection_component", "(", "0.0", ",", "1", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "multiply", "(", "1.0", ",", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalCoredPowerLaw.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = self.grid_to_grid_radii(grid=grid) deflection = np.multiply(2. * self.einstein_radius_rescaled, np.divide( np.add(np.power(np.add(self.core_radius ** 2, np.square(eta)), (3. - self.slope) / 2.), -self.core_radius ** (3 - self.slope)), np.multiply((3. - self.slope), eta))) return self.grid_to_grid_cartesian(grid=grid, radius=deflection)
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = self.grid_to_grid_radii(grid=grid) deflection = np.multiply(2. * self.einstein_radius_rescaled, np.divide( np.add(np.power(np.add(self.core_radius ** 2, np.square(eta)), (3. - self.slope) / 2.), -self.core_radius ** (3 - self.slope)), np.multiply((3. - self.slope), eta))) return self.grid_to_grid_cartesian(grid=grid, radius=deflection)
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L484-L497
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "eta", "=", "self", ".", "grid_to_grid_radii", "(", "grid", "=", "grid", ")", "deflection", "=", "np", ".", "multiply", "(", "2.", "*", "self", ".", "einstein_radius_rescaled", ",", "np", ".", "divide", "(", "np", ".", "add", "(", "np", ".", "power", "(", "np", ".", "add", "(", "self", ".", "core_radius", "**", "2", ",", "np", ".", "square", "(", "eta", ")", ")", ",", "(", "3.", "-", "self", ".", "slope", ")", "/", "2.", ")", ",", "-", "self", ".", "core_radius", "**", "(", "3", "-", "self", ".", "slope", ")", ")", ",", "np", ".", "multiply", "(", "(", "3.", "-", "self", ".", "slope", ")", ",", "eta", ")", ")", ")", "return", "self", ".", "grid_to_grid_cartesian", "(", "grid", "=", "grid", ",", "radius", "=", "deflection", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalIsothermal.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. For coordinates (0.0, 0.0) the analytic calculation of the deflection angle gives a NaN. Therefore, \ coordinates at (0.0, 0.0) are shifted slightly to (1.0e-8, 1.0e-8). Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. For coordinates (0.0, 0.0) the analytic calculation of the deflection angle gives a NaN. Therefore, \ coordinates at (0.0, 0.0) are shifted slightly to (1.0e-8, 1.0e-8). Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ factor = 2.0 * self.einstein_radius_rescaled * self.axis_ratio / np.sqrt(1 - self.axis_ratio ** 2) psi = np.sqrt(np.add(np.multiply(self.axis_ratio ** 2, np.square(grid[:, 1])), np.square(grid[:, 0]))) deflection_y = np.arctanh(np.divide(np.multiply(np.sqrt(1 - self.axis_ratio ** 2), grid[:, 0]), psi)) deflection_x = np.arctan(np.divide(np.multiply(np.sqrt(1 - self.axis_ratio ** 2), grid[:, 1]), psi)) return self.rotate_grid_from_profile(np.multiply(factor, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. For coordinates (0.0, 0.0) the analytic calculation of the deflection angle gives a NaN. Therefore, \ coordinates at (0.0, 0.0) are shifted slightly to (1.0e-8, 1.0e-8). Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ factor = 2.0 * self.einstein_radius_rescaled * self.axis_ratio / np.sqrt(1 - self.axis_ratio ** 2) psi = np.sqrt(np.add(np.multiply(self.axis_ratio ** 2, np.square(grid[:, 1])), np.square(grid[:, 0]))) deflection_y = np.arctanh(np.divide(np.multiply(np.sqrt(1 - self.axis_ratio ** 2), grid[:, 0]), psi)) deflection_x = np.arctan(np.divide(np.multiply(np.sqrt(1 - self.axis_ratio ** 2), grid[:, 1]), psi)) return self.rotate_grid_from_profile(np.multiply(factor, np.vstack((deflection_y, deflection_x)).T))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L673-L691
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "factor", "=", "2.0", "*", "self", ".", "einstein_radius_rescaled", "*", "self", ".", "axis_ratio", "/", "np", ".", "sqrt", "(", "1", "-", "self", ".", "axis_ratio", "**", "2", ")", "psi", "=", "np", ".", "sqrt", "(", "np", ".", "add", "(", "np", ".", "multiply", "(", "self", ".", "axis_ratio", "**", "2", ",", "np", ".", "square", "(", "grid", "[", ":", ",", "1", "]", ")", ")", ",", "np", ".", "square", "(", "grid", "[", ":", ",", "0", "]", ")", ")", ")", "deflection_y", "=", "np", ".", "arctanh", "(", "np", ".", "divide", "(", "np", ".", "multiply", "(", "np", ".", "sqrt", "(", "1", "-", "self", ".", "axis_ratio", "**", "2", ")", ",", "grid", "[", ":", ",", "0", "]", ")", ",", "psi", ")", ")", "deflection_x", "=", "np", ".", "arctan", "(", "np", ".", "divide", "(", "np", ".", "multiply", "(", "np", ".", "sqrt", "(", "1", "-", "self", ".", "axis_ratio", "**", "2", ")", ",", "grid", "[", ":", ",", "1", "]", ")", ",", "psi", ")", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "multiply", "(", "factor", ",", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalIsothermal.potential_from_grid
Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = self.grid_to_elliptical_radii(grid) return 2.0 * self.einstein_radius_rescaled * eta
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = self.grid_to_elliptical_radii(grid) return 2.0 * self.einstein_radius_rescaled * eta
[ "Calculate", "the", "potential", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L716-L726
[ "def", "potential_from_grid", "(", "self", ",", "grid", ")", ":", "eta", "=", "self", ".", "grid_to_elliptical_radii", "(", "grid", ")", "return", "2.0", "*", "self", ".", "einstein_radius_rescaled", "*", "eta" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalIsothermal.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ return self.grid_to_grid_cartesian(grid=grid, radius=np.full(grid.shape[0], 2.0 * self.einstein_radius_rescaled))
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ return self.grid_to_grid_cartesian(grid=grid, radius=np.full(grid.shape[0], 2.0 * self.einstein_radius_rescaled))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L730-L740
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "return", "self", ".", "grid_to_grid_cartesian", "(", "grid", "=", "grid", ",", "radius", "=", "np", ".", "full", "(", "grid", ".", "shape", "[", "0", "]", ",", "2.0", "*", "self", ".", "einstein_radius_rescaled", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractEllipticalGeneralizedNFW.tabulate_integral
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.
autolens/model/profiles/mass_profiles.py
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 = 1.05 * np.max(self.grid_to_elliptical_radii(grid)) minimum_log_eta = np.log10(eta_min) maximum_log_eta = np.log10(eta_max) bin_size = (maximum_log_eta - minimum_log_eta) / (tabulate_bins - 1) return eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size
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 = 1.05 * np.max(self.grid_to_elliptical_radii(grid)) minimum_log_eta = np.log10(eta_min) maximum_log_eta = np.log10(eta_max) bin_size = (maximum_log_eta - minimum_log_eta) / (tabulate_bins - 1) return eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size
[ "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", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L782-L800
[ "def", "tabulate_integral", "(", "self", ",", "grid", ",", "tabulate_bins", ")", ":", "eta_min", "=", "1.0e-4", "eta_max", "=", "1.05", "*", "np", ".", "max", "(", "self", ".", "grid_to_elliptical_radii", "(", "grid", ")", ")", "minimum_log_eta", "=", "np", ".", "log10", "(", "eta_min", ")", "maximum_log_eta", "=", "np", ".", "log10", "(", "eta_max", ")", "bin_size", "=", "(", "maximum_log_eta", "-", "minimum_log_eta", ")", "/", "(", "tabulate_bins", "-", "1", ")", "return", "eta_min", ",", "eta_max", ",", "minimum_log_eta", ",", "maximum_log_eta", ",", "bin_size" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalGeneralizedNFW.potential_from_grid
Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile.
autolens/model/profiles/mass_profiles.py
def potential_from_grid(self, grid, tabulate_bins=1000): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile. """ @jit_integrand def deflection_integrand(x, kappa_radius, scale_radius, inner_slope): return (x + kappa_radius / scale_radius) ** (inner_slope - 3) * ((1 - np.sqrt(1 - x ** 2)) / x) eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins) potential_grid = np.zeros(grid.shape[0]) deflection_integral = np.zeros((tabulate_bins,)) for i in range(tabulate_bins): eta = 10. ** (minimum_log_eta + (i - 1) * bin_size) integral = \ quad(deflection_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius, self.inner_slope), epsrel=EllipticalGeneralizedNFW.epsrel)[0] deflection_integral[i] = ((eta / self.scale_radius) ** (2 - self.inner_slope)) * ( (1.0 / (3 - self.inner_slope)) * special.hyp2f1(3 - self.inner_slope, 3 - self.inner_slope, 4 - self.inner_slope, - (eta / self.scale_radius)) + integral) for i in range(grid.shape[0]): potential_grid[i] = (2.0 * self.kappa_s * self.axis_ratio) * \ quad(self.potential_func, a=0.0, b=1.0, args=(grid[i, 0], grid[i, 1], self.axis_ratio, minimum_log_eta, maximum_log_eta, tabulate_bins, deflection_integral), epsrel=EllipticalGeneralizedNFW.epsrel)[0] return potential_grid
def potential_from_grid(self, grid, tabulate_bins=1000): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile. """ @jit_integrand def deflection_integrand(x, kappa_radius, scale_radius, inner_slope): return (x + kappa_radius / scale_radius) ** (inner_slope - 3) * ((1 - np.sqrt(1 - x ** 2)) / x) eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins) potential_grid = np.zeros(grid.shape[0]) deflection_integral = np.zeros((tabulate_bins,)) for i in range(tabulate_bins): eta = 10. ** (minimum_log_eta + (i - 1) * bin_size) integral = \ quad(deflection_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius, self.inner_slope), epsrel=EllipticalGeneralizedNFW.epsrel)[0] deflection_integral[i] = ((eta / self.scale_radius) ** (2 - self.inner_slope)) * ( (1.0 / (3 - self.inner_slope)) * special.hyp2f1(3 - self.inner_slope, 3 - self.inner_slope, 4 - self.inner_slope, - (eta / self.scale_radius)) + integral) for i in range(grid.shape[0]): potential_grid[i] = (2.0 * self.kappa_s * self.axis_ratio) * \ quad(self.potential_func, a=0.0, b=1.0, args=(grid[i, 0], grid[i, 1], self.axis_ratio, minimum_log_eta, maximum_log_eta, tabulate_bins, deflection_integral), epsrel=EllipticalGeneralizedNFW.epsrel)[0] return potential_grid
[ "Calculate", "the", "potential", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L954-L996
[ "def", "potential_from_grid", "(", "self", ",", "grid", ",", "tabulate_bins", "=", "1000", ")", ":", "@", "jit_integrand", "def", "deflection_integrand", "(", "x", ",", "kappa_radius", ",", "scale_radius", ",", "inner_slope", ")", ":", "return", "(", "x", "+", "kappa_radius", "/", "scale_radius", ")", "**", "(", "inner_slope", "-", "3", ")", "*", "(", "(", "1", "-", "np", ".", "sqrt", "(", "1", "-", "x", "**", "2", ")", ")", "/", "x", ")", "eta_min", ",", "eta_max", ",", "minimum_log_eta", ",", "maximum_log_eta", ",", "bin_size", "=", "self", ".", "tabulate_integral", "(", "grid", ",", "tabulate_bins", ")", "potential_grid", "=", "np", ".", "zeros", "(", "grid", ".", "shape", "[", "0", "]", ")", "deflection_integral", "=", "np", ".", "zeros", "(", "(", "tabulate_bins", ",", ")", ")", "for", "i", "in", "range", "(", "tabulate_bins", ")", ":", "eta", "=", "10.", "**", "(", "minimum_log_eta", "+", "(", "i", "-", "1", ")", "*", "bin_size", ")", "integral", "=", "quad", "(", "deflection_integrand", ",", "a", "=", "0.0", ",", "b", "=", "1.0", ",", "args", "=", "(", "eta", ",", "self", ".", "scale_radius", ",", "self", ".", "inner_slope", ")", ",", "epsrel", "=", "EllipticalGeneralizedNFW", ".", "epsrel", ")", "[", "0", "]", "deflection_integral", "[", "i", "]", "=", "(", "(", "eta", "/", "self", ".", "scale_radius", ")", "**", "(", "2", "-", "self", ".", "inner_slope", ")", ")", "*", "(", "(", "1.0", "/", "(", "3", "-", "self", ".", "inner_slope", ")", ")", "*", "special", ".", "hyp2f1", "(", "3", "-", "self", ".", "inner_slope", ",", "3", "-", "self", ".", "inner_slope", ",", "4", "-", "self", ".", "inner_slope", ",", "-", "(", "eta", "/", "self", ".", "scale_radius", ")", ")", "+", "integral", ")", "for", "i", "in", "range", "(", "grid", ".", "shape", "[", "0", "]", ")", ":", "potential_grid", "[", "i", "]", "=", "(", "2.0", "*", "self", ".", "kappa_s", "*", "self", ".", "axis_ratio", ")", "*", "quad", "(", "self", ".", "potential_func", ",", "a", "=", "0.0", ",", "b", "=", "1.0", ",", "args", "=", "(", "grid", "[", "i", ",", "0", "]", ",", "grid", "[", "i", ",", "1", "]", ",", "self", ".", "axis_ratio", ",", "minimum_log_eta", ",", "maximum_log_eta", ",", "tabulate_bins", ",", "deflection_integral", ")", ",", "epsrel", "=", "EllipticalGeneralizedNFW", ".", "epsrel", ")", "[", "0", "]", "return", "potential_grid" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalGeneralizedNFW.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid, tabulate_bins=1000): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile. """ @jit_integrand def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope): return (3 - inner_slope) * (x + kappa_radius / scale_radius) ** (inner_slope - 4) * (1 - np.sqrt(1 - x * x)) def calculate_deflection_component(npow, index): deflection_grid = 2.0 * self.kappa_s * self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, minimum_log_eta, maximum_log_eta, tabulate_bins, surface_density_integral), epsrel=EllipticalGeneralizedNFW.epsrel)[0] return deflection_grid eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins) surface_density_integral = np.zeros((tabulate_bins,)) for i in range(tabulate_bins): eta = 10. ** (minimum_log_eta + (i - 1) * bin_size) integral = quad(surface_density_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius, self.inner_slope), epsrel=EllipticalGeneralizedNFW.epsrel)[0] surface_density_integral[i] = ((eta / self.scale_radius) ** (1 - self.inner_slope)) * \ (((1 + eta / self.scale_radius) ** (self.inner_slope - 3)) + integral) deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid, tabulate_bins=1000): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. tabulate_bins : int The number of bins to tabulate the inner integral of this profile. """ @jit_integrand def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope): return (3 - inner_slope) * (x + kappa_radius / scale_radius) ** (inner_slope - 4) * (1 - np.sqrt(1 - x * x)) def calculate_deflection_component(npow, index): deflection_grid = 2.0 * self.kappa_s * self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, minimum_log_eta, maximum_log_eta, tabulate_bins, surface_density_integral), epsrel=EllipticalGeneralizedNFW.epsrel)[0] return deflection_grid eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size = self.tabulate_integral(grid, tabulate_bins) surface_density_integral = np.zeros((tabulate_bins,)) for i in range(tabulate_bins): eta = 10. ** (minimum_log_eta + (i - 1) * bin_size) integral = quad(surface_density_integrand, a=0.0, b=1.0, args=(eta, self.scale_radius, self.inner_slope), epsrel=EllipticalGeneralizedNFW.epsrel)[0] surface_density_integral[i] = ((eta / self.scale_radius) ** (1 - self.inner_slope)) * \ (((1 + eta / self.scale_radius) ** (self.inner_slope - 3)) + integral) deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1002-L1044
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ",", "tabulate_bins", "=", "1000", ")", ":", "@", "jit_integrand", "def", "surface_density_integrand", "(", "x", ",", "kappa_radius", ",", "scale_radius", ",", "inner_slope", ")", ":", "return", "(", "3", "-", "inner_slope", ")", "*", "(", "x", "+", "kappa_radius", "/", "scale_radius", ")", "**", "(", "inner_slope", "-", "4", ")", "*", "(", "1", "-", "np", ".", "sqrt", "(", "1", "-", "x", "*", "x", ")", ")", "def", "calculate_deflection_component", "(", "npow", ",", "index", ")", ":", "deflection_grid", "=", "2.0", "*", "self", ".", "kappa_s", "*", "self", ".", "axis_ratio", "*", "grid", "[", ":", ",", "index", "]", "deflection_grid", "*=", "quad_grid", "(", "self", ".", "deflection_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "npow", ",", "self", ".", "axis_ratio", ",", "minimum_log_eta", ",", "maximum_log_eta", ",", "tabulate_bins", ",", "surface_density_integral", ")", ",", "epsrel", "=", "EllipticalGeneralizedNFW", ".", "epsrel", ")", "[", "0", "]", "return", "deflection_grid", "eta_min", ",", "eta_max", ",", "minimum_log_eta", ",", "maximum_log_eta", ",", "bin_size", "=", "self", ".", "tabulate_integral", "(", "grid", ",", "tabulate_bins", ")", "surface_density_integral", "=", "np", ".", "zeros", "(", "(", "tabulate_bins", ",", ")", ")", "for", "i", "in", "range", "(", "tabulate_bins", ")", ":", "eta", "=", "10.", "**", "(", "minimum_log_eta", "+", "(", "i", "-", "1", ")", "*", "bin_size", ")", "integral", "=", "quad", "(", "surface_density_integrand", ",", "a", "=", "0.0", ",", "b", "=", "1.0", ",", "args", "=", "(", "eta", ",", "self", ".", "scale_radius", ",", "self", ".", "inner_slope", ")", ",", "epsrel", "=", "EllipticalGeneralizedNFW", ".", "epsrel", ")", "[", "0", "]", "surface_density_integral", "[", "i", "]", "=", "(", "(", "eta", "/", "self", ".", "scale_radius", ")", "**", "(", "1", "-", "self", ".", "inner_slope", ")", ")", "*", "(", "(", "(", "1", "+", "eta", "/", "self", ".", "scale_radius", ")", "**", "(", "self", ".", "inner_slope", "-", "3", ")", ")", "+", "integral", ")", "deflection_y", "=", "calculate_deflection_component", "(", "1.0", ",", "0", ")", "deflection_x", "=", "calculate_deflection_component", "(", "0.0", ",", "1", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "multiply", "(", "1.0", ",", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalGeneralizedNFW.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid)) deflection_grid = np.zeros(grid.shape[0]) for i in range(grid.shape[0]): deflection_grid[i] = np.multiply(4. * self.kappa_s * self.scale_radius, self.deflection_func_sph(eta[i])) return self.grid_to_grid_cartesian(grid, deflection_grid)
def deflections_from_grid(self, grid, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid)) deflection_grid = np.zeros(grid.shape[0]) for i in range(grid.shape[0]): deflection_grid[i] = np.multiply(4. * self.kappa_s * self.scale_radius, self.deflection_func_sph(eta[i])) return self.grid_to_grid_cartesian(grid, deflection_grid)
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1117-L1134
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ",", "*", "*", "kwargs", ")", ":", "eta", "=", "np", ".", "multiply", "(", "1.", "/", "self", ".", "scale_radius", ",", "self", ".", "grid_to_grid_radii", "(", "grid", ")", ")", "deflection_grid", "=", "np", ".", "zeros", "(", "grid", ".", "shape", "[", "0", "]", ")", "for", "i", "in", "range", "(", "grid", ".", "shape", "[", "0", "]", ")", ":", "deflection_grid", "[", "i", "]", "=", "np", ".", "multiply", "(", "4.", "*", "self", ".", "kappa_s", "*", "self", ".", "scale_radius", ",", "self", ".", "deflection_func_sph", "(", "eta", "[", "i", "]", ")", ")", "return", "self", ".", "grid_to_grid_cartesian", "(", "grid", ",", "deflection_grid", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalTruncatedNFW.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid)) deflection_grid = np.multiply((4. * self.kappa_s * self.scale_radius / eta), self.deflection_func_sph(eta)) return self.grid_to_grid_cartesian(grid, deflection_grid)
def deflections_from_grid(self, grid, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid)) deflection_grid = np.multiply((4. * self.kappa_s * self.scale_radius / eta), self.deflection_func_sph(eta)) return self.grid_to_grid_cartesian(grid, deflection_grid)
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1201-L1215
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ",", "*", "*", "kwargs", ")", ":", "eta", "=", "np", ".", "multiply", "(", "1.", "/", "self", ".", "scale_radius", ",", "self", ".", "grid_to_grid_radii", "(", "grid", ")", ")", "deflection_grid", "=", "np", ".", "multiply", "(", "(", "4.", "*", "self", ".", "kappa_s", "*", "self", ".", "scale_radius", "/", "eta", ")", ",", "self", ".", "deflection_func_sph", "(", "eta", ")", ")", "return", "self", ".", "grid_to_grid_cartesian", "(", "grid", ",", "deflection_grid", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalNFW.potential_from_grid
Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ potential_grid = quad_grid(self.potential_func, 0.0, 1.0, grid, args=(self.axis_ratio, self.kappa_s, self.scale_radius), epsrel=1.49e-5)[0] return potential_grid
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ potential_grid = quad_grid(self.potential_func, 0.0, 1.0, grid, args=(self.axis_ratio, self.kappa_s, self.scale_radius), epsrel=1.49e-5)[0] return potential_grid
[ "Calculate", "the", "potential", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1317-L1330
[ "def", "potential_from_grid", "(", "self", ",", "grid", ")", ":", "potential_grid", "=", "quad_grid", "(", "self", ".", "potential_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "self", ".", "axis_ratio", ",", "self", ".", "kappa_s", ",", "self", ".", "scale_radius", ")", ",", "epsrel", "=", "1.49e-5", ")", "[", "0", "]", "return", "potential_grid" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalNFW.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, self.kappa_s, self.scale_radius))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, self.kappa_s, self.scale_radius))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1336-L1357
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "def", "calculate_deflection_component", "(", "npow", ",", "index", ")", ":", "deflection_grid", "=", "self", ".", "axis_ratio", "*", "grid", "[", ":", ",", "index", "]", "deflection_grid", "*=", "quad_grid", "(", "self", ".", "deflection_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "npow", ",", "self", ".", "axis_ratio", ",", "self", ".", "kappa_s", ",", "self", ".", "scale_radius", ")", ")", "[", "0", "]", "return", "deflection_grid", "deflection_y", "=", "calculate_deflection_component", "(", "1.0", ",", "0", ")", "deflection_x", "=", "calculate_deflection_component", "(", "0.0", ",", "1", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "multiply", "(", "1.0", ",", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalNFW.potential_from_grid
Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = (1.0 / self.scale_radius) * self.grid_to_grid_radii(grid) + 0j return np.real(2.0 * self.scale_radius * self.kappa_s * self.potential_func_sph(eta))
def potential_from_grid(self, grid): """ Calculate the potential at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = (1.0 / self.scale_radius) * self.grid_to_grid_radii(grid) + 0j return np.real(2.0 * self.scale_radius * self.kappa_s * self.potential_func_sph(eta))
[ "Calculate", "the", "potential", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1424-L1434
[ "def", "potential_from_grid", "(", "self", ",", "grid", ")", ":", "eta", "=", "(", "1.0", "/", "self", ".", "scale_radius", ")", "*", "self", ".", "grid_to_grid_radii", "(", "grid", ")", "+", "0j", "return", "np", ".", "real", "(", "2.0", "*", "self", ".", "scale_radius", "*", "self", ".", "kappa_s", "*", "self", ".", "potential_func_sph", "(", "eta", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalNFW.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid=grid)) deflection_r = np.multiply(4. * self.kappa_s * self.scale_radius, self.deflection_func_sph(eta)) return self.grid_to_grid_cartesian(grid, deflection_r)
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ eta = np.multiply(1. / self.scale_radius, self.grid_to_grid_radii(grid=grid)) deflection_r = np.multiply(4. * self.kappa_s * self.scale_radius, self.deflection_func_sph(eta)) return self.grid_to_grid_cartesian(grid, deflection_r)
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1438-L1450
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "eta", "=", "np", ".", "multiply", "(", "1.", "/", "self", ".", "scale_radius", ",", "self", ".", "grid_to_grid_radii", "(", "grid", "=", "grid", ")", ")", "deflection_r", "=", "np", ".", "multiply", "(", "4.", "*", "self", ".", "kappa_s", "*", "self", ".", "scale_radius", ",", "self", ".", "deflection_func_sph", "(", "eta", ")", ")", "return", "self", ".", "grid_to_grid_cartesian", "(", "grid", ",", "deflection_r", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractEllipticalSersic.intensity_at_radius
Compute the intensity of the profile at a given radius. Parameters ---------- radius : float The distance from the centre of the profile.
autolens/model/profiles/mass_profiles.py
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. """ return self.intensity * np.exp( -self.sersic_constant * (((radius / self.effective_radius) ** (1. / self.sersic_index)) - 1))
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. """ return self.intensity * np.exp( -self.sersic_constant * (((radius / self.effective_radius) ** (1. / self.sersic_index)) - 1))
[ "Compute", "the", "intensity", "of", "the", "profile", "at", "a", "given", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1527-L1536
[ "def", "intensity_at_radius", "(", "self", ",", "radius", ")", ":", "return", "self", ".", "intensity", "*", "np", ".", "exp", "(", "-", "self", ".", "sersic_constant", "*", "(", "(", "(", "radius", "/", "self", ".", "effective_radius", ")", "**", "(", "1.", "/", "self", ".", "sersic_index", ")", ")", "-", "1", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractEllipticalSersic.sersic_constant
A parameter derived from Sersic index which ensures that effective radius contains 50% of the profile's total integrated light.
autolens/model/profiles/mass_profiles.py
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)) + ( 46. / (25515. * self.sersic_index ** 2)) + (131. / (1148175. * self.sersic_index ** 3)) - ( 2194697. / (30690717750. * self.sersic_index ** 4))
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)) + ( 46. / (25515. * self.sersic_index ** 2)) + (131. / (1148175. * self.sersic_index ** 3)) - ( 2194697. / (30690717750. * self.sersic_index ** 4))
[ "A", "parameter", "derived", "from", "Sersic", "index", "which", "ensures", "that", "effective", "radius", "contains", "50%", "of", "the", "profile", "s", "total", "integrated", "light", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1539-L1545
[ "def", "sersic_constant", "(", "self", ")", ":", "return", "(", "2", "*", "self", ".", "sersic_index", ")", "-", "(", "1.", "/", "3.", ")", "+", "(", "4.", "/", "(", "405.", "*", "self", ".", "sersic_index", ")", ")", "+", "(", "46.", "/", "(", "25515.", "*", "self", ".", "sersic_index", "**", "2", ")", ")", "+", "(", "131.", "/", "(", "1148175.", "*", "self", ".", "sersic_index", "**", "3", ")", ")", "-", "(", "2194697.", "/", "(", "30690717750.", "*", "self", ".", "sersic_index", "**", "4", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalSersicRadialGradient.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): sersic_constant = self.sersic_constant deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, self.intensity, self.sersic_index, self.effective_radius, self.mass_to_light_ratio, self.mass_to_light_gradient, sersic_constant))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ def calculate_deflection_component(npow, index): sersic_constant = self.sersic_constant deflection_grid = self.axis_ratio * grid[:, index] deflection_grid *= quad_grid(self.deflection_func, 0.0, 1.0, grid, args=(npow, self.axis_ratio, self.intensity, self.sersic_index, self.effective_radius, self.mass_to_light_ratio, self.mass_to_light_gradient, sersic_constant))[0] return deflection_grid deflection_y = calculate_deflection_component(1.0, 0) deflection_x = calculate_deflection_component(0.0, 1) return self.rotate_grid_from_profile(np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T))
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1813-L1837
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "def", "calculate_deflection_component", "(", "npow", ",", "index", ")", ":", "sersic_constant", "=", "self", ".", "sersic_constant", "deflection_grid", "=", "self", ".", "axis_ratio", "*", "grid", "[", ":", ",", "index", "]", "deflection_grid", "*=", "quad_grid", "(", "self", ".", "deflection_func", ",", "0.0", ",", "1.0", ",", "grid", ",", "args", "=", "(", "npow", ",", "self", ".", "axis_ratio", ",", "self", ".", "intensity", ",", "self", ".", "sersic_index", ",", "self", ".", "effective_radius", ",", "self", ".", "mass_to_light_ratio", ",", "self", ".", "mass_to_light_gradient", ",", "sersic_constant", ")", ")", "[", "0", "]", "return", "deflection_grid", "deflection_y", "=", "calculate_deflection_component", "(", "1.0", ",", "0", ")", "deflection_x", "=", "calculate_deflection_component", "(", "0.0", ",", "1", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "multiply", "(", "1.0", ",", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ExternalShear.deflections_from_grid
Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on.
autolens/model/profiles/mass_profiles.py
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ deflection_y = -np.multiply(self.magnitude, grid[:, 0]) deflection_x = np.multiply(self.magnitude, grid[:, 1]) return self.rotate_grid_from_profile(np.vstack((deflection_y, deflection_x)).T)
def deflections_from_grid(self, grid): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. Parameters ---------- grid : grids.RegularGrid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ deflection_y = -np.multiply(self.magnitude, grid[:, 0]) deflection_x = np.multiply(self.magnitude, grid[:, 1]) return self.rotate_grid_from_profile(np.vstack((deflection_y, deflection_x)).T)
[ "Calculate", "the", "deflection", "angles", "at", "a", "given", "set", "of", "arc", "-", "second", "gridded", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/mass_profiles.py#L1965-L1976
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "deflection_y", "=", "-", "np", ".", "multiply", "(", "self", ".", "magnitude", ",", "grid", "[", ":", ",", "0", "]", ")", "deflection_x", "=", "np", ".", "multiply", "(", "self", ".", "magnitude", ",", "grid", "[", ":", ",", "1", "]", ")", "return", "self", ".", "rotate_grid_from_profile", "(", "np", ".", "vstack", "(", "(", "deflection_y", ",", "deflection_x", ")", ")", ".", "T", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.intensities_from_grid
Calculate the summed intensities of all of the galaxy's light profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no light profiles, a grid of zeros is returned. See *profiles.light_profiles* for a description of how light profile intensities are computed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid.
autolens/model/galaxy/galaxy.py
def intensities_from_grid(self, grid): """Calculate the summed intensities of all of the galaxy's light profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no light profiles, a grid of zeros is returned. See *profiles.light_profiles* for a description of how light profile intensities are computed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_light_profile: return sum(map(lambda p: p.intensities_from_grid(grid), self.light_profiles)) else: return np.zeros((grid.shape[0],))
def intensities_from_grid(self, grid): """Calculate the summed intensities of all of the galaxy's light profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no light profiles, a grid of zeros is returned. See *profiles.light_profiles* for a description of how light profile intensities are computed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_light_profile: return sum(map(lambda p: p.intensities_from_grid(grid), self.light_profiles)) else: return np.zeros((grid.shape[0],))
[ "Calculate", "the", "summed", "intensities", "of", "all", "of", "the", "galaxy", "s", "light", "profiles", "using", "a", "grid", "of", "Cartesian", "(", "y", "x", ")", "\\", "coordinates", ".", "If", "the", "galaxy", "has", "no", "light", "profiles", "a", "grid", "of", "zeros", "is", "returned", ".", "See", "*", "profiles", ".", "light_profiles", "*", "for", "a", "description", "of", "how", "light", "profile", "intensities", "are", "computed", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L120-L136
[ "def", "intensities_from_grid", "(", "self", ",", "grid", ")", ":", "if", "self", ".", "has_light_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "intensities_from_grid", "(", "grid", ")", ",", "self", ".", "light_profiles", ")", ")", "else", ":", "return", "np", ".", "zeros", "(", "(", "grid", ".", "shape", "[", "0", "]", ",", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.luminosity_within_circle_in_units
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 to counts.
autolens/model/galaxy/galaxy.py
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 to counts. """ if self.has_light_profile: return sum(map(lambda p: p.luminosity_within_circle_in_units(radius=radius, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time), self.light_profiles)) else: return None
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 to counts. """ if self.has_light_profile: return sum(map(lambda p: p.luminosity_within_circle_in_units(radius=radius, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time), self.light_profiles)) else: return None
[ "Compute", "the", "total", "luminosity", "of", "the", "galaxy", "s", "light", "profiles", "within", "a", "circle", "of", "specified", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L138-L157
[ "def", "luminosity_within_circle_in_units", "(", "self", ",", "radius", ":", "dim", ".", "Length", ",", "unit_luminosity", "=", "'eps'", ",", "kpc_per_arcsec", "=", "None", ",", "exposure_time", "=", "None", ")", ":", "if", "self", ".", "has_light_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "luminosity_within_circle_in_units", "(", "radius", "=", "radius", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", ",", "self", ".", "light_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.luminosity_within_ellipse_in_units
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 ---------- major_axis : float The major-axis radius of the ellipse. 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 to counts.
autolens/model/galaxy/galaxy.py
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 ---------- major_axis : float The major-axis radius of the ellipse. 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 to counts. """ if self.has_light_profile: return sum(map(lambda p: p.luminosity_within_ellipse_in_units(major_axis=major_axis, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time), self.light_profiles)) else: return None
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 ---------- major_axis : float The major-axis radius of the ellipse. 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 to counts. """ if self.has_light_profile: return sum(map(lambda p: p.luminosity_within_ellipse_in_units(major_axis=major_axis, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time), self.light_profiles)) else: return 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", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L159-L180
[ "def", "luminosity_within_ellipse_in_units", "(", "self", ",", "major_axis", ":", "dim", ".", "Length", ",", "unit_luminosity", "=", "'eps'", ",", "kpc_per_arcsec", "=", "None", ",", "exposure_time", "=", "None", ")", ":", "if", "self", ".", "has_light_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "luminosity_within_ellipse_in_units", "(", "major_axis", "=", "major_axis", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", ",", "self", ".", "light_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.convergence_from_grid
Compute the summed convergence of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, a grid of zeros is returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid.
autolens/model/galaxy/galaxy.py
def convergence_from_grid(self, grid): """Compute the summed convergence of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, a grid of zeros is returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_mass_profile: return sum(map(lambda p: p.convergence_from_grid(grid), self.mass_profiles)) else: return np.zeros((grid.shape[0],))
def convergence_from_grid(self, grid): """Compute the summed convergence of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, a grid of zeros is returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_mass_profile: return sum(map(lambda p: p.convergence_from_grid(grid), self.mass_profiles)) else: return np.zeros((grid.shape[0],))
[ "Compute", "the", "summed", "convergence", "of", "the", "galaxy", "s", "mass", "profiles", "using", "a", "grid", "of", "Cartesian", "(", "y", "x", ")", "\\", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L182-L198
[ "def", "convergence_from_grid", "(", "self", ",", "grid", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "convergence_from_grid", "(", "grid", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "np", ".", "zeros", "(", "(", "grid", ".", "shape", "[", "0", "]", ",", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.deflections_from_grid
Compute the summed (y,x) deflection angles of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, two grid of zeros are returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid.
autolens/model/galaxy/galaxy.py
def deflections_from_grid(self, grid): """Compute the summed (y,x) deflection angles of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, two grid of zeros are returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_mass_profile: return sum(map(lambda p: p.deflections_from_grid(grid), self.mass_profiles)) else: return np.full((grid.shape[0], 2), 0.0)
def deflections_from_grid(self, grid): """Compute the summed (y,x) deflection angles of the galaxy's mass profiles using a grid of Cartesian (y,x) \ coordinates. If the galaxy has no mass profiles, two grid of zeros are returned. See *profiles.mass_profiles* module for details of how this is performed. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.has_mass_profile: return sum(map(lambda p: p.deflections_from_grid(grid), self.mass_profiles)) else: return np.full((grid.shape[0], 2), 0.0)
[ "Compute", "the", "summed", "(", "y", "x", ")", "deflection", "angles", "of", "the", "galaxy", "s", "mass", "profiles", "using", "a", "grid", "of", "Cartesian", "(", "y", "x", ")", "\\", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L218-L234
[ "def", "deflections_from_grid", "(", "self", ",", "grid", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "deflections_from_grid", "(", "grid", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "np", ".", "full", "(", "(", "grid", ".", "shape", "[", "0", "]", ",", "2", ")", ",", "0.0", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.mass_within_circle_in_units
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 \ units to physical units (e.g. solar masses).
autolens/model/galaxy/galaxy.py
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 \ units to physical units (e.g. solar masses). """ if self.has_mass_profile: return sum(map(lambda p: p.mass_within_circle_in_units(radius=radius, unit_mass=unit_mass, kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
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 \ units to physical units (e.g. solar masses). """ if self.has_mass_profile: return sum(map(lambda p: p.mass_within_circle_in_units(radius=radius, unit_mass=unit_mass, kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
[ "Compute", "the", "total", "angular", "mass", "of", "the", "galaxy", "s", "mass", "profiles", "within", "a", "circle", "of", "specified", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L236-L257
[ "def", "mass_within_circle_in_units", "(", "self", ",", "radius", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "None", ",", "critical_surface_density", "=", "None", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "mass_within_circle_in_units", "(", "radius", "=", "radius", ",", "unit_mass", "=", "unit_mass", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.mass_within_ellipse_in_units
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.
autolens/model/galaxy/galaxy.py
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. """ if self.has_mass_profile: return sum(map(lambda p: p.mass_within_ellipse_in_units(major_axis=major_axis, unit_mass=unit_mass, kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
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. """ if self.has_mass_profile: return sum(map(lambda p: p.mass_within_ellipse_in_units(major_axis=major_axis, unit_mass=unit_mass, kpc_per_arcsec=kpc_per_arcsec, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
[ "Compute", "the", "total", "angular", "mass", "of", "the", "galaxy", "s", "mass", "profiles", "within", "an", "ellipse", "of", "specified", "major_axis", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L259-L279
[ "def", "mass_within_ellipse_in_units", "(", "self", ",", "major_axis", ",", "unit_mass", "=", "'angular'", ",", "kpc_per_arcsec", "=", "None", ",", "critical_surface_density", "=", "None", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "mass_within_ellipse_in_units", "(", "major_axis", "=", "major_axis", ",", "unit_mass", "=", "unit_mass", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.einstein_radius_in_units
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
autolens/model/galaxy/galaxy.py
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 """ if self.has_mass_profile: return sum(map(lambda p: p.einstein_radius_in_units(unit_length=unit_length, kpc_per_arcsec=kpc_per_arcsec), self.mass_profiles)) else: return None
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 """ if self.has_mass_profile: return sum(map(lambda p: p.einstein_radius_in_units(unit_length=unit_length, kpc_per_arcsec=kpc_per_arcsec), self.mass_profiles)) else: return None
[ "The", "Einstein", "Radius", "of", "this", "galaxy", "which", "is", "the", "sum", "of", "Einstein", "Radii", "of", "its", "mass", "profiles", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L281-L291
[ "def", "einstein_radius_in_units", "(", "self", ",", "unit_length", "=", "'arcsec'", ",", "kpc_per_arcsec", "=", "None", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "einstein_radius_in_units", "(", "unit_length", "=", "unit_length", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Galaxy.einstein_mass_in_units
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 \ may be inaccurate. This is because the differently oriented ellipses of each mass profile
autolens/model/galaxy/galaxy.py
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 \ may be inaccurate. This is because the differently oriented ellipses of each mass profile """ if self.has_mass_profile: return sum( map(lambda p: p.einstein_mass_in_units(unit_mass=unit_mass, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
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 \ may be inaccurate. This is because the differently oriented ellipses of each mass profile """ if self.has_mass_profile: return sum( map(lambda p: p.einstein_mass_in_units(unit_mass=unit_mass, critical_surface_density=critical_surface_density), self.mass_profiles)) else: return None
[ "The", "Einstein", "Mass", "of", "this", "galaxy", "which", "is", "the", "sum", "of", "Einstein", "Radii", "of", "its", "mass", "profiles", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L293-L305
[ "def", "einstein_mass_in_units", "(", "self", ",", "unit_mass", "=", "'angular'", ",", "critical_surface_density", "=", "None", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "einstein_mass_in_units", "(", "unit_mass", "=", "unit_mass", ",", "critical_surface_density", "=", "critical_surface_density", ")", ",", "self", ".", "mass_profiles", ")", ")", "else", ":", "return", "None" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
HyperGalaxy.contributions_from_model_image_and_galaxy_image
Compute the contribution map of a galaxy, which represents the fraction of flux in each pixel that the \ galaxy is attributed to contain, scaled to the *contribution_factor* hyper-parameter. This is computed by dividing that galaxy's flux by the total flux in that pixel, and then scaling by the \ maximum flux such that the contribution map ranges between 0 and 1. Parameters ----------- model_image : ndarray The best-fit model image to the observed image from a previous analysis phase. This provides the \ total light attributed to each image pixel by the model. galaxy_image : ndarray A model image of the galaxy (from light profiles or an inversion) from a previous analysis phase. minimum_value : float The minimum contribution value a pixel must contain to not be rounded to 0.
autolens/model/galaxy/galaxy.py
def contributions_from_model_image_and_galaxy_image(self, model_image, galaxy_image, minimum_value=0.0): """Compute the contribution map of a galaxy, which represents the fraction of flux in each pixel that the \ galaxy is attributed to contain, scaled to the *contribution_factor* hyper-parameter. This is computed by dividing that galaxy's flux by the total flux in that pixel, and then scaling by the \ maximum flux such that the contribution map ranges between 0 and 1. Parameters ----------- model_image : ndarray The best-fit model image to the observed image from a previous analysis phase. This provides the \ total light attributed to each image pixel by the model. galaxy_image : ndarray A model image of the galaxy (from light profiles or an inversion) from a previous analysis phase. minimum_value : float The minimum contribution value a pixel must contain to not be rounded to 0. """ contributions = np.divide(galaxy_image, np.add(model_image, self.contribution_factor)) contributions = np.divide(contributions, np.max(contributions)) contributions[contributions < minimum_value] = 0.0 return contributions
def contributions_from_model_image_and_galaxy_image(self, model_image, galaxy_image, minimum_value=0.0): """Compute the contribution map of a galaxy, which represents the fraction of flux in each pixel that the \ galaxy is attributed to contain, scaled to the *contribution_factor* hyper-parameter. This is computed by dividing that galaxy's flux by the total flux in that pixel, and then scaling by the \ maximum flux such that the contribution map ranges between 0 and 1. Parameters ----------- model_image : ndarray The best-fit model image to the observed image from a previous analysis phase. This provides the \ total light attributed to each image pixel by the model. galaxy_image : ndarray A model image of the galaxy (from light profiles or an inversion) from a previous analysis phase. minimum_value : float The minimum contribution value a pixel must contain to not be rounded to 0. """ contributions = np.divide(galaxy_image, np.add(model_image, self.contribution_factor)) contributions = np.divide(contributions, np.max(contributions)) contributions[contributions < minimum_value] = 0.0 return contributions
[ "Compute", "the", "contribution", "map", "of", "a", "galaxy", "which", "represents", "the", "fraction", "of", "flux", "in", "each", "pixel", "that", "the", "\\", "galaxy", "is", "attributed", "to", "contain", "scaled", "to", "the", "*", "contribution_factor", "*", "hyper", "-", "parameter", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L343-L363
[ "def", "contributions_from_model_image_and_galaxy_image", "(", "self", ",", "model_image", ",", "galaxy_image", ",", "minimum_value", "=", "0.0", ")", ":", "contributions", "=", "np", ".", "divide", "(", "galaxy_image", ",", "np", ".", "add", "(", "model_image", ",", "self", ".", "contribution_factor", ")", ")", "contributions", "=", "np", ".", "divide", "(", "contributions", ",", "np", ".", "max", "(", "contributions", ")", ")", "contributions", "[", "contributions", "<", "minimum_value", "]", "=", "0.0", "return", "contributions" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
HyperGalaxy.hyper_noise_from_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 The observed noise-map (before scaling). contributions : ndarray The galaxy contribution map.
autolens/model/galaxy/galaxy.py
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 The observed noise-map (before scaling). contributions : ndarray The galaxy contribution map. """ return self.noise_factor * (noise_map * contributions) ** self.noise_power
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 The observed noise-map (before scaling). contributions : ndarray The galaxy contribution map. """ return self.noise_factor * (noise_map * contributions) ** self.noise_power
[ "Compute", "a", "scaled", "galaxy", "hyper", "noise", "-", "map", "from", "a", "baseline", "noise", "-", "map", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L365-L377
[ "def", "hyper_noise_from_contributions", "(", "self", ",", "noise_map", ",", "contributions", ")", ":", "return", "self", ".", "noise_factor", "*", "(", "noise_map", "*", "contributions", ")", "**", "self", ".", "noise_power" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Convolver.frame_at_coordinates_jit
Compute the frame (indexes of pixels light is blurred into) and psf_frame (psf kernel values of those \ pixels) for a given coordinate in a masks and its PSF. Parameters ---------- coordinates: (int, int) The coordinates of mask_index_array on which the frame should be centred psf_shape: (int, int) The shape of the psf for which this frame will be used
autolens/data/convolution.py
def frame_at_coordinates_jit(coordinates, mask, mask_index_array, psf): """ Compute the frame (indexes of pixels light is blurred into) and psf_frame (psf kernel values of those \ pixels) for a given coordinate in a masks and its PSF. Parameters ---------- coordinates: (int, int) The coordinates of mask_index_array on which the frame should be centred psf_shape: (int, int) The shape of the psf for which this frame will be used """ psf_shape = psf.shape psf_max_size = psf_shape[0] * psf_shape[1] half_x = int(psf_shape[0] / 2) half_y = int(psf_shape[1] / 2) frame = -1 * np.ones((psf_max_size)) psf_frame = -1.0 * np.ones((psf_max_size)) count = 0 for i in range(psf_shape[0]): for j in range(psf_shape[1]): x = coordinates[0] - half_x + i y = coordinates[1] - half_y + j if 0 <= x < mask_index_array.shape[0] and 0 <= y < mask_index_array.shape[1]: value = mask_index_array[x, y] if value >= 0 and not mask[x, y]: frame[count] = value psf_frame[count] = psf[i, j] count += 1 return frame, psf_frame
def frame_at_coordinates_jit(coordinates, mask, mask_index_array, psf): """ Compute the frame (indexes of pixels light is blurred into) and psf_frame (psf kernel values of those \ pixels) for a given coordinate in a masks and its PSF. Parameters ---------- coordinates: (int, int) The coordinates of mask_index_array on which the frame should be centred psf_shape: (int, int) The shape of the psf for which this frame will be used """ psf_shape = psf.shape psf_max_size = psf_shape[0] * psf_shape[1] half_x = int(psf_shape[0] / 2) half_y = int(psf_shape[1] / 2) frame = -1 * np.ones((psf_max_size)) psf_frame = -1.0 * np.ones((psf_max_size)) count = 0 for i in range(psf_shape[0]): for j in range(psf_shape[1]): x = coordinates[0] - half_x + i y = coordinates[1] - half_y + j if 0 <= x < mask_index_array.shape[0] and 0 <= y < mask_index_array.shape[1]: value = mask_index_array[x, y] if value >= 0 and not mask[x, y]: frame[count] = value psf_frame[count] = psf[i, j] count += 1 return frame, psf_frame
[ "Compute", "the", "frame", "(", "indexes", "of", "pixels", "light", "is", "blurred", "into", ")", "and", "psf_frame", "(", "psf", "kernel", "values", "of", "those", "\\", "pixels", ")", "for", "a", "given", "coordinate", "in", "a", "masks", "and", "its", "PSF", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/convolution.py#L213-L246
[ "def", "frame_at_coordinates_jit", "(", "coordinates", ",", "mask", ",", "mask_index_array", ",", "psf", ")", ":", "psf_shape", "=", "psf", ".", "shape", "psf_max_size", "=", "psf_shape", "[", "0", "]", "*", "psf_shape", "[", "1", "]", "half_x", "=", "int", "(", "psf_shape", "[", "0", "]", "/", "2", ")", "half_y", "=", "int", "(", "psf_shape", "[", "1", "]", "/", "2", ")", "frame", "=", "-", "1", "*", "np", ".", "ones", "(", "(", "psf_max_size", ")", ")", "psf_frame", "=", "-", "1.0", "*", "np", ".", "ones", "(", "(", "psf_max_size", ")", ")", "count", "=", "0", "for", "i", "in", "range", "(", "psf_shape", "[", "0", "]", ")", ":", "for", "j", "in", "range", "(", "psf_shape", "[", "1", "]", ")", ":", "x", "=", "coordinates", "[", "0", "]", "-", "half_x", "+", "i", "y", "=", "coordinates", "[", "1", "]", "-", "half_y", "+", "j", "if", "0", "<=", "x", "<", "mask_index_array", ".", "shape", "[", "0", "]", "and", "0", "<=", "y", "<", "mask_index_array", ".", "shape", "[", "1", "]", ":", "value", "=", "mask_index_array", "[", "x", ",", "y", "]", "if", "value", ">=", "0", "and", "not", "mask", "[", "x", ",", "y", "]", ":", "frame", "[", "count", "]", "=", "value", "psf_frame", "[", "count", "]", "=", "psf", "[", "i", ",", "j", "]", "count", "+=", "1", "return", "frame", ",", "psf_frame" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ConvolverImage.convolve_image
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 after PSF convolution.
autolens/data/convolution.py
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 after PSF convolution. """ return self.convolve_jit(image_array, self.image_frame_indexes, self.image_frame_psfs, self.image_frame_lengths, blurring_array, self.blurring_frame_indexes, self.blurring_frame_psfs, self.blurring_frame_lengths)
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 after PSF convolution. """ return self.convolve_jit(image_array, self.image_frame_indexes, self.image_frame_psfs, self.image_frame_lengths, blurring_array, self.blurring_frame_indexes, self.blurring_frame_psfs, self.blurring_frame_lengths)
[ "For", "a", "given", "1D", "regular", "array", "and", "blurring", "array", "convolve", "the", "two", "using", "this", "convolver", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/convolution.py#L287-L299
[ "def", "convolve_image", "(", "self", ",", "image_array", ",", "blurring_array", ")", ":", "return", "self", ".", "convolve_jit", "(", "image_array", ",", "self", ".", "image_frame_indexes", ",", "self", ".", "image_frame_psfs", ",", "self", ".", "image_frame_lengths", ",", "blurring_array", ",", "self", ".", "blurring_frame_indexes", ",", "self", ".", "blurring_frame_psfs", ",", "self", ".", "blurring_frame_lengths", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
intensities_of_galaxies_from_grid
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 \ intensities are calculated on. galaxies : [galaxy.Galaxy] The galaxies whose light profiles are used to compute the surface densities.
autolens/model/galaxy/util/galaxy_util.py
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 \ intensities are calculated on. galaxies : [galaxy.Galaxy] The galaxies whose light profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda g: g.intensities_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
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 \ intensities are calculated on. galaxies : [galaxy.Galaxy] The galaxies whose light profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda g: g.intensities_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
[ "Compute", "the", "intensities", "of", "a", "list", "of", "galaxies", "from", "an", "input", "grid", "by", "summing", "the", "individual", "intensities", "\\", "of", "each", "galaxy", "s", "light", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/util/galaxy_util.py#L7-L27
[ "def", "intensities_of_galaxies_from_grid", "(", "grid", ",", "galaxies", ")", ":", "if", "galaxies", ":", "return", "sum", "(", "map", "(", "lambda", "g", ":", "g", ".", "intensities_from_grid", "(", "grid", ")", ",", "galaxies", ")", ")", "else", ":", "return", "np", ".", "full", "(", "(", "grid", ".", "shape", "[", "0", "]", ")", ",", "0.0", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
convergence_of_galaxies_from_grid
Compute the convergence of a list of galaxies from an input grid, by summing the individual convergence \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the convergence 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 \ convergence is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the convergence.
autolens/model/galaxy/util/galaxy_util.py
def convergence_of_galaxies_from_grid(grid, galaxies): """Compute the convergence of a list of galaxies from an input grid, by summing the individual convergence \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the convergence 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 \ convergence is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the convergence. """ if galaxies: return sum(map(lambda g: g.convergence_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
def convergence_of_galaxies_from_grid(grid, galaxies): """Compute the convergence of a list of galaxies from an input grid, by summing the individual convergence \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the convergence 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 \ convergence is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the convergence. """ if galaxies: return sum(map(lambda g: g.convergence_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
[ "Compute", "the", "convergence", "of", "a", "list", "of", "galaxies", "from", "an", "input", "grid", "by", "summing", "the", "individual", "convergence", "\\", "of", "each", "galaxy", "s", "mass", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/util/galaxy_util.py#L31-L51
[ "def", "convergence_of_galaxies_from_grid", "(", "grid", ",", "galaxies", ")", ":", "if", "galaxies", ":", "return", "sum", "(", "map", "(", "lambda", "g", ":", "g", ".", "convergence_from_grid", "(", "grid", ")", ",", "galaxies", ")", ")", "else", ":", "return", "np", ".", "full", "(", "(", "grid", ".", "shape", "[", "0", "]", ")", ",", "0.0", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
potential_of_galaxies_from_grid
Compute the potential of a list of galaxies from an input grid, by summing the individual potential \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the surface-density 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 \ potential is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities.
autolens/model/galaxy/util/galaxy_util.py
def potential_of_galaxies_from_grid(grid, galaxies): """Compute the potential of a list of galaxies from an input grid, by summing the individual potential \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the surface-density 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 \ potential is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda g: g.potential_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
def potential_of_galaxies_from_grid(grid, galaxies): """Compute the potential of a list of galaxies from an input grid, by summing the individual potential \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the surface-density 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 \ potential is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda g: g.potential_from_grid(grid), galaxies)) else: return np.full((grid.shape[0]), 0.0)
[ "Compute", "the", "potential", "of", "a", "list", "of", "galaxies", "from", "an", "input", "grid", "by", "summing", "the", "individual", "potential", "\\", "of", "each", "galaxy", "s", "mass", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/util/galaxy_util.py#L55-L75
[ "def", "potential_of_galaxies_from_grid", "(", "grid", ",", "galaxies", ")", ":", "if", "galaxies", ":", "return", "sum", "(", "map", "(", "lambda", "g", ":", "g", ".", "potential_from_grid", "(", "grid", ")", ",", "galaxies", ")", ")", "else", ":", "return", "np", ".", "full", "(", "(", "grid", ".", "shape", "[", "0", "]", ")", ",", "0.0", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
deflections_of_galaxies_from_grid
Compute the deflections of a list of galaxies from an input grid, by summing the individual deflections \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the potential 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 \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities.
autolens/model/galaxy/util/galaxy_util.py
def deflections_of_galaxies_from_grid(grid, galaxies): """Compute the deflections of a list of galaxies from an input grid, by summing the individual deflections \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the potential 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 \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if len(galaxies) > 0: deflections = sum(map(lambda galaxy: galaxy.deflections_from_grid(grid), galaxies)) else: deflections = np.full((grid.shape[0], 2), 0.0) if isinstance(grid, grids.SubGrid): return np.asarray([grid.regular_data_1d_from_sub_data_1d(deflections[:, 0]), grid.regular_data_1d_from_sub_data_1d(deflections[:, 1])]).T return deflections
def deflections_of_galaxies_from_grid(grid, galaxies): """Compute the deflections of a list of galaxies from an input grid, by summing the individual deflections \ of each galaxy's mass profile. If the input grid is a *grids.SubGrid*, the potential 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 \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if len(galaxies) > 0: deflections = sum(map(lambda galaxy: galaxy.deflections_from_grid(grid), galaxies)) else: deflections = np.full((grid.shape[0], 2), 0.0) if isinstance(grid, grids.SubGrid): return np.asarray([grid.regular_data_1d_from_sub_data_1d(deflections[:, 0]), grid.regular_data_1d_from_sub_data_1d(deflections[:, 1])]).T return deflections
[ "Compute", "the", "deflections", "of", "a", "list", "of", "galaxies", "from", "an", "input", "grid", "by", "summing", "the", "individual", "deflections", "\\", "of", "each", "galaxy", "s", "mass", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/util/galaxy_util.py#L78-L104
[ "def", "deflections_of_galaxies_from_grid", "(", "grid", ",", "galaxies", ")", ":", "if", "len", "(", "galaxies", ")", ">", "0", ":", "deflections", "=", "sum", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "deflections_from_grid", "(", "grid", ")", ",", "galaxies", ")", ")", "else", ":", "deflections", "=", "np", ".", "full", "(", "(", "grid", ".", "shape", "[", "0", "]", ",", "2", ")", ",", "0.0", ")", "if", "isinstance", "(", "grid", ",", "grids", ".", "SubGrid", ")", ":", "return", "np", ".", "asarray", "(", "[", "grid", ".", "regular_data_1d_from_sub_data_1d", "(", "deflections", "[", ":", ",", "0", "]", ")", ",", "grid", ".", "regular_data_1d_from_sub_data_1d", "(", "deflections", "[", ":", ",", "1", "]", ")", "]", ")", ".", "T", "return", "deflections" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
deflections_of_galaxies_from_sub_grid
Compute the deflections of a list of galaxies from an input sub-grid, by summing the individual deflections \ of each galaxy's mass profile. The deflections are 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 ----------- sub_grid : RegularGrid The grid (regular or sub) of (y,x) arc-second coordinates at the centre of every unmasked pixel which the \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities.
autolens/model/galaxy/util/galaxy_util.py
def deflections_of_galaxies_from_sub_grid(sub_grid, galaxies): """Compute the deflections of a list of galaxies from an input sub-grid, by summing the individual deflections \ of each galaxy's mass profile. The deflections are 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 ----------- sub_grid : RegularGrid The grid (regular or sub) of (y,x) arc-second coordinates at the centre of every unmasked pixel which the \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda galaxy: galaxy.deflections_from_grid(sub_grid), galaxies)) else: return np.full((sub_grid.shape[0], 2), 0.0)
def deflections_of_galaxies_from_sub_grid(sub_grid, galaxies): """Compute the deflections of a list of galaxies from an input sub-grid, by summing the individual deflections \ of each galaxy's mass profile. The deflections are 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 ----------- sub_grid : RegularGrid The grid (regular or sub) of (y,x) arc-second coordinates at the centre of every unmasked pixel which the \ deflections is calculated on. galaxies : [galaxy.Galaxy] The galaxies whose mass profiles are used to compute the surface densities. """ if galaxies: return sum(map(lambda galaxy: galaxy.deflections_from_grid(sub_grid), galaxies)) else: return np.full((sub_grid.shape[0], 2), 0.0)
[ "Compute", "the", "deflections", "of", "a", "list", "of", "galaxies", "from", "an", "input", "sub", "-", "grid", "by", "summing", "the", "individual", "deflections", "\\", "of", "each", "galaxy", "s", "mass", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/util/galaxy_util.py#L107-L127
[ "def", "deflections_of_galaxies_from_sub_grid", "(", "sub_grid", ",", "galaxies", ")", ":", "if", "galaxies", ":", "return", "sum", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "deflections_from_grid", "(", "sub_grid", ")", ",", "galaxies", ")", ")", "else", ":", "return", "np", ".", "full", "(", "(", "sub_grid", ".", "shape", "[", "0", "]", ",", "2", ")", ",", "0.0", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
blurred_image_1d_from_1d_unblurred_and_blurring_images
For a 1D masked image and 1D blurring image (the regions outside the mask whose light blurs \ into the mask after PSF convolution), use both to compute the blurred image within the mask via PSF convolution. The convolution uses each image's convolver (*See ccd.convolution*). Parameters ---------- unblurred_image_1d : ndarray The 1D masked datas which is blurred. blurring_image_1d : ndarray The 1D masked blurring image which is used for blurring. convolver : ccd.convolution.ConvolverImage The image-convolver which performs the convolution in 1D.
autolens/lens/util/lens_fit_util.py
def blurred_image_1d_from_1d_unblurred_and_blurring_images(unblurred_image_1d, blurring_image_1d, convolver): """For a 1D masked image and 1D blurring image (the regions outside the mask whose light blurs \ into the mask after PSF convolution), use both to compute the blurred image within the mask via PSF convolution. The convolution uses each image's convolver (*See ccd.convolution*). Parameters ---------- unblurred_image_1d : ndarray The 1D masked datas which is blurred. blurring_image_1d : ndarray The 1D masked blurring image which is used for blurring. convolver : ccd.convolution.ConvolverImage The image-convolver which performs the convolution in 1D. """ return convolver.convolve_image(image_array=unblurred_image_1d, blurring_array=blurring_image_1d)
def blurred_image_1d_from_1d_unblurred_and_blurring_images(unblurred_image_1d, blurring_image_1d, convolver): """For a 1D masked image and 1D blurring image (the regions outside the mask whose light blurs \ into the mask after PSF convolution), use both to compute the blurred image within the mask via PSF convolution. The convolution uses each image's convolver (*See ccd.convolution*). Parameters ---------- unblurred_image_1d : ndarray The 1D masked datas which is blurred. blurring_image_1d : ndarray The 1D masked blurring image which is used for blurring. convolver : ccd.convolution.ConvolverImage The image-convolver which performs the convolution in 1D. """ return convolver.convolve_image(image_array=unblurred_image_1d, blurring_array=blurring_image_1d)
[ "For", "a", "1D", "masked", "image", "and", "1D", "blurring", "image", "(", "the", "regions", "outside", "the", "mask", "whose", "light", "blurs", "\\", "into", "the", "mask", "after", "PSF", "convolution", ")", "use", "both", "to", "compute", "the", "blurred", "image", "within", "the", "mask", "via", "PSF", "convolution", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L4-L19
[ "def", "blurred_image_1d_from_1d_unblurred_and_blurring_images", "(", "unblurred_image_1d", ",", "blurring_image_1d", ",", "convolver", ")", ":", "return", "convolver", ".", "convolve_image", "(", "image_array", "=", "unblurred_image_1d", ",", "blurring_array", "=", "blurring_image_1d", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
evidence_from_inversion_terms
Compute the evidence of an inversion's fit to the datas, where the evidence includes a number of \ terms which quantify the complexity of an inversion's reconstruction (see the *inversion* module): Likelihood = -0.5*[Chi_Squared_Term + Regularization_Term + Log(Covariance_Regularization_Term) - Log(Regularization_Matrix_Term) + Noise_Term] Parameters ---------- chi_squared : float The chi-squared term of the inversion's fit to the observed datas. regularization_term : float The regularization term of the inversion, which is the sum of the difference between reconstructed \ flux of every pixel multiplied by the regularization coefficient. log_curvature_regularization_term : float The log of the determinant of the sum of the curvature and regularization matrices. log_regularization_term : float The log of the determinant o the regularization matrix. noise_normalization : float The normalization noise_map-term for the observed datas's noise-map.
autolens/lens/util/lens_fit_util.py
def evidence_from_inversion_terms(chi_squared, regularization_term, log_curvature_regularization_term, log_regularization_term, noise_normalization): """Compute the evidence of an inversion's fit to the datas, where the evidence includes a number of \ terms which quantify the complexity of an inversion's reconstruction (see the *inversion* module): Likelihood = -0.5*[Chi_Squared_Term + Regularization_Term + Log(Covariance_Regularization_Term) - Log(Regularization_Matrix_Term) + Noise_Term] Parameters ---------- chi_squared : float The chi-squared term of the inversion's fit to the observed datas. regularization_term : float The regularization term of the inversion, which is the sum of the difference between reconstructed \ flux of every pixel multiplied by the regularization coefficient. log_curvature_regularization_term : float The log of the determinant of the sum of the curvature and regularization matrices. log_regularization_term : float The log of the determinant o the regularization matrix. noise_normalization : float The normalization noise_map-term for the observed datas's noise-map. """ return -0.5 * (chi_squared + regularization_term + log_curvature_regularization_term - log_regularization_term + noise_normalization)
def evidence_from_inversion_terms(chi_squared, regularization_term, log_curvature_regularization_term, log_regularization_term, noise_normalization): """Compute the evidence of an inversion's fit to the datas, where the evidence includes a number of \ terms which quantify the complexity of an inversion's reconstruction (see the *inversion* module): Likelihood = -0.5*[Chi_Squared_Term + Regularization_Term + Log(Covariance_Regularization_Term) - Log(Regularization_Matrix_Term) + Noise_Term] Parameters ---------- chi_squared : float The chi-squared term of the inversion's fit to the observed datas. regularization_term : float The regularization term of the inversion, which is the sum of the difference between reconstructed \ flux of every pixel multiplied by the regularization coefficient. log_curvature_regularization_term : float The log of the determinant of the sum of the curvature and regularization matrices. log_regularization_term : float The log of the determinant o the regularization matrix. noise_normalization : float The normalization noise_map-term for the observed datas's noise-map. """ return -0.5 * (chi_squared + regularization_term + log_curvature_regularization_term - log_regularization_term + noise_normalization)
[ "Compute", "the", "evidence", "of", "an", "inversion", "s", "fit", "to", "the", "datas", "where", "the", "evidence", "includes", "a", "number", "of", "\\", "terms", "which", "quantify", "the", "complexity", "of", "an", "inversion", "s", "reconstruction", "(", "see", "the", "*", "inversion", "*", "module", ")", ":" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L43-L66
[ "def", "evidence_from_inversion_terms", "(", "chi_squared", ",", "regularization_term", ",", "log_curvature_regularization_term", ",", "log_regularization_term", ",", "noise_normalization", ")", ":", "return", "-", "0.5", "*", "(", "chi_squared", "+", "regularization_term", "+", "log_curvature_regularization_term", "-", "log_regularization_term", "+", "noise_normalization", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
blurred_image_of_planes_from_1d_images_and_convolver
For a tracer, extract the image-plane image of every plane and blur it with the PSF. If none of the galaxies in a plane have a light profie or pixelization (and thus don't have an image) a *None* \ is used. Parameters ---------- total_planes : int The total number of planes that blurred images are computed for. image_plane_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane image. image_plane_blurring_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane blurring image. convolver : hyper.ccd.convolution.ConvolverImage Class which performs the PSF convolution of a masked image in 1D. map_to_scaled_array : func A function which maps a masked image from 1D to 2D.
autolens/lens/util/lens_fit_util.py
def blurred_image_of_planes_from_1d_images_and_convolver(total_planes, image_plane_image_1d_of_planes, image_plane_blurring_image_1d_of_planes, convolver, map_to_scaled_array): """For a tracer, extract the image-plane image of every plane and blur it with the PSF. If none of the galaxies in a plane have a light profie or pixelization (and thus don't have an image) a *None* \ is used. Parameters ---------- total_planes : int The total number of planes that blurred images are computed for. image_plane_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane image. image_plane_blurring_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane blurring image. convolver : hyper.ccd.convolution.ConvolverImage Class which performs the PSF convolution of a masked image in 1D. map_to_scaled_array : func A function which maps a masked image from 1D to 2D. """ blurred_image_of_planes = [] for plane_index in range(total_planes): # If all entries are zero, there was no light profile / pixeization if np.count_nonzero(image_plane_image_1d_of_planes[plane_index]) > 0: blurred_image_1d_of_plane = blurred_image_1d_from_1d_unblurred_and_blurring_images( unblurred_image_1d=image_plane_image_1d_of_planes[plane_index], blurring_image_1d=image_plane_blurring_image_1d_of_planes[plane_index], convolver=convolver) blurred_image_of_plane = map_to_scaled_array(array_1d=blurred_image_1d_of_plane) blurred_image_of_planes.append(blurred_image_of_plane) else: blurred_image_of_planes.append(None) return blurred_image_of_planes
def blurred_image_of_planes_from_1d_images_and_convolver(total_planes, image_plane_image_1d_of_planes, image_plane_blurring_image_1d_of_planes, convolver, map_to_scaled_array): """For a tracer, extract the image-plane image of every plane and blur it with the PSF. If none of the galaxies in a plane have a light profie or pixelization (and thus don't have an image) a *None* \ is used. Parameters ---------- total_planes : int The total number of planes that blurred images are computed for. image_plane_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane image. image_plane_blurring_image_1d_of_planes : [ndarray] For every plane, the 1D image-plane blurring image. convolver : hyper.ccd.convolution.ConvolverImage Class which performs the PSF convolution of a masked image in 1D. map_to_scaled_array : func A function which maps a masked image from 1D to 2D. """ blurred_image_of_planes = [] for plane_index in range(total_planes): # If all entries are zero, there was no light profile / pixeization if np.count_nonzero(image_plane_image_1d_of_planes[plane_index]) > 0: blurred_image_1d_of_plane = blurred_image_1d_from_1d_unblurred_and_blurring_images( unblurred_image_1d=image_plane_image_1d_of_planes[plane_index], blurring_image_1d=image_plane_blurring_image_1d_of_planes[plane_index], convolver=convolver) blurred_image_of_plane = map_to_scaled_array(array_1d=blurred_image_1d_of_plane) blurred_image_of_planes.append(blurred_image_of_plane) else: blurred_image_of_planes.append(None) return blurred_image_of_planes
[ "For", "a", "tracer", "extract", "the", "image", "-", "plane", "image", "of", "every", "plane", "and", "blur", "it", "with", "the", "PSF", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L69-L111
[ "def", "blurred_image_of_planes_from_1d_images_and_convolver", "(", "total_planes", ",", "image_plane_image_1d_of_planes", ",", "image_plane_blurring_image_1d_of_planes", ",", "convolver", ",", "map_to_scaled_array", ")", ":", "blurred_image_of_planes", "=", "[", "]", "for", "plane_index", "in", "range", "(", "total_planes", ")", ":", "# If all entries are zero, there was no light profile / pixeization", "if", "np", ".", "count_nonzero", "(", "image_plane_image_1d_of_planes", "[", "plane_index", "]", ")", ">", "0", ":", "blurred_image_1d_of_plane", "=", "blurred_image_1d_from_1d_unblurred_and_blurring_images", "(", "unblurred_image_1d", "=", "image_plane_image_1d_of_planes", "[", "plane_index", "]", ",", "blurring_image_1d", "=", "image_plane_blurring_image_1d_of_planes", "[", "plane_index", "]", ",", "convolver", "=", "convolver", ")", "blurred_image_of_plane", "=", "map_to_scaled_array", "(", "array_1d", "=", "blurred_image_1d_of_plane", ")", "blurred_image_of_planes", ".", "append", "(", "blurred_image_of_plane", ")", "else", ":", "blurred_image_of_planes", ".", "append", "(", "None", ")", "return", "blurred_image_of_planes" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
unmasked_blurred_image_of_planes_from_padded_grid_stack_and_psf
For lens data, compute the unmasked blurred image of every unmasked unblurred image of each plane. To do this, \ this function iterates over all planes to extract their unmasked unblurred images. If a galaxy in a plane has a pixelization, the unmasked image is returned as None, as as the inversion's model \ image cannot be mapped to an unmasked version. 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. This returns a list, where each list index corresponds to [plane_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution.
autolens/lens/util/lens_fit_util.py
def unmasked_blurred_image_of_planes_from_padded_grid_stack_and_psf(planes, padded_grid_stack, psf): """For lens data, compute the unmasked blurred image of every unmasked unblurred image of each plane. To do this, \ this function iterates over all planes to extract their unmasked unblurred images. If a galaxy in a plane has a pixelization, the unmasked image is returned as None, as as the inversion's model \ image cannot be mapped to an unmasked version. 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. This returns a list, where each list index corresponds to [plane_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution. """ unmasked_blurred_image_of_planes = [] for plane in planes: if plane.has_pixelization: unmasked_blurred_image_of_plane = None else: unmasked_blurred_image_of_plane = \ padded_grid_stack.unmasked_blurred_image_from_psf_and_unmasked_image( psf=psf, unmasked_image_1d=plane.image_plane_image_1d) unmasked_blurred_image_of_planes.append(unmasked_blurred_image_of_plane) return unmasked_blurred_image_of_planes
def unmasked_blurred_image_of_planes_from_padded_grid_stack_and_psf(planes, padded_grid_stack, psf): """For lens data, compute the unmasked blurred image of every unmasked unblurred image of each plane. To do this, \ this function iterates over all planes to extract their unmasked unblurred images. If a galaxy in a plane has a pixelization, the unmasked image is returned as None, as as the inversion's model \ image cannot be mapped to an unmasked version. 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. This returns a list, where each list index corresponds to [plane_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution. """ unmasked_blurred_image_of_planes = [] for plane in planes: if plane.has_pixelization: unmasked_blurred_image_of_plane = None else: unmasked_blurred_image_of_plane = \ padded_grid_stack.unmasked_blurred_image_from_psf_and_unmasked_image( psf=psf, unmasked_image_1d=plane.image_plane_image_1d) unmasked_blurred_image_of_planes.append(unmasked_blurred_image_of_plane) return unmasked_blurred_image_of_planes
[ "For", "lens", "data", "compute", "the", "unmasked", "blurred", "image", "of", "every", "unmasked", "unblurred", "image", "of", "each", "plane", ".", "To", "do", "this", "\\", "this", "function", "iterates", "over", "all", "planes", "to", "extract", "their", "unmasked", "unblurred", "images", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L114-L149
[ "def", "unmasked_blurred_image_of_planes_from_padded_grid_stack_and_psf", "(", "planes", ",", "padded_grid_stack", ",", "psf", ")", ":", "unmasked_blurred_image_of_planes", "=", "[", "]", "for", "plane", "in", "planes", ":", "if", "plane", ".", "has_pixelization", ":", "unmasked_blurred_image_of_plane", "=", "None", "else", ":", "unmasked_blurred_image_of_plane", "=", "padded_grid_stack", ".", "unmasked_blurred_image_from_psf_and_unmasked_image", "(", "psf", "=", "psf", ",", "unmasked_image_1d", "=", "plane", ".", "image_plane_image_1d", ")", "unmasked_blurred_image_of_planes", ".", "append", "(", "unmasked_blurred_image_of_plane", ")", "return", "unmasked_blurred_image_of_planes" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
unmasked_blurred_image_of_planes_and_galaxies_from_padded_grid_stack_and_psf
For lens data, compute the unmasked blurred image of every unmasked unblurred image of every galaxy in each \ plane. To do this, this function iterates over all planes and then galaxies to extract their unmasked unblurred \ images. If a galaxy in a plane has a pixelization, the unmasked image of that galaxy in the plane is returned as None \ as as the inversion's model image cannot be mapped to an unmasked version. 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. This returns a list of lists, where each list index corresponds to [plane_index][galaxy_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution.
autolens/lens/util/lens_fit_util.py
def unmasked_blurred_image_of_planes_and_galaxies_from_padded_grid_stack_and_psf(planes, padded_grid_stack, psf): """For lens data, compute the unmasked blurred image of every unmasked unblurred image of every galaxy in each \ plane. To do this, this function iterates over all planes and then galaxies to extract their unmasked unblurred \ images. If a galaxy in a plane has a pixelization, the unmasked image of that galaxy in the plane is returned as None \ as as the inversion's model image cannot be mapped to an unmasked version. 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. This returns a list of lists, where each list index corresponds to [plane_index][galaxy_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution. """ return [plane.unmasked_blurred_image_of_galaxies_from_psf(padded_grid_stack, psf) for plane in planes]
def unmasked_blurred_image_of_planes_and_galaxies_from_padded_grid_stack_and_psf(planes, padded_grid_stack, psf): """For lens data, compute the unmasked blurred image of every unmasked unblurred image of every galaxy in each \ plane. To do this, this function iterates over all planes and then galaxies to extract their unmasked unblurred \ images. If a galaxy in a plane has a pixelization, the unmasked image of that galaxy in the plane is returned as None \ as as the inversion's model image cannot be mapped to an unmasked version. 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. This returns a list of lists, where each list index corresponds to [plane_index][galaxy_index]. Parameters ---------- planes : [plane.Plane] The list of planes the unmasked blurred images are computed using. padded_grid_stack : grids.GridStack A padded-grid_stack, whose padded grid is used for PSF convolution. psf : ccd.PSF The PSF of the image used for convolution. """ return [plane.unmasked_blurred_image_of_galaxies_from_psf(padded_grid_stack, psf) for plane in planes]
[ "For", "lens", "data", "compute", "the", "unmasked", "blurred", "image", "of", "every", "unmasked", "unblurred", "image", "of", "every", "galaxy", "in", "each", "\\", "plane", ".", "To", "do", "this", "this", "function", "iterates", "over", "all", "planes", "and", "then", "galaxies", "to", "extract", "their", "unmasked", "unblurred", "\\", "images", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L152-L174
[ "def", "unmasked_blurred_image_of_planes_and_galaxies_from_padded_grid_stack_and_psf", "(", "planes", ",", "padded_grid_stack", ",", "psf", ")", ":", "return", "[", "plane", ".", "unmasked_blurred_image_of_galaxies_from_psf", "(", "padded_grid_stack", ",", "psf", ")", "for", "plane", "in", "planes", "]" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
contribution_maps_1d_from_hyper_images_and_galaxies
For a fitting hyper_galaxy_image, hyper_galaxy model image, list of hyper galaxies images and model hyper galaxies, compute their contribution maps, which are used to compute a scaled-noise_map map. All quantities are masked 1D arrays. The reason this is separate from the *contributions_from_fitting_hyper_images_and_hyper_galaxies* function is that each hyper_galaxy image has a list of hyper galaxies images and associated hyper galaxies (one for each galaxy). Thus, this function breaks down the calculation of each 1D masked contribution map and returns them in the same datas structure (2 lists with indexes [image_index][contribution_map_index]. Parameters ---------- hyper_model_image_1d : ndarray The best-fit model image to the datas (e.g. from a previous analysis phase). hyper_galaxy_images_1d : [ndarray] The best-fit model image of each hyper galaxy to the datas (e.g. from a previous analysis phase). hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. hyper_minimum_values : [float] The minimum value of each hyper_galaxy-image contribution map, which ensure zero's don't impact the scaled noise-map.
autolens/lens/util/lens_fit_util.py
def contribution_maps_1d_from_hyper_images_and_galaxies(hyper_model_image_1d, hyper_galaxy_images_1d, hyper_galaxies, hyper_minimum_values): """For a fitting hyper_galaxy_image, hyper_galaxy model image, list of hyper galaxies images and model hyper galaxies, compute their contribution maps, which are used to compute a scaled-noise_map map. All quantities are masked 1D arrays. The reason this is separate from the *contributions_from_fitting_hyper_images_and_hyper_galaxies* function is that each hyper_galaxy image has a list of hyper galaxies images and associated hyper galaxies (one for each galaxy). Thus, this function breaks down the calculation of each 1D masked contribution map and returns them in the same datas structure (2 lists with indexes [image_index][contribution_map_index]. Parameters ---------- hyper_model_image_1d : ndarray The best-fit model image to the datas (e.g. from a previous analysis phase). hyper_galaxy_images_1d : [ndarray] The best-fit model image of each hyper galaxy to the datas (e.g. from a previous analysis phase). hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. hyper_minimum_values : [float] The minimum value of each hyper_galaxy-image contribution map, which ensure zero's don't impact the scaled noise-map. """ # noinspection PyArgumentList return list(map(lambda hyper_galaxy, hyper_galaxy_image_1d, hyper_minimum_value: hyper_galaxy.contributions_from_model_image_and_galaxy_image(model_image=hyper_model_image_1d, galaxy_image=hyper_galaxy_image_1d, minimum_value=hyper_minimum_value), hyper_galaxies, hyper_galaxy_images_1d, hyper_minimum_values))
def contribution_maps_1d_from_hyper_images_and_galaxies(hyper_model_image_1d, hyper_galaxy_images_1d, hyper_galaxies, hyper_minimum_values): """For a fitting hyper_galaxy_image, hyper_galaxy model image, list of hyper galaxies images and model hyper galaxies, compute their contribution maps, which are used to compute a scaled-noise_map map. All quantities are masked 1D arrays. The reason this is separate from the *contributions_from_fitting_hyper_images_and_hyper_galaxies* function is that each hyper_galaxy image has a list of hyper galaxies images and associated hyper galaxies (one for each galaxy). Thus, this function breaks down the calculation of each 1D masked contribution map and returns them in the same datas structure (2 lists with indexes [image_index][contribution_map_index]. Parameters ---------- hyper_model_image_1d : ndarray The best-fit model image to the datas (e.g. from a previous analysis phase). hyper_galaxy_images_1d : [ndarray] The best-fit model image of each hyper galaxy to the datas (e.g. from a previous analysis phase). hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. hyper_minimum_values : [float] The minimum value of each hyper_galaxy-image contribution map, which ensure zero's don't impact the scaled noise-map. """ # noinspection PyArgumentList return list(map(lambda hyper_galaxy, hyper_galaxy_image_1d, hyper_minimum_value: hyper_galaxy.contributions_from_model_image_and_galaxy_image(model_image=hyper_model_image_1d, galaxy_image=hyper_galaxy_image_1d, minimum_value=hyper_minimum_value), hyper_galaxies, hyper_galaxy_images_1d, hyper_minimum_values))
[ "For", "a", "fitting", "hyper_galaxy_image", "hyper_galaxy", "model", "image", "list", "of", "hyper", "galaxies", "images", "and", "model", "hyper", "galaxies", "compute", "their", "contribution", "maps", "which", "are", "used", "to", "compute", "a", "scaled", "-", "noise_map", "map", ".", "All", "quantities", "are", "masked", "1D", "arrays", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L177-L204
[ "def", "contribution_maps_1d_from_hyper_images_and_galaxies", "(", "hyper_model_image_1d", ",", "hyper_galaxy_images_1d", ",", "hyper_galaxies", ",", "hyper_minimum_values", ")", ":", "# noinspection PyArgumentList", "return", "list", "(", "map", "(", "lambda", "hyper_galaxy", ",", "hyper_galaxy_image_1d", ",", "hyper_minimum_value", ":", "hyper_galaxy", ".", "contributions_from_model_image_and_galaxy_image", "(", "model_image", "=", "hyper_model_image_1d", ",", "galaxy_image", "=", "hyper_galaxy_image_1d", ",", "minimum_value", "=", "hyper_minimum_value", ")", ",", "hyper_galaxies", ",", "hyper_galaxy_images_1d", ",", "hyper_minimum_values", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
scaled_noise_map_from_hyper_galaxies_and_contribution_maps
For a contribution map and noise-map, use the model hyper galaxies to compute a scaled noise-map. Parameters ----------- contribution_maps : ndarray The image's list of 1D masked contribution maps (e.g. one for each hyper galaxy) hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. noise_map : ccd.NoiseMap or ndarray An array describing the RMS standard deviation error in each pixel, preferably in units of electrons per second.
autolens/lens/util/lens_fit_util.py
def scaled_noise_map_from_hyper_galaxies_and_contribution_maps(contribution_maps, hyper_galaxies, noise_map): """For a contribution map and noise-map, use the model hyper galaxies to compute a scaled noise-map. Parameters ----------- contribution_maps : ndarray The image's list of 1D masked contribution maps (e.g. one for each hyper galaxy) hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. noise_map : ccd.NoiseMap or ndarray An array describing the RMS standard deviation error in each pixel, preferably in units of electrons per second. """ scaled_noise_maps = list(map(lambda hyper_galaxy, contribution_map: hyper_galaxy.hyper_noise_from_contributions(noise_map=noise_map, contributions=contribution_map), hyper_galaxies, contribution_maps)) return noise_map + sum(scaled_noise_maps)
def scaled_noise_map_from_hyper_galaxies_and_contribution_maps(contribution_maps, hyper_galaxies, noise_map): """For a contribution map and noise-map, use the model hyper galaxies to compute a scaled noise-map. Parameters ----------- contribution_maps : ndarray The image's list of 1D masked contribution maps (e.g. one for each hyper galaxy) hyper_galaxies : [galaxy.Galaxy] The hyper galaxies which represent the model components used to scale the noise_map, which correspond to individual galaxies in the image. noise_map : ccd.NoiseMap or ndarray An array describing the RMS standard deviation error in each pixel, preferably in units of electrons per second. """ scaled_noise_maps = list(map(lambda hyper_galaxy, contribution_map: hyper_galaxy.hyper_noise_from_contributions(noise_map=noise_map, contributions=contribution_map), hyper_galaxies, contribution_maps)) return noise_map + sum(scaled_noise_maps)
[ "For", "a", "contribution", "map", "and", "noise", "-", "map", "use", "the", "model", "hyper", "galaxies", "to", "compute", "a", "scaled", "noise", "-", "map", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/util/lens_fit_util.py#L207-L225
[ "def", "scaled_noise_map_from_hyper_galaxies_and_contribution_maps", "(", "contribution_maps", ",", "hyper_galaxies", ",", "noise_map", ")", ":", "scaled_noise_maps", "=", "list", "(", "map", "(", "lambda", "hyper_galaxy", ",", "contribution_map", ":", "hyper_galaxy", ".", "hyper_noise_from_contributions", "(", "noise_map", "=", "noise_map", ",", "contributions", "=", "contribution_map", ")", ",", "hyper_galaxies", ",", "contribution_maps", ")", ")", "return", "noise_map", "+", "sum", "(", "scaled_noise_maps", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
rectangular_neighbors_from_shape
Compute the neighbors of every pixel as a list of the pixel index's each pixel shares a vertex with. The uniformity of the rectangular grid's geometry is used to compute this.
autolens/model/inversion/util/pixelization_util.py
def rectangular_neighbors_from_shape(shape): """Compute the neighbors of every pixel as a list of the pixel index's each pixel shares a vertex with. The uniformity of the rectangular grid's geometry is used to compute this. """ pixels = shape[0]*shape[1] pixel_neighbors = -1 * np.ones(shape=(pixels, 4)) pixel_neighbors_size = np.zeros(pixels) pixel_neighbors, pixel_neighbors_size = compute_corner_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_top_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_left_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_right_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_bottom_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_central_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) return pixel_neighbors, pixel_neighbors_size
def rectangular_neighbors_from_shape(shape): """Compute the neighbors of every pixel as a list of the pixel index's each pixel shares a vertex with. The uniformity of the rectangular grid's geometry is used to compute this. """ pixels = shape[0]*shape[1] pixel_neighbors = -1 * np.ones(shape=(pixels, 4)) pixel_neighbors_size = np.zeros(pixels) pixel_neighbors, pixel_neighbors_size = compute_corner_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_top_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_left_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_right_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_bottom_edge_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) pixel_neighbors, pixel_neighbors_size = compute_central_neighbors(pixel_neighbors, pixel_neighbors_size, shape, pixels) return pixel_neighbors, pixel_neighbors_size
[ "Compute", "the", "neighbors", "of", "every", "pixel", "as", "a", "list", "of", "the", "pixel", "index", "s", "each", "pixel", "shares", "a", "vertex", "with", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/pixelization_util.py#L5-L30
[ "def", "rectangular_neighbors_from_shape", "(", "shape", ")", ":", "pixels", "=", "shape", "[", "0", "]", "*", "shape", "[", "1", "]", "pixel_neighbors", "=", "-", "1", "*", "np", ".", "ones", "(", "shape", "=", "(", "pixels", ",", "4", ")", ")", "pixel_neighbors_size", "=", "np", ".", "zeros", "(", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_corner_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_top_edge_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_left_edge_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_right_edge_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_bottom_edge_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "pixel_neighbors", ",", "pixel_neighbors_size", "=", "compute_central_neighbors", "(", "pixel_neighbors", ",", "pixel_neighbors_size", ",", "shape", ",", "pixels", ")", "return", "pixel_neighbors", ",", "pixel_neighbors_size" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
voronoi_neighbors_from_pixels_and_ridge_points
Compute the neighbors of every pixel as a list 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_points : scipy.spatial.Voronoi.ridge_points Each Voronoi-ridge (two indexes representing a pixel mapping_matrix).
autolens/model/inversion/util/pixelization_util.py
def voronoi_neighbors_from_pixels_and_ridge_points(pixels, ridge_points): """Compute the neighbors of every pixel as a list 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_points : scipy.spatial.Voronoi.ridge_points Each Voronoi-ridge (two indexes representing a pixel mapping_matrix). """ pixel_neighbors_size = np.zeros(shape=(pixels)) for ridge_index in range(ridge_points.shape[0]): pair0 = ridge_points[ridge_index, 0] pair1 = ridge_points[ridge_index, 1] pixel_neighbors_size[pair0] += 1 pixel_neighbors_size[pair1] += 1 pixel_neighbors_index = np.zeros(shape=(pixels)) pixel_neighbors = -1 * np.ones(shape=(pixels, int(np.max(pixel_neighbors_size)))) for ridge_index in range(ridge_points.shape[0]): pair0 = ridge_points[ridge_index, 0] pair1 = ridge_points[ridge_index, 1] pixel_neighbors[pair0, int(pixel_neighbors_index[pair0])] = pair1 pixel_neighbors[pair1, int(pixel_neighbors_index[pair1])] = pair0 pixel_neighbors_index[pair0] += 1 pixel_neighbors_index[pair1] += 1 return pixel_neighbors, pixel_neighbors_size
def voronoi_neighbors_from_pixels_and_ridge_points(pixels, ridge_points): """Compute the neighbors of every pixel as a list 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_points : scipy.spatial.Voronoi.ridge_points Each Voronoi-ridge (two indexes representing a pixel mapping_matrix). """ pixel_neighbors_size = np.zeros(shape=(pixels)) for ridge_index in range(ridge_points.shape[0]): pair0 = ridge_points[ridge_index, 0] pair1 = ridge_points[ridge_index, 1] pixel_neighbors_size[pair0] += 1 pixel_neighbors_size[pair1] += 1 pixel_neighbors_index = np.zeros(shape=(pixels)) pixel_neighbors = -1 * np.ones(shape=(pixels, int(np.max(pixel_neighbors_size)))) for ridge_index in range(ridge_points.shape[0]): pair0 = ridge_points[ridge_index, 0] pair1 = ridge_points[ridge_index, 1] pixel_neighbors[pair0, int(pixel_neighbors_index[pair0])] = pair1 pixel_neighbors[pair1, int(pixel_neighbors_index[pair1])] = pair0 pixel_neighbors_index[pair0] += 1 pixel_neighbors_index[pair1] += 1 return pixel_neighbors, pixel_neighbors_size
[ "Compute", "the", "neighbors", "of", "every", "pixel", "as", "a", "list", "of", "the", "pixel", "index", "s", "each", "pixel", "shares", "a", "vertex", "with", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/pixelization_util.py#L107-L137
[ "def", "voronoi_neighbors_from_pixels_and_ridge_points", "(", "pixels", ",", "ridge_points", ")", ":", "pixel_neighbors_size", "=", "np", ".", "zeros", "(", "shape", "=", "(", "pixels", ")", ")", "for", "ridge_index", "in", "range", "(", "ridge_points", ".", "shape", "[", "0", "]", ")", ":", "pair0", "=", "ridge_points", "[", "ridge_index", ",", "0", "]", "pair1", "=", "ridge_points", "[", "ridge_index", ",", "1", "]", "pixel_neighbors_size", "[", "pair0", "]", "+=", "1", "pixel_neighbors_size", "[", "pair1", "]", "+=", "1", "pixel_neighbors_index", "=", "np", ".", "zeros", "(", "shape", "=", "(", "pixels", ")", ")", "pixel_neighbors", "=", "-", "1", "*", "np", ".", "ones", "(", "shape", "=", "(", "pixels", ",", "int", "(", "np", ".", "max", "(", "pixel_neighbors_size", ")", ")", ")", ")", "for", "ridge_index", "in", "range", "(", "ridge_points", ".", "shape", "[", "0", "]", ")", ":", "pair0", "=", "ridge_points", "[", "ridge_index", ",", "0", "]", "pair1", "=", "ridge_points", "[", "ridge_index", ",", "1", "]", "pixel_neighbors", "[", "pair0", ",", "int", "(", "pixel_neighbors_index", "[", "pair0", "]", ")", "]", "=", "pair1", "pixel_neighbors", "[", "pair1", ",", "int", "(", "pixel_neighbors_index", "[", "pair1", "]", ")", "]", "=", "pair0", "pixel_neighbors_index", "[", "pair0", "]", "+=", "1", "pixel_neighbors_index", "[", "pair1", "]", "+=", "1", "return", "pixel_neighbors", ",", "pixel_neighbors_size" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
LensDataFit.for_data_and_tracer
Fit lens data with a model tracer, automatically determining the type of fit based on the \ properties of the galaxies in the tracer. Parameters ----------- lens_data : lens_data.LensData or lens_data.LensDataHyper The lens-images that is fitted. tracer : ray_tracing.TracerNonStack The tracer, which describes the ray-tracing and strong lens configuration. padded_tracer : ray_tracing.Tracer or None A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \ padded grid_stack such that unmasked model-images can be computed.
autolens/lens/lens_fit.py
def for_data_and_tracer(cls, lens_data, tracer, padded_tracer=None): """Fit lens data with a model tracer, automatically determining the type of fit based on the \ properties of the galaxies in the tracer. Parameters ----------- lens_data : lens_data.LensData or lens_data.LensDataHyper The lens-images that is fitted. tracer : ray_tracing.TracerNonStack The tracer, which describes the ray-tracing and strong lens configuration. padded_tracer : ray_tracing.Tracer or None A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \ padded grid_stack such that unmasked model-images can be computed. """ if tracer.has_light_profile and not tracer.has_pixelization: return LensProfileFit(lens_data=lens_data, tracer=tracer, padded_tracer=padded_tracer) elif not tracer.has_light_profile and tracer.has_pixelization: return LensInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None) elif tracer.has_light_profile and tracer.has_pixelization: return LensProfileInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None) else: raise exc.FittingException('The fit routine did not call a Fit class - check the ' 'properties of the tracer')
def for_data_and_tracer(cls, lens_data, tracer, padded_tracer=None): """Fit lens data with a model tracer, automatically determining the type of fit based on the \ properties of the galaxies in the tracer. Parameters ----------- lens_data : lens_data.LensData or lens_data.LensDataHyper The lens-images that is fitted. tracer : ray_tracing.TracerNonStack The tracer, which describes the ray-tracing and strong lens configuration. padded_tracer : ray_tracing.Tracer or None A tracer with an identical strong lens configuration to the tracer above, but using the lens data's \ padded grid_stack such that unmasked model-images can be computed. """ if tracer.has_light_profile and not tracer.has_pixelization: return LensProfileFit(lens_data=lens_data, tracer=tracer, padded_tracer=padded_tracer) elif not tracer.has_light_profile and tracer.has_pixelization: return LensInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None) elif tracer.has_light_profile and tracer.has_pixelization: return LensProfileInversionFit(lens_data=lens_data, tracer=tracer, padded_tracer=None) else: raise exc.FittingException('The fit routine did not call a Fit class - check the ' 'properties of the tracer')
[ "Fit", "lens", "data", "with", "a", "model", "tracer", "automatically", "determining", "the", "type", "of", "fit", "based", "on", "the", "\\", "properties", "of", "the", "galaxies", "in", "the", "tracer", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/lens_fit.py#L26-L49
[ "def", "for_data_and_tracer", "(", "cls", ",", "lens_data", ",", "tracer", ",", "padded_tracer", "=", "None", ")", ":", "if", "tracer", ".", "has_light_profile", "and", "not", "tracer", ".", "has_pixelization", ":", "return", "LensProfileFit", "(", "lens_data", "=", "lens_data", ",", "tracer", "=", "tracer", ",", "padded_tracer", "=", "padded_tracer", ")", "elif", "not", "tracer", ".", "has_light_profile", "and", "tracer", ".", "has_pixelization", ":", "return", "LensInversionFit", "(", "lens_data", "=", "lens_data", ",", "tracer", "=", "tracer", ",", "padded_tracer", "=", "None", ")", "elif", "tracer", ".", "has_light_profile", "and", "tracer", ".", "has_pixelization", ":", "return", "LensProfileInversionFit", "(", "lens_data", "=", "lens_data", ",", "tracer", "=", "tracer", ",", "padded_tracer", "=", "None", ")", "else", ":", "raise", "exc", ".", "FittingException", "(", "'The fit routine did not call a Fit class - check the '", "'properties of the tracer'", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
transform_grid
Wrap the function in a function that checks whether the coordinates have been transformed. If they have not \ been transformed then they are transformed. Parameters ---------- func : (profiles, *args, **kwargs) -> Object A function that requires transformed coordinates Returns ------- A function that can except cartesian or transformed coordinates
autolens/model/profiles/geometry_profiles.py
def transform_grid(func): """Wrap the function in a function that checks whether the coordinates have been transformed. If they have not \ been transformed then they are transformed. Parameters ---------- func : (profiles, *args, **kwargs) -> Object A function that requires transformed coordinates Returns ------- A function that can except cartesian or transformed coordinates """ @wraps(func) def wrapper(profile, grid, *args, **kwargs): """ Parameters ---------- profile : GeometryProfile The profiles that owns the function grid : ndarray PlaneCoordinates in either cartesian or profiles coordinate system args kwargs Returns ------- A value or coordinate in the same coordinate system as those passed in. """ if not isinstance(grid, TransformedGrid): return func(profile, profile.transform_grid_to_reference_frame(grid), *args, **kwargs) else: return func(profile, grid, *args, **kwargs) return wrapper
def transform_grid(func): """Wrap the function in a function that checks whether the coordinates have been transformed. If they have not \ been transformed then they are transformed. Parameters ---------- func : (profiles, *args, **kwargs) -> Object A function that requires transformed coordinates Returns ------- A function that can except cartesian or transformed coordinates """ @wraps(func) def wrapper(profile, grid, *args, **kwargs): """ Parameters ---------- profile : GeometryProfile The profiles that owns the function grid : ndarray PlaneCoordinates in either cartesian or profiles coordinate system args kwargs Returns ------- A value or coordinate in the same coordinate system as those passed in. """ if not isinstance(grid, TransformedGrid): return func(profile, profile.transform_grid_to_reference_frame(grid), *args, **kwargs) else: return func(profile, grid, *args, **kwargs) return wrapper
[ "Wrap", "the", "function", "in", "a", "function", "that", "checks", "whether", "the", "coordinates", "have", "been", "transformed", ".", "If", "they", "have", "not", "\\", "been", "transformed", "then", "they", "are", "transformed", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L9-L45
[ "def", "transform_grid", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "profile", ",", "grid", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n\n Parameters\n ----------\n profile : GeometryProfile\n The profiles that owns the function\n grid : ndarray\n PlaneCoordinates in either cartesian or profiles coordinate system\n args\n kwargs\n\n Returns\n -------\n A value or coordinate in the same coordinate system as those passed in.\n \"\"\"", "if", "not", "isinstance", "(", "grid", ",", "TransformedGrid", ")", ":", "return", "func", "(", "profile", ",", "profile", ".", "transform_grid_to_reference_frame", "(", "grid", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")", "else", ":", "return", "func", "(", "profile", ",", "grid", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "wrapper" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
cache
Caches results of a call to a grid function. If a grid that evaluates to the same byte value is passed into the same function of the same instance as previously then the cached result is returned. Parameters ---------- func Some instance method that takes a grid as its argument Returns ------- result Some result, either newly calculated or recovered from the cache
autolens/model/profiles/geometry_profiles.py
def cache(func): """ Caches results of a call to a grid function. If a grid that evaluates to the same byte value is passed into the same function of the same instance as previously then the cached result is returned. Parameters ---------- func Some instance method that takes a grid as its argument Returns ------- result Some result, either newly calculated or recovered from the cache """ def wrapper(instance: GeometryProfile, grid: np.ndarray, *args, **kwargs): if not hasattr(instance, "cache"): instance.cache = {} key = (func.__name__, grid.tobytes()) if key not in instance.cache: instance.cache[key] = func(instance, grid) return instance.cache[key] return wrapper
def cache(func): """ Caches results of a call to a grid function. If a grid that evaluates to the same byte value is passed into the same function of the same instance as previously then the cached result is returned. Parameters ---------- func Some instance method that takes a grid as its argument Returns ------- result Some result, either newly calculated or recovered from the cache """ def wrapper(instance: GeometryProfile, grid: np.ndarray, *args, **kwargs): if not hasattr(instance, "cache"): instance.cache = {} key = (func.__name__, grid.tobytes()) if key not in instance.cache: instance.cache[key] = func(instance, grid) return instance.cache[key] return wrapper
[ "Caches", "results", "of", "a", "call", "to", "a", "grid", "function", ".", "If", "a", "grid", "that", "evaluates", "to", "the", "same", "byte", "value", "is", "passed", "into", "the", "same", "function", "of", "the", "same", "instance", "as", "previously", "then", "the", "cached", "result", "is", "returned", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L48-L72
[ "def", "cache", "(", "func", ")", ":", "def", "wrapper", "(", "instance", ":", "GeometryProfile", ",", "grid", ":", "np", ".", "ndarray", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "instance", ",", "\"cache\"", ")", ":", "instance", ".", "cache", "=", "{", "}", "key", "=", "(", "func", ".", "__name__", ",", "grid", ".", "tobytes", "(", ")", ")", "if", "key", "not", "in", "instance", ".", "cache", ":", "instance", ".", "cache", "[", "key", "]", "=", "func", "(", "instance", ",", "grid", ")", "return", "instance", ".", "cache", "[", "key", "]", "return", "wrapper" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
move_grid_to_radial_minimum
Checks whether any coordinates in the grid are radially near (0.0, 0.0), which can lead to numerical faults in \ the evaluation of a light or mass profiles. If any coordinates are radially within the the radial minimum \ threshold, their (y,x) coordinates are shifted to that value to ensure they are evaluated correctly. By default this radial minimum is not used, and users should be certain they use a value that does not impact \ results. Parameters ---------- func : (profile, *args, **kwargs) -> Object A function that takes a grid of coordinates which may have a singularity as (0.0, 0.0) Returns ------- A function that can except cartesian or transformed coordinates
autolens/model/profiles/geometry_profiles.py
def move_grid_to_radial_minimum(func): """ Checks whether any coordinates in the grid are radially near (0.0, 0.0), which can lead to numerical faults in \ the evaluation of a light or mass profiles. If any coordinates are radially within the the radial minimum \ threshold, their (y,x) coordinates are shifted to that value to ensure they are evaluated correctly. By default this radial minimum is not used, and users should be certain they use a value that does not impact \ results. Parameters ---------- func : (profile, *args, **kwargs) -> Object A function that takes a grid of coordinates which may have a singularity as (0.0, 0.0) Returns ------- A function that can except cartesian or transformed coordinates """ @wraps(func) def wrapper(profile, grid, *args, **kwargs): """ Parameters ---------- profile : SphericalProfile The profiles that owns the function grid : ndarray PlaneCoordinates in either cartesian or profiles coordinate system args kwargs Returns ------- A value or coordinate in the same coordinate system as those passed in. """ radial_minimum_config = conf.NamedConfig(f"{conf.instance.config_path}/radial_minimum.ini") grid_radial_minimum = radial_minimum_config.get("radial_minimum", profile.__class__.__name__, float) with np.errstate(all='ignore'): # Division by zero fixed via isnan grid_radii = profile.grid_to_grid_radii(grid=grid) grid_radial_scale = np.where(grid_radii < grid_radial_minimum, grid_radial_minimum / grid_radii, 1.0) grid = np.multiply(grid, grid_radial_scale[:, None]) grid[np.isnan(grid)] = grid_radial_minimum return func(profile, grid, *args, **kwargs) return wrapper
def move_grid_to_radial_minimum(func): """ Checks whether any coordinates in the grid are radially near (0.0, 0.0), which can lead to numerical faults in \ the evaluation of a light or mass profiles. If any coordinates are radially within the the radial minimum \ threshold, their (y,x) coordinates are shifted to that value to ensure they are evaluated correctly. By default this radial minimum is not used, and users should be certain they use a value that does not impact \ results. Parameters ---------- func : (profile, *args, **kwargs) -> Object A function that takes a grid of coordinates which may have a singularity as (0.0, 0.0) Returns ------- A function that can except cartesian or transformed coordinates """ @wraps(func) def wrapper(profile, grid, *args, **kwargs): """ Parameters ---------- profile : SphericalProfile The profiles that owns the function grid : ndarray PlaneCoordinates in either cartesian or profiles coordinate system args kwargs Returns ------- A value or coordinate in the same coordinate system as those passed in. """ radial_minimum_config = conf.NamedConfig(f"{conf.instance.config_path}/radial_minimum.ini") grid_radial_minimum = radial_minimum_config.get("radial_minimum", profile.__class__.__name__, float) with np.errstate(all='ignore'): # Division by zero fixed via isnan grid_radii = profile.grid_to_grid_radii(grid=grid) grid_radial_scale = np.where(grid_radii < grid_radial_minimum, grid_radial_minimum / grid_radii, 1.0) grid = np.multiply(grid, grid_radial_scale[:, None]) grid[np.isnan(grid)] = grid_radial_minimum return func(profile, grid, *args, **kwargs) return wrapper
[ "Checks", "whether", "any", "coordinates", "in", "the", "grid", "are", "radially", "near", "(", "0", ".", "0", "0", ".", "0", ")", "which", "can", "lead", "to", "numerical", "faults", "in", "\\", "the", "evaluation", "of", "a", "light", "or", "mass", "profiles", ".", "If", "any", "coordinates", "are", "radially", "within", "the", "the", "radial", "minimum", "\\", "threshold", "their", "(", "y", "x", ")", "coordinates", "are", "shifted", "to", "that", "value", "to", "ensure", "they", "are", "evaluated", "correctly", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L75-L119
[ "def", "move_grid_to_radial_minimum", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "profile", ",", "grid", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n\n Parameters\n ----------\n profile : SphericalProfile\n The profiles that owns the function\n grid : ndarray\n PlaneCoordinates in either cartesian or profiles coordinate system\n args\n kwargs\n\n Returns\n -------\n A value or coordinate in the same coordinate system as those passed in.\n \"\"\"", "radial_minimum_config", "=", "conf", ".", "NamedConfig", "(", "f\"{conf.instance.config_path}/radial_minimum.ini\"", ")", "grid_radial_minimum", "=", "radial_minimum_config", ".", "get", "(", "\"radial_minimum\"", ",", "profile", ".", "__class__", ".", "__name__", ",", "float", ")", "with", "np", ".", "errstate", "(", "all", "=", "'ignore'", ")", ":", "# Division by zero fixed via isnan", "grid_radii", "=", "profile", ".", "grid_to_grid_radii", "(", "grid", "=", "grid", ")", "grid_radial_scale", "=", "np", ".", "where", "(", "grid_radii", "<", "grid_radial_minimum", ",", "grid_radial_minimum", "/", "grid_radii", ",", "1.0", ")", "grid", "=", "np", ".", "multiply", "(", "grid", ",", "grid_radial_scale", "[", ":", ",", "None", "]", ")", "grid", "[", "np", ".", "isnan", "(", "grid", ")", "]", "=", "grid_radial_minimum", "return", "func", "(", "profile", ",", "grid", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "wrapper" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalProfile.grid_to_grid_radii
Convert a grid of (y, x) coordinates to a grid of their circular radii. If the coordinates have not been transformed to the profile's centre, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile.
autolens/model/profiles/geometry_profiles.py
def grid_to_grid_radii(self, grid): """Convert a grid of (y, x) coordinates to a grid of their circular radii. If the coordinates have not been transformed to the profile's centre, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ return np.sqrt(np.add(np.square(grid[:, 0]), np.square(grid[:, 1])))
def grid_to_grid_radii(self, grid): """Convert a grid of (y, x) coordinates to a grid of their circular radii. If the coordinates have not been transformed to the profile's centre, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ return np.sqrt(np.add(np.square(grid[:, 0]), np.square(grid[:, 1])))
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "to", "a", "grid", "of", "their", "circular", "radii", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L170-L180
[ "def", "grid_to_grid_radii", "(", "self", ",", "grid", ")", ":", "return", "np", ".", "sqrt", "(", "np", ".", "add", "(", "np", ".", "square", "(", "grid", "[", ":", ",", "0", "]", ")", ",", "np", ".", "square", "(", "grid", "[", ":", ",", "1", "]", ")", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalProfile.grid_to_grid_cartesian
Convert a grid of (y,x) coordinates with their specified circular radii to their original (y,x) Cartesian coordinates. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. radius : ndarray The circular radius of each coordinate from the profile center.
autolens/model/profiles/geometry_profiles.py
def grid_to_grid_cartesian(self, grid, radius): """ Convert a grid of (y,x) coordinates with their specified circular radii to their original (y,x) Cartesian coordinates. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. radius : ndarray The circular radius of each coordinate from the profile center. """ grid_thetas = np.arctan2(grid[:, 0], grid[:, 1]) cos_theta, sin_theta = self.grid_angle_to_profile(grid_thetas=grid_thetas) return np.multiply(radius[:, None], np.vstack((sin_theta, cos_theta)).T)
def grid_to_grid_cartesian(self, grid, radius): """ Convert a grid of (y,x) coordinates with their specified circular radii to their original (y,x) Cartesian coordinates. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. radius : ndarray The circular radius of each coordinate from the profile center. """ grid_thetas = np.arctan2(grid[:, 0], grid[:, 1]) cos_theta, sin_theta = self.grid_angle_to_profile(grid_thetas=grid_thetas) return np.multiply(radius[:, None], np.vstack((sin_theta, cos_theta)).T)
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "with", "their", "specified", "circular", "radii", "to", "their", "original", "(", "y", "x", ")", "Cartesian", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L192-L206
[ "def", "grid_to_grid_cartesian", "(", "self", ",", "grid", ",", "radius", ")", ":", "grid_thetas", "=", "np", ".", "arctan2", "(", "grid", "[", ":", ",", "0", "]", ",", "grid", "[", ":", ",", "1", "]", ")", "cos_theta", ",", "sin_theta", "=", "self", ".", "grid_angle_to_profile", "(", "grid_thetas", "=", "grid_thetas", ")", "return", "np", ".", "multiply", "(", "radius", "[", ":", ",", "None", "]", ",", "np", ".", "vstack", "(", "(", "sin_theta", ",", "cos_theta", ")", ")", ".", "T", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalProfile.transform_grid_to_reference_frame
Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid.
autolens/model/profiles/geometry_profiles.py
def transform_grid_to_reference_frame(self, grid): """Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ transformed = np.subtract(grid, self.centre) return transformed.view(TransformedGrid)
def transform_grid_to_reference_frame(self, grid): """Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ transformed = np.subtract(grid, self.centre) return transformed.view(TransformedGrid)
[ "Transform", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "to", "the", "reference", "frame", "of", "the", "profile", "including", "a", "translation", "to", "\\", "its", "centre", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L208-L218
[ "def", "transform_grid_to_reference_frame", "(", "self", ",", "grid", ")", ":", "transformed", "=", "np", ".", "subtract", "(", "grid", ",", "self", ".", "centre", ")", "return", "transformed", ".", "view", "(", "TransformedGrid", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
SphericalProfile.transform_grid_from_reference_frame
Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile.
autolens/model/profiles/geometry_profiles.py
def transform_grid_from_reference_frame(self, grid): """Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ transformed = np.add(grid, self.centre) return transformed.view(TransformedGrid)
def transform_grid_from_reference_frame(self, grid): """Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ transformed = np.add(grid, self.centre) return transformed.view(TransformedGrid)
[ "Transform", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "from", "the", "reference", "frame", "of", "the", "profile", "to", "the", "original", "observer", "\\", "reference", "frame", "including", "a", "translation", "from", "the", "profile", "s", "centre", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L220-L230
[ "def", "transform_grid_from_reference_frame", "(", "self", ",", "grid", ")", ":", "transformed", "=", "np", ".", "add", "(", "grid", ",", "self", ".", "centre", ")", "return", "transformed", ".", "view", "(", "TransformedGrid", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.cos_and_sin_from_x_axis
Determine the sin and cosine of the angle between the profile's ellipse and the positive x-axis, \ counter-clockwise.
autolens/model/profiles/geometry_profiles.py
def cos_and_sin_from_x_axis(self): """ Determine the sin and cosine of the angle between the profile's ellipse and the positive x-axis, \ counter-clockwise. """ phi_radians = np.radians(self.phi) return np.cos(phi_radians), np.sin(phi_radians)
def cos_and_sin_from_x_axis(self): """ Determine the sin and cosine of the angle between the profile's ellipse and the positive x-axis, \ counter-clockwise. """ phi_radians = np.radians(self.phi) return np.cos(phi_radians), np.sin(phi_radians)
[ "Determine", "the", "sin", "and", "cosine", "of", "the", "angle", "between", "the", "profile", "s", "ellipse", "and", "the", "positive", "x", "-", "axis", "\\", "counter", "-", "clockwise", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L268-L272
[ "def", "cos_and_sin_from_x_axis", "(", "self", ")", ":", "phi_radians", "=", "np", ".", "radians", "(", "self", ".", "phi", ")", "return", "np", ".", "cos", "(", "phi_radians", ")", ",", "np", ".", "sin", "(", "phi_radians", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.grid_angle_to_profile
The angle between each angle theta on the grid and the profile, in radians. Parameters ----------- grid_thetas : ndarray The angle theta counter-clockwise from the positive x-axis to each coordinate in radians.
autolens/model/profiles/geometry_profiles.py
def grid_angle_to_profile(self, grid_thetas): """The angle between each angle theta on the grid and the profile, in radians. Parameters ----------- grid_thetas : ndarray The angle theta counter-clockwise from the positive x-axis to each coordinate in radians. """ theta_coordinate_to_profile = np.add(grid_thetas, - self.phi_radians) return np.cos(theta_coordinate_to_profile), np.sin(theta_coordinate_to_profile)
def grid_angle_to_profile(self, grid_thetas): """The angle between each angle theta on the grid and the profile, in radians. Parameters ----------- grid_thetas : ndarray The angle theta counter-clockwise from the positive x-axis to each coordinate in radians. """ theta_coordinate_to_profile = np.add(grid_thetas, - self.phi_radians) return np.cos(theta_coordinate_to_profile), np.sin(theta_coordinate_to_profile)
[ "The", "angle", "between", "each", "angle", "theta", "on", "the", "grid", "and", "the", "profile", "in", "radians", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L274-L283
[ "def", "grid_angle_to_profile", "(", "self", ",", "grid_thetas", ")", ":", "theta_coordinate_to_profile", "=", "np", ".", "add", "(", "grid_thetas", ",", "-", "self", ".", "phi_radians", ")", "return", "np", ".", "cos", "(", "theta_coordinate_to_profile", ")", ",", "np", ".", "sin", "(", "theta_coordinate_to_profile", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.rotate_grid_from_profile
Rotate a grid of elliptical (y,x) coordinates from the reference frame of the profile back to the \ unrotated coordinate grid reference frame (coordinates are not shifted back to their original centre). This routine is used after computing deflection angles in the reference frame of the profile, so that the \ deflection angles can be re-rotated to the frame of the original coordinates before performing ray-tracing. Parameters ---------- grid_elliptical : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of an elliptical profile.
autolens/model/profiles/geometry_profiles.py
def rotate_grid_from_profile(self, grid_elliptical): """ Rotate a grid of elliptical (y,x) coordinates from the reference frame of the profile back to the \ unrotated coordinate grid reference frame (coordinates are not shifted back to their original centre). This routine is used after computing deflection angles in the reference frame of the profile, so that the \ deflection angles can be re-rotated to the frame of the original coordinates before performing ray-tracing. Parameters ---------- grid_elliptical : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of an elliptical profile. """ y = np.add(np.multiply(grid_elliptical[:, 1], self.sin_phi), np.multiply(grid_elliptical[:, 0], self.cos_phi)) x = np.add(np.multiply(grid_elliptical[:, 1], self.cos_phi), - np.multiply(grid_elliptical[:, 0], self.sin_phi)) return np.vstack((y, x)).T
def rotate_grid_from_profile(self, grid_elliptical): """ Rotate a grid of elliptical (y,x) coordinates from the reference frame of the profile back to the \ unrotated coordinate grid reference frame (coordinates are not shifted back to their original centre). This routine is used after computing deflection angles in the reference frame of the profile, so that the \ deflection angles can be re-rotated to the frame of the original coordinates before performing ray-tracing. Parameters ---------- grid_elliptical : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of an elliptical profile. """ y = np.add(np.multiply(grid_elliptical[:, 1], self.sin_phi), np.multiply(grid_elliptical[:, 0], self.cos_phi)) x = np.add(np.multiply(grid_elliptical[:, 1], self.cos_phi), - np.multiply(grid_elliptical[:, 0], self.sin_phi)) return np.vstack((y, x)).T
[ "Rotate", "a", "grid", "of", "elliptical", "(", "y", "x", ")", "coordinates", "from", "the", "reference", "frame", "of", "the", "profile", "back", "to", "the", "\\", "unrotated", "coordinate", "grid", "reference", "frame", "(", "coordinates", "are", "not", "shifted", "back", "to", "their", "original", "centre", ")", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L285-L299
[ "def", "rotate_grid_from_profile", "(", "self", ",", "grid_elliptical", ")", ":", "y", "=", "np", ".", "add", "(", "np", ".", "multiply", "(", "grid_elliptical", "[", ":", ",", "1", "]", ",", "self", ".", "sin_phi", ")", ",", "np", ".", "multiply", "(", "grid_elliptical", "[", ":", ",", "0", "]", ",", "self", ".", "cos_phi", ")", ")", "x", "=", "np", ".", "add", "(", "np", ".", "multiply", "(", "grid_elliptical", "[", ":", ",", "1", "]", ",", "self", ".", "cos_phi", ")", ",", "-", "np", ".", "multiply", "(", "grid_elliptical", "[", ":", ",", "0", "]", ",", "self", ".", "sin_phi", ")", ")", "return", "np", ".", "vstack", "(", "(", "y", ",", "x", ")", ")", ".", "T" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.grid_to_elliptical_radii
Convert a grid of (y,x) coordinates to an elliptical radius. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile.
autolens/model/profiles/geometry_profiles.py
def grid_to_elliptical_radii(self, grid): """ Convert a grid of (y,x) coordinates to an elliptical radius. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile. """ return np.sqrt(np.add(np.square(grid[:, 1]), np.square(np.divide(grid[:, 0], self.axis_ratio))))
def grid_to_elliptical_radii(self, grid): """ Convert a grid of (y,x) coordinates to an elliptical radius. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile. """ return np.sqrt(np.add(np.square(grid[:, 1]), np.square(np.divide(grid[:, 0], self.axis_ratio))))
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "to", "an", "elliptical", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L303-L313
[ "def", "grid_to_elliptical_radii", "(", "self", ",", "grid", ")", ":", "return", "np", ".", "sqrt", "(", "np", ".", "add", "(", "np", ".", "square", "(", "grid", "[", ":", ",", "1", "]", ")", ",", "np", ".", "square", "(", "np", ".", "divide", "(", "grid", "[", ":", ",", "0", "]", ",", "self", ".", "axis_ratio", ")", ")", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.grid_to_eccentric_radii
Convert a grid of (y,x) coordinates to an eccentric radius, which is (1.0/axis_ratio) * elliptical radius \ and used to define light profile half-light radii using circular radii. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile.
autolens/model/profiles/geometry_profiles.py
def grid_to_eccentric_radii(self, grid): """Convert a grid of (y,x) coordinates to an eccentric radius, which is (1.0/axis_ratio) * elliptical radius \ and used to define light profile half-light radii using circular radii. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile. """ return np.multiply(np.sqrt(self.axis_ratio), self.grid_to_elliptical_radii(grid)).view(np.ndarray)
def grid_to_eccentric_radii(self, grid): """Convert a grid of (y,x) coordinates to an eccentric radius, which is (1.0/axis_ratio) * elliptical radius \ and used to define light profile half-light radii using circular radii. If the coordinates have not been transformed to the profile's geometry, this is performed automatically. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the elliptical profile. """ return np.multiply(np.sqrt(self.axis_ratio), self.grid_to_elliptical_radii(grid)).view(np.ndarray)
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "to", "an", "eccentric", "radius", "which", "is", "(", "1", ".", "0", "/", "axis_ratio", ")", "*", "elliptical", "radius", "\\", "and", "used", "to", "define", "light", "profile", "half", "-", "light", "radii", "using", "circular", "radii", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L317-L328
[ "def", "grid_to_eccentric_radii", "(", "self", ",", "grid", ")", ":", "return", "np", ".", "multiply", "(", "np", ".", "sqrt", "(", "self", ".", "axis_ratio", ")", ",", "self", ".", "grid_to_elliptical_radii", "(", "grid", ")", ")", ".", "view", "(", "np", ".", "ndarray", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.transform_grid_to_reference_frame
Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre and a rotation to it orientation. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid.
autolens/model/profiles/geometry_profiles.py
def transform_grid_to_reference_frame(self, grid): """Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre and a rotation to it orientation. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.__class__.__name__.startswith("Spherical"): return super().transform_grid_to_reference_frame(grid) shifted_coordinates = np.subtract(grid, self.centre) radius = np.sqrt(np.sum(shifted_coordinates ** 2.0, 1)) theta_coordinate_to_profile = np.arctan2(shifted_coordinates[:, 0], shifted_coordinates[:, 1]) - self.phi_radians transformed = np.vstack( (radius * np.sin(theta_coordinate_to_profile), radius * np.cos(theta_coordinate_to_profile))).T return transformed.view(TransformedGrid)
def transform_grid_to_reference_frame(self, grid): """Transform a grid of (y,x) coordinates to the reference frame of the profile, including a translation to \ its centre and a rotation to it orientation. Parameters ---------- grid : ndarray The (y, x) coordinates in the original reference frame of the grid. """ if self.__class__.__name__.startswith("Spherical"): return super().transform_grid_to_reference_frame(grid) shifted_coordinates = np.subtract(grid, self.centre) radius = np.sqrt(np.sum(shifted_coordinates ** 2.0, 1)) theta_coordinate_to_profile = np.arctan2(shifted_coordinates[:, 0], shifted_coordinates[:, 1]) - self.phi_radians transformed = np.vstack( (radius * np.sin(theta_coordinate_to_profile), radius * np.cos(theta_coordinate_to_profile))).T return transformed.view(TransformedGrid)
[ "Transform", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "to", "the", "reference", "frame", "of", "the", "profile", "including", "a", "translation", "to", "\\", "its", "centre", "and", "a", "rotation", "to", "it", "orientation", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L330-L347
[ "def", "transform_grid_to_reference_frame", "(", "self", ",", "grid", ")", ":", "if", "self", ".", "__class__", ".", "__name__", ".", "startswith", "(", "\"Spherical\"", ")", ":", "return", "super", "(", ")", ".", "transform_grid_to_reference_frame", "(", "grid", ")", "shifted_coordinates", "=", "np", ".", "subtract", "(", "grid", ",", "self", ".", "centre", ")", "radius", "=", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "shifted_coordinates", "**", "2.0", ",", "1", ")", ")", "theta_coordinate_to_profile", "=", "np", ".", "arctan2", "(", "shifted_coordinates", "[", ":", ",", "0", "]", ",", "shifted_coordinates", "[", ":", ",", "1", "]", ")", "-", "self", ".", "phi_radians", "transformed", "=", "np", ".", "vstack", "(", "(", "radius", "*", "np", ".", "sin", "(", "theta_coordinate_to_profile", ")", ",", "radius", "*", "np", ".", "cos", "(", "theta_coordinate_to_profile", ")", ")", ")", ".", "T", "return", "transformed", ".", "view", "(", "TransformedGrid", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalProfile.transform_grid_from_reference_frame
Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a rotation to its original orientation and a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile.
autolens/model/profiles/geometry_profiles.py
def transform_grid_from_reference_frame(self, grid): """Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a rotation to its original orientation and a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ if self.__class__.__name__.startswith("Spherical"): return super().transform_grid_from_reference_frame(grid) y = np.add(np.add(np.multiply(grid[:, 1], self.sin_phi), np.multiply(grid[:, 0], self.cos_phi)), self.centre[0]) x = np.add(np.add(np.multiply(grid[:, 1], self.cos_phi), - np.multiply(grid[:, 0], self.sin_phi)), self.centre[1]) return np.vstack((y, x)).T
def transform_grid_from_reference_frame(self, grid): """Transform a grid of (y,x) coordinates from the reference frame of the profile to the original observer \ reference frame, including a rotation to its original orientation and a translation from the profile's centre. Parameters ---------- grid : TransformedGrid(ndarray) The (y, x) coordinates in the reference frame of the profile. """ if self.__class__.__name__.startswith("Spherical"): return super().transform_grid_from_reference_frame(grid) y = np.add(np.add(np.multiply(grid[:, 1], self.sin_phi), np.multiply(grid[:, 0], self.cos_phi)), self.centre[0]) x = np.add(np.add(np.multiply(grid[:, 1], self.cos_phi), - np.multiply(grid[:, 0], self.sin_phi)), self.centre[1]) return np.vstack((y, x)).T
[ "Transform", "a", "grid", "of", "(", "y", "x", ")", "coordinates", "from", "the", "reference", "frame", "of", "the", "profile", "to", "the", "original", "observer", "\\", "reference", "frame", "including", "a", "rotation", "to", "its", "original", "orientation", "and", "a", "translation", "from", "the", "profile", "s", "centre", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/geometry_profiles.py#L349-L364
[ "def", "transform_grid_from_reference_frame", "(", "self", ",", "grid", ")", ":", "if", "self", ".", "__class__", ".", "__name__", ".", "startswith", "(", "\"Spherical\"", ")", ":", "return", "super", "(", ")", ".", "transform_grid_from_reference_frame", "(", "grid", ")", "y", "=", "np", ".", "add", "(", "np", ".", "add", "(", "np", ".", "multiply", "(", "grid", "[", ":", ",", "1", "]", ",", "self", ".", "sin_phi", ")", ",", "np", ".", "multiply", "(", "grid", "[", ":", ",", "0", "]", ",", "self", ".", "cos_phi", ")", ")", ",", "self", ".", "centre", "[", "0", "]", ")", "x", "=", "np", ".", "add", "(", "np", ".", "add", "(", "np", ".", "multiply", "(", "grid", "[", ":", ",", "1", "]", ",", "self", ".", "cos_phi", ")", ",", "-", "np", ".", "multiply", "(", "grid", "[", ":", ",", "0", "]", ",", "self", ".", "sin_phi", ")", ")", ",", "self", ".", "centre", "[", "1", "]", ")", "return", "np", ".", "vstack", "(", "(", "y", ",", "x", ")", ")", ".", "T" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
mapping_matrix_from_sub_to_pix
Computes the mapping matrix, by iterating over the known mappings between the sub-grid and pixelization. Parameters ----------- sub_to_pix : ndarray The mappings between the observed regular's sub-pixels and pixelization's pixels. pixels : int The number of pixels in the pixelization. regular_pixels : int The number of datas pixels in the observed datas and thus on the regular grid. sub_to_regular : ndarray The mappings between the observed regular's sub-pixels and observed regular's pixels. sub_grid_fraction : float The fractional area each sub-pixel takes up in an regular-pixel.
autolens/model/inversion/util/mapper_util.py
def mapping_matrix_from_sub_to_pix(sub_to_pix, pixels, regular_pixels, sub_to_regular, sub_grid_fraction): """Computes the mapping matrix, by iterating over the known mappings between the sub-grid and pixelization. Parameters ----------- sub_to_pix : ndarray The mappings between the observed regular's sub-pixels and pixelization's pixels. pixels : int The number of pixels in the pixelization. regular_pixels : int The number of datas pixels in the observed datas and thus on the regular grid. sub_to_regular : ndarray The mappings between the observed regular's sub-pixels and observed regular's pixels. sub_grid_fraction : float The fractional area each sub-pixel takes up in an regular-pixel. """ mapping_matrix = np.zeros((regular_pixels, pixels)) for sub_index in range(sub_to_regular.shape[0]): mapping_matrix[sub_to_regular[sub_index], sub_to_pix[sub_index]] += sub_grid_fraction return mapping_matrix
def mapping_matrix_from_sub_to_pix(sub_to_pix, pixels, regular_pixels, sub_to_regular, sub_grid_fraction): """Computes the mapping matrix, by iterating over the known mappings between the sub-grid and pixelization. Parameters ----------- sub_to_pix : ndarray The mappings between the observed regular's sub-pixels and pixelization's pixels. pixels : int The number of pixels in the pixelization. regular_pixels : int The number of datas pixels in the observed datas and thus on the regular grid. sub_to_regular : ndarray The mappings between the observed regular's sub-pixels and observed regular's pixels. sub_grid_fraction : float The fractional area each sub-pixel takes up in an regular-pixel. """ mapping_matrix = np.zeros((regular_pixels, pixels)) for sub_index in range(sub_to_regular.shape[0]): mapping_matrix[sub_to_regular[sub_index], sub_to_pix[sub_index]] += sub_grid_fraction return mapping_matrix
[ "Computes", "the", "mapping", "matrix", "by", "iterating", "over", "the", "known", "mappings", "between", "the", "sub", "-", "grid", "and", "pixelization", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/mapper_util.py#L5-L27
[ "def", "mapping_matrix_from_sub_to_pix", "(", "sub_to_pix", ",", "pixels", ",", "regular_pixels", ",", "sub_to_regular", ",", "sub_grid_fraction", ")", ":", "mapping_matrix", "=", "np", ".", "zeros", "(", "(", "regular_pixels", ",", "pixels", ")", ")", "for", "sub_index", "in", "range", "(", "sub_to_regular", ".", "shape", "[", "0", "]", ")", ":", "mapping_matrix", "[", "sub_to_regular", "[", "sub_index", "]", ",", "sub_to_pix", "[", "sub_index", "]", "]", "+=", "sub_grid_fraction", "return", "mapping_matrix" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
voronoi_regular_to_pix_from_grids_and_geometry
Compute the mappings between a set of regular-grid pixels and pixelization pixels, using information on \ how regular pixels map to their closest pixelization pixel on the image-plane pix-grid and the pixelization's \ pixel centres. To determine the complete set of regular-pixel to pixelization pixel mappings, we must pair every regular-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search via a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : ndarray The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid.
autolens/model/inversion/util/mapper_util.py
def voronoi_regular_to_pix_from_grids_and_geometry(regular_grid, regular_to_nearest_pix, pixel_centres, pixel_neighbors, pixel_neighbors_size): """ Compute the mappings between a set of regular-grid pixels and pixelization pixels, using information on \ how regular pixels map to their closest pixelization pixel on the image-plane pix-grid and the pixelization's \ pixel centres. To determine the complete set of regular-pixel to pixelization pixel mappings, we must pair every regular-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search via a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : ndarray The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid. """ regular_to_pix = np.zeros((regular_grid.shape[0])) for regular_index in range(regular_grid.shape[0]): nearest_pix_pixel_index = regular_to_nearest_pix[regular_index] while True: nearest_pix_pixel_center = pixel_centres[nearest_pix_pixel_index] sub_to_nearest_pix_distance = (regular_grid[regular_index, 0] - nearest_pix_pixel_center[0]) ** 2 + \ (regular_grid[regular_index, 1] - nearest_pix_pixel_center[1]) ** 2 closest_separation_from_pix_neighbor = 1.0e8 for neighbor_index in range(pixel_neighbors_size[nearest_pix_pixel_index]): neighbor = pixel_neighbors[nearest_pix_pixel_index, neighbor_index] separation_from_neighbor = (regular_grid[regular_index, 0] - pixel_centres[neighbor, 0]) ** 2 + \ (regular_grid[regular_index, 1] - pixel_centres[neighbor, 1]) ** 2 if separation_from_neighbor < closest_separation_from_pix_neighbor: closest_separation_from_pix_neighbor = separation_from_neighbor closest_neighbor_index = neighbor_index neighboring_pix_pixel_index = pixel_neighbors[nearest_pix_pixel_index, closest_neighbor_index] sub_to_neighboring_pix_distance = closest_separation_from_pix_neighbor if sub_to_nearest_pix_distance <= sub_to_neighboring_pix_distance: regular_to_pix[regular_index] = nearest_pix_pixel_index break else: nearest_pix_pixel_index = neighboring_pix_pixel_index return regular_to_pix
def voronoi_regular_to_pix_from_grids_and_geometry(regular_grid, regular_to_nearest_pix, pixel_centres, pixel_neighbors, pixel_neighbors_size): """ Compute the mappings between a set of regular-grid pixels and pixelization pixels, using information on \ how regular pixels map to their closest pixelization pixel on the image-plane pix-grid and the pixelization's \ pixel centres. To determine the complete set of regular-pixel to pixelization pixel mappings, we must pair every regular-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search via a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : ndarray The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid. """ regular_to_pix = np.zeros((regular_grid.shape[0])) for regular_index in range(regular_grid.shape[0]): nearest_pix_pixel_index = regular_to_nearest_pix[regular_index] while True: nearest_pix_pixel_center = pixel_centres[nearest_pix_pixel_index] sub_to_nearest_pix_distance = (regular_grid[regular_index, 0] - nearest_pix_pixel_center[0]) ** 2 + \ (regular_grid[regular_index, 1] - nearest_pix_pixel_center[1]) ** 2 closest_separation_from_pix_neighbor = 1.0e8 for neighbor_index in range(pixel_neighbors_size[nearest_pix_pixel_index]): neighbor = pixel_neighbors[nearest_pix_pixel_index, neighbor_index] separation_from_neighbor = (regular_grid[regular_index, 0] - pixel_centres[neighbor, 0]) ** 2 + \ (regular_grid[regular_index, 1] - pixel_centres[neighbor, 1]) ** 2 if separation_from_neighbor < closest_separation_from_pix_neighbor: closest_separation_from_pix_neighbor = separation_from_neighbor closest_neighbor_index = neighbor_index neighboring_pix_pixel_index = pixel_neighbors[nearest_pix_pixel_index, closest_neighbor_index] sub_to_neighboring_pix_distance = closest_separation_from_pix_neighbor if sub_to_nearest_pix_distance <= sub_to_neighboring_pix_distance: regular_to_pix[regular_index] = nearest_pix_pixel_index break else: nearest_pix_pixel_index = neighboring_pix_pixel_index return regular_to_pix
[ "Compute", "the", "mappings", "between", "a", "set", "of", "regular", "-", "grid", "pixels", "and", "pixelization", "pixels", "using", "information", "on", "\\", "how", "regular", "pixels", "map", "to", "their", "closest", "pixelization", "pixel", "on", "the", "image", "-", "plane", "pix", "-", "grid", "and", "the", "pixelization", "s", "\\", "pixel", "centres", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/mapper_util.py#L30-L94
[ "def", "voronoi_regular_to_pix_from_grids_and_geometry", "(", "regular_grid", ",", "regular_to_nearest_pix", ",", "pixel_centres", ",", "pixel_neighbors", ",", "pixel_neighbors_size", ")", ":", "regular_to_pix", "=", "np", ".", "zeros", "(", "(", "regular_grid", ".", "shape", "[", "0", "]", ")", ")", "for", "regular_index", "in", "range", "(", "regular_grid", ".", "shape", "[", "0", "]", ")", ":", "nearest_pix_pixel_index", "=", "regular_to_nearest_pix", "[", "regular_index", "]", "while", "True", ":", "nearest_pix_pixel_center", "=", "pixel_centres", "[", "nearest_pix_pixel_index", "]", "sub_to_nearest_pix_distance", "=", "(", "regular_grid", "[", "regular_index", ",", "0", "]", "-", "nearest_pix_pixel_center", "[", "0", "]", ")", "**", "2", "+", "(", "regular_grid", "[", "regular_index", ",", "1", "]", "-", "nearest_pix_pixel_center", "[", "1", "]", ")", "**", "2", "closest_separation_from_pix_neighbor", "=", "1.0e8", "for", "neighbor_index", "in", "range", "(", "pixel_neighbors_size", "[", "nearest_pix_pixel_index", "]", ")", ":", "neighbor", "=", "pixel_neighbors", "[", "nearest_pix_pixel_index", ",", "neighbor_index", "]", "separation_from_neighbor", "=", "(", "regular_grid", "[", "regular_index", ",", "0", "]", "-", "pixel_centres", "[", "neighbor", ",", "0", "]", ")", "**", "2", "+", "(", "regular_grid", "[", "regular_index", ",", "1", "]", "-", "pixel_centres", "[", "neighbor", ",", "1", "]", ")", "**", "2", "if", "separation_from_neighbor", "<", "closest_separation_from_pix_neighbor", ":", "closest_separation_from_pix_neighbor", "=", "separation_from_neighbor", "closest_neighbor_index", "=", "neighbor_index", "neighboring_pix_pixel_index", "=", "pixel_neighbors", "[", "nearest_pix_pixel_index", ",", "closest_neighbor_index", "]", "sub_to_neighboring_pix_distance", "=", "closest_separation_from_pix_neighbor", "if", "sub_to_nearest_pix_distance", "<=", "sub_to_neighboring_pix_distance", ":", "regular_to_pix", "[", "regular_index", "]", "=", "nearest_pix_pixel_index", "break", "else", ":", "nearest_pix_pixel_index", "=", "neighboring_pix_pixel_index", "return", "regular_to_pix" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
voronoi_sub_to_pix_from_grids_and_geometry
Compute the mappings between a set of sub-grid pixels and pixelization pixels, using information on \ how the regular pixels hosting each sub-pixel map to their closest pixelization pixel on the image-plane pix-grid \ and the pixelization's pixel centres. To determine the complete set of sub-pixel to pixelization pixel mappings, we must pair every sub-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search by using a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : (float, float) The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid.
autolens/model/inversion/util/mapper_util.py
def voronoi_sub_to_pix_from_grids_and_geometry(sub_grid, regular_to_nearest_pix, sub_to_regular, pixel_centres, pixel_neighbors, pixel_neighbors_size): """ Compute the mappings between a set of sub-grid pixels and pixelization pixels, using information on \ how the regular pixels hosting each sub-pixel map to their closest pixelization pixel on the image-plane pix-grid \ and the pixelization's pixel centres. To determine the complete set of sub-pixel to pixelization pixel mappings, we must pair every sub-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search by using a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : (float, float) The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid. """ sub_to_pix = np.zeros((sub_grid.shape[0])) for sub_index in range(sub_grid.shape[0]): nearest_pix_pixel_index = regular_to_nearest_pix[sub_to_regular[sub_index]] while True: nearest_pix_pixel_center = pixel_centres[nearest_pix_pixel_index] sub_to_nearest_pix_distance = (sub_grid[sub_index, 0] - nearest_pix_pixel_center[0]) ** 2 + \ (sub_grid[sub_index, 1] - nearest_pix_pixel_center[1]) ** 2 closest_separation_from_pix_to_neighbor = 1.0e8 for neighbor_index in range(pixel_neighbors_size[nearest_pix_pixel_index]): neighbor = pixel_neighbors[nearest_pix_pixel_index, neighbor_index] separation_from_neighbor = (sub_grid[sub_index, 0] - pixel_centres[neighbor, 0]) ** 2 + \ (sub_grid[sub_index, 1] - pixel_centres[neighbor, 1]) ** 2 if separation_from_neighbor < closest_separation_from_pix_to_neighbor: closest_separation_from_pix_to_neighbor = separation_from_neighbor closest_neighbor_index = neighbor_index neighboring_pix_pixel_index = pixel_neighbors[nearest_pix_pixel_index, closest_neighbor_index] sub_to_neighboring_pix_distance = closest_separation_from_pix_to_neighbor if sub_to_nearest_pix_distance <= sub_to_neighboring_pix_distance: sub_to_pix[sub_index] = nearest_pix_pixel_index break else: nearest_pix_pixel_index = neighboring_pix_pixel_index return sub_to_pix
def voronoi_sub_to_pix_from_grids_and_geometry(sub_grid, regular_to_nearest_pix, sub_to_regular, pixel_centres, pixel_neighbors, pixel_neighbors_size): """ Compute the mappings between a set of sub-grid pixels and pixelization pixels, using information on \ how the regular pixels hosting each sub-pixel map to their closest pixelization pixel on the image-plane pix-grid \ and the pixelization's pixel centres. To determine the complete set of sub-pixel to pixelization pixel mappings, we must pair every sub-pixel to \ its nearest pixel. Using a full nearest neighbor search to do this is slow, thus the pixel neighbors (derived via \ the Voronoi grid) are used to localize each nearest neighbor search by using a graph search. Parameters ---------- regular_grid : RegularGrid The grid of (y,x) arc-second coordinates at the centre of every unmasked pixel, which has been traced to \ to an irregular grid via lens. regular_to_nearest_pix : ndarray A 1D array that maps every regular-grid pixel to its nearest pix-grid pixel (as determined on the unlensed \ 2D array). pixel_centres : (float, float) The (y,x) centre of every Voronoi pixel in arc-seconds. pixel_neighbors : ndarray An array of length (voronoi_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 : ndarray An array of length (voronoi_pixels) which gives the number of neighbors of every pixel in the \ Voronoi grid. """ sub_to_pix = np.zeros((sub_grid.shape[0])) for sub_index in range(sub_grid.shape[0]): nearest_pix_pixel_index = regular_to_nearest_pix[sub_to_regular[sub_index]] while True: nearest_pix_pixel_center = pixel_centres[nearest_pix_pixel_index] sub_to_nearest_pix_distance = (sub_grid[sub_index, 0] - nearest_pix_pixel_center[0]) ** 2 + \ (sub_grid[sub_index, 1] - nearest_pix_pixel_center[1]) ** 2 closest_separation_from_pix_to_neighbor = 1.0e8 for neighbor_index in range(pixel_neighbors_size[nearest_pix_pixel_index]): neighbor = pixel_neighbors[nearest_pix_pixel_index, neighbor_index] separation_from_neighbor = (sub_grid[sub_index, 0] - pixel_centres[neighbor, 0]) ** 2 + \ (sub_grid[sub_index, 1] - pixel_centres[neighbor, 1]) ** 2 if separation_from_neighbor < closest_separation_from_pix_to_neighbor: closest_separation_from_pix_to_neighbor = separation_from_neighbor closest_neighbor_index = neighbor_index neighboring_pix_pixel_index = pixel_neighbors[nearest_pix_pixel_index, closest_neighbor_index] sub_to_neighboring_pix_distance = closest_separation_from_pix_to_neighbor if sub_to_nearest_pix_distance <= sub_to_neighboring_pix_distance: sub_to_pix[sub_index] = nearest_pix_pixel_index break else: nearest_pix_pixel_index = neighboring_pix_pixel_index return sub_to_pix
[ "Compute", "the", "mappings", "between", "a", "set", "of", "sub", "-", "grid", "pixels", "and", "pixelization", "pixels", "using", "information", "on", "\\", "how", "the", "regular", "pixels", "hosting", "each", "sub", "-", "pixel", "map", "to", "their", "closest", "pixelization", "pixel", "on", "the", "image", "-", "plane", "pix", "-", "grid", "\\", "and", "the", "pixelization", "s", "pixel", "centres", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/inversion/util/mapper_util.py#L97-L160
[ "def", "voronoi_sub_to_pix_from_grids_and_geometry", "(", "sub_grid", ",", "regular_to_nearest_pix", ",", "sub_to_regular", ",", "pixel_centres", ",", "pixel_neighbors", ",", "pixel_neighbors_size", ")", ":", "sub_to_pix", "=", "np", ".", "zeros", "(", "(", "sub_grid", ".", "shape", "[", "0", "]", ")", ")", "for", "sub_index", "in", "range", "(", "sub_grid", ".", "shape", "[", "0", "]", ")", ":", "nearest_pix_pixel_index", "=", "regular_to_nearest_pix", "[", "sub_to_regular", "[", "sub_index", "]", "]", "while", "True", ":", "nearest_pix_pixel_center", "=", "pixel_centres", "[", "nearest_pix_pixel_index", "]", "sub_to_nearest_pix_distance", "=", "(", "sub_grid", "[", "sub_index", ",", "0", "]", "-", "nearest_pix_pixel_center", "[", "0", "]", ")", "**", "2", "+", "(", "sub_grid", "[", "sub_index", ",", "1", "]", "-", "nearest_pix_pixel_center", "[", "1", "]", ")", "**", "2", "closest_separation_from_pix_to_neighbor", "=", "1.0e8", "for", "neighbor_index", "in", "range", "(", "pixel_neighbors_size", "[", "nearest_pix_pixel_index", "]", ")", ":", "neighbor", "=", "pixel_neighbors", "[", "nearest_pix_pixel_index", ",", "neighbor_index", "]", "separation_from_neighbor", "=", "(", "sub_grid", "[", "sub_index", ",", "0", "]", "-", "pixel_centres", "[", "neighbor", ",", "0", "]", ")", "**", "2", "+", "(", "sub_grid", "[", "sub_index", ",", "1", "]", "-", "pixel_centres", "[", "neighbor", ",", "1", "]", ")", "**", "2", "if", "separation_from_neighbor", "<", "closest_separation_from_pix_to_neighbor", ":", "closest_separation_from_pix_to_neighbor", "=", "separation_from_neighbor", "closest_neighbor_index", "=", "neighbor_index", "neighboring_pix_pixel_index", "=", "pixel_neighbors", "[", "nearest_pix_pixel_index", ",", "closest_neighbor_index", "]", "sub_to_neighboring_pix_distance", "=", "closest_separation_from_pix_to_neighbor", "if", "sub_to_nearest_pix_distance", "<=", "sub_to_neighboring_pix_distance", ":", "sub_to_pix", "[", "sub_index", "]", "=", "nearest_pix_pixel_index", "break", "else", ":", "nearest_pix_pixel_index", "=", "neighboring_pix_pixel_index", "return", "sub_to_pix" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalLightProfile.luminosity_within_circle_in_units
Integrate the light profile to compute the total luminosity within a circle of specified radius. This is \ centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). 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 or None The exposure time of the observation, which converts luminosity from electrons per second units to counts.
autolens/model/profiles/light_profiles.py
def luminosity_within_circle_in_units(self, radius: dim.Length, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None): """Integrate the light profile to compute the total luminosity within a circle of specified radius. This is \ centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). 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 or None The exposure time of the observation, which converts luminosity from electrons per second units to counts. """ if not isinstance(radius, dim.Length): radius = dim.Length(value=radius, unit_length='arcsec') profile = self.new_profile_with_units_converted(unit_length=radius.unit_length, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time) luminosity = quad(profile.luminosity_integral, a=0.0, b=radius, args=(1.0,))[0] return dim.Luminosity(luminosity, unit_luminosity)
def luminosity_within_circle_in_units(self, radius: dim.Length, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None): """Integrate the light profile to compute the total luminosity within a circle of specified radius. This is \ centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). 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 or None The exposure time of the observation, which converts luminosity from electrons per second units to counts. """ if not isinstance(radius, dim.Length): radius = dim.Length(value=radius, unit_length='arcsec') profile = self.new_profile_with_units_converted(unit_length=radius.unit_length, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time) luminosity = quad(profile.luminosity_integral, a=0.0, b=radius, args=(1.0,))[0] return dim.Luminosity(luminosity, unit_luminosity)
[ "Integrate", "the", "light", "profile", "to", "compute", "the", "total", "luminosity", "within", "a", "circle", "of", "specified", "radius", ".", "This", "is", "\\", "centred", "on", "the", "light", "profile", "s", "centre", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L68-L95
[ "def", "luminosity_within_circle_in_units", "(", "self", ",", "radius", ":", "dim", ".", "Length", ",", "unit_luminosity", "=", "'eps'", ",", "kpc_per_arcsec", "=", "None", ",", "exposure_time", "=", "None", ")", ":", "if", "not", "isinstance", "(", "radius", ",", "dim", ".", "Length", ")", ":", "radius", "=", "dim", ".", "Length", "(", "value", "=", "radius", ",", "unit_length", "=", "'arcsec'", ")", "profile", "=", "self", ".", "new_profile_with_units_converted", "(", "unit_length", "=", "radius", ".", "unit_length", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", "luminosity", "=", "quad", "(", "profile", ".", "luminosity_integral", ",", "a", "=", "0.0", ",", "b", "=", "radius", ",", "args", "=", "(", "1.0", ",", ")", ")", "[", "0", "]", "return", "dim", ".", "Luminosity", "(", "luminosity", ",", "unit_luminosity", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalLightProfile.luminosity_within_ellipse_in_units
Integrate the light profiles to compute the total luminosity within an ellipse of specified major axis. \ This is centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). Parameters ---------- major_axis : float The major-axis radius of the ellipse. unit_luminosity : str The units the luminosity is returned in (eps | counts). exposure_time : float or None The exposure time of the observation, which converts luminosity from electrons per second units to counts.
autolens/model/profiles/light_profiles.py
def luminosity_within_ellipse_in_units(self, major_axis, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None): """Integrate the light profiles to compute the total luminosity within an ellipse of specified major axis. \ This is centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). Parameters ---------- major_axis : float The major-axis radius of the ellipse. unit_luminosity : str The units the luminosity is returned in (eps | counts). exposure_time : float or None The exposure time of the observation, which converts luminosity from electrons per second units to counts. """ if not isinstance(major_axis, dim.Length): major_axis = dim.Length(major_axis, 'arcsec') profile = self.new_profile_with_units_converted(unit_length=major_axis.unit_length, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time) luminosity = quad(profile.luminosity_integral, a=0.0, b=major_axis, args=(self.axis_ratio,))[0] return dim.Luminosity(luminosity, unit_luminosity)
def luminosity_within_ellipse_in_units(self, major_axis, unit_luminosity='eps', kpc_per_arcsec=None, exposure_time=None): """Integrate the light profiles to compute the total luminosity within an ellipse of specified major axis. \ This is centred on the light profile's centre. The following units for mass can be specified and output: - Electrons per second (default) - 'eps'. - Counts - 'counts' (multiplies the luminosity in electrons per second by the exposure time). Parameters ---------- major_axis : float The major-axis radius of the ellipse. unit_luminosity : str The units the luminosity is returned in (eps | counts). exposure_time : float or None The exposure time of the observation, which converts luminosity from electrons per second units to counts. """ if not isinstance(major_axis, dim.Length): major_axis = dim.Length(major_axis, 'arcsec') profile = self.new_profile_with_units_converted(unit_length=major_axis.unit_length, unit_luminosity=unit_luminosity, kpc_per_arcsec=kpc_per_arcsec, exposure_time=exposure_time) luminosity = quad(profile.luminosity_integral, a=0.0, b=major_axis, args=(self.axis_ratio,))[0] return dim.Luminosity(luminosity, unit_luminosity)
[ "Integrate", "the", "light", "profiles", "to", "compute", "the", "total", "luminosity", "within", "an", "ellipse", "of", "specified", "major", "axis", ".", "\\", "This", "is", "centred", "on", "the", "light", "profile", "s", "centre", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L97-L124
[ "def", "luminosity_within_ellipse_in_units", "(", "self", ",", "major_axis", ",", "unit_luminosity", "=", "'eps'", ",", "kpc_per_arcsec", "=", "None", ",", "exposure_time", "=", "None", ")", ":", "if", "not", "isinstance", "(", "major_axis", ",", "dim", ".", "Length", ")", ":", "major_axis", "=", "dim", ".", "Length", "(", "major_axis", ",", "'arcsec'", ")", "profile", "=", "self", ".", "new_profile_with_units_converted", "(", "unit_length", "=", "major_axis", ".", "unit_length", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", "luminosity", "=", "quad", "(", "profile", ".", "luminosity_integral", ",", "a", "=", "0.0", ",", "b", "=", "major_axis", ",", "args", "=", "(", "self", ".", "axis_ratio", ",", ")", ")", "[", "0", "]", "return", "dim", ".", "Luminosity", "(", "luminosity", ",", "unit_luminosity", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalLightProfile.luminosity_integral
Routine to integrate the luminosity of an elliptical light profile. The axis ratio is set to 1.0 for computing the luminosity within a circle
autolens/model/profiles/light_profiles.py
def luminosity_integral(self, x, axis_ratio): """Routine to integrate the luminosity of an elliptical light profile. The axis ratio is set to 1.0 for computing the luminosity within a circle""" r = x * axis_ratio return 2 * np.pi * r * self.intensities_from_grid_radii(x)
def luminosity_integral(self, x, axis_ratio): """Routine to integrate the luminosity of an elliptical light profile. The axis ratio is set to 1.0 for computing the luminosity within a circle""" r = x * axis_ratio return 2 * np.pi * r * self.intensities_from_grid_radii(x)
[ "Routine", "to", "integrate", "the", "luminosity", "of", "an", "elliptical", "light", "profile", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L126-L131
[ "def", "luminosity_integral", "(", "self", ",", "x", ",", "axis_ratio", ")", ":", "r", "=", "x", "*", "axis_ratio", "return", "2", "*", "np", ".", "pi", "*", "r", "*", "self", ".", "intensities_from_grid_radii", "(", "x", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalGaussian.intensities_from_grid_radii
Calculate the intensity of the Gaussian light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid.
autolens/model/profiles/light_profiles.py
def intensities_from_grid_radii(self, grid_radii): """Calculate the intensity of the Gaussian light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ return np.multiply(np.divide(self.intensity, self.sigma * np.sqrt(2.0 * np.pi)), np.exp(-0.5 * np.square(np.divide(grid_radii, self.sigma))))
def intensities_from_grid_radii(self, grid_radii): """Calculate the intensity of the Gaussian light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ return np.multiply(np.divide(self.intensity, self.sigma * np.sqrt(2.0 * np.pi)), np.exp(-0.5 * np.square(np.divide(grid_radii, self.sigma))))
[ "Calculate", "the", "intensity", "of", "the", "Gaussian", "light", "profile", "on", "a", "grid", "of", "radial", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L163-L172
[ "def", "intensities_from_grid_radii", "(", "self", ",", "grid_radii", ")", ":", "return", "np", ".", "multiply", "(", "np", ".", "divide", "(", "self", ".", "intensity", ",", "self", ".", "sigma", "*", "np", ".", "sqrt", "(", "2.0", "*", "np", ".", "pi", ")", ")", ",", "np", ".", "exp", "(", "-", "0.5", "*", "np", ".", "square", "(", "np", ".", "divide", "(", "grid_radii", ",", "self", ".", "sigma", ")", ")", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalSersic.intensities_from_grid_radii
Calculate the intensity of the Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid.
autolens/model/profiles/light_profiles.py
def intensities_from_grid_radii(self, grid_radii): """ Calculate the intensity of the Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ np.seterr(all='ignore') return np.multiply(self.intensity, np.exp( np.multiply(-self.sersic_constant, np.add(np.power(np.divide(grid_radii, self.effective_radius), 1. / self.sersic_index), -1))))
def intensities_from_grid_radii(self, grid_radii): """ Calculate the intensity of the Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ np.seterr(all='ignore') return np.multiply(self.intensity, np.exp( np.multiply(-self.sersic_constant, np.add(np.power(np.divide(grid_radii, self.effective_radius), 1. / self.sersic_index), -1))))
[ "Calculate", "the", "intensity", "of", "the", "Sersic", "light", "profile", "on", "a", "grid", "of", "radial", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L315-L327
[ "def", "intensities_from_grid_radii", "(", "self", ",", "grid_radii", ")", ":", "np", ".", "seterr", "(", "all", "=", "'ignore'", ")", "return", "np", ".", "multiply", "(", "self", ".", "intensity", ",", "np", ".", "exp", "(", "np", ".", "multiply", "(", "-", "self", ".", "sersic_constant", ",", "np", ".", "add", "(", "np", ".", "power", "(", "np", ".", "divide", "(", "grid_radii", ",", "self", ".", "effective_radius", ")", ",", "1.", "/", "self", ".", "sersic_index", ")", ",", "-", "1", ")", ")", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoreSersic.intensity_prime
Overall intensity normalisation in the rescaled Core-Sersic light profiles (electrons per second)
autolens/model/profiles/light_profiles.py
def intensity_prime(self): """Overall intensity normalisation in the rescaled Core-Sersic light profiles (electrons per second)""" return self.intensity_break * (2.0 ** (-self.gamma / self.alpha)) * np.exp( self.sersic_constant * (((2.0 ** (1.0 / self.alpha)) * self.radius_break) / self.effective_radius) ** ( 1.0 / self.sersic_index))
def intensity_prime(self): """Overall intensity normalisation in the rescaled Core-Sersic light profiles (electrons per second)""" return self.intensity_break * (2.0 ** (-self.gamma / self.alpha)) * np.exp( self.sersic_constant * (((2.0 ** (1.0 / self.alpha)) * self.radius_break) / self.effective_radius) ** ( 1.0 / self.sersic_index))
[ "Overall", "intensity", "normalisation", "in", "the", "rescaled", "Core", "-", "Sersic", "light", "profiles", "(", "electrons", "per", "second", ")" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L534-L538
[ "def", "intensity_prime", "(", "self", ")", ":", "return", "self", ".", "intensity_break", "*", "(", "2.0", "**", "(", "-", "self", ".", "gamma", "/", "self", ".", "alpha", ")", ")", "*", "np", ".", "exp", "(", "self", ".", "sersic_constant", "*", "(", "(", "(", "2.0", "**", "(", "1.0", "/", "self", ".", "alpha", ")", ")", "*", "self", ".", "radius_break", ")", "/", "self", ".", "effective_radius", ")", "**", "(", "1.0", "/", "self", ".", "sersic_index", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
EllipticalCoreSersic.intensities_from_grid_radii
Calculate the intensity of the cored-Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid.
autolens/model/profiles/light_profiles.py
def intensities_from_grid_radii(self, grid_radii): """Calculate the intensity of the cored-Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ return np.multiply(np.multiply(self.intensity_prime, np.power( np.add(1, np.power(np.divide(self.radius_break, grid_radii), self.alpha)), (self.gamma / self.alpha))), np.exp(np.multiply(-self.sersic_constant, (np.power(np.divide(np.add(np.power(grid_radii, self.alpha), ( self.radius_break ** self.alpha)), (self.effective_radius ** self.alpha)), ( 1.0 / (self.alpha * self.sersic_index)))))))
def intensities_from_grid_radii(self, grid_radii): """Calculate the intensity of the cored-Sersic light profile on a grid of radial coordinates. Parameters ---------- grid_radii : float The radial distance from the centre of the profile. for each coordinate on the grid. """ return np.multiply(np.multiply(self.intensity_prime, np.power( np.add(1, np.power(np.divide(self.radius_break, grid_radii), self.alpha)), (self.gamma / self.alpha))), np.exp(np.multiply(-self.sersic_constant, (np.power(np.divide(np.add(np.power(grid_radii, self.alpha), ( self.radius_break ** self.alpha)), (self.effective_radius ** self.alpha)), ( 1.0 / (self.alpha * self.sersic_index)))))))
[ "Calculate", "the", "intensity", "of", "the", "cored", "-", "Sersic", "light", "profile", "on", "a", "grid", "of", "radial", "coordinates", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/profiles/light_profiles.py#L540-L554
[ "def", "intensities_from_grid_radii", "(", "self", ",", "grid_radii", ")", ":", "return", "np", ".", "multiply", "(", "np", ".", "multiply", "(", "self", ".", "intensity_prime", ",", "np", ".", "power", "(", "np", ".", "add", "(", "1", ",", "np", ".", "power", "(", "np", ".", "divide", "(", "self", ".", "radius_break", ",", "grid_radii", ")", ",", "self", ".", "alpha", ")", ")", ",", "(", "self", ".", "gamma", "/", "self", ".", "alpha", ")", ")", ")", ",", "np", ".", "exp", "(", "np", ".", "multiply", "(", "-", "self", ".", "sersic_constant", ",", "(", "np", ".", "power", "(", "np", ".", "divide", "(", "np", ".", "add", "(", "np", ".", "power", "(", "grid_radii", ",", "self", ".", "alpha", ")", ",", "(", "self", ".", "radius_break", "**", "self", ".", "alpha", ")", ")", ",", "(", "self", ".", "effective_radius", "**", "self", ".", "alpha", ")", ")", ",", "(", "1.0", "/", "(", "self", ".", "alpha", "*", "self", ".", "sersic_index", ")", ")", ")", ")", ")", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractPlane.luminosities_of_galaxies_within_circles_in_units
Compute the total luminosity of all galaxies in this plane within a circle of specified radius. See *galaxy.light_within_circle* and *light_profiles.light_within_circle* for details \ of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. 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.
autolens/lens/plane.py
def luminosities_of_galaxies_within_circles_in_units(self, radius : dim.Length, unit_luminosity='eps', exposure_time=None): """Compute the total luminosity of all galaxies in this plane within a circle of specified radius. See *galaxy.light_within_circle* and *light_profiles.light_within_circle* for details \ of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. 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. """ return list(map(lambda galaxy: galaxy.luminosity_within_circle_in_units( radius=radius, unit_luminosity=unit_luminosity, kpc_per_arcsec=self.kpc_per_arcsec, exposure_time=exposure_time), self.galaxies))
def luminosities_of_galaxies_within_circles_in_units(self, radius : dim.Length, unit_luminosity='eps', exposure_time=None): """Compute the total luminosity of all galaxies in this plane within a circle of specified radius. See *galaxy.light_within_circle* and *light_profiles.light_within_circle* for details \ of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. 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. """ return list(map(lambda galaxy: galaxy.luminosity_within_circle_in_units( radius=radius, unit_luminosity=unit_luminosity, kpc_per_arcsec=self.kpc_per_arcsec, exposure_time=exposure_time), self.galaxies))
[ "Compute", "the", "total", "luminosity", "of", "all", "galaxies", "in", "this", "plane", "within", "a", "circle", "of", "specified", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L137-L155
[ "def", "luminosities_of_galaxies_within_circles_in_units", "(", "self", ",", "radius", ":", "dim", ".", "Length", ",", "unit_luminosity", "=", "'eps'", ",", "exposure_time", "=", "None", ")", ":", "return", "list", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "luminosity_within_circle_in_units", "(", "radius", "=", "radius", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "self", ".", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", ",", "self", ".", "galaxies", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractPlane.luminosities_of_galaxies_within_ellipses_in_units
Compute the total luminosity of all galaxies in this plane within a ellipse of specified major-axis. The value returned by this integral is dimensionless, and a conversion factor can be specified to convert it \ to a physical value (e.g. the photometric zeropoint). See *galaxy.light_within_ellipse* and *light_profiles.light_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.
autolens/lens/plane.py
def luminosities_of_galaxies_within_ellipses_in_units(self, major_axis : dim.Length, unit_luminosity='eps', exposure_time=None): """ Compute the total luminosity of all galaxies in this plane within a ellipse of specified major-axis. The value returned by this integral is dimensionless, and a conversion factor can be specified to convert it \ to a physical value (e.g. the photometric zeropoint). See *galaxy.light_within_ellipse* and *light_profiles.light_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. """ return list(map(lambda galaxy: galaxy.luminosity_within_ellipse_in_units( major_axis=major_axis, unit_luminosity=unit_luminosity, kpc_per_arcsec=self.kpc_per_arcsec, exposure_time=exposure_time), self.galaxies))
def luminosities_of_galaxies_within_ellipses_in_units(self, major_axis : dim.Length, unit_luminosity='eps', exposure_time=None): """ Compute the total luminosity of all galaxies in this plane within a ellipse of specified major-axis. The value returned by this integral is dimensionless, and a conversion factor can be specified to convert it \ to a physical value (e.g. the photometric zeropoint). See *galaxy.light_within_ellipse* and *light_profiles.light_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. """ return list(map(lambda galaxy: galaxy.luminosity_within_ellipse_in_units( major_axis=major_axis, unit_luminosity=unit_luminosity, kpc_per_arcsec=self.kpc_per_arcsec, exposure_time=exposure_time), self.galaxies))
[ "Compute", "the", "total", "luminosity", "of", "all", "galaxies", "in", "this", "plane", "within", "a", "ellipse", "of", "specified", "major", "-", "axis", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L157-L180
[ "def", "luminosities_of_galaxies_within_ellipses_in_units", "(", "self", ",", "major_axis", ":", "dim", ".", "Length", ",", "unit_luminosity", "=", "'eps'", ",", "exposure_time", "=", "None", ")", ":", "return", "list", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "luminosity_within_ellipse_in_units", "(", "major_axis", "=", "major_axis", ",", "unit_luminosity", "=", "unit_luminosity", ",", "kpc_per_arcsec", "=", "self", ".", "kpc_per_arcsec", ",", "exposure_time", "=", "exposure_time", ")", ",", "self", ".", "galaxies", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractPlane.masses_of_galaxies_within_circles_in_units
Compute the total mass of all galaxies in this plane within a circle of specified radius. See *galaxy.angular_mass_within_circle* and *mass_profiles.angular_mass_within_circle* for details of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. units_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 \ units to physical units (e.g. solar masses).
autolens/lens/plane.py
def masses_of_galaxies_within_circles_in_units(self, radius : dim.Length, unit_mass='angular', critical_surface_density=None): """Compute the total mass of all galaxies in this plane within a circle of specified radius. See *galaxy.angular_mass_within_circle* and *mass_profiles.angular_mass_within_circle* for details of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. units_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 \ units to physical units (e.g. solar masses). """ return list(map(lambda galaxy: galaxy.mass_within_circle_in_units( radius=radius, unit_mass=unit_mass, kpc_per_arcsec=self.kpc_per_arcsec, critical_surface_density=critical_surface_density), self.galaxies))
def masses_of_galaxies_within_circles_in_units(self, radius : dim.Length, unit_mass='angular', critical_surface_density=None): """Compute the total mass of all galaxies in this plane within a circle of specified radius. See *galaxy.angular_mass_within_circle* and *mass_profiles.angular_mass_within_circle* for details of how this is performed. Parameters ---------- radius : float The radius of the circle to compute the dimensionless mass within. units_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 \ units to physical units (e.g. solar masses). """ return list(map(lambda galaxy: galaxy.mass_within_circle_in_units( radius=radius, unit_mass=unit_mass, kpc_per_arcsec=self.kpc_per_arcsec, critical_surface_density=critical_surface_density), self.galaxies))
[ "Compute", "the", "total", "mass", "of", "all", "galaxies", "in", "this", "plane", "within", "a", "circle", "of", "specified", "radius", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L182-L202
[ "def", "masses_of_galaxies_within_circles_in_units", "(", "self", ",", "radius", ":", "dim", ".", "Length", ",", "unit_mass", "=", "'angular'", ",", "critical_surface_density", "=", "None", ")", ":", "return", "list", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "mass_within_circle_in_units", "(", "radius", "=", "radius", ",", "unit_mass", "=", "unit_mass", ",", "kpc_per_arcsec", "=", "self", ".", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", ",", "self", ".", "galaxies", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractPlane.masses_of_galaxies_within_ellipses_in_units
Compute the total mass of all galaxies in this plane within a ellipse of specified major-axis. See *galaxy.angular_mass_within_ellipse* and *mass_profiles.angular_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.
autolens/lens/plane.py
def masses_of_galaxies_within_ellipses_in_units(self, major_axis : dim.Length, unit_mass='angular', critical_surface_density=None): """Compute the total mass of all galaxies in this plane within a ellipse of specified major-axis. See *galaxy.angular_mass_within_ellipse* and *mass_profiles.angular_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. """ return list(map(lambda galaxy: galaxy.mass_within_ellipse_in_units( major_axis=major_axis, unit_mass=unit_mass, kpc_per_arcsec=self.kpc_per_arcsec, critical_surface_density=critical_surface_density), self.galaxies))
def masses_of_galaxies_within_ellipses_in_units(self, major_axis : dim.Length, unit_mass='angular', critical_surface_density=None): """Compute the total mass of all galaxies in this plane within a ellipse of specified major-axis. See *galaxy.angular_mass_within_ellipse* and *mass_profiles.angular_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. """ return list(map(lambda galaxy: galaxy.mass_within_ellipse_in_units( major_axis=major_axis, unit_mass=unit_mass, kpc_per_arcsec=self.kpc_per_arcsec, critical_surface_density=critical_surface_density), self.galaxies))
[ "Compute", "the", "total", "mass", "of", "all", "galaxies", "in", "this", "plane", "within", "a", "ellipse", "of", "specified", "major", "-", "axis", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L204-L223
[ "def", "masses_of_galaxies_within_ellipses_in_units", "(", "self", ",", "major_axis", ":", "dim", ".", "Length", ",", "unit_mass", "=", "'angular'", ",", "critical_surface_density", "=", "None", ")", ":", "return", "list", "(", "map", "(", "lambda", "galaxy", ":", "galaxy", ".", "mass_within_ellipse_in_units", "(", "major_axis", "=", "major_axis", ",", "unit_mass", "=", "unit_mass", ",", "kpc_per_arcsec", "=", "self", ".", "kpc_per_arcsec", ",", "critical_surface_density", "=", "critical_surface_density", ")", ",", "self", ".", "galaxies", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractGriddedPlane.trace_grid_stack_to_next_plane
Trace this plane's grid_stacks to the next plane, using its deflection angles.
autolens/lens/plane.py
def trace_grid_stack_to_next_plane(self): """Trace this plane's grid_stacks to the next plane, using its deflection angles.""" def minus(grid, deflections): return grid - deflections return self.grid_stack.map_function(minus, self.deflection_stack)
def trace_grid_stack_to_next_plane(self): """Trace this plane's grid_stacks to the next plane, using its deflection angles.""" def minus(grid, deflections): return grid - deflections return self.grid_stack.map_function(minus, self.deflection_stack)
[ "Trace", "this", "plane", "s", "grid_stacks", "to", "the", "next", "plane", "using", "its", "deflection", "angles", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L287-L293
[ "def", "trace_grid_stack_to_next_plane", "(", "self", ")", ":", "def", "minus", "(", "grid", ",", "deflections", ")", ":", "return", "grid", "-", "deflections", "return", "self", ".", "grid_stack", ".", "map_function", "(", "minus", ",", "self", ".", "deflection_stack", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractGriddedPlane.yticks
Compute the yticks labels of this grid_stack, used for plotting the y-axis ticks when visualizing an image \
autolens/lens/plane.py
def yticks(self): """Compute the yticks labels of this grid_stack, used for plotting the y-axis ticks when visualizing an image \ """ return np.linspace(np.amin(self.grid_stack.regular[:, 0]), np.amax(self.grid_stack.regular[:, 0]), 4)
def yticks(self): """Compute the yticks labels of this grid_stack, used for plotting the y-axis ticks when visualizing an image \ """ return np.linspace(np.amin(self.grid_stack.regular[:, 0]), np.amax(self.grid_stack.regular[:, 0]), 4)
[ "Compute", "the", "yticks", "labels", "of", "this", "grid_stack", "used", "for", "plotting", "the", "y", "-", "axis", "ticks", "when", "visualizing", "an", "image", "\\" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L371-L374
[ "def", "yticks", "(", "self", ")", ":", "return", "np", ".", "linspace", "(", "np", ".", "amin", "(", "self", ".", "grid_stack", ".", "regular", "[", ":", ",", "0", "]", ")", ",", "np", ".", "amax", "(", "self", ".", "grid_stack", ".", "regular", "[", ":", ",", "0", "]", ")", ",", "4", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
AbstractGriddedPlane.xticks
Compute the xticks labels of this grid_stack, used for plotting the x-axis ticks when visualizing an \ image
autolens/lens/plane.py
def xticks(self): """Compute the xticks labels of this grid_stack, used for plotting the x-axis ticks when visualizing an \ image""" return np.linspace(np.amin(self.grid_stack.regular[:, 1]), np.amax(self.grid_stack.regular[:, 1]), 4)
def xticks(self): """Compute the xticks labels of this grid_stack, used for plotting the x-axis ticks when visualizing an \ image""" return np.linspace(np.amin(self.grid_stack.regular[:, 1]), np.amax(self.grid_stack.regular[:, 1]), 4)
[ "Compute", "the", "xticks", "labels", "of", "this", "grid_stack", "used", "for", "plotting", "the", "x", "-", "axis", "ticks", "when", "visualizing", "an", "\\", "image" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L377-L380
[ "def", "xticks", "(", "self", ")", ":", "return", "np", ".", "linspace", "(", "np", ".", "amin", "(", "self", ".", "grid_stack", ".", "regular", "[", ":", ",", "1", "]", ")", ",", "np", ".", "amax", "(", "self", ".", "grid_stack", ".", "regular", "[", ":", ",", "1", "]", ")", ",", "4", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Plane.unmasked_blurred_image_of_galaxies_from_psf
This is a utility function for the function above, which performs the iteration over each plane's galaxies \ and computes each galaxy's unmasked blurred image. Parameters ---------- padded_grid_stack psf : ccd.PSF The PSF of the image used for convolution.
autolens/lens/plane.py
def unmasked_blurred_image_of_galaxies_from_psf(self, padded_grid_stack, psf): """This is a utility function for the function above, which performs the iteration over each plane's galaxies \ and computes each galaxy's unmasked blurred image. Parameters ---------- padded_grid_stack psf : ccd.PSF The PSF of the image used for convolution. """ return [padded_grid_stack.unmasked_blurred_image_from_psf_and_unmasked_image( psf, image) if not galaxy.has_pixelization else None for galaxy, image in zip(self.galaxies, self.image_plane_image_1d_of_galaxies)]
def unmasked_blurred_image_of_galaxies_from_psf(self, padded_grid_stack, psf): """This is a utility function for the function above, which performs the iteration over each plane's galaxies \ and computes each galaxy's unmasked blurred image. Parameters ---------- padded_grid_stack psf : ccd.PSF The PSF of the image used for convolution. """ return [padded_grid_stack.unmasked_blurred_image_from_psf_and_unmasked_image( psf, image) if not galaxy.has_pixelization else None for galaxy, image in zip(self.galaxies, self.image_plane_image_1d_of_galaxies)]
[ "This", "is", "a", "utility", "function", "for", "the", "function", "above", "which", "performs", "the", "iteration", "over", "each", "plane", "s", "galaxies", "\\", "and", "computes", "each", "galaxy", "s", "unmasked", "blurred", "image", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L416-L428
[ "def", "unmasked_blurred_image_of_galaxies_from_psf", "(", "self", ",", "padded_grid_stack", ",", "psf", ")", ":", "return", "[", "padded_grid_stack", ".", "unmasked_blurred_image_from_psf_and_unmasked_image", "(", "psf", ",", "image", ")", "if", "not", "galaxy", ".", "has_pixelization", "else", "None", "for", "galaxy", ",", "image", "in", "zip", "(", "self", ".", "galaxies", ",", "self", ".", "image_plane_image_1d_of_galaxies", ")", "]" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
PlanePositions.trace_to_next_plane
Trace the positions to the next plane.
autolens/lens/plane.py
def trace_to_next_plane(self): """Trace the positions to the next plane.""" return list(map(lambda positions, deflections: np.subtract(positions, deflections), self.positions, self.deflections))
def trace_to_next_plane(self): """Trace the positions to the next plane.""" return list(map(lambda positions, deflections: np.subtract(positions, deflections), self.positions, self.deflections))
[ "Trace", "the", "positions", "to", "the", "next", "plane", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/lens/plane.py#L490-L493
[ "def", "trace_to_next_plane", "(", "self", ")", ":", "return", "list", "(", "map", "(", "lambda", "positions", ",", "deflections", ":", "np", ".", "subtract", "(", "positions", ",", "deflections", ")", ",", "self", ".", "positions", ",", "self", ".", "deflections", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_arcsec_to_grid_pixels
Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as floats such that they include the decimal offset from each pixel's top-left corner. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ highest y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray A grid of (y,x) coordinates in arc seconds.
autolens/data/array/scaled_array.py
def grid_arcsec_to_grid_pixels(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as floats such that they include the decimal offset from each pixel's top-left corner. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ highest y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray A grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixels_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
def grid_arcsec_to_grid_pixels(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as floats such that they include the decimal offset from each pixel's top-left corner. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ highest y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray A grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixels_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "arc", "second", "coordinates", "to", "a", "grid", "of", "(", "y", "x", ")", "pixel", "values", ".", "Pixel", "coordinates", "are", "\\", "returned", "as", "floats", "such", "that", "they", "include", "the", "decimal", "offset", "from", "each", "pixel", "s", "top", "-", "left", "corner", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L60-L76
[ "def", "grid_arcsec_to_grid_pixels", "(", "self", ",", "grid_arcsec", ")", ":", "return", "grid_util", ".", "grid_arcsec_1d_to_grid_pixels_1d", "(", "grid_arcsec_1d", "=", "grid_arcsec", ",", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_arcsec_to_grid_pixel_centres
Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as integers such that they map directly to the pixel they are contained within. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds.
autolens/data/array/scaled_array.py
def grid_arcsec_to_grid_pixel_centres(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as integers such that they map directly to the pixel they are contained within. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixel_centres_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin).astype('int')
def grid_arcsec_to_grid_pixel_centres(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel values. Pixel coordinates are \ returned as integers such that they map directly to the pixel they are contained within. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixel_centres_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin).astype('int')
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "arc", "second", "coordinates", "to", "a", "grid", "of", "(", "y", "x", ")", "pixel", "values", ".", "Pixel", "coordinates", "are", "\\", "returned", "as", "integers", "such", "that", "they", "map", "directly", "to", "the", "pixel", "they", "are", "contained", "within", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L78-L96
[ "def", "grid_arcsec_to_grid_pixel_centres", "(", "self", ",", "grid_arcsec", ")", ":", "return", "grid_util", ".", "grid_arcsec_1d_to_grid_pixel_centres_1d", "(", "grid_arcsec_1d", "=", "grid_arcsec", ",", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")", ".", "astype", "(", "'int'", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_arcsec_to_grid_pixel_indexes
Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel 1D indexes. Pixel coordinates are \ returned as integers such that they are the pixel from the top-left of the 2D grid going rights and then \ downwards. For example: The pixel at the top-left, whose 2D index is [0,0], corresponds to 1D index 0. The fifth pixel on the top row, whose 2D index is [0,5], corresponds to 1D index 4. The first pixel on the second row, whose 2D index is [0,1], has 1D index 10 if a row has 10 pixels. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds.
autolens/data/array/scaled_array.py
def grid_arcsec_to_grid_pixel_indexes(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel 1D indexes. Pixel coordinates are \ returned as integers such that they are the pixel from the top-left of the 2D grid going rights and then \ downwards. For example: The pixel at the top-left, whose 2D index is [0,0], corresponds to 1D index 0. The fifth pixel on the top row, whose 2D index is [0,5], corresponds to 1D index 4. The first pixel on the second row, whose 2D index is [0,1], has 1D index 10 if a row has 10 pixels. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixel_indexes_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin).astype('int')
def grid_arcsec_to_grid_pixel_indexes(self, grid_arcsec): """Convert a grid of (y,x) arc second coordinates to a grid of (y,x) pixel 1D indexes. Pixel coordinates are \ returned as integers such that they are the pixel from the top-left of the 2D grid going rights and then \ downwards. For example: The pixel at the top-left, whose 2D index is [0,0], corresponds to 1D index 0. The fifth pixel on the top row, whose 2D index is [0,5], corresponds to 1D index 4. The first pixel on the second row, whose 2D index is [0,1], has 1D index 10 if a row has 10 pixels. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_arcsec: ndarray The grid of (y,x) coordinates in arc seconds. """ return grid_util.grid_arcsec_1d_to_grid_pixel_indexes_1d(grid_arcsec_1d=grid_arcsec, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin).astype('int')
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "arc", "second", "coordinates", "to", "a", "grid", "of", "(", "y", "x", ")", "pixel", "1D", "indexes", ".", "Pixel", "coordinates", "are", "\\", "returned", "as", "integers", "such", "that", "they", "are", "the", "pixel", "from", "the", "top", "-", "left", "of", "the", "2D", "grid", "going", "rights", "and", "then", "\\", "downwards", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L98-L120
[ "def", "grid_arcsec_to_grid_pixel_indexes", "(", "self", ",", "grid_arcsec", ")", ":", "return", "grid_util", ".", "grid_arcsec_1d_to_grid_pixel_indexes_1d", "(", "grid_arcsec_1d", "=", "grid_arcsec", ",", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")", ".", "astype", "(", "'int'", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_pixels_to_grid_arcsec
Convert a grid of (y,x) pixel coordinates to a grid of (y,x) arc second values. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_pixels : ndarray The grid of (y,x) coordinates in pixels.
autolens/data/array/scaled_array.py
def grid_pixels_to_grid_arcsec(self, grid_pixels): """Convert a grid of (y,x) pixel coordinates to a grid of (y,x) arc second values. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_pixels : ndarray The grid of (y,x) coordinates in pixels. """ return grid_util.grid_pixels_1d_to_grid_arcsec_1d(grid_pixels_1d=grid_pixels, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
def grid_pixels_to_grid_arcsec(self, grid_pixels): """Convert a grid of (y,x) pixel coordinates to a grid of (y,x) arc second values. The pixel coordinate origin is at the top left corner of the grid, such that the pixel [0,0] corresponds to \ higher y arc-second coordinate value and lowest x arc-second coordinate. The arc-second coordinate origin is defined by the class attribute origin, and coordinates are shifted to this \ origin before computing their 1D grid pixel indexes. Parameters ---------- grid_pixels : ndarray The grid of (y,x) coordinates in pixels. """ return grid_util.grid_pixels_1d_to_grid_arcsec_1d(grid_pixels_1d=grid_pixels, shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
[ "Convert", "a", "grid", "of", "(", "y", "x", ")", "pixel", "coordinates", "to", "a", "grid", "of", "(", "y", "x", ")", "arc", "second", "values", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L122-L137
[ "def", "grid_pixels_to_grid_arcsec", "(", "self", ",", "grid_pixels", ")", ":", "return", "grid_util", ".", "grid_pixels_1d_to_grid_arcsec_1d", "(", "grid_pixels_1d", "=", "grid_pixels", ",", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_1d
The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds.
autolens/data/array/scaled_array.py
def grid_1d(self): """ The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds. """ return grid_util.regular_grid_1d_from_shape_pixel_scales_and_origin(shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
def grid_1d(self): """ The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds. """ return grid_util.regular_grid_1d_from_shape_pixel_scales_and_origin(shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
[ "The", "arc", "second", "-", "grid", "of", "(", "y", "x", ")", "coordinates", "of", "every", "pixel", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L140-L148
[ "def", "grid_1d", "(", "self", ")", ":", "return", "grid_util", ".", "regular_grid_1d_from_shape_pixel_scales_and_origin", "(", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
RectangularArrayGeometry.grid_2d
The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds.
autolens/data/array/scaled_array.py
def grid_2d(self): """ The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds. """ return grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
def grid_2d(self): """ The arc second-grid of (y,x) coordinates of every pixel. This is defined from the top-left corner, such that the first pixel at location [0, 0] will have a negative x \ value y value in arc seconds. """ return grid_util.regular_grid_2d_from_shape_pixel_scales_and_origin(shape=self.shape, pixel_scales=self.pixel_scales, origin=self.origin)
[ "The", "arc", "second", "-", "grid", "of", "(", "y", "x", ")", "coordinates", "of", "every", "pixel", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L151-L159
[ "def", "grid_2d", "(", "self", ")", ":", "return", "grid_util", ".", "regular_grid_2d_from_shape_pixel_scales_and_origin", "(", "shape", "=", "self", ".", "shape", ",", "pixel_scales", "=", "self", ".", "pixel_scales", ",", "origin", "=", "self", ".", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
Array.new_with_array
Parameters ---------- array: ndarray An ndarray Returns ------- new_array: ScaledSquarePixelArray A new instance of this class that shares all of this instances attributes with a new ndarray.
autolens/data/array/scaled_array.py
def new_with_array(self, array): """ Parameters ---------- array: ndarray An ndarray Returns ------- new_array: ScaledSquarePixelArray A new instance of this class that shares all of this instances attributes with a new ndarray. """ arguments = vars(self) arguments.update({"array": array}) if 'centre' in arguments: arguments.pop("centre") return self.__class__(**arguments)
def new_with_array(self, array): """ Parameters ---------- array: ndarray An ndarray Returns ------- new_array: ScaledSquarePixelArray A new instance of this class that shares all of this instances attributes with a new ndarray. """ arguments = vars(self) arguments.update({"array": array}) if 'centre' in arguments: arguments.pop("centre") return self.__class__(**arguments)
[ "Parameters", "----------", "array", ":", "ndarray", "An", "ndarray" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L189-L205
[ "def", "new_with_array", "(", "self", ",", "array", ")", ":", "arguments", "=", "vars", "(", "self", ")", "arguments", ".", "update", "(", "{", "\"array\"", ":", "array", "}", ")", "if", "'centre'", "in", "arguments", ":", "arguments", ".", "pop", "(", "\"centre\"", ")", "return", "self", ".", "__class__", "(", "*", "*", "arguments", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledSquarePixelArray.from_fits_with_pixel_scale
Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the image image. pixel_scale: float The arc-second to pixel conversion factor of each pixel.
autolens/data/array/scaled_array.py
def from_fits_with_pixel_scale(cls, file_path, hdu, pixel_scale, origin=(0.0, 0.0)): """ Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the image image. pixel_scale: float The arc-second to pixel conversion factor of each pixel. """ return cls(array_util.numpy_array_2d_from_fits(file_path, hdu), pixel_scale, origin)
def from_fits_with_pixel_scale(cls, file_path, hdu, pixel_scale, origin=(0.0, 0.0)): """ Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the image image. pixel_scale: float The arc-second to pixel conversion factor of each pixel. """ return cls(array_util.numpy_array_2d_from_fits(file_path, hdu), pixel_scale, origin)
[ "Loads", "the", "image", "from", "a", ".", "fits", "file", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L282-L295
[ "def", "from_fits_with_pixel_scale", "(", "cls", ",", "file_path", ",", "hdu", ",", "pixel_scale", ",", "origin", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "return", "cls", "(", "array_util", ".", "numpy_array_2d_from_fits", "(", "file_path", ",", "hdu", ")", ",", "pixel_scale", ",", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledSquarePixelArray.single_value
Creates an instance of Array and fills it with a single value Parameters ---------- value: float The value with which the array should be filled shape: (int, int) The shape of the array pixel_scale: float The scale of a pixel in arc seconds Returns ------- array: ScaledSquarePixelArray An array filled with a single value
autolens/data/array/scaled_array.py
def single_value(cls, value, shape, pixel_scale, origin=(0.0, 0.0)): """ Creates an instance of Array and fills it with a single value Parameters ---------- value: float The value with which the array should be filled shape: (int, int) The shape of the array pixel_scale: float The scale of a pixel in arc seconds Returns ------- array: ScaledSquarePixelArray An array filled with a single value """ array = np.ones(shape) * value return cls(array, pixel_scale, origin)
def single_value(cls, value, shape, pixel_scale, origin=(0.0, 0.0)): """ Creates an instance of Array and fills it with a single value Parameters ---------- value: float The value with which the array should be filled shape: (int, int) The shape of the array pixel_scale: float The scale of a pixel in arc seconds Returns ------- array: ScaledSquarePixelArray An array filled with a single value """ array = np.ones(shape) * value return cls(array, pixel_scale, origin)
[ "Creates", "an", "instance", "of", "Array", "and", "fills", "it", "with", "a", "single", "value" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L298-L317
[ "def", "single_value", "(", "cls", ",", "value", ",", "shape", ",", "pixel_scale", ",", "origin", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "array", "=", "np", ".", "ones", "(", "shape", ")", "*", "value", "return", "cls", "(", "array", ",", "pixel_scale", ",", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledSquarePixelArray.flatten
Returns ------- flat_scaled_array: ScaledSquarePixelArray A copy of this array flattened to 1D
autolens/data/array/scaled_array.py
def flatten(self, order='C'): """ Returns ------- flat_scaled_array: ScaledSquarePixelArray A copy of this array flattened to 1D """ return self.new_with_array(super(ScaledSquarePixelArray, self).flatten(order))
def flatten(self, order='C'): """ Returns ------- flat_scaled_array: ScaledSquarePixelArray A copy of this array flattened to 1D """ return self.new_with_array(super(ScaledSquarePixelArray, self).flatten(order))
[ "Returns", "-------", "flat_scaled_array", ":", "ScaledSquarePixelArray", "A", "copy", "of", "this", "array", "flattened", "to", "1D" ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L319-L326
[ "def", "flatten", "(", "self", ",", "order", "=", "'C'", ")", ":", "return", "self", ".", "new_with_array", "(", "super", "(", "ScaledSquarePixelArray", ",", "self", ")", ".", "flatten", "(", "order", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledSquarePixelArray.zoomed_scaled_array_around_mask
Extract the 2D region of an array corresponding to the rectangle encompassing all unmasked values. This is used to extract and visualize only the region of an image that is used in an analysis. Parameters ---------- mask : mask.Mask The mask around which the scaled array is extracted. buffer : int The buffer of pixels around the extraction.
autolens/data/array/scaled_array.py
def zoomed_scaled_array_around_mask(self, mask, buffer=1): """Extract the 2D region of an array corresponding to the rectangle encompassing all unmasked values. This is used to extract and visualize only the region of an image that is used in an analysis. Parameters ---------- mask : mask.Mask The mask around which the scaled array is extracted. buffer : int The buffer of pixels around the extraction. """ return self.new_with_array(array=array_util.extracted_array_2d_from_array_2d_and_coordinates( array_2d=self, y0=mask.zoom_region[0]-buffer, y1=mask.zoom_region[1]+buffer, x0=mask.zoom_region[2]-buffer, x1=mask.zoom_region[3]+buffer))
def zoomed_scaled_array_around_mask(self, mask, buffer=1): """Extract the 2D region of an array corresponding to the rectangle encompassing all unmasked values. This is used to extract and visualize only the region of an image that is used in an analysis. Parameters ---------- mask : mask.Mask The mask around which the scaled array is extracted. buffer : int The buffer of pixels around the extraction. """ return self.new_with_array(array=array_util.extracted_array_2d_from_array_2d_and_coordinates( array_2d=self, y0=mask.zoom_region[0]-buffer, y1=mask.zoom_region[1]+buffer, x0=mask.zoom_region[2]-buffer, x1=mask.zoom_region[3]+buffer))
[ "Extract", "the", "2D", "region", "of", "an", "array", "corresponding", "to", "the", "rectangle", "encompassing", "all", "unmasked", "values", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L335-L349
[ "def", "zoomed_scaled_array_around_mask", "(", "self", ",", "mask", ",", "buffer", "=", "1", ")", ":", "return", "self", ".", "new_with_array", "(", "array", "=", "array_util", ".", "extracted_array_2d_from_array_2d_and_coordinates", "(", "array_2d", "=", "self", ",", "y0", "=", "mask", ".", "zoom_region", "[", "0", "]", "-", "buffer", ",", "y1", "=", "mask", ".", "zoom_region", "[", "1", "]", "+", "buffer", ",", "x0", "=", "mask", ".", "zoom_region", "[", "2", "]", "-", "buffer", ",", "x1", "=", "mask", ".", "zoom_region", "[", "3", "]", "+", "buffer", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledSquarePixelArray.resized_scaled_array_from_array
resized the array to a new shape and at a new origin. Parameters ----------- new_shape : (int, int) The new two-dimensional shape of the array.
autolens/data/array/scaled_array.py
def resized_scaled_array_from_array(self, new_shape, new_centre_pixels=None, new_centre_arcsec=None): """resized the array to a new shape and at a new origin. Parameters ----------- new_shape : (int, int) The new two-dimensional shape of the array. """ if new_centre_pixels is None and new_centre_arcsec is None: new_centre = (-1, -1) # In Numba, the input origin must be the same image type as the origin, thus we cannot # pass 'None' and instead use the tuple (-1, -1). elif new_centre_pixels is not None and new_centre_arcsec is None: new_centre = new_centre_pixels elif new_centre_pixels is None and new_centre_arcsec is not None: new_centre = self.arc_second_coordinates_to_pixel_coordinates(arc_second_coordinates=new_centre_arcsec) else: raise exc.DataException('You have supplied two centres (pixels and arc-seconds) to the resize scaled' 'array function') return self.new_with_array(array=array_util.resized_array_2d_from_array_2d_and_resized_shape( array_2d=self, resized_shape=new_shape, origin=new_centre))
def resized_scaled_array_from_array(self, new_shape, new_centre_pixels=None, new_centre_arcsec=None): """resized the array to a new shape and at a new origin. Parameters ----------- new_shape : (int, int) The new two-dimensional shape of the array. """ if new_centre_pixels is None and new_centre_arcsec is None: new_centre = (-1, -1) # In Numba, the input origin must be the same image type as the origin, thus we cannot # pass 'None' and instead use the tuple (-1, -1). elif new_centre_pixels is not None and new_centre_arcsec is None: new_centre = new_centre_pixels elif new_centre_pixels is None and new_centre_arcsec is not None: new_centre = self.arc_second_coordinates_to_pixel_coordinates(arc_second_coordinates=new_centre_arcsec) else: raise exc.DataException('You have supplied two centres (pixels and arc-seconds) to the resize scaled' 'array function') return self.new_with_array(array=array_util.resized_array_2d_from_array_2d_and_resized_shape( array_2d=self, resized_shape=new_shape, origin=new_centre))
[ "resized", "the", "array", "to", "a", "new", "shape", "and", "at", "a", "new", "origin", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L351-L371
[ "def", "resized_scaled_array_from_array", "(", "self", ",", "new_shape", ",", "new_centre_pixels", "=", "None", ",", "new_centre_arcsec", "=", "None", ")", ":", "if", "new_centre_pixels", "is", "None", "and", "new_centre_arcsec", "is", "None", ":", "new_centre", "=", "(", "-", "1", ",", "-", "1", ")", "# In Numba, the input origin must be the same image type as the origin, thus we cannot", "# pass 'None' and instead use the tuple (-1, -1).", "elif", "new_centre_pixels", "is", "not", "None", "and", "new_centre_arcsec", "is", "None", ":", "new_centre", "=", "new_centre_pixels", "elif", "new_centre_pixels", "is", "None", "and", "new_centre_arcsec", "is", "not", "None", ":", "new_centre", "=", "self", ".", "arc_second_coordinates_to_pixel_coordinates", "(", "arc_second_coordinates", "=", "new_centre_arcsec", ")", "else", ":", "raise", "exc", ".", "DataException", "(", "'You have supplied two centres (pixels and arc-seconds) to the resize scaled'", "'array function'", ")", "return", "self", ".", "new_with_array", "(", "array", "=", "array_util", ".", "resized_array_2d_from_array_2d_and_resized_shape", "(", "array_2d", "=", "self", ",", "resized_shape", "=", "new_shape", ",", "origin", "=", "new_centre", ")", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7
valid
ScaledRectangularPixelArray.from_fits_with_pixel_scale
Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the hyper. pixel_scales: (float, float) The arc-second to pixel conversion factor of each pixel.
autolens/data/array/scaled_array.py
def from_fits_with_pixel_scale(cls, file_path, hdu, pixel_scales, origin=(0.0, 0.0)): """ Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the hyper. pixel_scales: (float, float) The arc-second to pixel conversion factor of each pixel. """ return cls(array_util.numpy_array_2d_from_fits(file_path, hdu), pixel_scales, origin)
def from_fits_with_pixel_scale(cls, file_path, hdu, pixel_scales, origin=(0.0, 0.0)): """ Loads the image from a .fits file. Parameters ---------- file_path : str The full path of the fits file. hdu : int The HDU number in the fits file containing the hyper. pixel_scales: (float, float) The arc-second to pixel conversion factor of each pixel. """ return cls(array_util.numpy_array_2d_from_fits(file_path, hdu), pixel_scales, origin)
[ "Loads", "the", "image", "from", "a", ".", "fits", "file", "." ]
Jammy2211/PyAutoLens
python
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/scaled_array.py#L446-L459
[ "def", "from_fits_with_pixel_scale", "(", "cls", ",", "file_path", ",", "hdu", ",", "pixel_scales", ",", "origin", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "return", "cls", "(", "array_util", ".", "numpy_array_2d_from_fits", "(", "file_path", ",", "hdu", ")", ",", "pixel_scales", ",", "origin", ")" ]
91e50369c7a9c048c83d217625578b72423cd5a7