punchbowl.level1.despike#

Functions#

despike_polseq(...)

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

despike_polseq_task(→ punchbowl.data.punchcube.PUNCHCube)

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

Module Contents#

punchbowl.level1.despike.despike_polseq(reference: punchbowl.data.punchcube.PUNCHCube, neighbors: list[punchbowl.data.punchcube.PUNCHCube], filter_width: float = 25.0, hpf_zscore_thresh: float = 10.0) tuple[punchbowl.data.punchcube.PUNCHCube, 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 (PUNCHCube) – a PUNCHCube to correct for cosmic rays

  • neighbors (List[PUNCHCube]) – a list of PUNCHCube 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 PUNCHCube with spikes replaced by the average of their neighbors,

and a list of spike locations for all neighbors

Return type:

(PUNCHCube, np.ndarray)

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

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

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

  • neighbors (list[PUNCHCube] | 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:

PUNCHCube