@@ -169,112 +169,4 @@ def mapped_reconstructed_image_from(
169169 xp = self .mapper ._xp ,
170170 ),
171171 mask = self .mapper .mapper_grids .mask ,
172- )
173-
174- def magnification_via_mesh_from (
175- self ,
176- ) -> float :
177- """
178- Returns the magnification of the reconstruction computed via the mesh, where the magnification is the ratio
179- of the surface brightness of image in the image-plane over the surface brightness of the source in
180- the source-plane.
181-
182- In the image-plane, this is computed by mapping the reconstruction to the image, summing all reconstructed
183- values and multiplying by the area of each image pixel. This image-plane image is not convolved with the
184- PSF, as the source plane reconstruction is a non-convolved image.
185-
186- In the source-plane, this is computed by summing the reconstruction values multiplied by the area of each
187- mesh pixel, for example if the source-plane is a `Delaunay` mesh this is the area of each corresponding
188- Delaunay pixel.
189-
190- This calculatiion is generally more robust that using an interpolated
191- image (see `magnification_via_interpolation_from`), because it uses the exact the source-plane reconstruction
192- values. However, certain meshes have irregular pixels, especially at the edge, which can produce large
193- areas that can artificially decrease the magnification. Including cuts on which source-plane pixels are used,
194- for example based on brightness, is recommended to ensure the magnification is robust.
195-
196- Parameters
197- ----------
198- mesh_pixel_mask
199- The mask of pixels that are omitted from the reconstruction when computing the image, for example to
200- remove pixels with low signal-to-noise so they do not impact the magnification calculation.
201-
202- Returns
203- -------
204- The magnification of the reconstruction computed via the mesh.
205- """
206-
207- if isinstance (self .mapper , MapperDelaunay ):
208- raise exc .MeshException (
209- """
210- The method `magnification_via_mesh_from` does not currently support `Delaunay` mesh objects.
211-
212- To compute the magnification of a `Delaunay` mesh, use the method `magnification_via_interpolation_from`.
213-
214- This method only supports a `RectangularAdaptDensity`.
215- """
216- )
217-
218- mapped_reconstructed_image = self .mapped_reconstructed_image_from ()
219-
220- try :
221- mesh_areas = self .mapper .source_plane_mesh_grid .areas_for_magnification
222- except AttributeError :
223- mesh_areas = self .mapper .areas_for_magnification
224-
225- if np .all (mesh_areas == 0.0 ):
226- raise exc .MeshException (
227- """
228- The magnification cannot be computed because the areas of the source-plane mesh pixels are all zero.
229-
230- This probably means you have specified an invalid source-plane mesh.
231- """
232- )
233-
234- return np .sum (
235- mapped_reconstructed_image * mapped_reconstructed_image .pixel_area
236- ) / np .sum (self .values_masked * mesh_areas )
237-
238- def magnification_via_interpolation_from (
239- self ,
240- shape_native : Tuple [int , int ] = (201 , 201 ),
241- extent : Optional [Tuple [float , float , float , float ]] = None ,
242- ) -> float :
243- """
244- Returns the magnification of the reconstruction computed via interpolation, where the magnification is the ratio
245- of the surface brightness of image in the image-plane over the surface brightness of the source in
246- the source-plane.
247-
248- In the image-plane, this is computed by mapping the reconstruction to the image, summing all reconstructed
249- values and multiplying by the area of each image pixel. This image-plane image is not convolved with the
250- PSF, as the source plane reconstruction is a non-convolved image. This image therefore does not use
251- interpolation.
252-
253- In the source-plane, this is computed by interpolating the reconstruction to a regular grid of pixels, for
254- example a 2D grid of 401 x 401 pixels, and summing the reconstruction values multiplied by the area of each
255- pixel. This calculation uses interpolation to compute the source-plane image.
256-
257- This calculation is generally less robust than using the mesh to compute the magnification,
258- (see `magnification_via_mesh_from`), as the interpolation may not perfectly represent the source-plane
259- reconstruction. However, it is computationally faster and can be used when the source-plane mesh has
260- irregular pixels that are not suitable for computing the magnification.
261-
262- Parameters
263- ----------
264- mesh_pixel_mask
265- The mask of pixels that are omitted from the reconstruction when computing the image, for example to
266- remove pixels with low signal-to-noise so they do not impact the magnification calculation.
267-
268- Returns
269- -------
270- The magnification of the reconstruction computed via interpolation.
271- """
272- mapped_reconstructed_image = self .mapped_reconstructed_image_from ()
273-
274- interpolated_reconstruction = self .interpolated_array_from (
275- shape_native = shape_native , extent = extent
276- )
277-
278- return np .sum (
279- mapped_reconstructed_image * mapped_reconstructed_image .pixel_area
280- ) / np .sum (interpolated_reconstruction * interpolated_reconstruction .pixel_area )
172+ )
0 commit comments