fips.Posterior.desroziers#

Posterior.desroziers(by=None)[source]#

Compare the observation error variances Desroziers et al. (2005) diagnose with those the solve used.

With \(d^b = z - H x_0 - c\) (the innovation) and \(d^a = z - H \hat{x} - c\) (the residual), the expected value of \(d^a_i d^b_i\) is the variance of the error of observation \(i\) when the covariances of the problem are right. One observation’s product is noisy; its mean over a group of observations (a site, a month) is the diagnostic.

Parameters:

by (Any) – The levels of the observations’ labels to group by, as pandas.DataFrame.groupby() takes them: "site", ["site", "block"], or pd.Grouper(level="obs_time", freq="MS"). Observations whose block lacks a level are left out of a grouping by it. By default, one row per observation.

Returns:

diagnosed (\(d^a_i d^b_i\), or its mean over a group), specified (the diagonal of \(S_z / \gamma\), the variances the solve used, or their mean), and ratio (diagnosed over specified; near 1 when they agree). Indexed by the observations’ labels, or by the groups.

Return type:

DataFrame

References

Desroziers, G., Berre, L., Chapnik, B., & Poli, P. (2005). Diagnosis of observation, background and analysis-error statistics in observation space. Q.J.R. Meteorol. Soc., 131, 3385-3396.

Examples

>>> import numpy as np
>>> import pandas as pd
>>> import fips
>>> sites = pd.MultiIndex.from_product(
...     [["A", "B"], [0, 1, 2]], names=["site", "hour"]
... )
>>> cell = pd.Index(["c"], name="cell")
>>> prior = fips.Vector.from_series(pd.Series(0.0, index=cell), block="flux")
>>> obs = fips.Vector.from_series(
...     pd.Series([1.0, 2.0, 0.5, 3.0, 2.5, 1.0], index=sites), block="co2"
... )
>>> problem = fips.Problem(
...     prior=prior,
...     prior_cov=fips.Independent().with_std(1.0),
...     obs=obs,
...     obs_cov=fips.Independent().with_std(1.0),
...     forward=fips.Operator(np.ones((6, 1)), obs.space, prior.space),
... )
>>> fips.solve(problem).desroziers(by="site").round(3).reset_index()
  site  diagnosed  specified  ratio
0    A      0.083        1.0  0.083
1    B      2.321        1.0  2.321