Read examples¶
In [1]:
Copied!
# Useful for debugging
%load_ext autoreload
%autoreload 2
# Useful for debugging
%load_ext autoreload
%autoreload 2
In [2]:
Copied!
from pmd_beamphysics import ParticleGroup
from pmd_beamphysics import ParticleGroup
elegant hdf5 format¶
In [3]:
Copied!
from pmd_beamphysics.interfaces.elegant import elegant_h5_to_data
from pmd_beamphysics.interfaces.elegant import elegant_h5_to_data
This will convert to a data dict
In [4]:
Copied!
data = elegant_h5_to_data("data/elegant_raw.h5")
data
data = elegant_h5_to_data("data/elegant_raw.h5")
data
Out[4]:
{'x': array([-1.12390181e-04, -7.20268439e-05, -1.14543953e-04, ..., 1.05737263e-04, -7.24786314e-05, 5.78264247e-05]), 'y': array([-1.23229455e-04, -1.08820261e-04, -9.27723036e-05, ..., 8.55980575e-05, 8.58175111e-05, 9.07622257e-05]), 'z': array([0, 0, 0, ..., 0, 0, 0]), 'px': array([ -3083.62425792, 2225.50915788, 2725.71118129, ..., -15364.10017428, 15821.42533783, -4733.37386475]), 'py': array([ 83545.5978262 , 83389.57148069, 68275.02698773, ..., -70430.7889418 , -70600.14619666, -69547.74375481]), 'pz': array([8.00396787e+09, 8.00007258e+09, 8.00139350e+09, ..., 7.99685994e+09, 7.99660958e+09, 7.99818064e+09]), 't': array([5.11804566e-06, 5.11804568e-06, 5.11804567e-06, ..., 5.11804569e-06, 5.11804569e-06, 5.11804569e-06]), 'status': array([1, 1, 1, ..., 1, 1, 1]), 'species': 'electron', 'weight': array([2.e-17, 2.e-17, 2.e-17, ..., 2.e-17, 2.e-17, 2.e-17]), 'id': array([ 1, 2, 3, ..., 49998, 49999, 50000], dtype=int32)}
Create ParticleGroup
and plot:
In [5]:
Copied!
P = ParticleGroup(data=data)
P.plot("delta_t", "delta_pz")
P = ParticleGroup(data=data)
P.plot("delta_t", "delta_pz")
Genesis4 HDF5 format¶
In [6]:
Copied!
from pmd_beamphysics.interfaces.genesis import genesis4_par_to_data
from pmd_beamphysics.interfaces.genesis import genesis4_par_to_data
In [7]:
Copied!
P = ParticleGroup(data=genesis4_par_to_data("data/genesis4.par.h5"))
P
P = ParticleGroup(data=genesis4_par_to_data("data/genesis4.par.h5"))
P
Out[7]:
<ParticleGroup with 14336 particles at 0x7f1e407efc50>
In [8]:
Copied!
P.plot("z", "pz")
P.plot("z", "pz")