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], shape=(50000,)), 'y': array([-1.23229455e-04, -1.08820261e-04, -9.27723036e-05, ..., 8.55980575e-05, 8.58175111e-05, 9.07622257e-05], shape=(50000,)), 'z': array([0, 0, 0, ..., 0, 0, 0], shape=(50000,)), 'px': array([ -3083.62426208, 2225.50916089, 2725.71118497, ..., -15364.10019502, 15821.42535919, -4733.37387114], shape=(50000,)), 'py': array([ 83545.59793901, 83389.57159329, 68275.02707993, ..., -70430.7890369 , -70600.14629199, -69547.74384872], shape=(50000,)), 'pz': array([8.00396788e+09, 8.00007259e+09, 8.00139351e+09, ..., 7.99685995e+09, 7.99660959e+09, 7.99818066e+09], shape=(50000,)), 't': array([5.11804566e-06, 5.11804568e-06, 5.11804567e-06, ..., 5.11804569e-06, 5.11804569e-06, 5.11804569e-06], shape=(50000,)), 'status': array([1, 1, 1, ..., 1, 1, 1], shape=(50000,)), 'species': 'electron', 'weight': array([2.e-17, 2.e-17, 2.e-17, ..., 2.e-17, 2.e-17, 2.e-17], shape=(50000,)), 'id': array([ 1, 2, 3, ..., 49998, 49999, 50000], shape=(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 0x7f21e448e490>
In [8]:
Copied!
P.plot("z", "pz")
P.plot("z", "pz")