Data processing

Data parsing

liso.proc.parse_astra_phasespace(particle_file, *, cathode=False)

Parse the ASTRA particle file.

Parameters
  • particle_file (string) – pathname of the particle file.

  • cathode (bool) – True for a particle file for the cathode.

Return pandas.DataFrame data

phase-space data.

Return float charge

charge (C) of the bunch.

liso.proc.parse_astra_line(root_name)

Parse the ASTRA output file.

Columns in the input files:

xdata:

z (m), t (ns), Cx (mm), Sx (mm), Sxp (mm), emitx (um), x_xp (um).

ydata:

z (m), t (ns), Cy (mm), Sy (mm), Syp (mm), emity (um), y_yp (um).

zdata:

z (m), t (ns), Ek (MeV), Sz (mm), SdE (keV), emitz (um), z_dE (um).

Note: x_xp = <x.*xp>/sqrt(<x^2>)/<pz>,

y_yp = <y.*yp>/sqrt(<y^2>)/<pz>, z_de = <z.*dE>/sqrt(<z^2>), Sxp = Spx/<pz>, this is not Sxp, so I cannot calculate the trace-space emittance!!! Syp = Spy/<pz>.

Even thought the trace-space emittance is read from the TRemit file, there is still a little difference between the correct value since we do not know the real <x.*xp>

liso.proc.parse_impactt_phasespace(particle_file)

Parse the IMPACT-T particle file.

Parameters

particle_file (string) – pathname of the particle file.

Return pandas.DataFrame data

phase-space data.

Return None charge

Impact-T particle file does not contain charge information.

liso.proc.parse_impactt_line(root_name)

Parse the IMPACT-T output file.

Columns in the input files:

xdata:

t (s), z (m), Cx (m), Sx (m), px (/mc), Spx (/mc), twiss (m), emitx (m).

ydata:

t (s), z (m), Cy (m), Sy (m), py (/mc), Spy (/mc), twiss (m), emity (m).

zdata:.

t (s), z (m), Sz (m), pz (/mc), Spz (/mc), twiss (m), emitz (m).

Note: twiss = -<x - <x>><px - <px>>

Phasespace analysis

class liso.proc.Phasespace(data, charge)

Bases: object

__init__(data, charge)

Initialization.

Parameters
  • data (pandas.DataFrame) – phasespace data containing the following entries which can be accessed via [] operator: x (m), px (mc), y (m), py (mc), z (m), pz (mc), t (s)

  • charge (None/float) – bunch charge

slice(start=None, stop=None, step=None, *, inplace=False)

Slice the phasespace.

Parameters
  • start (None/int) – starting integer when the slicing of the phasespace starts.

  • stop (None/int) – integer until which the slicing takes place. The slicing stops at index stop - 1.

  • step (None/int) – integer value which determines the increment between each index for slicing.

  • inplace (bool) – True for inplace operation.

Return Phasespace

the sliced phasespace instance.

cut_halo(percent)

Remove halo from the phasespace.

Parameters

percent (float) – percentage of particles to be removed based on their transverse distance to the bunch centroid.

cut_tail(percent)

Remove tail from the phasespace.

Parameters

percent (float) – percentage of particles to be removed in the tail.

rotate(angle)

Rotate the phasespace.

Parameters

angle (float) – angle of the rotation in rad.

analyze(*, current_bins='auto', filter_size=1, slice_percent=0.1, slice_with_peak_current=True, min_particles=20)

Calculate beam parameters.

Parameters
  • current_bins (int/'auto') – No. of bins to calculate the current profile.

  • filter_size (int/float) – Standard deviation of the Gaussian kernel of the 1D Gaussian filter used for current profile calculation.

  • slice_percent (float) – percent of the slice bunch length to the total bunch length.

  • slice_with_peak_current (bool) – True for calculating slice properties of the slice with peak current; False for calculating slice properties of the slice in the center of the bunch.

  • min_particles (int) – minimum number of particles required for phasespace analysis.

Return BeamParameters

Beam parameters.

liso.proc.compute_canonical_emit(x, px)

Calculate the canonical emittance.

Parameters
  • x (pandas.Series) – position coordinates

  • px (pandas.Series) – momentum coordinates

:return Normalized canonical emittance.

liso.proc.compute_current_profile(t, n_bins, charge)

Calculate the current profile.

Parameters
  • t (array-like) – an array of t for each particle.

  • n_bins (int) – number of current bins.

  • charge (float) – total bunch charge (in C).

liso.proc.compute_twiss(x, dz, px, pz, gamma)

Calculate the Twiss parameters

Note: In the calculation (except the canonical emittance), the particles are drifted back to the center of the bunch without considering the collective effects!!!

Parameters
  • x (pandas.Series) – position coordinates.

  • dz (pandas.Series) – longitudinal distance to the bunch centre.

  • px (pandas.Series) – momentum coordinates

  • pz (pandas.Series) – longitudinal momentum.

  • gamma (float) – average Lorentz factor of the bunch.

Return float sigma_x

RMS transverse beam size.

Return float betax

beta function.

Return float alphax

alpha function.

Return float emitnx

normalized trace-space emittance