def calc_storage(area, infiltration, storage, flowrate, dt=86400):
    """
    Explicitly solves for the future storage in a layer for each subbasin by
    rearranging the equation:

    dS/dt = I - (Q/area)

    into the following equation:

    S_t1 = (I - Q/area) * dt + S_t

    Where S_t1 is Storage @ time=t+dt, S_t is Storage @ time=t,
    dt is the time step in seconds, Q is flowrate, I is infiltation, and area
    is the subbasin area.

    Args:
        area:
        infiltration: pandas.Series of infiltration at the current timestep
        storage: pandas.Series for storage at the current timestep
        flowrate: pandas.Series for flowrate at the current timestep
        dt: timestep in seconds

    Returns:
        future_storage: pandas.Series of the storage for the next timestep
    """
    future_storage = (infiltration - flowrate / area) * dt + storage
    return future_storage
