Skip to content
Snippets Groups Projects
Commit bb777c1a authored by Watanyu Foosang's avatar Watanyu Foosang Committed by Gamelin Alexis
Browse files

Add a simple plot method to Bunch class

Phase space plotting method was added
parent e6ad76ba
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,15 @@ Module where particles, bunches and beams are described as objects. ...@@ -4,13 +4,15 @@ Module where particles, bunches and beams are described as objects.
@author: Alexis Gamelin @author: Alexis Gamelin
@date: 11/03/2020 @date: 11/03/2020
""" """
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt
from tracking.parallel import Mpi from tracking.parallel import Mpi
import seaborn as sns
from scipy.constants import c, m_e, m_p, e from scipy.constants import c, m_e, m_p, e
import matplotlib.pyplot as plt
class Particle: class Particle:
""" """
...@@ -319,6 +321,26 @@ class Bunch: ...@@ -319,6 +321,26 @@ class Bunch:
ax = fig.gca() ax = fig.gca()
ax.plot(bins.mid, profile) ax.plot(bins.mid, profile)
def getplot(self,x,y,p_type):
"""
Plot the parameters from particles object.
Parameters
----------
x: str, name from Bunch object to plot on hor. axis.
y: str, name from Bunch object to plot on ver. axis.
p_type: str, "sc" for a scatter plot or "j" for a joint plot.
"""
x = self.particles[x]
y = self.particles[y]
if p_type == "sc":
plt.scatter(x,y)
elif p_type == "j":
sns.jointplot(x,y,kind="kde")
class Beam: class Beam:
""" """
Define a Beam object composed of several Bunch objects. Define a Beam object composed of several Bunch objects.
...@@ -578,4 +600,4 @@ class Beam: ...@@ -578,4 +600,4 @@ class Beam:
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment