From 96fc2c87f224553f6cd7a7354ba66e0b44a6f6da Mon Sep 17 00:00:00 2001 From: AngelFP Date: Tue, 7 Apr 2020 18:30:25 +0200 Subject: [PATCH] Add more OpenPMD particle components to read --- visualpic/data_reading/particle_readers.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/visualpic/data_reading/particle_readers.py b/visualpic/data_reading/particle_readers.py index 64620cfe..0aed072a 100644 --- a/visualpic/data_reading/particle_readers.py +++ b/visualpic/data_reading/particle_readers.py @@ -153,7 +153,10 @@ def __init__(self, *args, **kwargs): 'pz': 'momentum/z', 'px': 'momentum/x', 'py': 'momentum/y', - 'q': 'charge'} + 'q': 'charge', + 'm': 'mass', + 'tag': 'id', + 'w': 'weighting'} return super().__init__(*args, **kwargs) def _read_component_data(self, file_path, species, component): @@ -179,6 +182,12 @@ def _read_component_data(self, file_path, species, component): data = beam_species[component_to_read].attrs['value'] w = beam_species['weighting'][:] data = data * w + elif component_to_read == 'mass': + data = beam_species[component_to_read].attrs['value'] + w = beam_species['weighting'][:] + data = data * w + else: + data = beam_species[component_to_read][:] return data def _read_component_metadata(self, file_path, species, component): @@ -193,6 +202,10 @@ def _read_component_metadata(self, file_path, species, component): metadata['units'] = 'm_e*c' elif component_to_read == 'charge': metadata['units'] = 'C' + elif component_to_read == 'mass': + metadata['units'] = 'kg' + else: + metadata['units'] = '' metadata['time'] = {} metadata['time']['value'] = t metadata['time']['units'] = 's'