def ebalance(sdat, tstart=None, tend=None):
tseries = sdat.tseries_between(tstart, tend)<EOL>rbot, rtop = misc.get_rbounds(sdat.steps.last)<EOL>if rbot != <NUM_LIT:0>:  <EOL><INDENT>coefsurf = (rtop / rbot)**<NUM_LIT:2><EOL>volume = rbot * ((rtop / rbot)**<NUM_LIT:3> - <NUM_LIT:1>) / <NUM_LIT:3><EOL><DEDENT>else:<EOL><INDENT>coefsurf = <NUM_LIT:1.><EOL>volume = <NUM_LIT:1.><EOL><DEDENT>dtdt, time = dt_dt(sdat, tstart, tend)<EOL>ftop = tseries['<STR_LIT>'].values * coefsurf<EOL>fbot = tseries['<STR_LIT>'].values<EOL>radio = tseries['<STR_LIT>'].values<EOL>ebal = ftop[<NUM_LIT:1>:] - fbot[<NUM_LIT:1>:] + volume * (dtdt - radio[<NUM_LIT:1>:])<EOL>return ebal, time<EOL>
Energy balance.

    Compute Nu_t - Nu_b + V*dT/dt as a function of time using an explicit
    Euler scheme. This should be zero if energy is conserved.

    Args:
        sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
        tstart (float): time at which the computation should start. Use the
            beginning of the time series data if set to None.
        tend (float): time at which the computation should end. Use the
            end of the time series data if set to None.
    Returns:
        tuple of :class:`numpy.array`: energy balance and time arrays.