Skip to content

Commit 4448dae

Browse files
authored
Merge pull request #52 from picmi-standard/make_data_list_none
In the diagnostics, data_list defaults to None
2 parents 985cbac + b62a059 commit 4448dae

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

PICMI_Python/diagnostics.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class PICMI_FieldDiagnostic(_ClassWithInit):
1515
Defines the electromagnetic field diagnostics in the simulation frame
1616
- grid: Grid object for the diagnostic
1717
- period: Period of time steps that the diagnostic is performed
18-
- data_list: List of quantities to write out. Possible values 'rho', 'E', 'B', 'J', 'Ex' etc.
18+
- data_list=None: List of quantities to write out. Possible values 'rho', 'E', 'B', 'J', 'Ex' etc.
19+
Defaults to the output list of the implementing code.
1920
- write_dir='.': Directory where data is to be written
2021
- step_min=None: Minimum step at which diagnostics could be written (optional)
2122
Defaults to step 0.
@@ -31,7 +32,7 @@ class PICMI_FieldDiagnostic(_ClassWithInit):
3132
- name: Sets the base name for the diagnostic output files (optional)
3233
3334
"""
34-
def __init__(self, grid, period, data_list,
35+
def __init__(self, grid, period, data_list=None,
3536
write_dir = None,
3637
step_min = None,
3738
step_max = None,
@@ -42,7 +43,8 @@ def __init__(self, grid, period, data_list,
4243
name = None,
4344
**kw):
4445

45-
assert isinstance(data_list, list), 'FieldDiagnostic: data_list must be a list'
46+
if data_list is not None:
47+
assert isinstance(data_list, list), 'FieldDiagnostic: data_list must be a list'
4648

4749
self.grid = grid
4850
self.period = period
@@ -64,7 +66,8 @@ class PICMI_ElectrostaticFieldDiagnostic(_ClassWithInit):
6466
Defines the electrostatic field diagnostics in the simulation frame
6567
- grid: Grid object for the diagnostic
6668
- period: Period of time steps that the diagnostic is performed
67-
- data_list: List of quantities to write out. Possible values 'rho', 'E', 'B', 'Ex' etc.
69+
- data_list=None: List of quantities to write out. Possible values 'rho', 'E', 'B', 'Ex' etc.
70+
Defaults to the output list of the implementing code.
6871
- write_dir='.': Directory where data is to be written
6972
- step_min=None: Minimum step at which diagnostics could be written (optional)
7073
Defaults to step 0.
@@ -79,7 +82,7 @@ class PICMI_ElectrostaticFieldDiagnostic(_ClassWithInit):
7982
- parallelio=None: If set to True, field diagnostics are dumped in parallel (optional)
8083
- name: Sets the base name for the diagnostic output files (optional)
8184
"""
82-
def __init__(self, grid, period, data_list,
85+
def __init__(self, grid, period, data_list=None,
8386
write_dir = None,
8487
step_min = None,
8588
step_max = None,
@@ -90,7 +93,8 @@ def __init__(self, grid, period, data_list,
9093
name = None,
9194
**kw):
9295

93-
assert isinstance(data_list, list), 'ElectrostaticFieldDiagnostic: data_list must be a list'
96+
if data_list is not None:
97+
assert isinstance(data_list, list), 'ElectrostaticFieldDiagnostic: data_list must be a list'
9498

9599
self.grid = grid
96100
self.period = period
@@ -113,7 +117,8 @@ class PICMI_ParticleDiagnostic(_ClassWithInit) :
113117
- period: Period of time steps that the diagnostic is performed
114118
- species: Species or list of species to write out
115119
Note that the name attribute must be defined for the species.
116-
- data_list: The data to be written out. Possible values 'position', 'momentum', 'weighting'.
120+
- data_list=None: The data to be written out. Possible values 'position', 'momentum', 'weighting'.
121+
Defaults to the output list of the implementing code.
117122
- write_dir='.': Directory where data is to be written
118123
- step_min=None: Minimum step at which diagnostics could be written (optional)
119124
Defaults to step 0.
@@ -123,15 +128,16 @@ class PICMI_ParticleDiagnostic(_ClassWithInit) :
123128
- name: Sets the base name for the diagnostic output files (optional)
124129
"""
125130

126-
def __init__(self, period, species, data_list,
131+
def __init__(self, period, species, data_list=None,
127132
write_dir = None,
128133
step_min = None,
129134
step_max = None,
130135
parallelio = None,
131136
name = None,
132137
**kw):
133138

134-
assert isinstance(data_list, list), 'ParticleDiagnostic: data_list must be a list'
139+
if data_list is not None:
140+
assert isinstance(data_list, list), 'ParticleDiagnostic: data_list must be a list'
135141

136142
self.period = period
137143
self.species = species
@@ -156,21 +162,23 @@ class PICMI_LabFrameFieldDiagnostic(_ClassWithInit):
156162
- grid: Grid object for the diagnostic
157163
- num_snapshots: Number of lab frame snapshots to make
158164
- dt_snapshots: Time between each snapshot in lab frame
159-
- data_list: List of quantities to write out. Possible values 'rho', 'E', 'B', 'J', 'Ex' etc.
165+
- data_list=None: List of quantities to write out. Possible values 'rho', 'E', 'B', 'J', 'Ex' etc.
166+
Defaults to the output list of the implementing code.
160167
- z_subsampling=1: A factor which is applied on the resolution of the lab frame reconstruction. (integer)
161168
- time_start=0.: Time for the first snapshot in lab frame
162169
- write_dir='.': Directory where data is to be written
163170
- parallelio=None: If set to True, field diagnostics are dumped in parallel (optional)
164171
- name: Sets the base name for the diagnostic output files (optional)
165172
"""
166-
def __init__(self, grid, num_snapshots, dt_snapshots, data_list,
173+
def __init__(self, grid, num_snapshots, dt_snapshots, data_list=None,
167174
z_subsampling = 1, time_start = 0.,
168175
write_dir = None,
169176
parallelio = None,
170177
name = None,
171178
**kw):
172179

173-
assert isinstance(data_list, list), 'LabFrameFieldDiagnostic: data_list must be a list'
180+
if data_list is not None:
181+
assert isinstance(data_list, list), 'LabFrameFieldDiagnostic: data_list must be a list'
174182

175183
self.grid = grid
176184
self.num_snapshots = num_snapshots
@@ -191,23 +199,25 @@ class PICMI_LabFrameParticleDiagnostic(_ClassWithInit):
191199
- grid: Grid object for the diagnostic
192200
- num_snapshots: Number of lab frame snapshots to make
193201
- dt_snapshots: Time between each snapshot in lab frame
194-
- data_list: The data to be written out. Possible values 'position', 'momentum', 'weighting'.
202+
- data_list=None: The data to be written out. Possible values 'position', 'momentum', 'weighting'.
203+
Defaults to the output list of the implementing code.
195204
- time_start=0.: Time for the first snapshot in lab frame
196205
- species: Species or list of species to write out
197206
Note that the name attribute must be defined for the species.
198207
- write_dir='.': Directory where data is to be written
199208
- parallelio=None: If set to True, particle diagnostics are dumped in parallel (optional)
200209
- name: Sets the base name for the diagnostic output files (optional)
201210
"""
202-
def __init__(self, grid, num_snapshots, dt_snapshots, data_list,
211+
def __init__(self, grid, num_snapshots, dt_snapshots, data_list=None,
203212
time_start = 0.,
204213
species = None,
205214
write_dir = None,
206215
parallelio = None,
207216
name = None,
208217
**kw):
209218

210-
assert isinstance(data_list, list), 'LabFrameParticleDiagnostic: data_list must be a list'
219+
if data_list is not None:
220+
assert isinstance(data_list, list), 'LabFrameParticleDiagnostic: data_list must be a list'
211221

212222
self.grid = grid
213223
self.num_snapshots = num_snapshots

0 commit comments

Comments
 (0)