Plot examples¶
In [1]:
Copied!
from pmd_beamphysics import ParticleGroup, particle_paths
from h5py import File
from pmd_beamphysics import ParticleGroup, particle_paths
from h5py import File
In [2]:
Copied!
# Open a file, fine the particle paths from the root attributes
# Pick one:
H5FILE = "data/bmad_particles2.h5"
# H5FILE = 'data/distgen_particles.h5'
# H5FILE = 'data/astra_particles.h5'
# Load
h5 = File(H5FILE, "r")
ppaths = particle_paths(h5)
ph5 = h5[ppaths[0]]
P = ParticleGroup(ph5)
ppaths
# Open a file, fine the particle paths from the root attributes
# Pick one:
H5FILE = "data/bmad_particles2.h5"
# H5FILE = 'data/distgen_particles.h5'
# H5FILE = 'data/astra_particles.h5'
# Load
h5 = File(H5FILE, "r")
ppaths = particle_paths(h5)
ph5 = h5[ppaths[0]]
P = ParticleGroup(ph5)
ppaths
Out[2]:
['/data/00001/particles/']
Density plots¶
In [3]:
Copied!
P.plot("t")
P.plot("t")
Slice statistics Plots¶
In [4]:
Copied!
P.t = P.t - P["mean_t"]
P.slice_plot("sigma_x", "sigma_y", xlim=(None, 80e-15), ylim=(0, 30e-6))
P.t = P.t - P["mean_t"]
P.slice_plot("sigma_x", "sigma_y", xlim=(None, 80e-15), ylim=(0, 30e-6))
Marginal plots¶
In [5]:
Copied!
P.plot("y_bar", "py_bar", ellipse=True)
P.plot("y_bar", "py_bar", ellipse=True)
Combined density and slice plot¶
In [6]:
Copied!
from pmd_beamphysics.plot import density_and_slice_plot
from pmd_beamphysics.plot import density_and_slice_plot
In [7]:
Copied!
P.species
P.species
Out[7]:
'electron'
In [8]:
Copied!
density_and_slice_plot(
P, "t", "energy", stat_keys=["sigma_x", "sigma_y"], n_slice=200, bins=200
)
density_and_slice_plot(
P, "t", "energy", stat_keys=["sigma_x", "sigma_y"], n_slice=200, bins=200
)