11#!/usr/bin/env python3
22
3+ import os
4+ import re
35import sys
46
57import numpy as np
68import openpmd_api as io
79
10+ sys .path .insert (1 , "../../../../warpx/Regression/Checksum/" )
11+ from checksumAPI import evaluate_checksum
12+
13+
14+ def analyze_openpmd_regression (output_file ):
15+ # Run checksum regression test
16+ if re .search ("single_precision" , output_file ):
17+ evaluate_checksum (
18+ test_name = test_name ,
19+ output_file = output_file ,
20+ output_format = "openpmd" ,
21+ rtol = 2e-6 ,
22+ )
23+ else :
24+ evaluate_checksum (
25+ test_name = test_name ,
26+ output_file = output_file ,
27+ output_format = "openpmd" ,
28+ )
29+
830
931def load_field_from_iteration (
1032 series , iteration : int , field : str , coord : str = None
@@ -27,15 +49,15 @@ def load_field_from_iteration(
2749 return field_data
2850
2951
30- def main ():
52+ def compare_time_avg_with_instantaneous_diags (dir_inst : str , dir_avg : str ):
53+ """Compare instantaneous data (multiple iterations averaged in post-processing) with in-situ averaged data."""
54+
3155 field = "E"
3256 coord = "z"
3357 avg_period_steps = 5
3458 avg_output_step = 100
3559
36- path_tpl_inst = "diags/diagInst/openpmd_%T.h5"
37-
38- dir_avg = sys .argv [1 ]
60+ path_tpl_inst = f"{ dir_inst } /openpmd_%T.h5"
3961 path_tpl_avg = f"{ dir_avg } /openpmd_%T.h5"
4062
4163 si = io .Series (path_tpl_inst , io .Access .read_only )
@@ -63,4 +85,18 @@ def main():
6385
6486
6587if __name__ == "__main__" :
66- main ()
88+
89+ test_name = os .path .split (os .getcwd ())[1 ]
90+ inst_output_file = sys .argv [1 ]
91+
92+ # Regression checksum test
93+ # NOTE: works only in the example directory due to relative path import
94+ analyze_openpmd_regression (inst_output_file )
95+
96+ # TODO: implement intervals parser for PICMI that allows more complex output periods
97+ if "picmi" not in test_name :
98+ # Functionality test for TimeAveragedDiagnostics
99+ compare_time_avg_with_instantaneous_diags (
100+ dir_inst = sys .argv [1 ],
101+ dir_avg = "diags/diagTimeAvg/" ,
102+ )
0 commit comments