Skip to content
Snippets Groups Projects
Commit ecf337f5 authored by Vadim Gubaidulin's avatar Vadim Gubaidulin
Browse files

-applying formatters

parent 9a978863
No related branches found
No related tags found
1 merge request!9Emittance calculation
This commit is part of merge request !9. Comments created here will be created in the context of that merge request.
...@@ -283,26 +283,32 @@ class Bunch: ...@@ -283,26 +283,32 @@ class Bunch:
Return the bunch emittance for each plane. Return the bunch emittance for each plane.
""" """
cor = np.squeeze([[self[name] - self[name].mean()] for name in self]) cor = np.squeeze([[self[name] - self[name].mean()] for name in self])
cov_x = np.cov(self['x'], self['xp']) cov_x = np.cov(self['x'], self['xp'])
cov_y = np.cov(self['y'], self['yp']) cov_y = np.cov(self['y'], self['yp'])
cov_z = np.cov(self['tau'], self['delta']) cov_z = np.cov(self['tau'], self['delta'])
if (self.ring.optics.local_dispersion != [0, 0, 0, 0]): if (self.ring.optics.local_dispersion != [0, 0, 0, 0]):
cov_xdelta = np.cov(self['x'], self['delta']) cov_xdelta = np.cov(self['x'], self['delta'])
cov_xpdelta = np.cov(self['xp'], self['delta']) cov_xpdelta = np.cov(self['xp'], self['delta'])
cov_ydelta = np.cov(self['y'], self['delta']) cov_ydelta = np.cov(self['y'], self['delta'])
cov_ypdelta = np.cov(self['yp'], self['delta']) cov_ypdelta = np.cov(self['yp'], self['delta'])
sig11 = cov_x[0, 0] - cov_xdelta[0, 1] * cov_xdelta[0, 1] / cov_z[1,1] sig11 = cov_x[
sig12 = cov_x[0, 1] - cov_xdelta[0, 1] * cov_xpdelta[0, 1] / cov_z[1, 1] 0, 0] - cov_xdelta[0, 1] * cov_xdelta[0, 1] / cov_z[1, 1]
sig22 = cov_x[1, 1] - cov_xpdelta[0, 1] * cov_xpdelta[0, 1] / cov_z[1, 1] sig12 = cov_x[
emitX = np.sqrt(sig11*sig22-sig12*sig12) 0, 1] - cov_xdelta[0, 1] * cov_xpdelta[0, 1] / cov_z[1, 1]
sig22 = cov_x[
sig11 = cov_y[0, 0] - cov_ydelta[0, 1] * cov_ydelta[0, 1] / cov_z[1,1] 1, 1] - cov_xpdelta[0, 1] * cov_xpdelta[0, 1] / cov_z[1, 1]
sig12 = cov_y[0, 1] - cov_ydelta[0, 1] * cov_ypdelta[0, 1] / cov_z[1, 1] emitX = np.sqrt(sig11*sig22 - sig12*sig12)
sig22 = cov_y[1, 1] - cov_ypdelta[0, 1] * cov_ypdelta[0, 1] / cov_z[1, 1]
emitY = np.sqrt(sig11*sig22-sig12*sig12) sig11 = cov_y[
0, 0] - cov_ydelta[0, 1] * cov_ydelta[0, 1] / cov_z[1, 1]
sig12 = cov_y[
0, 1] - cov_ydelta[0, 1] * cov_ypdelta[0, 1] / cov_z[1, 1]
sig22 = cov_y[
1, 1] - cov_ypdelta[0, 1] * cov_ypdelta[0, 1] / cov_z[1, 1]
emitY = np.sqrt(sig11*sig22 - sig12*sig12)
else: else:
emitX = np.sqrt(np.linalg.det(cov_x)) emitX = np.sqrt(np.linalg.det(cov_x))
emitY = np.sqrt(np.linalg.det(cov_y)) emitY = np.sqrt(np.linalg.det(cov_y))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment