MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / convolve

Function convolve

pyxrf/core/map_processing.py:1269–1285  ·  view source on GitHub ↗
(background, s)

Source from the content-addressed store, hash-verified

1267 # effects in general convolution.
1268
1269 def convolve(background, s):
1270 # Modifies the contents of the 'background' array.
1271 # This implementation of convolution replaces the original
1272 # implementation based on 'np.convolve'. Seems to work as fast
1273 # as the original implementation.
1274 s_len = len(s)
1275 n_beg = (s_len - 1) // 2
1276 A = s.sum()
1277 source = np.hstack(
1278 (
1279 np.zeros(n_beg, dtype=background.dtype),
1280 background,
1281 np.zeros(s_len - n_beg, dtype=background.dtype),
1282 )
1283 )
1284 for n in range(len(background)):
1285 background[n] = np.sum(source[n : n + s_len] * s) / A
1286
1287 convolve(background, s)
1288

Callers 1

snip_method_numbaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected