Skip to content

Commit f10c2e4

Browse files
committed
Add more comments
1 parent 262da3f commit f10c2e4

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

lib/python/picongpu/plugins/plot_mpl/base_visualizer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ class Visualizer(object):
2424
def __init__(self, run_directory):
2525
"""
2626
Initialize the reader and data as member parameters.
27+
28+
Parameters
29+
----------
30+
run_directory : string
31+
path to the run directory of PIConGPU
32+
(the path before ``simOutput/``)
2733
"""
2834
if run_directory is None:
2935
raise ValueError('The run_directory parameter can not be None!')
@@ -46,6 +52,10 @@ def _create_plt_obj(self, ax):
4652
object (or derived classes) which can be updated
4753
by feeding new data into it.
4854
Only called on the first call for visualization.
55+
56+
Parameters
57+
----------
58+
ax: matplotlib.axes.Axes instance
4959
"""
5060
raise NotImplementedError
5161

@@ -60,6 +70,13 @@ def _ax_or_gca(self, ax):
6070
"""
6171
Returns the passed ax if it is not None or the current
6272
matplotlib axes object otherwise.
73+
74+
Parameters
75+
----------
76+
ax: None or matplotlib.axes.Axes instance
77+
Returns
78+
-------
79+
A matplotlib.axes.Axes instance
6380
"""
6481

6582
return ax or plt.gca()

lib/python/picongpu/plugins/plot_mpl/energy_histogram_visualizer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,33 @@ class Visualizer(BaseVisualizer):
1717
"""
1818

1919
def __init__(self, run_directory):
20+
"""
21+
Parameters
22+
----------
23+
run_directory : string
24+
path to the run directory of PIConGPU
25+
(the path before ``simOutput/``)
26+
"""
2027
super(Visualizer, self).__init__(run_directory)
2128

2229
def _create_data_reader(self, run_directory):
30+
"""
31+
Implementation of base class function.
32+
"""
2333
return EnergyHistogram(run_directory)
2434

2535
def _create_plt_obj(self, ax):
36+
"""
37+
Implementation of base class function.
38+
Turns 'self.plt_obj' into a matplotlib.pyplot.plot object.
39+
"""
2640
bins, counts = self.data
2741
self.plt_obj = ax.semilogy(bins, counts, nonposy='clip')[0]
2842

2943
def _update_plt_obj(self):
44+
"""
45+
Implementation of base class function.
46+
"""
3047
bins, counts = self.data
3148
self.plt_obj.set_data(bins, counts)
3249

lib/python/picongpu/plugins/plot_mpl/phase_space_visualizer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ def __init__(self, run_directory):
3434
self.e_mc_r = 1. / (9.1e-31 * 2.9979e8)
3535

3636
def _create_data_reader(self, run_directory):
37+
"""
38+
Implementation of base class function.
39+
"""
3740
return PhaseSpace(run_directory)
3841

3942
def _create_plt_obj(self, ax):
43+
"""
44+
Implementation of base class function.
45+
Turns 'self.plt_obj' into a matplotlib.image.AxesImage object.
46+
"""
4047
dat, meta = self.data
4148
self.plt_obj = ax.imshow(
4249
np.abs(dat).T * meta.dV,
@@ -48,6 +55,9 @@ def _create_plt_obj(self, ax):
4855
)
4956

5057
def _update_plt_obj(self):
58+
"""
59+
Implementation of base class function.
60+
"""
5161
dat, meta = self.data
5262
self.plt_obj.set_data(np.abs(dat).T * meta.dV)
5363

lib/python/picongpu/plugins/plot_mpl/png_visualizer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,23 @@ def __init__(self, run_directory):
2727
super(Visualizer, self).__init__(run_directory)
2828

2929
def _create_data_reader(self, run_directory):
30+
"""
31+
Implementation of base class function.
32+
"""
33+
3034
return PNG(run_directory)
3135

3236
def _create_plt_obj(self, ax):
37+
"""
38+
Implementation of base class function.
39+
Turns 'self.plt_obj' into a matplotlib.image.AxesImage object.
40+
"""
3341
self.plt_obj = ax.imshow(self.data)
3442

3543
def _update_plt_obj(self):
44+
"""
45+
Implementation of base class function.
46+
"""
3647
self.plt_obj.set_data(self.data)
3748

3849
def visualize(self, ax=None, **kwargs):

0 commit comments

Comments
 (0)