Skip to content

Commit

Permalink
better output handling so it's not checking against a list of output …
Browse files Browse the repository at this point in the history
…times
  • Loading branch information
scotthavens committed Aug 4, 2020
1 parent daa60d9 commit 9e526e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions profile/profile_pysnobal.sh
Original file line number Diff line number Diff line change
@@ -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
# kernprof -l profile/profile_pysnobal.py
11 changes: 4 additions & 7 deletions pysnobal/point/snobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9e526e0

Please sign in to comment.