|
1 | 1 | from __future__ import annotations |
2 | 2 | import numpy as np |
| 3 | +import os |
3 | 4 |
|
4 | 5 | from typing import Optional |
5 | 6 |
|
@@ -238,7 +239,6 @@ def image_plane_mesh_grid_from( |
238 | 239 | self, |
239 | 240 | mask: Mask2D, |
240 | 241 | adapt_data: Optional[np.ndarray], |
241 | | - settings: SettingsInversion = None, |
242 | 242 | ) -> Grid2DIrregular: |
243 | 243 | """ |
244 | 244 | Returns an image mesh by running the Hilbert curve on the weight map. |
@@ -290,14 +290,6 @@ def image_plane_mesh_grid_from( |
290 | 290 |
|
291 | 291 | mesh_grid = Grid2DIrregular(values=np.stack((drawn_y, drawn_x), axis=-1)) |
292 | 292 |
|
293 | | - self.check_mesh_pixels_per_image_pixels( |
294 | | - mask=mask, mesh_grid=mesh_grid, settings=settings |
295 | | - ) |
296 | | - |
297 | | - self.check_adapt_background_pixels( |
298 | | - mask=mask, mesh_grid=mesh_grid, adapt_data=adapt_data, settings=settings |
299 | | - ) |
300 | | - |
301 | 293 | return mesh_grid |
302 | 294 |
|
303 | 295 | def check_mesh_pixels_per_image_pixels( |
@@ -344,21 +336,20 @@ def check_mesh_pixels_per_image_pixels( |
344 | 336 | if os.environ.get("PYAUTOFIT_TEST_MODE") == "1": |
345 | 337 | return |
346 | 338 |
|
347 | | - if settings is not None: |
348 | | - if image_mesh_min_mesh_pixels_per_pixel is not None: |
349 | | - mesh_pixels_per_image_pixels = self.mesh_pixels_per_image_pixels_from( |
350 | | - mask=mask, mesh_grid=mesh_grid |
351 | | - ) |
| 339 | + if image_mesh_min_mesh_pixels_per_pixel is not None: |
| 340 | + mesh_pixels_per_image_pixels = self.mesh_pixels_per_image_pixels_from( |
| 341 | + mask=mask, mesh_grid=mesh_grid |
| 342 | + ) |
352 | 343 |
|
353 | | - indices_of_highest_values = np.argsort(mesh_pixels_per_image_pixels)[ |
354 | | - -image_mesh_min_mesh_number: |
355 | | - ] |
356 | | - lowest_mesh_pixels = np.min( |
357 | | - mesh_pixels_per_image_pixels[indices_of_highest_values] |
358 | | - ) |
| 344 | + indices_of_highest_values = np.argsort(mesh_pixels_per_image_pixels)[ |
| 345 | + -image_mesh_min_mesh_number: |
| 346 | + ] |
| 347 | + lowest_mesh_pixels = np.min( |
| 348 | + mesh_pixels_per_image_pixels[indices_of_highest_values] |
| 349 | + ) |
359 | 350 |
|
360 | | - if lowest_mesh_pixels < image_mesh_min_mesh_pixels_per_pixel: |
361 | | - raise exc.InversionException() |
| 351 | + if lowest_mesh_pixels < image_mesh_min_mesh_pixels_per_pixel: |
| 352 | + raise exc.InversionException() |
362 | 353 |
|
363 | 354 | return mesh_grid |
364 | 355 |
|
@@ -412,27 +403,26 @@ def check_adapt_background_pixels( |
412 | 403 | if os.environ.get("PYAUTOFIT_TEST_MODE") == "1": |
413 | 404 | return |
414 | 405 |
|
415 | | - if settings is not None: |
416 | | - if image_mesh_adapt_background_percent_threshold is not None: |
417 | | - pixels = mesh_grid.shape[0] |
| 406 | + if image_mesh_adapt_background_percent_threshold is not None: |
| 407 | + pixels = mesh_grid.shape[0] |
418 | 408 |
|
419 | | - pixels_in_background = int( |
420 | | - mask.shape_slim * image_mesh_adapt_background_percent_check |
421 | | - ) |
| 409 | + pixels_in_background = int( |
| 410 | + mask.shape_slim * image_mesh_adapt_background_percent_check |
| 411 | + ) |
422 | 412 |
|
423 | | - indices_of_lowest_values = np.argsort(adapt_data)[:pixels_in_background] |
424 | | - mask_background = np.zeros_like(adapt_data, dtype=bool) |
425 | | - mask_background[indices_of_lowest_values] = True |
| 413 | + indices_of_lowest_values = np.argsort(adapt_data)[:pixels_in_background] |
| 414 | + mask_background = np.zeros_like(adapt_data, dtype=bool) |
| 415 | + mask_background[indices_of_lowest_values] = True |
426 | 416 |
|
427 | | - mesh_pixels_per_image_pixels = self.mesh_pixels_per_image_pixels_from( |
428 | | - mask=mask, mesh_grid=mesh_grid |
429 | | - ) |
| 417 | + mesh_pixels_per_image_pixels = self.mesh_pixels_per_image_pixels_from( |
| 418 | + mask=mask, mesh_grid=mesh_grid |
| 419 | + ) |
430 | 420 |
|
431 | | - mesh_pixels_in_background = sum( |
432 | | - mesh_pixels_per_image_pixels[mask_background] |
433 | | - ) |
| 421 | + mesh_pixels_in_background = sum( |
| 422 | + mesh_pixels_per_image_pixels[mask_background] |
| 423 | + ) |
434 | 424 |
|
435 | | - if mesh_pixels_in_background < ( |
436 | | - pixels * image_mesh_adapt_background_percent_threshold |
437 | | - ): |
438 | | - raise exc.InversionException() |
| 425 | + if mesh_pixels_in_background < ( |
| 426 | + pixels * image_mesh_adapt_background_percent_threshold |
| 427 | + ): |
| 428 | + raise exc.InversionException() |
0 commit comments