@@ -300,9 +300,14 @@ def image_plane_mesh_grid_from(
300300
301301 return mesh_grid
302302
303-
304303 def check_mesh_pixels_per_image_pixels (
305- self , mask : Mask2D , mesh_grid : Grid2DIrregular , settings : SettingsInversion
304+ self ,
305+ mask : Mask2D ,
306+ mesh_grid : Grid2DIrregular ,
307+ image_mesh_min_mesh_pixels_per_pixel = None ,
308+ image_mesh_min_mesh_number : int = 5 ,
309+ image_mesh_adapt_background_percent_threshold : float = None ,
310+ image_mesh_adapt_background_percent_check : float = 0.8 ,
306311 ):
307312 """
308313 Checks the number of mesh pixels in every image pixel and raises an `InversionException` if there are fewer
@@ -315,12 +320,12 @@ def check_mesh_pixels_per_image_pixels(
315320
316321 1) Compute the 2D array of the number of mesh pixels in every masked data image pixel.
317322 2) Find the number of mesh pixels in the N data pixels with the larger number of mesh pixels, where N is
318- given by `settings. image_mesh_min_mesh_number`. For example, if `settings. image_mesh_min_mesh_number=5` then
323+ given by `image_mesh_min_mesh_number`. For example, if `image_mesh_min_mesh_number=5` then
319324 the number of mesh pixels in the 5 data pixels with the most data pixels is computed.
320- 3) Compare the lowest value above to the value `settings. image_mesh_min_mesh_pixels_per_pixel`. If the value is
325+ 3) Compare the lowest value above to the value `image_mesh_min_mesh_pixels_per_pixel`. If the value is
321326 below this value, raise an `InversionException`.
322327
323- Therefore, by settings `settings. image_mesh_min_mesh_pixels_per_pixel` to a value above 1 the code is forced
328+ Therefore, by settings `image_mesh_min_mesh_pixels_per_pixel` to a value above 1 the code is forced
324329 to adapt the image mesh enough to put many mesh pixels in the brightest image pixels.
325330
326331 Parameters
@@ -340,19 +345,19 @@ def check_mesh_pixels_per_image_pixels(
340345 return
341346
342347 if settings is not None :
343- if settings . image_mesh_min_mesh_pixels_per_pixel is not None :
348+ if image_mesh_min_mesh_pixels_per_pixel is not None :
344349 mesh_pixels_per_image_pixels = self .mesh_pixels_per_image_pixels_from (
345350 mask = mask , mesh_grid = mesh_grid
346351 )
347352
348353 indices_of_highest_values = np .argsort (mesh_pixels_per_image_pixels )[
349- - settings . image_mesh_min_mesh_number :
354+ - image_mesh_min_mesh_number :
350355 ]
351356 lowest_mesh_pixels = np .min (
352357 mesh_pixels_per_image_pixels [indices_of_highest_values ]
353358 )
354359
355- if lowest_mesh_pixels < settings . image_mesh_min_mesh_pixels_per_pixel :
360+ if lowest_mesh_pixels < image_mesh_min_mesh_pixels_per_pixel :
356361 raise exc .InversionException ()
357362
358363 return mesh_grid
@@ -362,7 +367,10 @@ def check_adapt_background_pixels(
362367 mask : Mask2D ,
363368 mesh_grid : Grid2DIrregular ,
364369 adapt_data : Optional [np .ndarray ],
365- settings : SettingsInversion ,
370+ image_mesh_min_mesh_pixels_per_pixel = None ,
371+ image_mesh_min_mesh_number : int = 5 ,
372+ image_mesh_adapt_background_percent_threshold : float = None ,
373+ image_mesh_adapt_background_percent_check : float = 0.8 ,
366374 ):
367375 """
368376 Checks the number of mesh pixels in the background of the image-mesh and raises an `InversionException` if
@@ -375,15 +383,15 @@ def check_adapt_background_pixels(
375383 The check works as follows:
376384
377385 1) Find all pixels in the background of the `adapt_data`, which are N pixels with the lowest values, where N is
378- a percentage given by `settings. image_mesh_adapt_background_percent_check`. If N is 50%, then the half of
386+ a percentage given by `image_mesh_adapt_background_percent_check`. If N is 50%, then the half of
379387 pixels in `adapt_data` with the lowest values will be checked.
380388 2) Sum the total number of mesh pixels in these background pixels, thereby estimating the number of mesh pixels
381389 assigned to background pixels.
382390 3) Compare this value to the total number of mesh pixels multiplied
383- by `settings. image_mesh_adapt_background_percent_threshold` and raise an `InversionException` if the number
391+ by `image_mesh_adapt_background_percent_threshold` and raise an `InversionException` if the number
384392 of mesh pixels is below this value, meaning the background did not have sufficient mesh pixels in it.
385393
386- Therefore, by setting `settings. image_mesh_adapt_background_percent_threshold` the code is forced
394+ Therefore, by setting `image_mesh_adapt_background_percent_threshold` the code is forced
387395 to adapt the image mesh in a way that places many mesh pixels in the background regions.
388396
389397 Parameters
@@ -405,11 +413,11 @@ def check_adapt_background_pixels(
405413 return
406414
407415 if settings is not None :
408- if settings . image_mesh_adapt_background_percent_threshold is not None :
416+ if image_mesh_adapt_background_percent_threshold is not None :
409417 pixels = mesh_grid .shape [0 ]
410418
411419 pixels_in_background = int (
412- mask .shape_slim * settings . image_mesh_adapt_background_percent_check
420+ mask .shape_slim * image_mesh_adapt_background_percent_check
413421 )
414422
415423 indices_of_lowest_values = np .argsort (adapt_data )[:pixels_in_background ]
@@ -425,6 +433,6 @@ def check_adapt_background_pixels(
425433 )
426434
427435 if mesh_pixels_in_background < (
428- pixels * settings . image_mesh_adapt_background_percent_threshold
436+ pixels * image_mesh_adapt_background_percent_threshold
429437 ):
430438 raise exc .InversionException ()
0 commit comments