Skip to content

Instantly share code, notes, and snippets.

@DanHickstein
Created April 19, 2019 13:52
Show Gist options
  • Save DanHickstein/3eb197236afa3b15a4c4e28278321b27 to your computer and use it in GitHub Desktop.
Save DanHickstein/3eb197236afa3b15a4c4e28278321b27 to your computer and use it in GitHub Desktop.
import abel
from abel.tools.analytical import PiecewisePolynomial
from itertools import chain
import matplotlib.pyplot as plt
import numpy as np
hw = 1 # peak half-width - Or is this the full-width?
step = 10 # center-to-center distance between peaks
n = 10 # number of peaks
rmax = int(n * step)
def peak(i):
c = i * step
if i:
return [(c - hw, c, [1, 1], c, hw),
(c, c + hw, [1, -1], c, hw)]
else:
return [(c, c + hw, [1, -1], c, hw)]
comb = PiecewisePolynomial(rmax + 1, rmax,
chain(*[peak(i) for i in range(1, n)]),
symmetric=False)
func = comb.abel
zeros_array = np.zeros_like(func)
IM = np.array([zeros_array, zeros_array, func, zeros_array, zeros_array])
trans = abel.onion_bordas.onion_bordas_transform(IM)
fig, axs = plt.subplots(1,2,figsize=(8,4))
axs[0].imshow(IM, aspect='auto')
axs[1].imshow(trans, aspect='auto')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment