Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mathause committed Jul 11, 2022
1 parent b79586a commit 940e5b1
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions mesmer/calibrate_mesmer/train_lv.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,15 @@ def train_lv_AR1_sci(params_lv, targs, y, wgt_scen_eq, aux, cfg):
# compute localized cov matrix of the innovations of the AR(1) process
loc_ecov_AR1_innovs = _adjust_ecov_ar1(
params_lv["loc_ecov"][targ_name], params_lv["AR1_coef"][targ_name]
)
)

params_lv["loc_ecov_AR1_innovs"][targ_name] = loc_ecov_AR1_innovs

return params_lv


def _adjust_ecov_ar1(ecov, ar_coefs):
"""
adjust localized empirical covariance matrix for autoregressive process of order 1
"""adjust localized empirical covariance matrix for autoregressive process of order 1
Parameters
----------
Expand All @@ -283,27 +282,27 @@ def _adjust_ecov_ar1(ecov, ar_coefs):
- The formula is specific for an AR(1) process, see also https://github.com/MESMER-group/mesmer/pull/167#discussion_r912481495
- According to [2]_ "The multiplication with the ``reduction_factor`` scales the
empirical standard error under the assumption of an autoregressive process of
empirical standard error under the assumption of an autoregressive process of
order 1 [3]_. This accounts for the fact that the variance of an autoregressive
process is larger than that of the driving white noise process."
- This formula is wrong in [1]_. However, it is correct in the code. See also [2]_
and [3]_.
.. [1] Beusch, L., Gudmundsson, L., and Seneviratne, S. I.: Emulating Earth system model
temperatures with MESMER: from global mean temperature trajectories to grid-point-
level realizations on land, Earth Syst. Dynam., 11, 139–159,
https://doi.org/10.5194/esd-11-139-2020, 2020.
.. [1] Beusch, L., Gudmundsson, L., and Seneviratne, S. I.: Emulating Earth system model
temperatures with MESMER: from global mean temperature trajectories to grid-point-
level realizations on land, Earth Syst. Dynam., 11, 139–159,
https://doi.org/10.5194/esd-11-139-2020, 2020.
.. [2] Humphrey, V. and Gudmundsson, L.: GRACE-REC: a reconstruction of climate-driven
water storage changes over the last century, Earth Syst. Sci. Data, 11, 1153–1170,
https://doi.org/10.5194/essd-11-1153-2019, 2019.
.. [2] Humphrey, V. and Gudmundsson, L.: GRACE-REC: a reconstruction of climate-driven
water storage changes over the last century, Earth Syst. Sci. Data, 11, 1153–1170,
https://doi.org/10.5194/essd-11-1153-2019, 2019.
.. [3] Cressie, N. and Wikle, C. K.: Statistics for spatio-temporal data, John Wiley &
Sons, Hoboken, New Jersey, USA, 2011.
.. [3] Cressie, N. and Wikle, C. K.: Statistics for spatio-temporal data, John Wiley &
Sons, Hoboken, New Jersey, USA, 2011.
"""

reduction_factor = np.sqrt(1 - ar_coefs ** 2)
reduction_factor = np.sqrt(1 - ar_coefs**2)
reduction_factor = np.atleast_2d(reduction_factor) # so it can be transposed

# equivalent to ``diag(reduction_factor) @ ecov @ diag(reduction_factor)``
Expand Down

0 comments on commit 940e5b1

Please sign in to comment.