Existence of Locally (Lebesgue-)Integrable Function Given a locally integrable function $f: \mathbb R_{\geq0} \rightarrow \mathbb R_{\geq0}$, I wonder whether there exists an equivalent function that operates at a certain capacity $\nu\in\mathbb R_{>0}$.
More specifically, I would like to show the existence of a (measurable) function $g: \mathbb R_{\geq 0} \rightarrow \mathbb R_{\geq0}$ that fulfills the following two conditions for almost all $t\in\mathbb R_{\geq0}$:
(1) $g(t)\leq \nu$
(2)
$$ g(t) = \begin{cases}
  \nu, &\text{if } q(t) := \int_{0}^t f - g \, \mathrm{d}\lambda > 0,\\
  f(t), &\text{otherwise.}
 \end{cases} $$
It seems quite obvious, that such a function should exist, as the condition "$\int_{0}^t f - g \, \mathrm{d}\lambda > 0$" to determine $g(t)$ only depends on "the past" of $g$, i.e. only on $g\vert_{(0,t)}$.
Nevertheless, I lack a formal proof of the existence of $g$.
One idea I had was to first show the statement for simple functions, i.e. $f = \sum_{i=1}^k a_k \mathbf{1}_{A_k}$ for measurable sets $A_k$ and $a_k > 0$ and then use an approximation using only simple functions.
Nevertheless, I got stuck here. Maybe someone else has an idea or a proof sketch?
Is it even impossible to do for some integrable functions $f$?
 A: It is worth mentioning that the origin of the question lies in queue dynamics of dynamic flows (also called flows over time) with the so-called Vickrey's deterministic fluid queuing.
More specifically, I found an answer in the paper [1, Section 2.2] of Cominetti, Correa und Larré.
I worked out the relevant proofs in the following.
It has proven beneficial to first analyze the uniqueness of the queue function $q(t):= \int_0^t f - g \,\mathrm{d}\lambda$.
Claim 1. Given a function $g$ fulfilling (1) and (2) a.e., the queue function is of the form $$q(t) = \max_{u\in[0,t]} \int_u^t f - \nu \, \mathrm d\lambda.$$
Proof.
We first show, that $q$ is never negative.
Assume the contrary and let $t>0$ fulfill $q(t) < 0$.
Choose $u^* := \max\{u\leq t \,\vert\, q(u) = 0 \}$ to be the latest time before $t$ at which the queue was zero.
By the continuity of $q$ we know that $q$ is strictly negative on $(u^*, t]$.
Thus using property (2) we get $$q(t) = \int_0^t f - g \,\mathrm d\lambda = \int_0^{u^*} f - g \,\mathrm d\lambda + \int_{u^*}^t f - f \,\mathrm d\lambda = q(u^{*})=0,$$
a contradiction.
Now, we focus on the statement of the claim. Let $t\in \mathbb R$ and let us define $u^* := \max\{u\leq t \,\vert\, q(u) = 0 \}$ again to be the latest time before $t$ at which the queue is empty.
Then by definition we have $q(u) > 0$ for all $u\in(u^*, t]$ and hence (2) implies $g(u) = \nu$ for almost all $u\in(u^*, t]$.
This shows $$q(t) = \int_0^{u^*} f - g \,\mathrm d\lambda + \int_{u^*}^t f - g \,\mathrm{d}\lambda = q(u^*) - \int_{u^*}^t f - \nu \,\mathrm{d}\lambda =  \int_{u^*}^t f - \nu \,\mathrm{d}\lambda.$$
It remains to show, that $\int_u^t f - \nu \,\mathrm d\lambda \leq q(t)$ holds for any other $u\in[0,t]$.
If $u\leq u^*$, then (1) implies $$\int_u^t f - \nu \,\mathrm d\lambda\leq \int_u^t f - g\,\mathrm d\lambda = q(t) - q(u) \leq q(t).$$
If $u > u^*$, we use (2) and get $$\int_u^t f - \nu \,\mathrm d\lambda = q(t) - \int_{u^*}^{u}f - \nu \,\mathrm d\lambda - q(u^*) = q(t) - q(u) \leq q(t). $$
$\square$
Note: We haven't used that $\nu$ is constant. Instead it could be any locally integrable function.

Claim 2. The function $q(t) := \max_{u\in[0,t]} \int_u^t f - \nu \, \mathrm d\lambda$ is almost everywhere differentiable with $$
q'(t) = \begin{cases}
  f(t) - \nu, &\text{if } q(t) > 0,\\
  0, &\text{otherwise}.
\end{cases}
$$
Moreover, we have $f(t) \leq \nu(t)$ for almost all $t$ with $q(t)=0$.
I refer to this answer for a worked out proof.
The "Moreover"-part is proven here.
Note: We could replace $\nu$ by any non-negative locally integrable function.

Final Claim. Given a locally integrable function $f:\mathbb R_{\geq 0}\rightarrow \mathbb R_{\geq0}$, there exists a locally integrable $g: \mathbb R_{\geq 0}\rightarrow \mathbb R_{\geq0}$ fulfilling (1) and (2) a.e..
Moreover, $g$ is unique up to a null set.
Proof.
We first define $q(t) := \max_{u\in[0,t]} \int_u^t f - \nu \,\mathrm d \lambda$.
We define $g(t) := f(t) - q'(t)$ wherever $q'(t)$ is defined, and $g(t):=0$ elsewhere.
Then, we have $q(t) = \int_0^t f - g \,\mathrm d\lambda$ and $g$ automatically fulfills (2) a.e. by Claim 2.
It remains to show, that $g(t)\leq \nu$ almost everywhere. For $q(t) > 0$, this is given by (2) already.
For $q(t)=0$ this follows from Claim 2.
Now assume there is another function $h$ fulfilling (1) and (2) almost everywhere. By Claim 1 we have $$\int_0^t f - g \,\mathrm d\lambda = \max_{u\in[0,t]} \int_u^t f -\nu \,\mathrm d\lambda = \int_0^t f -h \,\mathrm d\lambda.$$
for any $t\geq 0$. Hence $g$ and $h$ coincide almost everywhere.
$\square$
Note: We haven't used that $\nu$ is constant. Instead it could be any locally integrable function.

References
[1] "Dynamic Equilibria in Fluid Queuing Networks" by Roberto Cominetti, José R. Correa, Omar Larré. Available at arXiv:1401.6914 [math.OC].
