Skip to content

Commit

Permalink
Merge branch 'feature/proportional_interesting_times' into 'master'
Browse files Browse the repository at this point in the history
Interesting times to be proportional to the simulation time

Closes #320

See merge request caimira/caimira!437
  • Loading branch information
lrdossan committed Apr 26, 2023
2 parents be42dfe + f0a8753 commit 7ab8cd0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions caimira/apps/calculator/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,24 @@ def walk_model(model, name=""):
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 15 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
that the step size is at most ``(t_end - t_start) / approx_n_pts``.
"""
times = non_temp_transition_times(model)
sim_duration = max(times) - min(times)
if not approx_n_pts: approx_n_pts = sim_duration * 15

# 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


Expand Down

0 comments on commit 7ab8cd0

Please sign in to comment.