From e4636e5fe6a4c84d3ce6b10c2df7769ab067a6f5 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Wed, 5 Apr 2023 15:51:30 +0200 Subject: [PATCH] interesting times to be proportional to the simulation time --- caimira/apps/calculator/report_generator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/caimira/apps/calculator/report_generator.py b/caimira/apps/calculator/report_generator.py index 39919fac..fa495999 100644 --- a/caimira/apps/calculator/report_generator.py +++ b/caimira/apps/calculator/report_generator.py @@ -80,10 +80,11 @@ def non_temp_transition_times(model: models.ExposureModel): return sorted(time for time in change_times if (t_start <= time <= t_end)) -def interesting_times(model: models.ExposureModel, approx_n_pts=100) -> typing.List[float]: +def interesting_times(model: models.ExposureModel, approx_n_pts: typing.Optional[int] = None) -> typing.List[float]: """ Pick approximately ``approx_n_pts`` time points which are interesting for the - given model. + given model. If not provided by argument, ``approx_n_pts`` is set to be 25 times + the number of hours of the simulation. Initially the times are seeded by important state change times (excluding outside temperature), and the times are then subsequently expanded to ensure @@ -91,10 +92,12 @@ def interesting_times(model: models.ExposureModel, approx_n_pts=100) -> typing.L """ times = non_temp_transition_times(model) + sim_duration = max(times) - min(times) + if not approx_n_pts: approx_n_pts = sim_duration * 25 # Expand the times list to ensure that we have a maximum gap size between # the key times. - nice_times = fill_big_gaps(times, gap_size=(max(times) - min(times)) / approx_n_pts) + nice_times = fill_big_gaps(times, gap_size=(sim_duration) / approx_n_pts) return nice_times