Skip to content

Commit 3e928f4

Browse files
Adjust the DQM formula (#107)
1 parent 19bdbfa commit 3e928f4

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-13
lines changed

cmethods/distribution.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,8 @@ def detrended_quantile_mapping(
144144
m_simp_mean = np.nanmean(m_simp)
145145

146146
if kind in ADDITIVE:
147-
epsilon = np.interp(
148-
m_simp - m_simp_mean + m_simh_mean,
149-
xbins,
150-
cdf_simh,
151-
) # Eq. 1
152-
X = get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean - m_simh_mean # Eq. 1
147+
epsilon = np.interp(m_simp - m_simp_mean, xbins, cdf_simh) # Eq. 1
148+
X = get_inverse_of_cdf(cdf_obs, epsilon, xbins) + m_simp_mean # Eq. 1
153149

154150
else: # kind in cls.MULTIPLICATIVE:
155151
epsilon = np.interp( # Eq. 2

doc/methods.rst

+47-7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ for both additive and multiplicative Linear Scaling are shown:
5555
5656
X^{*LS}_{sim,p}(i) = X_{sim,p}(i) + \mu_{m}(X_{obs,h}(i)) - \mu_{m}(X_{sim,h}(i))
5757
58+
where:
59+
60+
.. math::
61+
62+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
63+
5864
**Multiplicative**:
5965

6066
The multiplicative Linear Scaling differs from the additive variant in such
@@ -64,6 +70,12 @@ for both additive and multiplicative Linear Scaling are shown:
6470
6571
X^{*LS}_{sim,h}(i) = X_{sim,h}(i) \cdot \left[\frac{\mu_{m}(X_{obs,h}(i))}{\mu_{m}(X_{sim,h}(i))}\right]
6672
73+
where:
74+
75+
.. math::
76+
77+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
78+
6779
6880
.. code-block:: python
6981
:linenos:
@@ -119,6 +131,12 @@ deviation in the mean.
119131
120132
X^{*LS}_{sim,p}(i) = X_{sim,p}(i) + \mu_{m}(X_{obs,h}(i)) - \mu_{m}(X_{sim,h}(i))
121133
134+
where:
135+
136+
.. math::
137+
138+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
139+
122140
**(2)** In the second step, the time-series are shifted to a zero mean. This
123141
enables the adjustment of the standard deviation in the following step.
124142

@@ -202,6 +220,12 @@ for both additive and multiplicative Delta Method are shown:
202220
203221
X^{*DM}_{sim,p}(i) = X_{obs,h}(i) + \mu_{m}(X_{sim,p}(i)) - \mu_{m}(X_{sim,h}(i))
204222
223+
where:
224+
225+
.. math::
226+
227+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
228+
205229
**Multiplicative**:
206230

207231
The multiplicative variant behaves like the additive, but with the
@@ -212,6 +236,12 @@ for both additive and multiplicative Delta Method are shown:
212236
213237
X^{*DM}_{sim,p}(i) = X_{obs,h}(i) \cdot \left[\frac{ \mu_{m}(X_{sim,p}(i)) }{ \mu_{m}(X_{sim,h}(i))}\right]
214238
239+
where:
240+
241+
.. math::
242+
243+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
244+
215245
.. code-block:: python
216246
:linenos:
217247
:caption: Example: Delta Method
@@ -325,10 +355,11 @@ Detrended Quantile Mapping
325355
The Detrended Quantile Mapping bias correction technique can be used to minimize
326356
distributional biases between modeled and observed time-series climate data like
327357
the regular Quantile Mapping. Detrending means, that the values of
328-
:math:`X_{sim,p}` are shifted by the mean of :math:`X_{sim,h}` before the
329-
regular Quantile Mapping is applied. After the Quantile Mapping was applied, the
330-
mean is shifted back. Since it does not make sense to take the whole mean to
331-
rescale the data, the month-dependent long-term mean is used.
358+
:math:`X_{sim,p}` are shifted by the mean of :math:`X_{sim,p}` before the
359+
regular Quantile Mapping is applied. The shift is performed on a monthly basis.
360+
After the Quantile Mapping was applied, the mean is shifted back. Since it does
361+
not make sense to take the whole mean to rescale the data, the month-dependent
362+
long-term mean is used.
332363

333364
This method must be applied on a 1-dimensional data set i.e., there is only one
334365
time-series passed for each of ``obs``, ``simh``, and ``simp``. This method
@@ -351,17 +382,26 @@ shift of :math:`X_{sim,p}(i)`:
351382

352383
.. math::
353384
354-
X_{sim,p}^{*DT}(i) & = X_{sim,p}(i) + \Delta\mu \\[1pt]
385+
X_{sim,p}^{*DT}(i) & = X_{sim,p}(i) - \mu_m(X_{sim,p}(i)) \\[1pt]
355386
X_{sim,p}^{*DQM}(i) & = F_{obs,h}^{-1}\left\{F_{sim,h}\left[X_{sim,p}^{*DT}(i)\right]\right\}
356387
388+
where:
389+
390+
.. math::
391+
392+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
357393
358394
**Multiplicative**:
359395

360396
.. math::
361397
362-
X_{sim,p}^{*DT}(i) & = X_{sim,p}(i) \cdot \Delta\mu \\[1pt]
363-
X^{*DQM}_{sim,p}(i) & = F^{-1}_{obs,h}\Biggl\{F_{sim,h}\left[\frac{\mu{X_{sim,h}} \cdot X_{sim,p}^{*DT}(i)}{\mu{X_{sim,p}^{*DT}(i)}}\right]\Biggr\}\frac{\mu{X_{sim,p}^{*DT}(i)}}{\mu{X_{sim,h}}}
398+
X^{*DQM}_{sim,p}(i) = F^{-1}_{obs,h}\Biggl\{F_{sim,h}\left[\frac{\mu_m(X_{sim,h}(i)) \cdot X_{sim,p}(i)}{\mu_m(X_{sim,p}(i))}\right]\Biggr\}\frac{\mu_m(X_{sim,p}(i))}{\mu_m(X_{sim,h}(i))}
399+
400+
where:
401+
402+
.. math::
364403
404+
\mu_m(X\ldots(i)) = \text{long-term monthly mean of month related to day at index } i
365405
366406
.. code-block:: python
367407
:linenos:

0 commit comments

Comments
 (0)