Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Oct 25, 2023
1 parent 94e118f commit 1a915f8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions autoarray/inversion/pixelization/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from .rectangular import Rectangular
from .voronoi import VoronoiMagnification
from .voronoi import VoronoiBrightnessImage
from .voronoi import VoronoiSNRImage
from .voronoi_nn import VoronoiNNMagnification
from .voronoi_nn import VoronoiNNBrightnessImage
from .voronoi_nn import VoronoiNNSNRImage
from .delaunay import DelaunayMagnification
from .delaunay import DelaunayBrightnessImage
4 changes: 3 additions & 1 deletion autoarray/inversion/pixelization/mesh/voronoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,10 @@ def image_plane_mesh_grid_from(
"""
snr_map = self.weight_map_from(adapt_data=adapt_data, noise_map=noise_map)

return Grid2DSparse.from_weight_map_split(
return Grid2DSparse.from_snr_split(
pixels=self.pixels,
fraction_high_snr=self.fraction_high_snr,
snr_cut=self.snr_cut,
grid=image_plane_data_grid,
snr_map=snr_map,
seed=settings.kmeans_seed,
Expand Down
54 changes: 54 additions & 0 deletions autoarray/inversion/pixelization/mesh/voronoi_nn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from autoarray.inversion.pixelization.mesh.voronoi import VoronoiMagnification
from autoarray.inversion.pixelization.mesh.voronoi import VoronoiBrightnessImage
from autoarray.inversion.pixelization.mesh.voronoi import VoronoiSNRImage


class VoronoiNNMagnification(VoronoiMagnification):
Expand Down Expand Up @@ -95,3 +96,56 @@ def uses_interpolation(self):
@property
def is_stochastic(self) -> bool:
return True


class VoronoiNNSNRImage(VoronoiSNRImage):
"""
An irregular mesh of Voronoi pixels, which using natural neighbor interpolation are paired with a 2D grid of (y,x)
coordinates. The Voronoi cell centers are derived in the image-plane by applying a KMeans
clustering algorithm to the image's weight map.
For a full description of how a mesh is paired with another grid,
see the :meth:`Pixelization API documentation <autoarray.inversion.pixelization.pixelization.Pixelization>`.
The Voronoi mesh represents pixels as an irregular 2D grid of Voronoi cells.
A ``Pixelization`` using a ``Voronoi`` mesh has four grids associated with it:
- ``image_plane_data_grid``: The observed data grid in the image-plane (which is paired with the mesh in
the source-plane).
- ``image_plane_mesh_grid``: The (y,x) mesh coordinates in the image-plane (which are the centres of Voronoi
cells in the source-plane).
- ``source_plane_data_grid``: The observed data grid mapped to the source-plane (e.g. after gravitational lensing).
- ``source_plane_mesh_grid``: The centre of each Voronoi cell in the source-plane
(the ``image_plane_mesh_grid`` maps to this after gravitational lensing).
Each (y,x) coordinate in the ``source_plane_data_grid`` is paired with all Voronoi cells it falls within,
using a natural neighbor interpolation scheme (https://en.wikipedia.org/wiki/Natural_neighbor_interpolation).
The centers of the Voronoi cell pixels are derived in the image plane, by applying a KMeans clustering algorithm
to the masked image data's weight-map. The ``weight_floor`` and ``weight_power`` allow the KMeans algorithm to
adapt the image-plane coordinates to the image's brightest or faintest values. The computed valies are
mapped to the source-plane via gravitational lensing, where they form the Voronoi cell pixel centers.
Parameters
----------
pixels
The total number of pixels in the mesh, which is therefore also the number of (y,x) coordinates computed
via the KMeans clustering algorithm in image-plane.
weight_floor
A parameter which reweights the data values the KMeans algorithm is applied too; as the floor increases
more weight is applied to values with lower values thus allowing mesh pixels to be placed in these
regions of the data.
weight_power
A parameter which reweights the data values the KMeans algorithm is applied too; as the power increases
more weight is applied to values with higher values thus allowing mesh pixels to be placed in these
regions of the data.
"""

@property
def uses_interpolation(self):
return True

@property
def is_stochastic(self) -> bool:
return True

0 comments on commit 1a915f8

Please sign in to comment.