Skip to content
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
| mo-marqh | mark Hedley | Met Office | 2026-03-10 |
| oakleybrunt | Oakley Brunt | Met Office | 2026-03-09 |
| EdHone | Ed Hone | Met Office | 2026-03-20 |
| MetBenjaminWent | Benjamin Went | Met Office | 2026-03-25 |
| t00sa | Sam Clarke-Green | Met Office | 2026-03-26 |
6 changes: 3 additions & 3 deletions post-processing/tests/test_cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def setUp(self):
self.test_data_dir = Path(__file__).parent / 'data'
# pylint: disable=line-too-long
self.test_data_kgo = (
'| Routine | Total time (s) | Self (s) | Cumul time (s) | Max no. calls | % time | Time per call (s) |\n' +
'| __test_app__ | 6.3465 | 2.5855 | 4.0895 | 1 | 40.9825 | 6.3465 |\n' +
'| some_process | 2.573 | 2.516 | 3.8075 | 2 | 39.277 | 1.2865 |\n'
'| Routine | Total Mean(s) | Total Min(s) | Total Max(s) | Self Mean(s) | Self Min(s) | Self Max(s) | Cumul time(s) | Max no. calls | % time | Time per call(s) |\n' +
'| __test_app__ | 6.3465 | 5.854 | 6.839 | 2.5855 | 2.583 | 2.588 | 4.0895 | 1 | 40.9825 | 6.3465 |\n' +
'| some_process | 2.573 | 2.077 | 3.069 | 2.516 | 2.023 | 3.009 | 3.8075 | 2 | 39.277 | 1.2865 |\n'
)
return super().setUp()

Expand Down
10 changes: 7 additions & 3 deletions post-processing/tests/test_vernier_calliper.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ def test_reduce(self):
reduced_data = self.calliper_a.reduce()
self.assertEqual(reduced_data[0], "test_calliper_a")
self.assertEqual(reduced_data[1], 30.0)
self.assertEqual(reduced_data[2], 10.0)
self.assertEqual(reduced_data[2], 25.0)
self.assertEqual(reduced_data[3], 35.0)
self.assertEqual(reduced_data[4], 2)
self.assertEqual(reduced_data[5], 15.0)
self.assertEqual(reduced_data[4], 10.0)
self.assertEqual(reduced_data[5], 5.0)
self.assertEqual(reduced_data[6], 15.0)
self.assertEqual(reduced_data[7], 35.0)
self.assertEqual(reduced_data[8], 2)
self.assertEqual(reduced_data[9], 15.0)
self.assertEqual(reduced_data[10], 15.0)

def test_compare(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions post-processing/tests/test_vernier_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def test_write_txt_output_file(self):
self.test_data.write_txt_output(Path(tmp_file.name))
contents = Path(tmp_file.name).read_text().splitlines()
# pylint: disable=line-too-long
self.assertEqual("| Routine | Total time (s) | Self (s) | Cumul time (s) | Max no. calls | % time | Time per call (s) |", contents[0])
self.assertEqual("| test_calliper | 30.0 | 10.0 | 35.0 | 2 | 15.0 | 15.0 |", contents[1])
self.assertEqual("| Routine | Total Mean(s) | Total Min(s) | Total Max(s) | Self Mean(s) | Self Min(s) | Self Max(s) | Cumul time(s) | Max no. calls | % time | Time per call(s) |", contents[0])
self.assertEqual("| test_calliper | 30.0 | 25.0 | 35.0 | 10.0 | 5.0 | 15.0 | 35.0 | 2 | 15.0 | 15.0 |", contents[1])

def test_write_txt_output_terminal(self):
"""
Expand All @@ -205,8 +205,8 @@ def test_write_txt_output_terminal(self):
sys.stdout = sys.__stdout__

# pylint: disable=line-too-long
self.assertEqual("| Routine | Total time (s) | Self (s) | Cumul time (s) | Max no. calls | % time | Time per call (s) |", write_output.getvalue().splitlines()[0])
self.assertEqual("| test_calliper | 35.0 | 3.5 | 11.0 | 2 | 45.0 | 17.5 |", write_output.getvalue().splitlines()[1])
self.assertEqual("| Routine | Total Mean(s) | Total Min(s) | Total Max(s) | Self Mean(s) | Self Min(s) | Self Max(s) | Cumul time(s) | Max no. calls | % time | Time per call(s) |", write_output.getvalue().splitlines()[0])
self.assertEqual("| test_calliper | 35.0 | 15.0 | 55.0 | 3.5 | 3.0 | 4.0 | 11.0 | 2 | 45.0 | 17.5 |", write_output.getvalue().splitlines()[1])

def test_aggregate(self):
"""
Expand Down
27 changes: 15 additions & 12 deletions post-processing/vernier/lib/vernier_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __len__(self):
"""
result = None
if (len(self.time_percent) == len(self.cumul_time) ==
len(self.self_time) == len(self.total_time) == len(self.n_calls)):
len(self.self_time) == len(self.total_time) == len(self.n_calls)):
result = len(self.time_percent)
return result

Expand Down Expand Up @@ -140,19 +140,23 @@ def reduce(self) -> list:

"""
return [
self.name, # calliper name
round(np.mean(self.total_time), 5), # mean total time across calls
round(np.mean(self.self_time), 5), # mean self time across calls
round(np.mean(self.cumul_time), 5), # mean cumulative time across calls
self.n_calls[0], # number of calls (should be the same for all entries, so just take the first)
round(np.mean(self.time_percent), 5), # mean percentage of time across calls
round(np.mean(np.array(self.total_time) / np.array(self.n_calls)), 5) # mean time per call
self.name, # calliper name
round(np.mean(self.total_time), 5), # mean total time across calls
round(np.min(self.total_time), 5), # min total time across calls
round(np.max(self.total_time), 5), # max total time across calls
round(np.mean(self.self_time), 5), # mean self time across calls
round(np.min(self.self_time), 5), # min self time across calls
round(np.max(self.self_time), 5), # max self time across calls
round(np.mean(self.cumul_time), 5), # mean cumulative time across calls
self.n_calls[0], # number of calls (should be the same for all entries, so just take the first)
round(np.mean(self.time_percent), 5), # mean percentage of time across calls
round(np.mean(np.array(self.total_time) / np.array(self.n_calls)), 5) # mean time per call
]

@classmethod
def labels(self):
return ["Routine", "Total time (s)", "Self (s)", "Cumul time (s)",
"Max no. calls", "% time", "Time per call (s)"]
return ["Routine", "Total Mean(s)", "Total Min(s)", "Total Max(s)", "Self Mean(s)", "Self Min(s)", "Self Max(s)", "Cumul time(s)",
"Max no. calls", "% time", "Time per call(s)"]


class VernierData():
Expand Down Expand Up @@ -240,7 +244,7 @@ def write_txt_output(self, txt_path: Optional[Path] = None):
out = open(txt_path, 'w')

for row in txt_table:
out.write('| {:>{}} | {:>14} | {:>12} | {:>14} | {:>13} | {:>8} | {:>17} |\n'.format(row[0], max_calliper_len, *row[1:]))
out.write('| {:>{}} | {:>14} | {:>14} | {:>14} | {:>14} | {:>14} | {:>12} | {:>14} | {:>13} | {:>8} | {:>17} |\n'.format(row[0], max_calliper_len, *row[1:]))

if txt_path is not None:
out.close()
Expand Down Expand Up @@ -328,7 +332,6 @@ def aggregate(self, vernier_data_list=None, internal_consistency=True):
self.data[calliper].thread.extend(vernier_data.data[calliper].thread)



class VernierDataCollation():
"""
Class to hold an collation of VernierData instances.
Expand Down
Loading