Remove Background

The remove_background() method subtracts the spatially varying background signal from each spectral slice.

Note

Apart from remove_background(), the DataCube class provides many other operations. See DataCube Operations for details.

Example

Below is a demonstration of loading a data cube, removing its background, and plotting a selected wavelength slice:

 1import wizard
 2from wizard._utils.example import generate_pattern_stack
 3from matplotlib import pyplot as plt
 4
 5# generate random data
 6data = generate_pattern_stack(20, 600, 400, n_circles=10, n_rects=0, n_triangles=0)
 7
 8# build two cubes: one original, one to resize
 9dc = wizard.DataCube(data)
10
11# plot them side by side
12fig, axes = plt.subplots(1, 3, figsize=(12, 6))
13
14# original
15axes[0].imshow(dc[10])
16axes[0].set_title("Original")
17
18dc.remove_background(style='dark')
19
20# resized
21axes[1].imshow(dc[10])
22axes[1].set_title("Removed Background `dark`")
23
24dc.remove_background(style='bright')
25
26axes[2].imshow(dc[10])
27axes[2].set_title("Removed Background `bright`")
28
29plt.tight_layout()
30plt.show()
DataCube slice after background removal at the central wavelength showing enhanced signal features.