cutcutcodec.core.signal.window.alpha_to_att
- cutcutcodec.core.signal.window.alpha_to_att(alpha: float) float[source]
Empirical estimation based on regression.
The fitted model is (attenuation = a*alpha + b + c*tanh(d*alpha)).
Examples
>>> import torch >>> from cutcutcodec.core.signal.window import find_dpss_law >>> alphas, atts, _ = find_dpss_law() >>> alphas, atts = alphas.to(torch.float64), atts.to(torch.float64) >>> abcd = torch.tensor([26.54, 12.94, -22.85, 0.954], dtype=torch.float64, requires_grad=True) >>> optim = torch.optim.Adam([abcd]) >>> for _ in range(10000): ... pred = abcd[0]*alphas + abcd[1] + abcd[2]*torch.tanh(abcd[3]*alphas) ... optim.zero_grad() ... torch.mean((atts - pred)**2).backward() ... optim.step() ... >>> abcd.detach().to(torch.float32) tensor([ 26.5422, 12.9422, -22.8484, 0.9542]) >>> # import matplotlib.pyplot as plt >>> # _ = plt.plot(alphas.numpy(force=True), atts.numpy(force=True)) >>> # _ = plt.plot(alphas.numpy(force=True), pred.numpy(force=True)) >>> # plt.show() >>>