<jupyter_start><jupyter_text>Convolution experiment<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format='retina'
sns.set_context('paper')
import torch
xv = torch.arange(0, 10, 0.01)
xv.shape
period = 0.85
yv = (torch.clamp(torch.sin(2.0*3.14*xv/period), 0.85, 0.851) - 0.85)*1000.0
plt.figure(figsize=(20, 5))
plt.step(xv, yv);
conv = torch.nn.Conv1d(1, 1, kernel_size=31, padding=2)
%%time
output = torch.nn.functional.conv1d(yv.unsqueeze(0).unsqueeze(1), weights.unsqueeze(0).unsqueeze(1), padding=15)
output = output.squeeze()
plt.figure(figsize=(20, 5))
plt.step(xv, yv);
plt.step(xv, output);
from blase.datasets import HPFDataset
from blase.multiorder import MultiOrder
dat = HPFDataset('../test/data/Goldilocks_20191022T013208_v1.0_0003.spectra.fits')
model = MultiOrder(wl_data=dat.data_cube[6, :, :])
import torch
with torch.no_grad():
    model.log_blur_size -= 0.5
model.log_blur_size
np.exp(-1.5)
plt.plot(dat.data_cube[6, 5, :],model(5).cpu().detach())
np.exp(1.67)
%%time
out = model.wl_native.cpu().numpy()
dat.data_cube[6, 5, :]
vec = dat.data_cube[6, 5, :]
np.median(np.diff(vec.numpy()))
190/2
import torch
x1 = torch.arange(190) - 190 // 2
189//2
import math
math.pi
torch.inverse()
torch.div(1, torch.tensor(3))
weights = torch.exp((-self.conv_x ** 2 / (2 * blur_size_pixels ** 2)))
x1
kornia.filters.get_gaussian_kernel1d(131, sigma=3.1).double().to('cuda')
inp = torch.randn(1, 10, 1)
sns.heatmap(inp.squeeze(2), square=True);
inp = inp.permute(1, 2, 0)
print(inp.shape) # [batch_size, channels, seq]
output = conv(inp)
output.shape
sns.heatmap(output.squeeze().unsqueeze(0).detach(), square=True);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18056354226566992, 'fraction_numerical': 0.06900517538815411, 'mean_word_length': 5.796875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '294390', 'license': 'MIT', 'n_tokens_mistral': 816, 'n_tokens_neox': 749, 'n_words': 129, 'path': 'notebooks/deprecated/convolve.ipynb', 'repo_name': 'gully/blase', 'size': '1739'}