Skip to content

Commit

Permalink
Better compute_diagnostics(). Now iterates three times (by default) t…
Browse files Browse the repository at this point in the history
…hrough the timestep, to make sure all subprocess coupling is occurring properly. So now we can finally calculate the instantaneous OLR!
  • Loading branch information
brian-rose committed Feb 26, 2015
1 parent c0a3a0a commit 0c24dff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions climlab/process/time_dependent_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ def step_forward(self):
self.diagnostics.update(proc.diagnostics)
proc._update_time()

def compute_diagnostics(self):
'''Compute all tendencies and diagnostics, but don't update model state.'''
def compute_diagnostics(self, num_iter=3):
'''Compute all tendencies and diagnostics, but don't update model state.
By default it will call step_forward() 3 times to make sure all
subprocess coupling is accounted for. The number of iterations can
be changed with the input argument.'''
# This might create a time problem because it updates the time counter...
this_state = copy.deepcopy(self.state)
self.step_forward()
for name, value in self.state.iteritems():
self.state[name][:] = this_state[name][:]
for n in range(num_iter):
self.step_forward()
for name, value in self.state.iteritems():
self.state[name][:] = this_state[name][:]

def _update_time(self):
'''Increment the timestep counter by one.
Expand Down

0 comments on commit 0c24dff

Please sign in to comment.