Script execution
This commit is contained in:
@@ -8,44 +8,6 @@ import ch.psi.pshell.imaging.ImageListener as ImageListener
|
||||
from operator import add, mul, sub, truediv
|
||||
from ch.psi.pshell.imaging.Utils import sub
|
||||
|
||||
def arrmul(a, b):
|
||||
"""Multiply 2 series of the same size.
|
||||
|
||||
Args:
|
||||
|
||||
a(list, tuple, array ...): subscriptable object containing numbers
|
||||
b(list, tuple, array ...): subscriptable object containing numbers
|
||||
|
||||
Returns:
|
||||
List
|
||||
|
||||
"""
|
||||
return map(mul, a, b)
|
||||
|
||||
def center_of_mass(data, x = None):
|
||||
"""Calculate the center of mass of a series, and its rms.
|
||||
|
||||
Args:
|
||||
|
||||
data(list, tuple, array ...): subscriptable object containing numbers
|
||||
x(list, tuple, array ..., optional): x coordinates
|
||||
|
||||
Returns:
|
||||
Tuple (com, rms)
|
||||
|
||||
"""
|
||||
if x is None:
|
||||
x = Arr.indexesDouble(len(data))
|
||||
data_sum = sum(data)
|
||||
if (data_sum==0):
|
||||
return float('nan')
|
||||
xmd = arrmul( x, data)
|
||||
com = sum(xmd) / data_sum
|
||||
xmd2 = arrmul( x, xmd)
|
||||
com2 = sum(xmd2) / data_sum
|
||||
rms = math.sqrt(abs(com2 - com * com))
|
||||
return (com, rms)
|
||||
|
||||
def get_centroid(source):
|
||||
bi = source.getImage()
|
||||
if bi is None:
|
||||
@@ -231,6 +193,7 @@ if __name__ == "__builtin__":
|
||||
sensors = [image_stats.com_x_mean, image_stats.com_y_mean, image_stats.com_x_stdev, image_stats.com_y_stdev]
|
||||
|
||||
image_stats.captureBackground(5)
|
||||
#image_stats.enableBackground(True)
|
||||
|
||||
def before_sample():
|
||||
image_stats.update()
|
||||
|
||||
Reference in New Issue
Block a user