Example: RingMultiBunchΒΆ
[1]:
from opal.opal import load_dataset
ds = load_dataset('./RingMultiBunch/', fname='RingMultiBunch.h5')
[2]:
print ( ds )
H5 dataset.
Number of steps: 4
Available step attributes (42):
#sigma
#varepsilon
#varepsilon-geom
AZIMUTH
B-head
B-ref
B-tail
CHARGE
E-head
E-ref
E-tail
ELEVATION
ENERGY
GlobalTrackStep
LOCAL
LocalTrackStep
MASS
NumBunch
OPAL_flavour
REFPR
REFPT
REFPZ
REFR
REFTHETA
REFZ
RMSP
RMSX
RefPartP
RefPartR
SPOS
Step
SteptoLastInj
TIME
centroid
dE
maxP
maxX
minP
minX
spos-head
spos-ref
spos-tail
Available step datasets (10):
bin
id
mass
px
py
pz
q
x
y
z
[3]:
from opal.visualization.styles import load_style
load_style('jupyter')
/home/opalci/pyOPALTools/opal/visualization/styles/default.py:186: MatplotlibDeprecationWarning:
The mathtext.fallback_to_cm rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
mpl.rcParams['mathtext.fallback_to_cm'] = True
/home/opalci/pyOPALTools/opal/visualization/styles/default.py:186: MatplotlibDeprecationWarning: Support for setting the 'mathtext.fallback_to_cm' rcParam is deprecated since 3.3 and will be removed two minor releases later; use 'mathtext.fallback : 'cm' instead.
mpl.rcParams['mathtext.fallback_to_cm'] = True
/home/opalci/pyOPALTools/opal/visualization/styles/default.py:186: MatplotlibDeprecationWarning:
The validate_bool_maybe_none function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
mpl.rcParams['mathtext.fallback_to_cm'] = True
/home/opalci/pyOPALTools/opal/visualization/styles/default.py:419: MatplotlibDeprecationWarning:
The savefig.jpeg_quality rcparam was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
mpl.rcParams['savefig.jpeg_quality'] = 95 # when a jpeg is saved, the default quality parameter.
[4]:
plt = ds.plot_phase_space('x', 'y', xsci=True, ysci=True, step=3, bins=[0, 1])
plt.legend(['bin 0', 'bin 1'], markerscale=10)
plt.show()
[5]:
plt = ds.plot_phase_space('x', 'z', xsci=True, ysci=True, step=3, bins=[0, 1])
plt.legend(['bin 0', 'bin 1'], markerscale=10)
plt.show()
[6]:
try:
print ( "Central moment: " + str(ds.moment('x', k=1, bunch=1, step=3)) )
print ( "Arithmetic mean: " + str(ds.mean('x', bunch=1, step=3)) )
print ( "Skewness: " + str(ds.skew('x', bunch=1, step=3)) )
print ( "Kurtosis: " + str(ds.kurtosis('x', bunch=1, step=3)) )
print ( "Halo: " + str(ds.halo_ellipsoidal_beam('x', bunch=1, step=3)) )
print ( "Halo (2D): " + str(ds.halo_2d_ellipsoidal_beam('x', bunch=1, step=3)) )
print ( "Radial halo: " + str(ds.radial_halo_ellipsoidal_beam(bunch=1, step=3)) )
print ( "Radial halo (2D): " + str(ds.radial_halo_2d_ellipsoidal_beam(azimuth=110, bunch=1, step=3)) )
except Exception as e:
print ( e )
Central moment: 0.0
Arithmetic mean: 2.1856373634845316
Skewness: 0.056635976870648995
Kurtosis: -1.446404768615836
Halo: -0.5892619114729787
Halo (2D): 0.4246858053662188
Radial halo: -0.5896525325693598
Radial halo (2D): 0.09139639984105807
[7]:
minima = ds.find_beams('x', step=3)[0]
print ( minima )
[30 68]
[8]:
kde = ds.gaussian_kde('x', step=3)
import numpy as np
points = np.linspace(2.1, 2.3, 500)
pdf = kde.pdf(points)
plt.plot(points, pdf)
plt.xlabel('x [m]')
plt.ylabel('evaluated kde')
plt.show()
[9]:
plt = ds.plot_histogram('x', step=3, bins=600)
plt.show()
[10]:
plt = ds.plot_joint(xvar='x', yvar='y', join='contour', step=3)
plt.show()
/usr/local/lib/python3.6/dist-packages/seaborn/axisgrid.py:1595: UserWarning:
The `size` parameter has been renamed to `height`; please update your code.
/usr/local/lib/python3.6/dist-packages/seaborn/distributions.py:2557: FutureWarning:
`distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
[11]:
plt = ds.plot_joint(xvar='x', yvar='y', join='scatter', marginals='kde', step=3)
plt.show()
/usr/local/lib/python3.6/dist-packages/seaborn/axisgrid.py:1595: UserWarning:
The `size` parameter has been renamed to `height`; please update your code.
[12]:
help(ds.plot_joint)
Help on method plot_joint in module opal.visualization.H5Plotter:
plot_joint(xvar, yvar, join, **kwargs) method of opal.datasets.H5Dataset.H5Dataset instance
Do a joint plot (marginals + contour / scatter)
Parameters
----------
xvar : str
x-axis variable to consider
yvar : str
y-axis variable to consider
join : str
'all', 'contour' or 'scatter'
step : int, optional
Step of dataset
See Also
--------
visualization.statistics.impl_plots.plot_joint
Returns
-------
matplotlib.pyplot
Plot handle
[13]:
plt = ds.plot_joint(xvar='x', yvar='y', join='all', marginals='kde+hist', step=3)
plt.show()
/usr/local/lib/python3.6/dist-packages/seaborn/axisgrid.py:1595: UserWarning:
The `size` parameter has been renamed to `height`; please update your code.
/usr/local/lib/python3.6/dist-packages/seaborn/distributions.py:2557: FutureWarning:
`distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
/usr/local/lib/python3.6/dist-packages/seaborn/distributions.py:2557: FutureWarning:
`distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
/usr/local/lib/python3.6/dist-packages/seaborn/distributions.py:1647: FutureWarning:
The `vertical` parameter is deprecated and will be removed in a future version. Assign the data to the `y` variable instead.
[14]:
plt = ds.plot_density_scipy(xvar='x', yvar='y', step=3)
plt.show()
/home/opalci/pyOPALTools/opal/visualization/H5Plotter.py:398: MatplotlibDeprecationWarning:
shading='flat' when X and Y have the same dimensions as C is deprecated since 3.3. Either specify the corners of the quadrilaterals with X and Y, or pass shading='auto', 'nearest' or 'gouraud', or set rcParams['pcolor.shading']. This will become an error two minor releases later.
[15]:
plt = ds.plot_density(xvar='x', yvar='y', step=3)
plt.show()