# `cso_tools` module

## Methods

cso_tools.linearize_avg_kernel(AK, xa, xa_ratio_max)

  Linearizes the averaging kernel.

  Based on Appendix A of:

  > Zhang et al., Intercomparison methods for satellite measurements of atmospheric composition, ACP, 2010

  - in log space with \(\mathbf{A}\) in log(VMR)-based:

    \[\ln(\mathbf{x}_{est}) = \ln(\mathbf{x}_a) + \mathbf{\mathbf{A}} ( \ln(\mathbf{x}) - \ln(\mathbf{x}_a) )\]

  - We want to convert \(\mathbf{A}\) into \(\mathbf{A}^T\) in VMR-based. Thus by definition:

    \[\mathbf{x}_{ext} = \mathbf{x}_a + \mathbf{A}^T( \mathbf{x} - \mathbf{x}_a)\]

  - Let \(\mathbf{x}(i)\) be the VMR for layer/level \(i\), which is the i-th element of the vector \(\mathbf{x}\). Like above, assuming the difference between \(\mathbf{x}\) and \(\mathbf{x}_a\) is relatively small so that:

    \[ln(\mathbf{x}) - ln(\mathbf{x}_a) ~= (\mathbf{x} - \mathbf{x}_a) / \mathbf{x}_a\]

    with the same relationship holding between \(\mathbf{x}_{est}\) and \(\mathbf{x}_a\).

  - The elements \(\mathbf{A}^T(i,j)\) of the converted matrix \(\mathbf{A}^T\) are then related to the elements \(\mathbf{A}(i,j)\) of the averaging kernel \(\mathbf{A}\) by:

    \[\mathbf{A}^T(i,j) = (\mathbf{x}_a(i)/\mathbf{x}_a(j))\ \mathbf{A}(i,j)\]