From 9e526e0d70eadf65f39c99ff5390bd090e1e3bcd Mon Sep 17 00:00:00 2001 From: Scott Havens Date: Tue, 4 Aug 2020 16:29:44 -0600 Subject: [PATCH] better output handling so it's not checking against a list of output times --- profile/profile_pysnobal.sh | 4 ++-- pysnobal/point/snobal.py | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/profile/profile_pysnobal.sh b/profile/profile_pysnobal.sh index c58f5be..ac2a6a2 100644 --- a/profile/profile_pysnobal.sh +++ b/profile/profile_pysnobal.sh @@ -1,3 +1,3 @@ -# pyinstrument -r html -o profile/pysnobal_profile.html profile/profile_pysnobal.py +pyinstrument -r html -o profile/pysnobal_profile.html profile/profile_pysnobal.py -kernprof -l profile/profile_pysnobal.py \ No newline at end of file +# kernprof -l profile/profile_pysnobal.py \ No newline at end of file diff --git a/pysnobal/point/snobal.py b/pysnobal/point/snobal.py index 98cb896..4a4c7bf 100644 --- a/pysnobal/point/snobal.py +++ b/pysnobal/point/snobal.py @@ -52,10 +52,6 @@ def __init__(self, params, tstep_info, snow_prop, meas_heights, self.output_divided = False if self.output_timesteps is None: self.output_divided = True - self.output_timesteps_epoch = [] - else: - self.output_timesteps_epoch = [ - t.value // 10**9 for t in output_timesteps] self.P_a = libsnobal.hysat( SEA_LEVEL, @@ -213,6 +209,9 @@ def divide_tstep(self): if not self.do_tstep(curr_lvl_tstep): return False + if self.current_level == 0 and not self.output_divided: + self.output() + self.current_level -= 1 self.next_level -= 1 @@ -282,11 +281,9 @@ def do_tstep(self, tstep): self.current_time = self.current_time + self.time_step self.current_datetime = self.current_datetime + \ tstep['time_step_timedelta'] - self.current_datetime_epoch = self.current_datetime.value // 10**9 # output if on the whole timestep - if self.output_divided or \ - self.current_datetime_epoch in self.output_timesteps_epoch: + if self.output_divided: self.output() # Update the model's input parameters