diff --git a/documentation/Sphinx/user_guide/output/post-processing.rst b/documentation/Sphinx/user_guide/output/post-processing.rst index 948614ee..6a669f9d 100644 --- a/documentation/Sphinx/user_guide/output/post-processing.rst +++ b/documentation/Sphinx/user_guide/output/post-processing.rst @@ -50,6 +50,9 @@ script, these are given in the table below. * - ``-i/ --input_name`` - vernier-output- - Vernier files to read from + * - ``-d/ --decimals`` + - 3 + - Number of decimal places to report calculated values to * - ``-m/ --max_only`` - False - If used will only calculate maximum values across MPI ranks @@ -59,6 +62,7 @@ script, these are given in the table below. Below is an example of the current script output without additional flags. + .. code-block:: text Routine Mean_Total Min_Total Max_Total Mean_Self Min_Self Max_Self diff --git a/post-processing/post-process.py b/post-processing/post-process.py index ce9db005..6baf32b7 100755 --- a/post-processing/post-process.py +++ b/post-processing/post-process.py @@ -29,11 +29,13 @@ def parse_cli_arguments(input_arguments: list[str] = None, """ parser = argparse.ArgumentParser(description="This script is for merging the outputs from a test that uses Vernier callipers into one file. For full documentation please see the post-processing section of the user guide.") + parser.add_argument("-p", "--path", type=Path, default=(os.getcwd()), help="Path to Vernier output files") parser.add_argument("-o", "--output_name", type=str, default=str("vernier-merged-output"), help="Name of file to write to") parser.add_argument("-i", "--input_name", type=str, default=str("vernier-output-"), help="Vernier files to read from") parser.add_argument("-m", "--max_only", action="store_true", default=False, help="Only calculates the maximum value across all ranks") parser.add_argument("-f", "--full_info", action="store_true", default=False, help="Enables merging and displaying of all information Vernier records") + parser.add_argument("-d", "--decimals", type=int, default=3, help="Number of decimal places calculated results will be reported to") return parser.parse_args(args=input_arguments) @@ -193,8 +195,14 @@ def main(): input_name = args.input_name max_only_bool = args.max_only full_info_bool = args.full_info + decimals = args.decimals + mpiranks = read_mpi_ranks(file_path, input_name) + if decimals >= 4: + + print("WARNING: Vernier typically reports values to 3 d.p, so calculated values may not be accurate or representative at higher precisions and may not display correctly") + if mpiranks == 0: print("Error, no vernier-outputs detected") @@ -209,7 +217,7 @@ def main(): thread_string = "@0" merged_frame["Routine"] = merged_frame["Routine"].str.replace(thread_string, '') - + merged_frame = merged_frame.round(decimals) print("\nWriting...") with open(f"{merged_file_name}", 'w') as f: f.write(merged_frame.to_string(index=False, col_space=10))