Field-over-dt diagnostic
Divides any input field by the model timestep dt = t_current − t_start_of_step.
This is useful for converting accumulated differences into per-second rates.
Configuration
Request the expression X.over_dt():
field_names:
- X_rate := X.over_dt()
The output field has the same layout and grid as X, with units [X_units / s].
Behavior
- At the start of each timestep (
init_timestep), the start-of-step timestamp is saved internally. - At evaluation time (
compute_diagnostic),dtis computed as the difference between the field's current timestamp and the saved start timestamp (in seconds). - The output is
X / dtelement-wise. - Before
init_timestephas ever been called, the output is filled with the standard EAMxx fill value (constants::fill_value<Real>). Note this does NOT cover the case whereinit_timestepHAS been called but no time has elapsed since: theredtis zero, which is an error rather than a fill value (see the caveats below).
Example: atmospheric backward tendency
field_names:
- T_tend := (T_mid-T_mid.shift(time=1)).over_dt()
This composes three diagnostics:
T_mid.shift(time=1)—FieldPrev: value ofT_midat the start of the stepT_mid-T_mid.shift(time=1)—BinaryOp: difference(..).over_dt()—FieldOverDt: rate
The shorthand T_mid.tend() expands to the same expression.
Caveats
dtmust be strictly positive; a zero or negative timestep triggers a runtime error.- This diagnostic cannot be written to an
instantoutput stream. An instant stream takes a snapshot att0, before the first step has run, sodtis zero and the run aborts with "dt must be positive". Use an averaged stream (averaging_type: average,max,min) instead. The same applies to everything built on top of it, includingX.tend(). - Only fields with
Realdata type are supported. dtis not a field or constant:X/dtdoes not work, useX.over_dt().