punchbowl.level1.despike#

Functions#

despike_polseq(→ tuple[ndcube.NDCube, numpy.ndarray])

Remove cosmic ray spikes from a single polarization sequence of images.

despike_polseq_task(→ ndcube.NDCube)

Despike a polarization sequence of images using a simple statistical test.

Module Contents#

punchbowl.level1.despike.despike_polseq(reference: ndcube.NDCube, neighbors: list[ndcube.NDCube], filter_width: float = 25.0, hpf_zscore_thresh: float = 10.0) tuple[ndcube.NDCube, numpy.ndarray][source]#

Remove cosmic ray spikes from a single polarization sequence of images.

This code takes as input multiple (N) images from the same roll sequence. It constructs a high-pass-filtered version of the input images. At each pixel, it computes the median and standard deviation of the (N-1) dimmest pixels, and then the z-score of each pixel. If the z-score exceeds a threshold, a cosmic ray is assumed and the pixel is filled in with the mean of its neighbors.

Parameters:
  • reference (NDCube) – an NDCube to correct for cosmic rays

  • neighbors (List[NDCube]) – a list of NDCube objects representing a polarization image sequence, should not include the reference image

  • filter_width (float) – width of the gaussian filter used in created the high-pass-filtered image

  • hpf_zscore_thresh (float) – number of standard deviations above the sequence median[sic] that causes a pixel to be marked as a cosmic ray.

Returns:

a NDCube with spikes replaced by the average of their neighbors,

and a list of spike locations for all neighbors

Return type:

(NDCube, np.ndarray)

punchbowl.level1.despike.despike_polseq_task(data_object: ndcube.NDCube, neighbors: list[ndcube.NDCube] | list[str], filter_width: float = 25.0, hpf_zscore_thresh: float = 10.0, max_workers: int | None = None) ndcube.NDCube[source]#

Despike a polarization sequence of images using a simple statistical test.

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

  • neighbors (list[NDCube] | list[str]) – Sequence of neighbor images from the same spacecraft and roll sequence to use in despiking.

  • filter_width (float, optional) – width of the gaussian filter used to construct the high-pass-filtered image, in pixels.

  • hpf_zscore_thresh (float, optional) – number of standard deviations above the sequence median[sic] that causes a pixel to be marked as a cosmic ray.

  • max_workers (int, optional) – Max number of threads to use

Returns:

Despiked cube.

Return type:

NDCube