Search#

Perform optimal region search and show some plots

Thin wrapper around find_regions().

Parameters:
  • mask – Bad pixel mask

  • img (ndarray) – Full frame image used as reference

  • region_size (int) – Region size to optimize

  • psf (ndarray) – PSF used for weighting and siplay

  • n_top (int) – Number of regions

  • kernel (str | ndarray) – Kernel to weigh the bad pixels in the window. One of: - “uniform”: uniform on the region - “weighted”: weighted by a PSF centered on the region - A custom array

  • forbidden_size (int | None) – Size of the central region where no bad pixels are allowed. Defaults to None.

  • joint_offsets (list[tuple[int, int]] | None) – Offests to apply after the pointing to generate the window in pixels. Useful to replicate dithers. Should be a list of (dx, dy) offsets where y is along rows and x along columns. Defaults to None.

  • min_edge_distance (int | None) – Minimal distance to keep from the edge in pixels. Defaults to None.

  • subarray (str | None) – Subarray to use for the region search. This is mostly useful in cases where the LW and SW channels have different field of view. If None, all pixels in the image are used. Defaults to None.

  • show (bool) – Show the plots if True

  • dq_mask (ndarray)

  • dither_pattern (str | None)

  • n_dithers (int | None)

  • detector (str | None)

Return type:

tuple[ndarray, ndarray]

Returns:

The X and Y offsets

jwpoint.search.find_regions(mask, window_size, kernel='uniform', n_top=10, forbidden_size=None, joint_offsets=None, min_edge_distance=None, subarray=None, return_weighted=False)[source]#

Find regions for optimal pointing

Searches the n_top windows that minimize the number of bad pixels. Returns the optimal pointing position for each window.

Parameters:
  • mask (ndarray) – Bad pixel mask

  • window_size (int) – Window size to optimize

  • kernel (str | ndarray) – Kernel used to weigh bad pixels in the window. Can be “uniform” or a custom array. Defaults to “uniform”.

  • n_top (int) – Number of optimal pointings to return. 10 by default.

  • forbidden_size (int | None) – Size of the central region where no bad pixels are allowed. Defaults to None.

  • joint_offsets (list[tuple[int, int]] | ndarray | None) – Offests to apply after the pointing to generate the window in pixels. Useful to replicate dithers. Should be a list of (dx, dy) offsets where y is along rows and x along columns. Defaults to None.

  • min_edge_distance (int | None) – Minimal distance to keep from the edge in pixels. Defaults to None.

  • subarray (str | None) – Subarray to use for the region search. If None, the FULL subarray is used. Defaults to None.

  • return_weighted (bool) – Whether the mask weighted by the kernel for all explored windows should be returned. Defaults to False.

Return type:

tuple[ndarray, ndarray] | tuple[ndarray, ndarray, ndarray]

Returns:

Arrays of x and y optimal pointing coordinate, along with the weighted mask if return_weighted is true.