Example: RingCyclotron

Load the RingCyclotron.stat file

[1]:
from opal import load_dataset

ds = load_dataset('./RingCyclotron/', fname='RingCyclotron.stat')
[2]:
print ( ds )

        Statistic dataset.

        Size: 42 x 1441

        Available variables (42) :

        Bx_ref                   Bx-Field component of ref particle
        By_ref                   By-Field component of ref particle
        Bz_ref                   Bz-Field component of ref particle
        DDx                      Derivative of dispersion in x
        DDy                      Derivative of dispersion in y
        Dx                       Dispersion in x
        Dy                       Dispersion in y
        Ex_ref                   Ex-Field component of ref particle
        Ey_ref                   Ey-Field component of ref particle
        Ez_ref                   Ez-Field component of ref particle
        charge                   Bunch Charge
        dE                       energy spread of the beam
        dt                       time step size
        emit_s                   Normalized Emittance s
        emit_x                   Normalized Emittance x
        emit_y                   Normalized Emittance y
        energy                   Mean Energy
        max_s                    Max Beamsize in s
        max_x                    Max Beamsize in x
        max_y                    Max Beamsize in y
        mean_s                   Mean Beam Position in s
        mean_x                   Mean Beam Position in x
        mean_y                   Mean Beam Position in y
        numParticles             Number of Macro Particles
        partsOutside             outside n*sigma of the beam
        ref_px                   x momentum of reference particle in lab cs
        ref_py                   y momentum of reference particle in lab cs
        ref_pz                   z momentum of reference particle in lab cs
        ref_x                    x coordinate of reference particle in lab cs
        ref_y                    y coordinate of reference particle in lab cs
        ref_z                    z coordinate of reference particle in lab cs
        rms_ps                   RMS Momenta in s
        rms_px                   RMS Momenta in x
        rms_py                   RMS Momenta in y
        rms_s                    RMS Beamsize in s
        rms_x                    RMS Beamsize in x
        rms_y                    RMS Beamsize in y
        s                        Average Longitudinal Position
        t                        Time
        xpx                      Correlation xpx
        ypy                      Correlation ypyy
        zpz                      Correlation zpz

Set the plotting style

[3]:
from opal.visualization.styles import load_style

load_style('jupyter')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 3
      1 from opal.visualization.styles import load_style
----> 3 load_style('jupyter')

File ~/pyOPALTools/opal/visualization/styles/load_style.py:31, in load_style(use)
     29 from opal.utilities.logger import opal_logger
     30 opal_logger.info("Loading '" + use + "' plotting style")
---> 31 eval(use + '()')

File <string>:1

File ~/pyOPALTools/opal/visualization/styles/jupyter.py:31, in jupyter()
     29 # reset
     30 from opal.visualization.styles.default import default
---> 31 default()
     33 if mpl.__version__ < '2':
     34     opal_logger.error('jupyter style not available for matplotlib version ' + mpl.__version__)

File ~/pyOPALTools/opal/visualization/styles/default.py:38, in default()
     36 mpl.rcParams['lines.linestyle']         = '-'           # solid line
     37 mpl.rcParams['lines.color']             = 'C0'          # has no affect on plot(); see axes.prop_cycle
---> 38 mpl.rcParams['lines.marker']            = None          # the default marker
     39 mpl.rcParams['lines.markeredgewidth']   = 1.0           # the line width around the marker symbol
     40 mpl.rcParams['lines.markersize']        = 6             # markersize, in points

File /usr/local/lib/python3.8/dist-packages/matplotlib/__init__.py:722, in RcParams.__setitem__(self, key, val)
    720         cval = self.validate[key](val)
    721     except ValueError as ve:
--> 722         raise ValueError(f"Key {key}: {ve}") from None
    723     self._set(key, cval)
    724 except KeyError as err:

ValueError: Key lines.marker: Could not convert None to str

Do some plotting …

[4]:
plt = ds.plot_profile1D('time', 'rms_x', xsci=True)

plt.show()
_images/RingCyclotron_7_0.svg
[5]:
plt = ds.plot_profile1D('time', 'Bx_ref', xsci=True)

plt.show()
_images/RingCyclotron_8_0.svg

Load the RingCyclotron.h5 file

[6]:
ds = load_dataset('./RingCyclotron/', fname='RingCyclotron.h5')
[7]:
plt = ds.plot_phase_space('x', 'y', xsci=True, ysci=True)

plt.show()
_images/RingCyclotron_11_0.svg

Do some plotting …

[8]:
plt = ds.plot_phase_space('x', 'y', xsci=True, ysci=True)

plt.show()
_images/RingCyclotron_13_0.svg
[9]:
plt = ds.plot_density('x', 'y', xsci=True, ysci=True, bins=(100, 100))

plt.show()
_images/RingCyclotron_14_0.svg

Do some statistics on data

[10]:
try:
    print ( "Central moment:  " + str(ds.moment('x', k=1)) )

    print ( "Arithmetic mean: " + str(ds.mean('x')) )

    print ( "Skewness:        " + str(ds.skew('x')) )

    print ( "Kurtosis:        " + str(ds.kurtosis('x')) )

except Exception as e:
    print ( e )
Central moment:  0.0
Arithmetic mean: 2.130006912733799
Skewness:        -0.006440553238663452
Kurtosis:        -0.18906667046073933

Load the RingCyclotron.mem file

[11]:
ds = load_dataset('./RingCyclotron/', fname='RingCyclotron.mem')

Do some plotting …

[12]:
plt = ds.plot_total_memory()

plt.show()
_images/RingCyclotron_20_0.svg
[13]:
plt = ds.plot_memory_summary()

plt.show()
_images/RingCyclotron_21_0.svg

Load the RingCyclotron.lbal file

[14]:
ds = load_dataset('./RingCyclotron/', fname='RingCyclotron.lbal')

Do some plotting …

[15]:
plt = ds.plot_lbal_summary()

plt.show()
_images/RingCyclotron_25_0.svg
[16]:
plt = ds.plot_lbal_histogram()

plt.show()
_images/RingCyclotron_26_0.svg

Load the RingCyclotron-trackOrbit file

[17]:
ds = load_dataset('./RingCyclotron/', fname='RingCyclotron-trackOrbit.dat')

Do some plotting …

[18]:
plt = ds.plot_orbits()
plt.show()
_images/RingCyclotron_30_0.svg

Load timing.dat file

[19]:
ds = load_dataset('./RingCyclotron/', fname ='timing.dat')

Do some plotting …

[20]:
plt = ds.plot_pie_chart(prop='cpu max', first=7)

plt.show()
_images/RingCyclotron_34_0.svg
[21]:
plt = ds.plot_time_summary(prop='cpu', grid=True)

plt.show()
_images/RingCyclotron_35_0.svg