Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 18, 2024
1 parent 171ce3c commit 13cd6e4
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/usr/bin/env python3

import sys

import numpy as np
import openpmd_api as io


def load_field_from_iteration(series, iteration : int, field : str, coord : str = None) -> np.ndarray:
def load_field_from_iteration(
series, iteration: int, field: str, coord: str = None
) -> np.ndarray:
"""Load iteration of field data from file."""

it = series.iterations[iteration]
Expand All @@ -16,14 +19,15 @@ def load_field_from_iteration(series, iteration : int, field : str, coord : str
elif coord in [item[0] for item in list(field_obj.items())]:
field_data = field_obj[coord].load_chunk()
else:
raise Exception(f"Specified coordinate: f{coord} is not available for field: f{field}.")
raise Exception(
f"Specified coordinate: f{coord} is not available for field: f{field}."
)
series.flush()

return field_data


def main():

field = "E"
coord = "z"
avg_period_steps = 5
Expand All @@ -43,7 +47,7 @@ def main():

data_inst = np.zeros(shape)

for i in np.arange(avg_output_step-avg_period_steps+1,avg_output_step+1):
for i in np.arange(avg_output_step - avg_period_steps + 1, avg_output_step + 1):
data_inst += load_field_from_iteration(si, i, field, coord)

data_inst = data_inst / avg_period_steps
Expand All @@ -59,4 +63,4 @@ def main():


if __name__ == "__main__":
main()
main()

0 comments on commit 13cd6e4

Please sign in to comment.