Skip to content

Commit 96fc2c8

Browse files
committed
Add more OpenPMD particle components to read
1 parent 0aab813 commit 96fc2c8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

visualpic/data_reading/particle_readers.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def __init__(self, *args, **kwargs):
153153
'pz': 'momentum/z',
154154
'px': 'momentum/x',
155155
'py': 'momentum/y',
156-
'q': 'charge'}
156+
'q': 'charge',
157+
'm': 'mass',
158+
'tag': 'id',
159+
'w': 'weighting'}
157160
return super().__init__(*args, **kwargs)
158161

159162
def _read_component_data(self, file_path, species, component):
@@ -179,6 +182,12 @@ def _read_component_data(self, file_path, species, component):
179182
data = beam_species[component_to_read].attrs['value']
180183
w = beam_species['weighting'][:]
181184
data = data * w
185+
elif component_to_read == 'mass':
186+
data = beam_species[component_to_read].attrs['value']
187+
w = beam_species['weighting'][:]
188+
data = data * w
189+
else:
190+
data = beam_species[component_to_read][:]
182191
return data
183192

184193
def _read_component_metadata(self, file_path, species, component):
@@ -193,6 +202,10 @@ def _read_component_metadata(self, file_path, species, component):
193202
metadata['units'] = 'm_e*c'
194203
elif component_to_read == 'charge':
195204
metadata['units'] = 'C'
205+
elif component_to_read == 'mass':
206+
metadata['units'] = 'kg'
207+
else:
208+
metadata['units'] = ''
196209
metadata['time'] = {}
197210
metadata['time']['value'] = t
198211
metadata['time']['units'] = 's'

0 commit comments

Comments
 (0)