box

tayph.box(x, A, c, w)[source] [edit on github]

This function computes a box with width w, amplitude A and center c on grid x. It would be a simple multiplication of two heaviside functions, where it not that I am taking care to interpolate the edge pixels. And because I didn’t want to do the cheap hack of oversampling x by a factor of many and then using np.interpolate, I computed the interpolation manually myself. This function guarantees* to preserve the integral of the box, i.e. np.sum(box(x,A,c,w))*dwl equals w, unless the box is truncated by the edge.)

Uncomment the two relevant lines below if you don’t believe me and want to make sure.