From 315634f64ac695f12aaa537f0af96e78364463ea Mon Sep 17 00:00:00 2001 From: OwenSelevert <68349996+OwenSlevert@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:45:54 +0200 Subject: [PATCH] smilei reader: add the possibility to process real fields (#287) Add the possibility to process real fields The field of the laser envelope is real without imaginary part, therefore the structure of the hdf5 file is slightly different. With this small adjustment of getExpanded it is now possible to also process the real fields of Laser Envelope. --- postpic/datareader/smileih5.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postpic/datareader/smileih5.py b/postpic/datareader/smileih5.py index e0a4a7c..b2cf68d 100644 --- a/postpic/datareader/smileih5.py +++ b/postpic/datareader/smileih5.py @@ -216,9 +216,14 @@ def _getExpanded(self, key, theta=0): field_name = key+"_mode_"+str(mode) field_array = np.array(self._data[field_name]) - field_array_shape = field_array.shape - reshaped_array = field_array.reshape(field_array_shape[0], field_array_shape[1]//2, 2) - complex_array = reshaped_array[:, :, 0] + 1j * reshaped_array[:, :, 1] + # The Envelope Fields are real without imaginary part. + if key.startswith('Env_'): + complex_array = field_array + else: + field_array_shape = field_array.shape + reshaped_array = field_array.reshape(field_array_shape[0], + field_array_shape[1]//2, 2) + complex_array = reshaped_array[:, :, 0] + 1j * reshaped_array[:, :, 1] array_list.append(complex_array) # Modified array of shape (Nmodes, Nx, Nr)