-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
executable file
·46 lines (36 loc) · 1.01 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Some useful functions."""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
def PlotPSF(PSF, title: str = None):
"""
Plot the PSF.
"""
fig, ax = plt.subplots()
im = ax.imshow(PSF, cmap='inferno')
fig.colorbar(im, ax=ax, label='photons')
ax.set(
title=title,
xticks=[0, PSF.shape[0] - 1],
yticks=[0, PSF.shape[1] - 1],
)
plt.show()
return
def PlotSqrtPSF(PSF, title: str = None):
"""
Plot the square root of the PSF.
"""
# Checking for negative values
if np.any(PSF < 0):
PSF = np.abs(PSF)
print('Warning: Negative values in PSF. Taking absolute value.')
fig, ax = plt.subplots()
im = ax.imshow(PSF, cmap='inferno', norm=colors.PowerNorm(gamma=0.5))
fig.colorbar(im, ax=ax, label='photons')
ax.set(
title=title,
xticks=[0, PSF.shape[0] - 1],
yticks=[0, PSF.shape[1] - 1],
)
plt.show()
return