Generate lookup tables
[3]:
import soapcw
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as st
cannot import matplotlib
/home/joseph.bayley/.conda/envs/soapcw/lib/python3.9/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
There are three peices of code which generate the line aware statistic
Uses python trapz integration (almost as fast as C++ but not as accurate (generally good enough), this is the default)
Uses python quad integration (slowest)
Uses C++ integration (fastest but requires other libraries to be installed) (this also requires the package to be build from source and an edit of the current setup file)
We can generate the line aware statistic in for one detector with
[12]:
powers = np.linspace(1,400,10) # we use a low resolution for speed in this example
[10]:
lineaware_1d = soapcw.line_aware_stat.gen_lookup_python.LineAwareStatistic(
powers,
ndet=1,
signal_prior_width=1.5,
line_prior_width=1.5,
noise_line_model_ratio=0.3)
[11]:
fig, ax = plt.subplots(figsize = (14,6))
ax.plot(powers, lineaware_1d.signoiseline)
ax.set_xlabel("Normalised spectogram power")
ax.set_ylabel("Line aware statistic")
ax.grid(True)
where is can be saved to a file by
[14]:
lineaware_1d.save_lookup("./")
Or in 2D with
[13]:
lineaware_2d = soapcw.line_aware_stat.gen_lookup_python.LineAwareStatistic(
powers,
ndet=2,
signal_prior_width=1.5,
line_prior_width=1.5,
noise_line_model_ratio=0.3
)
[23]:
fig, ax = plt.subplots(figsize=(14,10))
img = ax.imshow(np.log(lineaware_2d.signoiseline),origin="lower",extent=[powers.min(),powers.max(),powers.min(),powers.max()], cmap="cividis")
ax.set_xlabel("normalised spectogram power (det1)")
ax.set_ylabel("normalised spectogram power (det2)")
fig.colorbar(img, ax=ax, label="Output Line aware statistic")
[23]:
<matplotlib.colorbar.Colorbar at 0x7f5fc2482a30>
This can be saved as a lookup table file using the script
[15]:
lineaware_2d.save_lookup("./")
[ ]:
[ ]: