punchbowl.level1.despike#

Functions#

radial_array(→ numpy.ndarray)

Create radial array.

spikejones(→ tuple[numpy.ndarray, numpy.ndarray])

Remove cosmic ray spikes from an image using spikejones algorithm.

despike_task(→ ndcube.NDCube)

Despike an image using astroscrappy.detect_cosmics.

despikejones_task(→ ndcube.NDCube)

Prefect task to perform despiking.

Module Contents#

punchbowl.level1.despike.radial_array(shape: tuple[int], center: tuple[int] | None = None) numpy.ndarray#

Create radial array.

punchbowl.level1.despike.spikejones(image: numpy.ndarray, unsharp_size: int = 3, method: str = 'convolve', alpha: float = 1, dilation: int = 0) tuple[numpy.ndarray, numpy.ndarray]#

Remove cosmic ray spikes from an image using spikejones algorithm.

This code is based on drzowie/solarpdl-tools

Parameters:
  • image (np.ndarray) – an array representing an image

  • unsharp_size (int) – half window size in pixels for unsharp mask

  • method (str (either "convolve" or "median")) – method for applying the unsharp mask

  • alpha (float) – threshold for deciding a pixel is a cosmic ray spike, i.e. difference between unsharp and smoothed image

  • dilation (int) – how many times to dilate pixels identified as spikes, allows for identifying a larger spike region

Returns:

an image with spikes replaced by the average of their neighbors and the locations of all spikes

Return type:

(np.ndarray, np.ndarray)

punchbowl.level1.despike.despike_task(data_object: ndcube.NDCube, sigclip: float = 50, sigfrac: float = 0.25, objlim: float = 160.0, niter: int = 10, gain: float = 4.9, readnoise: float = 17, cleantype: str = 'meanmask') ndcube.NDCube#

Despike an image using astroscrappy.detect_cosmics.

Parameters:
  • data_object (NDCube) – Input image to be despiked.

  • sigclip (float, optional) – Laplacian-to-noise limit for cosmic ray detection.

  • sigfrac (float, optional) – Fractional detection limit for neighboring pixels.

  • objlim (float, optional) – Contrast limit between Laplacian image and the fine structure image.

  • niter (int, optional) – Number of iterations.

  • gain (float, optional) – Gain of the image (electrons/ADU).

  • readnoise (float, optional) – Read noise of the image (electrons).

  • cleantype (str, optional) – Type of cleaning algorithm: ‘meanmask’, ‘medmask’, or ‘idw’.

Returns:

Despiked cube.

Return type:

NDCube

punchbowl.level1.despike.despikejones_task(data_object: ndcube.NDCube, unsharp_size: int = 3, method: str = 'convolve', alpha: float = 1, dilation: int = 0) ndcube.NDCube#

Prefect task to perform despiking.

Parameters:
  • data_object (NDCube) – data to operate on

  • unsharp_size (int) – half window size in pixels for unsharp mask

  • method (str (either "convolve" or "median")) – method for applying the unsharp mask

  • alpha (float) – threshold for deciding a pixel is a cosmic ray spike, i.e. difference between unsharp and smoothed image

  • dilation (int) – how many times to dilate pixels identified as spikes, allows for identifying a larger spike region

Returns:

a modified version of the input with spikes removed

Return type:

NDCube