Skip to content

Instantly share code, notes, and snippets.

@btel
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save btel/63aed22414151c6806f4 to your computer and use it in GitHub Desktop.

Select an option

Save btel/63aed22414151c6806f4 to your computer and use it in GitHub Desktop.
#from github.com/gdetor/SPySort
def get_jitter(self, evts, center, centerD, centerDD):
""" Estimates the jitter given an event or a matrix of events where
individual events form the rows, a median event and the first two
derivatives of the latter.
**Parameters**
evts : double (array)
The actual clean events to be realigned
center : double (array)
The estimate of the center (obtained from the median)
centerD : double (array)
The estimate of the center's derivative (obtained from the median
of events cut on the derivative of data)
centerDD : double (array)
The estimate of the center's second derivative (obtained from the
median of events cut on the second derivative of data)
**Returns**
The first approximation of the jitter (numerical value).
"""
centerD_norm2 = np.dot(centerD, centerD)
centerDD_norm2 = np.dot(centerDD, centerDD)
centerD_dot_centerDD = np.dot(centerD, centerDD)
if evts.ndim == 1:
evts = evts.reshape(1, len(center))
evts = evts - center
h_dot_centerD = np.dot(evts, centerD)
delta0 = h_dot_centerD/centerD_norm2
h_dot_centerDD = np.dot(evts, centerDD)
first = (-2. * h_dot_centerD + 2. * delta0 *
(centerD_norm2 - h_dot_centerDD) + 3. * delta0**2 *
centerD_dot_centerDD + delta0**3 * centerDD_norm2)
second = (2. * (centerD_norm2 - h_dot_centerDD) + 6. * delta0 *
centerD_dot_centerDD + 3. * delta0**2 * centerDD_norm2)
return delta0 - first/second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment