\documentclass[aps, prd, reprint, nofootinbib, groupedaddress, showpacs]{revtex4-1}
\usepackage{amsmath,amssymb, amsthm,amstext}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{color}
\usepackage{array}
\usepackage{bm}
\usepackage{multirow}
\usepackage[breaklinks,colorlinks, citecolor=blue]{hyperref}
\usepackage{pifont, ragged2e}
\usepackage{enumitem}

\def\nn{\nonumber}
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\mE{\mathcal E}
\def\Planck{\emph{Planck} }

\newcommand*\Bell{\ensuremath{\boldsymbol\ell}}
\newcommand{\xmark}{\text{\ding{55}}}

\begin{document}
\title{Approximate Likelihood Approaches for Detecting the Influence of Primordial
Gravitational Waves in Cosmic Microwave Background Polarization}
\author{Zhen Pan}
\email{zhpan@ucdavis.edu}
\affiliation{Department of Physics, University of California,
One Shields Avenue, Davis, CA, 95616}
\author{Ethan Anderes}
\email{anderes@ucdavis.edu}
\affiliation{Department of Statistics, University of California,
One Shields Avenue, Davis, CA, 95616, USA}
\author{Lloyd Knox}
\email{lknox@ucdavis.edu}
\affiliation{Department of Physics, University of California,
One Shields Avenue, Davis, CA, 95616, USA}

\date{\today}

\begin{abstract}
One of the major targets for next-generation cosmic microwave background (CMB)
experiments is the detection of the primordial B-mode signal. Planning is under
way for Stage-IV experiments that are projected to have instrumental noise small
enough to make lensing and foregrounds the dominant source of uncertainty for estimating
the tensor-to-scalar ratio $r$ from polarization maps.
This makes delensing a crucial part of future CMB polarization science.
In this paper we  present a likelihood method for estimating the
tensor-to-scalar ratio $r$ from CMB polarization observations, which
combines the benefits of a full-scale likelihood approach with the tractability
of the quadratic delensing technique.
This method is a pixel space, all order likelihood analysis of the quadratic delensed B modes,
and it essentially builds upon the quadratic
delenser by taking into account all order lensing and pixel space anomalies.
Its tractability relies on a crucial factorization of the pixel space covariance matrix of the
polarization observations which allows one to compute the full Gaussian approximate likelihood profile,
as a function of $r$, at the same computational cost of a single likelihood evaluation.
\end{abstract}

\pacs{98.70.Vc, 98.62.Sb}

\maketitle

\section{\label{sec:intro}Introduction}
The inflation paradigm has successfully explained the origin of primordial density
perturbations that grew into the Cosmic Microwave Background (CMB)
anisotropies and large scale structure we
observe \citep[e.g.][]{Mukhanov1981, Guth1981, Linde1982, Albrecht1982, Lidsey1997, Lyth1999}.
A key prediction of inflation is the background of primordial
gravitational waves (GWs) or tensor-mode perturbations
\citep[e.g.][]{Starobinskii1979, Rubakov1982, Fabbri1983,%
Abbott1984, Starobinskii1985},
which imprints a unique polarization pattern,
called a primordial B mode, on the CMB anisotropies
\cite{Stebbins1996, Kamionkowski1997a, Kamionkowski1997,Seljak1997,%
Seljak1997a,Zaldarriaga1997a}.
Further, detection of a nearly scale-invariant background of
GWs would severely challenge non-inflationary models
\cite[e.g.][]{Khoury2001, Khoury2001a,Khoury2003a,Steinhardt2002, Boyle2004a}.
The strength of primordial gravitational waves or tensor-mode power is commonly
quantified by the tensor-to-scalar ratio $r$.
Joint analysis of BICEP2/Keck Array and \Planck data yields an upper bound
$r < 0.12$ at $95\%$ confidence level \citep{BICEP2/Keck2015},
the bound is slightly tightened  when the \Planck high-$\ell$
polarization data are included \citep{PlanckCollaborationXX2015},
and BICEP2/Keck Collaboration gives the latest upper bound $r < 0.09$ at
$95\%$ confidence level \citep{BICEP2/Keck2016}.
Fourth generation experiments,
including COrE, LiteBird, and CMB Stage-IV,  are expected to
constrain $r$ with uncertainty $\sigma(r)\simeq 0.001$
\citep{COrECollaboration2011, LiteBirdCollaboration2014,%
LiteBird2016, s42016,Cabass2016, Kamionkowski2016, Delabrouille2017}.

The primordial B modes are contaminated by several sources:
emission from galactic dust and other foregrounds
\cite{Hildebrand1999, Draine2004, Benoit2004,Mortonson2014, Niemack2015,%
PlanckCollaborationXXX2016, PlanckCollaborationL2016, Krachmalnicoff2016},
instrumental noise, and gravitational lensing of scalar CMB perturbations.
The B modes generated by gravitational lensing of the CMB have  been detected
\citep{Hanson2013, Ade2014, VanEngelen2014, Story2014, BICEP2/Keck2015, PlanckCollaboration2015a}.
The lensed B-mode power spectrum is nearly a constant at small multipoles ($\ell \lesssim 1000$) and
therefore manifests as an effective white noise with amplitude $\sim 5$ $\mu$K-arcmin
\citep{Lewis2006, Sherwin2015}.
For CMB Stage-IV, we expect to decrease the instrumental noise to $\sim 1\ \mu$K-arcmin \citep{s42016}.
Then, the lensing B noise (and foregrounds) would become the dominant noise source
limiting the primordial B-mode survey.

Fortunately,  the lensing B noise is well understood.
Up to leading order, one can effectively delense observed B modes by utilizing
a quadratic combination of observed E modes and an estimate of the lensing potential field $\phi^{\rm est}$
\citep{Knox2002, Kesden2002, Seljak2003a, Simard2015a, Sherwin2015}.
We find that the validity of the quadratic delenser crucially depends on a partial cancellation of
higher order lensing terms (see Section \ref{sec:app4} for details).
However, in the regime of low instrumental noise and small lensing potential field estimate uncertainty,
higher-order lensing terms, ignored by the quadratic delensing technique,
can have an appreciable effect. These higher order terms not only induce
a delensing bias but also contain information on primordial B modes.
In addition, experimental complexities such as non-stationary noise and sky cuts
become non-trivial for spectral based methods such as the quadratic delenser.

As an alternative, a full-scale likelihood analysis of the tensor-to-scalar ratio $r$ can,
in principle, optimally account for all the Gaussian and non-Gaussian information in the CMB observations.
Unfortunately, a full likelihood analysis requires computation resources beyond
what is available in the near future.
In this paper, we introduce a likelihood approximation which is modified from the full-scale
likelihood, so as to be computationally tractable.

We start with introducing a Gaussian likelihood incorporating all the 2-point information.
A key element of our likelihood analysis is the covariance matrix of the polarization maps.
For each data pair ($d_i, d_j$) ($d$ can be $Q$ or $U$),  its covariance
depends on the primordial polarization power spectra $C_\ell^{EE}$ and $C_\ell^{BB,r}$,
lensing potential field $\phi(x)$ (and instrumental noise $N^{QQ}$ and $N^{UU}$),
where the E-mode power $C_\ell^{EE}$ has been well constrained
\citep[e.g.][]{PlanckCollaborationXI2015, PlanckCollaborationXIII2015},
while the primordial B-mode signal has not been detected.
Following the prediction of the inflation paradigm,
we assume the tensor perturbations to be scale-invariant and Gaussian.
Hence all the primordial B-mode  information is encoded in the single parameter $r$, the
tensor-to-scalar ratio at $k=0.05$ Mpc$^{-1}$.
Then the covariance matrix $\tilde \Sigma_{r,\phi}$
depends on the unknown parameter $r$ and the underlying lensing potential field $\phi(x)$,
where $\phi(x)$ can be estimated from exterior tracers, e.g. cosmic infrared background (CIB)
\citep{Song2003, Dole2006, PlanckCollaborationXVII2014,%
PlanckCollaboration2015a, Larsen2016, Manzotti2017} or
from intrinsic CMB via, e.g. quadratic estimators \citep{Hu2001, Hu2002b}
or Bayesian approach \citep{Hirata2003a, Hirata2003,Anderes2011, Anderes2015, Millea2017}.
We obtain a covariance matrix $\Sigma_r$ depending only on $r$ by marginalizing $\tilde \Sigma_{r,\phi}$
over uncertainties in the lensing potential field estimate $\phi^{\rm est}$.
With this full covariance matrix $\Sigma_r$, it is then straightforward to compute the likelihood of $r$
for given data vector $d$ by approximating $d$ as a Gaussian vector.

In principle, this Gaussian likelihood method can exploit
all the 2-point $r$ information from the polarization maps,
but usually the computation resource demands are still excessive. For example,
to constrain $r$ from some polarization maps with $p$ pixels,
we need to compute the full likelihood profile $L(r|d)$ as a function of $r$,
which in practice requires computing the likelihood on a range of $r$ values,
say $50$  values evenly distributed in the interval $[0, 0.2]$.
For each different $r$, we need to compute the quadratic form $d^\intercal\Sigma_r^{-1} d$ and
the determinant $\det(\Sigma_r)$, due to the $r$ dependence of the covariance matrix.
In any realistic experiments with $p \gtrsim 10^4$,
it is a huge amount of work to compute and invert the covariance matrix of dimension $2p\times 2p$
for that many $r$ values, where the factor $2$ comes from two observables $Q$ and $U$ on each pixel.

In this paper, we present a modified Gaussian likelihood tailoring
the full-scale likelihood analysis so as to be computationally tractable.
The method consists of two parts.
In the first part, we decompose the covariance matrix $\Sigma_r$ as $\Sigma^{\rm en}+ r\Sigma^{\rm b}$,
where $\Sigma^{\rm en}$ is the contribution from E modes and instrumental noise,
and $r\Sigma^{\rm b}$ is the contribution from B modes. This decomposition allows us to compute
the covariance $\Sigma_r$, as a function of $r$,
at the same computational cost of a single covariance matrix computation.
In the second part, we suppress data size by tracking only $s$
high signal-to-noise modes, say the large-scale quadratic delensed B modes.
We project out the lensing-generated B modes and obtain the delensed modes $B^{\rm del}$
from the polarization data $d$ via a projection matrix $v$,
$(^0B^{\rm del}_{\Bell})_s = (v^\intercal)_{s\times 2p} d_{2p}$,
with $s\sim 500$ and the upper left index $^0$ denoting the projected data vector
limited to the $s$ lowest frequency  modes available.
Then, the covariance matrix of the projected data vector  $^0B^{\rm del}_{\Bell}$
is given by $v^\intercal \Sigma_r v$,
with which the computation of the $r$ likelihood  $L(r|^0B^{\rm del}_{\Bell} )$
given the projected data vector turns out to be tractable.
This method can be naturally extended to incorporate higher frequency modes,
as we describe in Section \ref{sec:like}.

The paper is organized as follows. We introduce the quadratic delenser
and the likelihood based delenser in Section \ref{sec:delen} and Section \ref{sec:like}, respectively.
In Section \ref{sec:sims}, we apply the two $r$ constraining techniques
on simulations mimicking Stage III and IV CMB surveys,
and compare their $r$ constraints.
We conclude with Section \ref{sec:summary}. For reference, we derive the analytic expression
for the covariance matrices of the polarization maps, and the eigenvalue method for inverting large matrices
in Appendices \ref{sec:app1}, \ref{sec:app2} and \ref{sec:app3}, respectively.

\section{Quadratic Delenser}
\label{sec:delen}
For simplicity, we assume no contamination of foregrounds throughout this paper.
Then the observed B modes can generally be expressed as
\be
B^{\rm obs} = B^{r} + B^{\rm len} + N^B,
\ee
where $B^r, B^{\rm len}, N^B$ are primordial B signal, lensing B noise
and instrumental B noise, respectively. To constrain the primordial B signal,
delensing is essential, where we obtain an estimate of the lensing B noise and subtract it off from the
observed B modes. Here we introduce a quadratic delenser.

Accurate to the leading order of the lensing potential $\phi_{\Bell}$,
$B^{\rm len}$ is the convolution of the lensing potential and primordial E modes, i.e.,
\be
\label{eq:convol}
B^{\rm len}_{\Bell} = \int \frac{d^2\Bell'}{2\pi} \Bell'\cdot(\Bell-\Bell') \sin(2\varphi_{\Bell,\Bell'}) E_{\Bell'}\phi_{\Bell-\Bell'}.
\ee
Usually, the underlying lensing potential is not  known {\it a priori}, but can be estimated from either intrinsic CMB
or from external tracers. From an estimated lensing potential $\phi^{\rm est}_{\Bell}$
and observed modes $E_{\Bell}^{\rm obs}$, we construct a quadratic estimate of the lensing B noise
\be
\label{eq:wconvol}
B^{\rm len, est}_{\Bell} = \int \frac{d^2\Bell'}{2\pi} f_{\Bell,\Bell'} \Bell' \cdot(\Bell-\Bell')\sin(2\varphi_{\Bell,\Bell'})  E^{\rm obs}_{\Bell'} \phi^{\rm est}_{\Bell-\Bell'},
\ee
where $\varphi_{\Bell,\Bell'} = \varphi_{\Bell} - \varphi_{\Bell'}$,
$E^{\rm obs}$ is the observed E modes (to the lowest order, the difference between
lensed E and primordial E can be neglected),
and the weighting function $f_{\Bell,\Bell'}$ is to be determined by minimizing the residual,
$B_{\Bell}^{\rm res} = B^{\rm len}_{\Bell} - B^{\rm len, est}_{\Bell}$.
If we define the correlation coefficient of $\phi_{\Bell}$ and $\phi^{\rm est}_{\Bell}$
\be
\label{eq:corr}
\rho_\ell =  \frac{C_\ell^{\phi, \phi^{\rm est}}}{\sqrt{C_\ell^{\phi\phi} C_\ell^{\phi^{\rm est}\phi^{\rm est}}}},
\ee
the optimal weight at leading order was proved to be \citep{Sherwin2015}
\be
f_{\Bell,\Bell'} = \frac{C_{l'}^{EE}}{C_{l'}^{EE} + N_{l'}^{EE}} \rho_{|\Bell-\Bell'|}^2,
\ee
which enables a minimal residual power spectrum
\be
\label{eq:respower}
\begin{aligned}
C_{\Bell}^{BB, {\rm res}}
& =\int \frac{d^2\Bell'}{(2\pi)^2} \left[\Bell'\cdot(\Bell-\Bell') \sin(2\varphi_{\Bell,\Bell'})  \right]^2\\
&\times C_{\Bell'}^{EE} C^{\phi\phi}_{\Bell-\Bell'} (1-f_{\Bell,\Bell'}).
\end{aligned}
\ee

After subtracting off the template $B_{\Bell}^{\rm len, est}$, we obtain a quadratic delensed B-mode map
\be
\label{eq:bdel}
B_{\Bell}^{\rm del} = B_{\Bell}^{\rm obs} - B_{\Bell}^{\rm len, est} = B_{\Bell}^r + B_{\Bell}^{\rm res} + N_{\Bell}^B,
\ee
and its power spectrum
\be
\label{eq:delpower}
C_\ell^{BB, {\rm del}} = C_\ell^{BB,r} + C_\ell^{BB, {\rm res}} + N^{BB}_\ell.
\ee
From the delensed B modes, one can better constrain $r$ due to the suppressed lensing B noise.
Note that in the evaluation of
the residual lensing B power
$C_\ell^{BB, {\rm res}} $ of Eq. (\ref{eq:respower}) we have made two approximations:
1) we keep only the linear order lensing in $B^{\rm len}$;
2) we completely ignore the lensing in $E^{\rm obs}$.

\section{Gaussian Likelihood Delenser}
\label{sec:like}

In contrast to the quadratic delenser, the likelihood analysis works on observables
$Q^{\rm obs}$ and $U^{\rm obs}$ in pixel space.
Concatenating the polarization data on all pixels yields a length-$2p$ data vector
\be
d = [Q^{\rm obs}(x_1) \cdots Q^{\rm obs}(x_p), U^{\rm obs}(x_1) \cdots  U^{\rm obs}(x_p)]^\intercal,
\ee
with $p$ being the number of pixels.
We first evaluate the covariance matrix of the data vector,
which depends on the primordial polarization power spectra $C_\ell^{EE}$ and $C_\ell^{BB,r}$,
lensing potential field $\phi(x)$ (and instrumental noise). With $C_\ell^{EE}$ being well-determined,
and $C_\ell^{BB,r}$ being parametrized by the tensor-to-scalar ratio $r$,
we marginalize the covariance matrix $\tilde \Sigma_{r,\phi}$ over uncertainties in $\phi(x)$ estimate,
and obtain a covariance matrix $\Sigma_r$ depending only on $r$. Then it is straightforward to compute the approximate likelihood of $r$ for given data $d$
by approximating $d$ as a Gaussian vector, i.e.,
\be
\label{eq:likeli}
    -2\log L(r|d) = d^\intercal\Sigma^{-1}_r d + \log \det\Sigma_r,
\ee
up to a constant term.

\subsection{Comparison with the Quadratic Delenser}
Before delving into the details of the Gaussian likelihood delenser,
it would be useful to do a brief comparison with the quadratic delenser (see Table \ref{table1}):
\begin{itemize}
    \item The Quadratic Delenser works on the delensed modes $B^{\rm del}_{\Bell}$ in Fourier space,
    and approximates these modes as stationary and Gaussian, i.e.,
    \[
    \begin{pmatrix}
        \vdots \\
        B^{\rm del}_{\Bell}\\
        \vdots
    \end{pmatrix} \sim
    N(0, \begin{bmatrix}
    \ddots & 0 & 0 \\
    0 & C^{BB,\rm del}_{\ell} & 0\\
    0 & 0 & \ddots
    \end{bmatrix}),
    \]
    where the power spectrum $C^{BB,\rm del}_{\ell}$, derived in Eq. (\ref{eq:delpower}), only
    takes into account the leading-order in $\phi$.
    Therefore, the quadratic delenser exploits the 2-point information in
    a biased way by ignoring the non-stationarity and higher-order lensing in the power spectrum.

    \item The Gaussian Likelihood  Delenser works on the observables $d$ in pixel space, and approximates the data
    vector $d$ as Gaussian after marginalizing over uncertainties in the $\phi$ estimate. In the computation of
    the covariance matrix $\Sigma_r$, all-order lensing is taken into account
    and no stationarity assumption is made. Therefore, the Gaussian likelihood
    delenser naturally incorporates all the 2-point information.
\end{itemize}

\begin{table}
\begin{tabular}{ m{2.4cm} |c| c}
      Delenser & Quadratic Delenser  & Gaussian Likelihood  \\ \hline
     working space  & Fourier & pixel\\ \hline
      power spectrum / cov. matrix & leading order & all order\\ \hline
     non-stationarity& $\xmark $ & $\checkmark$ \\
     non-Gaussianity &  $\xmark $ & $\xmark $ \\ \hline
\end{tabular}
\caption{A brief comparison of the two delensers.}
\label{table1}
\end{table}

The Gaussian likelihood is potentially favored in several aspects,
but usually is computationally excessive.
As explained in the Introduction, the bottleneck of the likelihood analysis is
the covariance matrix $\Sigma_r$ related computation,
which is of large size $2p\times 2p$, and is a function of $r$.
Here we introduce a modified Gaussian likelihood method.
The method consists of two parts, covariance decomposition and data compression,
where the former allows us to compute the covariance matrix $\Sigma_r$,
as a function of $r$, at the computation cost of a single covariance matrix computation;
and the latter allows us to compress the covariance matrix
by tracking a small number of high $S/N$ modes.

\subsection{Covariance Decomposition}
To avoid repeating the computation of the covariance matrix $\Sigma_r$ for each different $r$,
we find it is possible to single out the $r$ dependence by decomposing the  covariance matrix as
\be
\label{eq:dec}
\Sigma_r = \Sigma^{\rm en} + r \Sigma^{\rm b},
\ee
where $\Sigma^{\rm en}$ is the contribution from E modes and instrumental noise,
and $r \Sigma^{\rm b}$ is the contribution from primordial B modes.
With this decomposition, we can obtain the covariance matrix $\Sigma_r$ as a function
of $r$, as long as the $r$-independent components $\Sigma^{\rm en}$ and  $\Sigma^{\rm b}$ are obtained.

For the covariance decomposition of Eq. (\ref{eq:dec}),
we first decompose observables $Q^{\rm obs}$ and $U^{\rm obs}$ as linear combinations of E modes and B modes.
Stokes parameters $Q$ and $U$ are related to coordinate independent quantities $E$ and $B$ via
\citep{Stebbins1996, Kamionkowski1997a, Kamionkowski1997, Seljak1997a}
\be
\label{eq:queb}
\begin{aligned}
Q_{\Bell} &= - \cos(2\varphi_{\Bell}) E_{\Bell} + \sin(2\varphi_{\Bell}) B_{\Bell}, \\
U_{\Bell} &= - \sin(2\varphi_{\Bell}) E_{\Bell} - \cos(2\varphi_{\Bell}) B_{\Bell}.
\end{aligned}
\ee
We define the following modulated E/B modes
\be
\begin{aligned}
SE_{\Bell} & \equiv - \sin(2\varphi_{\Bell}) E_{\Bell}, \quad  & SB_{\Bell}  \equiv +\sin(2\varphi_{\Bell}) B_{\Bell},\\
CE_{\Bell} & \equiv - \cos(2\varphi_{\Bell}) E_{\Bell}, \quad  & CB_{\Bell} \equiv -\cos(2\varphi_{\Bell}) B_{\Bell},
\end{aligned}
\ee
then the observables $Q^{\rm obs}$ and $U^{\rm obs}$ are consequently expressed as
\be
\begin{aligned}
Q^{\rm obs}(x) &= \widetilde{CE}(x) + \sqrt{r} \widetilde{SB^0}(x) + N^Q(x),\\
U^{\rm obs}(x) &= \widetilde{SE}(x) + \sqrt{r} \widetilde{CB^0}(x) + N^U(x),
\end{aligned}
\ee
where $B^0$ denotes fiducial B modes with unity power spectrum $C_\ell^{BB,r=1}$,
tildes denote lensed fields $\widetilde X(x) = X(x+\nabla\phi(x))$ ($X = CE, SE, CB, SB$),
and $N^{Q,U}$ is the $Q/U$ noise.

With above decomposition, we find the data vector $d$ is Gaussian with covariance $\tilde\Sigma_{r, \phi}$
for given $r$ and $\phi(x)$, i.e., $d \sim  N(0, \tilde\Sigma_{r, \phi})$, where
\be
\tilde\Sigma_{r, \phi} \equiv
\left[
\begin{tabular}{cc}
  $\tilde \Sigma^{Q^{\rm obs},Q^{\rm obs}}$ & $\tilde\Sigma^{Q^{\rm obs},U^{\rm obs}}$  \\
  $\tilde \Sigma^{Q^{\rm obs},U^{\rm obs}}$ & $\tilde\Sigma^{U^{\rm obs},U^{\rm obs}}$
  \end{tabular}
\right]_{r,\phi}
\ee
and the covariance matrix is naturally expressible in the form of Eq. (\ref{eq:dec}), i.e.,
\be
\label{eq:elements}
\begin{aligned}
    \tilde \Sigma^{Q^{\rm obs},Q^{\rm obs}} &= \tilde\Sigma^{CE,CE} + r \tilde\Sigma^{SB^0, SB^0} + \Sigma^{NQ,NQ},\\
    \tilde \Sigma^{Q^{\rm obs},U^{\rm obs}} &= \tilde\Sigma^{CE,SE} + r \tilde\Sigma^{SB^0, CB^0} ,\\
    \tilde \Sigma^{U^{\rm obs},U^{\rm obs}} &= \tilde\Sigma^{SE,SE} + r \tilde\Sigma^{CB^0, CB^0} + \Sigma^{NU,NU}.
\end{aligned}
\ee

In a more practical case, we only have an estimate of lensing potential $\phi_{\Bell}^{\rm est}$
which is a noisy version of the true $\phi_{\Bell}$,
i.e., $\phi_{\Bell}^{\rm est} = \phi_{\Bell} + n^\phi_{\Bell}$,
where $n^\phi_{\Bell}$ is the uncertainty of the $\phi$ estimate
and its power spectrum $N_\ell^{\phi\phi}$ is usually an output of the lensing estimator used.
For an unbiased estimator with Gaussian uncertainty, one can write $n^\phi_{\Bell}\sim N(0, N_\ell^{\phi\phi})$.
Then the correlation coefficient of $\phi$ and $\phi^{\rm est}$ defined in Eq. (\ref{eq:corr}) now
is explicitly known as
\be
\rho_\ell =  \sqrt{\frac{C_\ell^{\phi\phi}}{C_\ell^{\phi\phi} + N_\ell^{\phi\phi}}}.
\ee
In this context, one can treat $\phi^{\rm est}$ as data and compute the
posterior on $\phi$ given $\phi^{\rm est}$, i.e.,
\be
P(\phi_{\Bell} | \phi^{\rm est}_{\Bell})
\sim N\left(\mu\phi_{\Bell},
C_{\ell}^{n\phi,n\phi}\right).
\ee
with
\be
\label{eq:wf}
\begin{aligned}
\mu \phi_{\Bell} &= \frac{C_\ell^{\phi\phi}}{C_\ell^{\phi\phi} + N_\ell^{\phi\phi}} \phi_{\Bell}^{\rm est}
=\rho_\ell^2 \phi_{\Bell}^{\rm est}, \\
C_{\ell}^{n\phi,n\phi}& = \frac{C_\ell^{\phi\phi}}{C_\ell^{\phi\phi} + N_\ell^{\phi\phi}}N_\ell^{\phi\phi}
=\rho_\ell^2  N_\ell^{\phi\phi},
\end{aligned}
\ee
Therefore a sample $\phi_{\Bell}  \sim P(\phi_{\Bell} | \phi^{\rm est}_{\Bell})$ can be writen as
\be
\phi_{\Bell} = \mu\phi_{\Bell} + n\phi_{\Bell},
\ee
with $n\phi_{\Bell}\sim N(0, C_\ell^{n\phi,n\phi})$.

Marginalizing $\tilde \Sigma_{r,\phi}$ over $n\phi$, we obtain a covariance matrix only depending on $r$, i.e.,
$\Sigma_r \equiv \langle \tilde \Sigma_{r,\phi} \rangle_{n\phi}$,
where its analytic form is presented in Appendices \ref{sec:app1} and \ref{sec:app2}.
The computation of its inverse matrix $\Sigma_r^{-1}$ is presented in Appendix \ref{sec:app3}.

\subsection{Data Compression}
\subsubsection{idea}
To compress the data, we project the original length-$2p$ data vector $d$ to
a length-$s$ data ($s\sim 500$) via a projection matrix $v$, and apply the likelihood analysis on the
projected data $\hat d_s = (v^\intercal)_{s\times 2p} d_{2p}$. Let $\Sigma_r$ be the covariance matrix of data vector $d$,
then $v^\intercal\Sigma_r v$ is the covariance matrix of projected data vector $\hat d$, i.e.,
$d\sim N\left(0, \Sigma_r\right)$,
and
$\hat d \sim N\left(0, v^\intercal \Sigma_r v \right)$.
Then the likelihood of $r$ given projected data $\hat d$ is simply
\be
\label{eq:projlikeli}
    -2\log L(r|\hat d)
    = \hat d^\intercal (v^\intercal\Sigma_r v)^{-1} \hat d + \log \det(v^\intercal\Sigma_r v),
\ee
up to a constant term.

The goal is to find a projection matrix $v$ such that $\hat d$ is highly informative for $r$.
Since the primordial B modes at large scales are less contaminated by the lensing B noise,
a natural choice is to project the polarization data to the large-scale quadratic delensed modes
defined in Equation (\ref{eq:bdel}),
i.e., $\hat d^0 =$ $^0B_{\Bell}^{\rm del}$, where the upper index $^0$ denotes the projected data vector
limited to the $s$ lowest frequency  modes available (Figure \ref{fig:Bdel}).
The method can be naturally extended to higher frequency modes,
$\hat d^i = \ ^iB^{\rm del}_{\Bell}$ $(i = 1,2,\dots)$
with $\Bell$ running over the $s$ next/next-next/$\dots$ lowest frequency modes.
With these projected data vectors $\hat d^i = \ ^iB^{\rm del}_{\Bell}= (v^\intercal)^i d$,
the total likelihood is given by
\be
\label{eq:totlikeli}
    \log L(r|d) \approx \sum_{i=0}^{i_{\rm max}}\log L(r|\hat d^i),
\ee
assuming negligible correlation for different projected vectors.\footnote{
The large-scale delensed B modes are no longer the highest $S/N$ modes,
when foregrounds, contaminating the primordial B modes more at large scales, are considered.
Our methodology is flexible. In principle, modes could be selected that
minimizes noise and residual foreground contamination.}
We will confirm the validity of ignoring the cross correlation via simulations in Section \ref{sec:sims}.

\begin{figure}
\centering
\includegraphics[height=1.8in]{f1.pdf}
\caption{ \label{fig:Bdel}
The modes covered by each different projected vector $^i B_{\Bell}^{\rm del} (i = 0, 1, 2, \cdots)$.
Here we only show the modes with $\ell_2 \geq 0$, since our observables $Q^{\rm obs}$
and $U^{\rm obs}$ are real numbers.}
\end{figure}

We find that the modified Gaussian likelihood
method works better if we incorporate the same number of E modes
and delensed B modes in each projected vector,
i.e.,
\be
\label{eq:ebproj}
[\hat d^i]_{2s} =
\begin{bmatrix}
    (^iB^{\rm del}_{\Bell})_s\\
    (^iE^{\rm obs}_{\Bell})_s
\end{bmatrix}
= \begin{bmatrix}
    (v_b^\intercal)^i_{s\times 2p}\\
    (v_e^\intercal)^i_{s\times 2p}
\end{bmatrix}  d_{2p} = (v^\intercal)^i_{2s\times 2p} d_{2p}.
\ee

\subsubsection{projection matrix}
In this subsection, we focus on the computation of the projection matrix.
As described in Section \ref{sec:delen}, the quadratic delenser is actually a linear operator,
i.e.,
\be
\label{eq:qdrdel}
\begin{aligned}
d=(Q^{\rm obs}, U^{\rm obs})^\intercal &\xrightarrow{{\rm Eq.}(\ref{eq:queb})}  (E^{\rm obs}, B^{\rm obs}) ,  \\
 & \xrightarrow{{\rm Eq.}(\ref{eq:wconvol})} (B^{\rm len, est}, B^{\rm obs}) , \\
 & \xrightarrow {{\rm Eq.}(\ref{eq:bdel}) } B^{\rm obs}- B^{\rm len, est} = B^{\rm del}.
\end{aligned}
\ee
Therefore we can formally write the quadratic delensing as
$(B^{\rm del}_{\Bell})_{2p} = \mathcal P_{2p\times 2p} d_{2p}$,
where $\mathcal P$ is a concatenation of the three linear operations above,
and its matrix elements can be found by
recording the impulse response of the delensed modes
to each element in the data vector.
For example, we first do the quadratic delensing to a ``data vector"
$\delta_1 = (1,0, \dots,0)^\intercal_{2p}$
and denote the corresponding delensed modes as $(B^{\rm del}_{\Bell}|_{\delta_1})$,
i.e.,
\be
(B^{\rm del}_{\Bell}|_{\delta_1})_{2p} = \mathcal P_{2p\times2p} (\delta_1)_{2p} = \textrm{1st col. of}\ \mathcal P.
\ee
where $(B^{\rm del}_{\Bell}|_{\delta_1})$ is obtained via delensing of Eq. (\ref{eq:qdrdel}).
In this way, we obtain the matrix $\mathcal P$.

It is clear that the projection matrices of vectors $ ^iB^{\rm del}_{\Bell}$
correspond to row blocks of $\mathcal P$.
Explicitly, we write $(B^{\rm del}_{\Bell})_{2p} = \mathcal P_{2p\times 2p} d_{2p}$ as
\be
\begin{pmatrix}
    (^0B_{\Bell}^{\rm del})_s\\
    (^1B_{\Bell}^{\rm del})_s\\
    (^2B_{\Bell}^{\rm del})_s\\
    \dots
\end{pmatrix}
= \mathcal P_{2p\times 2p} d_{2p}
= \begin{pmatrix}
    (^0\mathcal P)_{s\times 2p}\\
    (^1\mathcal P)_{s\times 2p}\\
    (^2\mathcal P)_{s\times 2p}\\
    \dots
\end{pmatrix} d_{2p}.
\ee
and therefore we obtain $(v_b^\intercal)^i_{s\times 2p} = (^i\mathcal P)_{s\times 2p}$.
The projection matrices $(v_e^\intercal)^i$ can be obtained in a similar way.

\section{Simulations}
\label{sec:sims}
In this section, we apply the quadratic delenser and the modified Gaussian likelihood  method
on CMB polarization simulations, and compare the resulting $r$ constraints.
The fiducial cosmology we use is a flat $\Lambda$CDM cosmology with
a baryon density $\omega_{\rm b} = 0.02246$, a cold dark matter density $\omega_{\rm c} = 0.1185$,
a reionization optical depth $\tau = 0.1283$,
an angular size of sound horizon at recombination $100\theta_{\star} = 1.0410$,
an amplitude and a spectral index of the primordial scalar the perturbation power spectrum
$10^9A_{\rm s} = 2.1333, n_{\rm s} = 0.9686$,
and a tensor-to-scalar ratio $r$ in the range of $[0.001, 0.1]$.
For each different $r$, we simulate $500$ realizations of primordial polarization fields $Q(x)$ and $U(x)$,
then lense these fields via the same lensing potential field $\phi(x)$.
All the power spectra used in simulations are computed from the Boltzmann code  {\tt CLASS} \citep{Lesg2011}.

\subsection{Two Surveys}

\begin{table}
\scalebox{1.3} {
\begin{tabular}{ l r|c| c |c}
     &  & $\Delta_{\rm T} (\mu$K-arcmin) & $\theta_{\rm FWHM}$ & $f_{\rm sky}$ \\ \hline
    \multirow{2}{*}{Lb}  &  $\phi$ & 0.5  & $2'$ & \multirow{2}{*}{$2.7\%$}\\ \cline{2-4}
                         &  $B$    & 0.5 & $10'$ & \\ \hline
    \multirow{2}{*}{La}  &  $\phi$ & 1  & $2'$ & \multirow{2}{*}{$2.7\%$}\\ \cline{2-4}
                        &  $B$    & 1 & $10'$ & \\ \hline
    \multirow{2}{*}{N}  &  $\phi$ & 10  & $2'$  & \multirow{2}{*}{$2.7\%$} \\ \cline{2-4}
                        &  $B$ & 10 & $10'$ & \\ \hline
\end{tabular}
}
\caption{The three scenarios we simulated.}
\label{table}
\end{table}

\begin{figure}
\centering
\includegraphics[height=3in]{f2.pdf}
\caption{ \label{fig:phi_noise}
The $\phi(x)$ reconstruction noises for Scenario N ($\Delta_{\rm T} = 10$ $\mu$K-arcmin), La
($\Delta_{\rm T} = 1$ $\mu$K-arcmin) and Lb ($\Delta_{\rm T} = 0.5$ $\mu$K-arcmin) surveys.}
\end{figure}

We consider a survey strategy consisting of two different surveys of the same area of sky, differing
in angular resolution. The main goal of the higher-resolution survey is to allow for a reconstruction of
the lensing potential. Such reconstructions benefit from reaching an angular scale comparable to the typical
lensing deflection angle of $\sim 2$ arcmin. In contrast, the primordial B-mode signal is on fairly large angular scales of
greater than a degree. In principal, one high-resolution survey could be used both for the lensing reconstruction
and for sensitivity to the primordial B-mode signal. However, there are advantages to using a survey dedicated
to the large-scale signals. These advantages do not appear in the idealized analyses that we perform here,
as they are related to systematic error control and foreground cleaning, as we now explain briefly.
The large-scale survey can be achieved with a smaller telescope with a simplified optics chain.
Having a smaller telescope facilitates boresight rotation, which BICEP2/Keck have used for null
tests to bound certain systematic errors. Foreground cleaning is also likely to be more of a challenge
at larger angular scales than it is for the smaller-angular scales with the bulk of the lensing information,
and serves as a further driver of differences in optimal design for the two surveys.
For these reasons a two-survey approach is likely to be a part of the strawman concepts for
the CMB Stage-IV instrument soon to emerge from the CMB Stage-IV Concept Definition Taskforce.

In this paper, we simulate three scenarios.
We consider a scenario `N' in which the B-mode instrument noise power
is larger than the B-mode lensing power, and two scenarios
`La' and `Lb' with the opposite situation.
The more sensitive scenarios La and Lb are motivated by potential CMB-S4 scenarios.
Each scenario consists of two surveys, a high-resolution survey for $\phi$ reconstruction
and a low-resolution survey capturing the B-mode signal, covering the same patch of the sky
(see Table \ref{table} for the survey configurations in detail).
For the high-resolution surveys, the lensing potential reconstruction noise
expected from the EB quadratic estimator \citep{Hu2001, Hu2002b,Anderes2013}
is shown in Figure \ref{fig:phi_noise}.

\begin{figure*}
\centering
\includegraphics[height=4in]{f3.pdf}
\caption{\label{fig:f3}
Upper three panels show the detection levels $r/\sigma(r)$ expected from surveys of Scenario N, La, and Lb,
and lower three panels show the corresponding bias levels ${\rm Bias(r)}/r$.}
\end{figure*}

\subsection{$r$ Constraints}
For each simulated CMB realization, we first reconstruct the lensing potential field from
the $\phi$ survey (\emph{high} resolution survey)
using the EB quadratic estimator,
then use the reconstructed lensing field $\phi^{\rm est}(x)$ to delense the
\emph{low} resolution polarization maps using the quadratic delenser (Section \ref{sec:delen})
and the modified Gaussian likelihood method (Section \ref{sec:like}),
and finally compare their $r$ constraints from the two delensers.\footnote{For intrinsic estimators,
the reconstructed lensing potential field and its reconstruction noise are
correlated with the fields being delensed, and the correlation is expected to bias
the delensing. Fortunately, corresponding debias techniques have been extensively investigated
and used \citep[see e.g.][]{Teng2011,Namikawa2015,Sehgal2016,Carron2017}.
To avoid unnecessary complexity, we choose not to directly use the reconstructed field
$\phi^{\rm est}(x)$ for delensing,
instead use a simulated one $\phi^{\rm est}(x) = \phi(x) + n^\phi(x)$,
with $\phi(x)$ being the true lensing potential field and $n^\phi(x)$ being Gaussian noise
with power expected from the EB quadratic estimator (Figure \ref{fig:phi_noise}).}

In Figure \ref{fig:f3}, we show the detection level $r/\sigma(r)$
and bias level ${\rm Bias}(r)/r$ obtained from the quadratic delenser
and from the modified Gaussian likelihood method,
where $\sigma(r)$ and ${\rm Bias}(r)$ are the standard error and
the average bias of the $500$ best-fit $r$ values (from $500$ CMB realizations), respectively.
For Scenario N, both methods  obtain  similar $r$ detection levels,
while the modified Gaussian likelihood method shows its advantages in the
Scenario La and Lb.
We find that in the regime of low map noise  ($\lesssim 1$ $\mu$K-arcmin),
the bias of the modified Gaussian likelihood method is appreciably smaller than
that of the quadratic delenser (see next subsection for the detailed bias analysis
for the quadratic delenser).

For Scenario La with map noise $\Delta_{\rm T} = 1$ $\mu$K-arcmin and
sky coverage $f_{\rm sky} = 2.7\%$, we expect to detect the primordial B-mode signal at
$\sim 1\ \sigma$ level for $r = 0.001$ and at $\sim 15 \ \sigma$ level for $r = 0.1$.
The lower noise Scenario Lb with map noise $\Delta_{\rm T} = 0.5$ $\mu$K-arcmin
and the same sky coverage, only marginally increases the detection level,
due to the saturation of cosmic variance.

\subsection{Bias Analysis for the Quadratic Delenser}
\label{sec:app4}
In this subsection, we aim to quantify the bias of the quadratic delenser
introduced by ignoring the lensing in E modes and higher order lensing in
B modes.\footnote{ In principle, ignoring the non-stationarity of the delensed B modes also induces
some bias to the $r$ constraint. But we will see this bias is negligible. }
For clarity, we use the following notation to denote
the connection between lensed and primordial variables
\be
\begin{aligned}
\widetilde E = E + \delta E_{\text{\rm from E}} + \delta E_{\text{\rm from B}} , \\
\widetilde B = B + \delta B_{\text{\rm from E}} + \delta B_{\text{\rm from B}} ,
\end{aligned}
\ee
where $\delta X_{\text{\rm from Y}}$ is the lensing in (lensed) $X$ from  (primordial) $Y$.
In addition, $\delta E_{\text{\rm from B}}$ and $\delta B_{\text{\rm from B}}$ are much smaller
than their counterparts $\delta E_{\text{\rm from E}} $ and $\delta B_{\text{\rm from E}}$, so we simply ignore them
in this subsection.

\begin{figure*}
\centering
\includegraphics[height=2.8in]{f4a.pdf}
\includegraphics[height=2.8in]{f4b.pdf}
\caption{\label{fig:f4}
Bias analysis of the quadratic delenser via simulations under different assumptions:
(black/solid lines) null test assuming $E^{\rm obs} = E + N^E$ and
$B^{\rm obs} = B + \delta^1B_{\text{\rm from E}} + N^B$;
(green/bar lines) all order E from E test assuming
$E^{\rm obs} = E + \delta E_{\text{\rm from E}} + N^E$,
$B^{\rm obs} = B + \delta^1B_{\text{\rm from E}} + N^B$;
(blue/dashed lines) all order B from E test assuming
$E^{\rm obs} = E + N^E$ and
$B^{\rm obs} = B +  \delta B_{\text{\rm from E}} + N^B$;
(red/dots) all order E/B from E test assuming
$E^{\rm obs} = E + \delta E_{\text{\rm from E}} + N^E$ and
$B^{\rm obs} = B +  \delta B_{\text{\rm from E}} + N^B$.
}
\end{figure*}

\begin{enumerate}[label=(\roman*)]
    \item First we do a null test.
In accordance with the two approximations made in the quadratic delenser (Section \ref{sec:delen}),
we completely drop lensing in E modes and only keep linear order lensing in B modes, i.e.,
we simulate polarization maps assuming $E^{\rm obs} = E + N^E$
and $B^{\rm obs} = B + \delta^1B_{\text{\rm from E}} + N^B$, where
$N^{E/B}$ is the E/B map noise, and  $\delta^1B_{\text{\rm from E}}$ is the linear order lensing in B from E.
As expected, we find the quadratic delenser is not biased in this context
(Figure \ref{fig:f4}, black/solid lines).\footnote{From the null test,
where we ignore the non-stationarity of the delensed B modes,
we conclude that the bias induced by ignoring  the non-stationarity
is negligible.}\footnote{Comparing the detection level of the null test (solid line in the left panel of Figure \ref{fig:f4}),
and the detection level of the modified Gaussian likelihood (solid line in the second panel of Figure \ref{fig:f3}),
we find the two matches exactly. Therefore, we confirm the validity of
the two major approximations used in the modified Gaussian likelihood:
only keeping a few projected data vectors,
and igoring the cross relation between different projected data vectors.}

    \item To scrutinize the bias introduced by ignoring lensing in E modes,
we keep all order lensing in E modes and linear order lensing in B modes,
i.e., we simulate polarization maps assuming
$E^{\rm obs} = E +  \delta E_{\text{\rm from E}} + N^E$
and $B^{\rm obs} = B^r + \delta^1B_{\text{\rm from E}} + N^B$.
In this context, the quadratic delenser is highly biased (Figure \ref{fig:f4}, green/bar lines).

    \item In the same way, to test the bias introduced by ignoring high order lensing terms in B modes,
we ignore lensing in E modes and keep all order lensing in B modes, i.e.,
we do simulations assuming $E^{\rm obs} = E  + N^E$
and $B^{\rm obs} = B + \delta B_{\text{\rm from E}} + N^B$.
In this context, we also find the quadratic delenser is highly biased.
More interestingly, we find that the bias level almost exactly matches that of ignoring lensing in E modes
(Figure \ref{fig:f4}, blue/dashed lines).

    \item The final step is to check the interaction between the two bias terms from (iii) and (iv).
For this purpose, we keep all order lensing in E modes and all order lensing in B modes,
i.e., we simulate polarization maps assuming $E^{\rm obs} = E + \delta E_{\text{\rm from E}} + N^E$,
and $B^{\rm obs} = B +  \delta B_{\text{\rm from E}} + N^B$.
We find that the two bias contributions cancel to a high precision
and therefore the net bias is strongly suppressed (Figure \ref{fig:f4}, red/dots).

To make sense of the bias cancellation, we do a simple magnitude analysis.
In the quadratic delenser, we delense the B modes via a quadratic template subtraction
$B^{\rm res} = B_{\text{\rm from E}}- E^{\rm obs}*\phi^{\rm est}$,
and assume a residual power spectrum
$C^{BB,{\rm res}}_\ell = \langle |\delta^1 B_{\text{\rm from E}}- E*\phi^{\rm est}|_\ell^2 \rangle$,
where $*$ denotes the convolution defined in Equation (\ref{eq:convol},\ref{eq:wconvol}),
in the $\delta^1 B_{\text{\rm from E}}$ term we ignore
the second (and higher) order lensing in B modes $\delta^2 B_{\text{\rm from E}}$,
and in the $E*\phi$ term we ignore the difference of $E$ and $\widetilde E$.
Therefore the template subtraction used has an error
$\delta^2 B_{\text{\rm from E}}- \delta^1 E_{\text{\rm from E}} * \phi$,
where both error terms are of the same order $O(E\phi^2)$ considering that
\be
\begin{aligned}
&(\delta^2 B_{\text{\rm from E}})_{\Bell} \\
=& -\frac{1}{2}\int \frac{d^2 {\Bell_1}d^2 {\Bell_2}}{(2\pi)^2}
[({\Bell_1}+ {\Bell})\cdot({\Bell_1}+ {\Bell_2})]  \\
& [({\Bell_1}+ {\Bell})\cdot {\Bell_2}] E_{{\Bell_1}+ {\Bell}} \sin(2\varphi_{{\Bell_1}+ {\Bell}, {\Bell}})
\phi^*_{{\Bell_1}+ {\Bell_2}} \phi_{\Bell_2},
\end{aligned}
\ee
and
\be
\begin{aligned}
&(\delta^1 E_{\text{\rm from E}})_{\Bell} \\
= & \int \frac{d^2 {\Bell'}}{2\pi} {\Bell'} \cdot ({\Bell'}+ \Bell) E_{{\Bell'}+\Bell}
\cos(2\varphi_{{\Bell'}+\Bell,\Bell}) \phi^*_{\Bell'}.
\end{aligned}
\ee

\end{enumerate}

To summarize, in the quadratic delenser,
\be
B^{\rm del}_{\Bell} = B^r_{\Bell} + B^{\rm res}_{\Bell} + N^B_{\Bell},
\ee
we have ignored lensing in E modes and high order lensing in B modes when estimating
the residual power spectrum $\langle |B^{\rm res}_{\Bell}|^2\rangle$.
We find that each of the two approximation introduces a strong bias in the $r$ estimate,
while the two bias contributions cancel to a high precision,
and the validity of the quadratic delenser sensitively depends on the cancellation.

According to the above analysis, the bias in the residual power estimate
in principle is independent of primordial B-mode signal $B^r$,
therefore we naively expect a $r$-independent bias ${\rm Bias}(r)$
and therefore a bias level ${\rm Bias}(r)/r$ decaying with growing $r$,
which is indeed the behavior we observe for
$r\lesssim 0.01$ (Figure \ref{fig:f3} and \ref{fig:f4}).
But the bias level does not dies down for even greater $r$,
since the $r$ constraints become more sensitive to higher frequency
regime where the bias is stronger. Here we give an informal analysis
of the  bias level behavior.
From a single delensed B modes $B^{\rm del}_{\Bell}$,
we can estimate the primordial B-mode power spectrum
with root variance $\Delta C_{\Bell} = C^{BB,r}_{\Bell} + C^{BB,{\rm res}}_{\Bell} + N^{BB}_{\Bell}$,
and  consequently estimate $r$ with mean value
\be
r^{\rm est}_{\Bell} = \frac{|B^{\rm del}_{\Bell}|^2 - C^{BB,{\rm res}}_{\Bell}- N^{BB}_{\Bell}}{C^{BB,r=1}_{\Bell}},
\ee
and
with root variance $\sigma_{\Bell}(r) = \Delta C_{\Bell}/C^{BB,r=1}_{\Bell}$.
These estimators from different modes can be added with inverse-variance weighting
$r^{\rm est} = \sum_{\Bell} W_{\Bell} r^{\rm est}_{\Bell}$,
where
\be
W_{\Bell}(r) = \frac{\frac{1}{\sigma^2_{\Bell}(r)}}{\sum_{\Bell} \frac{1}{\sigma^2_{\Bell}(r)}}.
\ee
It is straightforward to understand that  $W_{\Bell}(r)$ increases with $r$ for large $|{\Bell}|$
where $C^{BB,{\rm res}}_{\Bell}+ N^{BB}_{\Bell}$ dominates $\Delta C_{\Bell}$,
and decreases with $r$ for small $|{\Bell}|$ where $C^{BB,r}_{\Bell} $ dominates $\Delta C_{\Bell}$.
In addition, we know that the quadratic delenser is a biased estimator, i.e.,
\be
\langle |B^{\rm del}_{\Bell}|^2 \rangle = C^{BB,{\rm res}}_{\Bell} + N^{BB}_{\Bell} + C^{BB,r}_{\Bell} + C^{BB,{\rm bias}}_{\Bell},
\ee
and
\be
\langle r^{\rm est}_{\Bell} \rangle = \frac{C^{BB,r}_{\Bell} + C^{BB,{\rm bias}}_{\Bell} }{C^{BB,r=1}_{\Bell}}
= r + r^{\rm bias}_{\Bell},
\ee
where $r^{\rm bias}_{\Bell}$ increases with $|{\Bell}|$.
Therefore, we have $\langle r^{\rm est}\rangle
= \sum_{\Bell} W_{\Bell} \langle r^{\rm est}_{\Bell}\rangle
= r   + \sum_{\Bell} W_{\Bell}(r) r^{\rm bias}_{\Bell}
= r   + {\rm Bias}(r)$,
with ${\rm Bias}(r)$ increasing with $r$.
It also explains the increasing bias level ${\rm Bias}(r)$ with
decreasing map noise $N^{BB}_{\Bell}$ (see Figure \ref{fig:f3}).
Note that we do not expect the quadratic delenser
to exactly match the inverse-variance weighted estimator described above, but the latter
should a good proxy for interpreting the bias behavior.

\subsection{Non-stationary Noise }
\label{sec:nonsta}

\begin{figure*}
\centering
\includegraphics[height=2in]{f5a.pdf}%
\includegraphics[height=2in]{f5b.pdf}%
\includegraphics[height=2in]{f5c.pdf}
\caption{\label{fig:nonsta}
The impact of non-stationary map noise on the $r$ constraints for the Scenario La experiments
($\Delta_{\rm T} = 1\ \mu$K-arcmin).
Left panel: the non-stationary noise modulation $\sigma(\mathbf x)$.
Middle/Right panel: the detection/bias level of $r$ constraints inferred from the two delensers.}
\end{figure*}

The modified Gaussian likelihood  works not only as a correction to
the quadratic template subtraction estimator,
but also shows its advantage in dealing with realistic experiment complexities,
e.g., non-stationary noise and sky cuts.
Here we explore an example of non-stationary noise with pixel
dependent noise, i.e., $\left< n(\mathbf x) n(\mathbf y)\right>
= \sigma^2(\mathbf x)\Delta_{\rm P}^2 \delta_D(\mathbf x-\mathbf y)$,
with $\Delta_{\rm P}=\sqrt{2} \ \Delta_{\rm T} = \sqrt{2}\ \mu$K-arcmin, and
$\sigma(\mathbf x)$  a pixel-dependent modulation (Figure \ref{fig:nonsta}).
We expect the likelihood based estimator to work robustly in the presence of non-stationary noise,
as long as we take the pixel dependent noise into account
when calculating the covariance matrix of noise (see Appendix \ref{sec:app2}).
But the non-stationary noise becomes troublesome for
the quadratic delenser in  Fourier space.
\footnote{In the case of non-stationary noise,
the noise power spectrum loses the protection of symmetry,
i.e, $\langle n_{\Bell}n_{\Bell'}\rangle = N_{\Bell,\Bell'}$ now depends on
both multipoles instead of their linear combination $\Bell,\Bell'$.
If we were to correctly use the quadratic delenser,
then the residual power evaluation in Equation (\ref{eq:respower})
becomes difficult, and is out of the scope of this paper.
Here we simply (but incorrectly) assume the stationary noise power spectrum in Equation (\ref{eq:respower}),
and test how the non-stationary noise biases the $r$ constraint from the quadratic delenser.}

Applying the two estimators on simulations with non-stationary noise,
we find that the modified Gaussian likelihood method works as well as in the case of stationary noise,
while the quadratic delenser is significantly biased (Figure \ref{fig:nonsta}).

\section{Summary and Conclusions}
\label{sec:summary}

Delensing is a crucial part for future CMB experiments aiming to detect a primordial B-mode signal.
Up to linear order, one can effectively delense observed B-modes by utilizing
a quadratic combination of observed E-modes and an estimate of the lensing potential.
This is the underlying idea of the quadratic delenser.
However, in the regime of small map noise,
the lensing in E modes, and higher order lensing in B modes
ignored by the quadratic delenser, significantly bias the $r$ constraint.
We investigated the bias induced by each of the two approximations via simulations,
finding that each of two approximations induce a large bias, while the two bias terms
partly cancel and therefore the net bias is moderately suppressed.
The validity of the quadratic delenser sensitively depends on the cancellation.

Alternatively,  a full-scale likelihood analysis of the tensor-to-scalar ratio $r$ can,
in principle, optimally account for all the $r$ information in the CMB observations and
remedy possible bias problems.
Unfortunately, a full likelihood analysis requires computation resources beyond
what is available in the near future.
In this paper, we presented a modified Gaussian likelihood method.
This method consists of two parts, covariance decomposition and data compression.
In the first part, we decomposed the covariance matrix
in the form of $\Sigma_r = \Sigma^{\rm en} + r \Sigma^{\rm b}$,
which allows us to compute the covariance matrix $\Sigma_r$, as a function of $r$, at the computational cost
of a single covariance matrix evaluation.
In the second part, we compressed the data size by keeping only $s\sim 500$
high signal-to-noise modes, say the large-scale quadratic delensed B modes.
We obtained these B modes from polarization data $d$ via a projection matrix $v$,
$(^0B^{\rm del}_{\Bell})_s = (v^\intercal)_{s\times 2p} d_{2p}$,
and applied the likelihood analysis on the projected data vector.
This method can be naturally extended to incorporate higher frequency modes.

Finally, we applied the quadratic delenser and
the modified Gaussian likelihood method on simulated CMB observations mimicking experiments of
Scenario N, La, and Lb, and compare the resulting $r$ constraints.
We found that, the two methods have similar performance in constraining $r$
for Scenario N, while the quadratic delenser does not perform
as well for the lower-noise Scenario La and Lb due to a strong $r$ constraint bias
in the regime of low map noise. For Scenario La, we expected to detect the
primordial B-mode signal at $\sim 1 \sigma$ level for $r=0.001$, and at $\sim 15 \sigma$ level for $r=0.1$,
from the modified Gaussian likelihood method.
For Scenario Lb with even lower map noise and the same sky coverage,
the detection level only marginally increases due to the saturation of cosmic variance.
Therefore it would be valuable to optimize the survey configurations (${\Delta_{\rm T}, f_{\rm sky}}$)
for the coming CMB experiments given a fixed amount of survey time \citep{s42016}.

We also explored the impact of realistic experiment complexities:
in the presence of non-stationary noise, the modified Gaussian likelihood method also works robustly
as long as we slightly modify the noise covariance matrix to take into account the pixel dependent noise.

\begin{acknowledgements}
ZP is supported by UC Davis Dissertation Year Fellowship.
EA acknowledges support from NSF CAREER grant DMS-1252795.
This work made extensive use of the NASA Astrophysics Data System and
of the {\tt astro-ph} preprint archive at {\tt arXiv.org}.
\end{acknowledgements}

\bibliography{ms}

\appendix
\section{Signal Covariance Matrix}
\label{sec:app1}

There are eight different terms in the map covariance matrix $\Sigma_r$:
$\{ \tilde\Sigma^{SE,SE},\tilde\Sigma^{CE,SE},\tilde\Sigma^{CE,CE} \}$,
$\{ \tilde\Sigma^{SB,SB},\tilde\Sigma^{CB,SB},\tilde\Sigma^{CB,CB} \}$,
and $\{ \Sigma^{NQ,NQ},\Sigma^{NU,NU} \}$ (see Equations (\ref{eq:elements})).
In this subsection, we show how the marginalization over uncertainty in the $\phi$ estimate
is done for the six lensed signal terms,
and leave the two noise terms to the next subsection.
Take $\tilde\Sigma^{XX} (X = SE)$ as an example,
\begin{widetext}
\be
\begin{aligned}
\left<\tilde\Sigma^{XX}_{r,\phi} \right>_{n\phi}
& = \left<\widetilde X(\mathbf x) \widetilde X(\mathbf y)  \right>_{n\phi} \\
& = \left<X(x + \nabla \mu\phi(\mathbf x) + \nabla n\phi(\mathbf x))
 X(\mathbf y + \nabla \mu\phi(\mathbf y) + \nabla n\phi(\mathbf y)) \right>_{n\phi} \\
& = \int \frac{d^2\Bell}{(2\pi)^2} e^{i \Bell\cdot (\mathbf x- \mathbf y+\nabla\mu\phi(\mathbf x) - \nabla\mu\phi(\mathbf y))}
C_\ell^{XX} \left< e^{i\Bell\cdot(\nabla n\phi(\mathbf x) -\nabla n\phi(\mathbf y))}\right>_{n\phi} \\
& = \int \frac{d^2\Bell}{(2\pi)^2} e^{i \Bell\cdot (\mathbf x-\mathbf y+\nabla\mu\phi(\mathbf x) - \nabla\mu\phi(\mathbf y))}
C_\ell^{XX} \exp\{-\Bell\cdot \left[\Sigma^{n\phi}(0)-\Sigma^{n\phi}(\mathbf x-\mathbf y)\right] \cdot \Bell\}  \\
&\simeq \int \frac{d^2\Bell}{(2\pi)^2} e^{i \Bell\cdot (\mathbf x-\mathbf y+\nabla\mu\phi(\mathbf x) - \nabla\mu\phi(\mathbf y))}
C_\ell^{XX} \left(1- \Bell\cdot \left[\Sigma^{n\phi}(0)-\Sigma^{n\phi}(\mathbf x-\mathbf y)\right] \cdot \Bell\right)  \\
& = \int \frac{d^2\Bell}{(2\pi)^2} e^{i \Bell\cdot (\mathbf x-\mathbf y+\nabla\mu\phi(\mathbf x) - \nabla\mu\phi(\mathbf y))} C_\ell^{XX}  \\
& - \sum_{p,q=1}^2 \left[\Sigma^{n\phi}(0)-\Sigma^{n\phi}(\mathbf x-\mathbf y)\right]_{p,q}
\int \frac{d^2\Bell}{(2\pi)^2} \ell_p \ell_q e^{i \Bell\cdot (\mathbf x-\mathbf y+\nabla\mu\phi(\mathbf x) - \nabla\mu\phi(\mathbf y))} C_\ell^{XX} \\
& = {\rm Cov}(X(\mathbf w), X(0))
+ \sum_{p,q=1}^2 \left[\Sigma^{n\phi}(0)-\Sigma^{n\phi}(\mathbf x-\mathbf y)\right]_{p,q}
\partial_{p,q} {\rm Cov}(X(\mathbf w), X(0))
\end{aligned}
\ee
where we have used cumulant expansion at the 4th equal sign,  $\left[\Sigma^{n\phi}(\mathbf x-\mathbf y)\right]_{p,q}$
is the covariance of $\nabla(n\phi)$, i.e.,
\be
\begin{aligned}
\label{eq:a2}
    \left[\Sigma^{n\phi}(\mathbf x-\mathbf y)\right]_{p,q}
  & = \left< \nabla_p n\phi(\mathbf x) \nabla_q n\phi(\mathbf y)\right>_{n\phi}
    = \int \frac{d^2\Bell}{(2\pi)^2} \ell_p \ell_q e^{i\Bell\cdot (\mathbf x-\mathbf y)} N_\ell^{\phi\phi},
\end{aligned}
\ee

\end{widetext}
and ${\rm Cov}(X(\mathbf w), X(0))$ is the covariance of $X$
at separation $\mathbf w =\mathbf x-\mathbf y + \nabla\mu\phi(\mathbf x)-\nabla\mu\phi(\mathbf y)$,
\be
\label{eq:a3}
    {\rm Cov}(X(\mathbf w), X(0)) = \int \frac{d^2\Bell}{(2\pi)^2} e^{i \Bell\cdot \mathbf w} C_\ell^{XX}.
\ee

The above two dimensional integrals (Equations (\ref{eq:a2}-\ref{eq:a3})) can be simplified as  one dimensional integrals
as follows. Take Equation (\ref{eq:a3}) as an example,
\be
\label{eq:a4}
\begin{aligned}
{\rm Cov}\left( X(\mathbf w), X(0) \right)
& = 4\partial_1^2\partial_2^2 \int \frac{d^2\Bell}{(2\pi)^2} e^{i\Bell\cdot \mathbf w} C_\ell^{\mE\mE}\\
&\equiv 4\partial_1^2\partial_2^2 K^{\mathcal E}(w),
\end{aligned}
\ee
where we have used $C_\ell^{XX} = 4\ell_1^2 \ell_2^2 (C_\ell^{EE}/\ell^4)$
and defined $C_\ell^{\mE\mE} \equiv C_\ell^{EE}/\ell^4 $.
Exploiting the integral representation of Bessel functions, we rewrite $K^{\mathcal E}(\mathbf w)$ as a one dimensional
integral
\be
\begin{aligned}
K^{\mathcal E}(\mathbf w)
&=\int \frac{d^2\Bell}{(2\pi)^2} e^{i\Bell\cdot \mathbf w} C_\ell^{\mE\mE} \\
&=\frac{1}{2\pi}\int  J_0\left(\ell w \right)  C_\ell^{\mE\mE} \ell d\ell,
\end{aligned}
\ee
which has no angular dependence.
For derivative calculation, we define $\hat K(w^2) \equiv K^{\mathcal E}(\mathbf w)$,
then
\be
\label{eq:a6}
\begin{aligned}
&\partial_1^2 \partial_2^2 K^{\mathcal E}(\mathbf w)
=\partial_1^2 \partial_2^2 \hat K (w^2) \\
&= 16w_1^2w_2^2 \ \hat K^{(4)}(w^2)  \\
& + 8(w_1^2 + w_2^2) \ \hat K^{(3)}(w^2)  + 4\hat K^{(2)}(w^2).
\end{aligned}
\ee
Using the property
\be
\frac{d}{dz} z^{-s} J_s(z) = - z^{-s} J_{s+1}(z),
\ee
the $n$-th order derivative $\hat K^{(n)}$ is explicitly expressed as
\be
\label{eq:a8}
\hat K^{(n)}(w^2)
= \frac{1}{2\pi} \int \left(-\frac{\ell}{2w} \right)^n  J_n(\ell w) \ell d\ell.
\ee
Collecting Equations (\ref{eq:a4}, \ref{eq:a6}, \ref{eq:a8}),  ${\rm Cov}\left( X(\mathbf w), X(0) \right)$
is decomposed into a few one dimensional integrals.
The calculation of $\partial_{p,q}{\rm Cov}\left( X(\mathbf w), X(0) \right)$ and
$\left[\Sigma^{n\phi}(\mathbf x-\mathbf y)\right]_{p,q}$ is conducted in the same way.
For other lensed terms, the above formulas apply similarly.

\section{Noise Covariance Matrix}
\label{sec:app2}

In Section \ref{sec:app1}, we completely ignore the consequence of the finite beam size in
the signal covariance evaluation, since the signal suppression by the beam convolution
can be interpreted as the noise enhancement by the beam deconvolution.
For noise field $n(\mathbf x)$,  we denote the deconvolved noise field as
$X(\mathbf x) = \varphi^{-1}_x[ n(\mathbf x) ]$, with
\be
\begin{aligned}
    \varphi^{-1}_x[ n(\mathbf x) ]
    &= \int \frac{d^2\Bell}{2\pi} e^{i\Bell\cdot \mathbf x}  \frac{n_{\Bell}}{\varphi_{\Bell} }\\
    &=\int \frac{d^2\Bell}{2\pi} \frac{d^2\mathbf x'}{2\pi}
    e^{i\Bell\cdot (\mathbf x- \mathbf x')}  \frac{n(\mathbf x')}{\varphi_{\Bell} },
\end{aligned}
\ee
\begin{widetext}
where for Gaussian beam profile
$\varphi(\mathbf x) = \frac{1}{2\pi\sigma_b^2} \exp\left(-\frac{\mathbf x^2}{2\sigma_b^2}\right)$,
$\varphi_{\Bell} = \exp \left(-\frac{l^2 \sigma_b^2}{2} \right)$, and $\sigma_b^2 = \theta^2_{\rm FWHM}/(8 \ln 2)$.
Then
\begin{align}
    \Sigma^{XX} = \left< X(\mathbf x) X(\mathbf y)\right>
    &= \int \frac{d^2\Bell}{2\pi}
    \frac{d^2\mathbf x'}{2\pi} \frac{d^2\mathbf k}{2\pi} \frac{d^2\mathbf y'}{2\pi}
    e^{i\Bell\cdot (\mathbf x- \mathbf x')}
     e^{i\mathbf k\cdot (\mathbf y- \mathbf y')}  \frac{1}{ \varphi_{\Bell}\varphi_{\mathbf k} }
    \left<n(\mathbf x') n(\mathbf y') \right>,
\end{align}
For simple white noise
$\left< n(\mathbf x) n(\mathbf y)\right> =\Delta_{\rm P}^2 \delta_D(\mathbf x-\mathbf y)$, we have
\begin{align}
    \left< X(\mathbf x) X(\mathbf y)\right>
    &= \int \frac{d^2\Bell}{(2\pi)^2}
    e^{i\Bell\cdot (\mathbf x -\mathbf y)}
    \frac{\Delta_{\rm P}^2 }{ \varphi_{\Bell} \varphi_{-\Bell} }
    = \Delta_{\rm P}^2 \int \frac{d^2\Bell}{(2\pi)^2}
    e^{i\Bell\cdot (\mathbf x -\mathbf y)}\ e^{\ell^2\sigma_b^2},
\end{align}

where
$\Delta_{\rm P}$ is polarization noise and we usually take $\Delta_{\rm P} = \sqrt{2} \Delta_{\rm T}$.
For more realistic non-stationary noise $\left< n(\mathbf x) n(\mathbf y)\right>
= \sigma^2(\mathbf x)\Delta_{\rm P}^2 \delta_D(\mathbf x-\mathbf y)$,
the covariance matrix of the deconvolved noise field $X(\mathbf x)$ is written as
\be
\begin{aligned}
    \left< X(\mathbf x) X(\mathbf y)\right>
    &= \left<\varphi_x^{-1}[n(\mathbf x)]  \ \varphi_y^{-1}[n(\mathbf y)]\right> \\
    &= \left<\varphi_x^{-1}[n(\mathbf x)]  \ \int \frac{d^2\Bell}{2\pi} \frac{d^2\mathbf y'}{2\pi}
    e^{i\Bell\cdot (\mathbf y- \mathbf y')}  \frac{n(\mathbf y')}{\varphi_{\Bell}} \right>\\
    &= \varphi_x^{-1} \left[  \int \frac{d^2\Bell}{2\pi} \frac{d^2\mathbf y'}{2\pi}
    e^{i\Bell\cdot (\mathbf y- \mathbf y')}  \frac{1}{\varphi_{\Bell}} \left<n(\mathbf x)n(\mathbf y') \right> \right] \\
    &=\varphi_x^{-1} \left[ \sigma^2(\mathbf x) \Delta_{\rm P}^2  \int \frac{d^2\Bell}{(2\pi)^2}
    e^{i\Bell\cdot (\mathbf y- \mathbf x)}  e^{\frac{\ell^2\sigma_b^2}{2}} \right]
\end{aligned}
\ee
where we have exchanged the order of deconvolution and ensemble average at the 3rd equal sign,
since deconvolution is a linear operator.

\be
\begin{aligned}
    \left< X(\mathbf x) X(\mathbf y)\right>
    &= \Delta_{\rm P}^2 \int \frac{d^2\Bell}{(2\pi)^2}
    \frac{d^2\mathbf k}{2\pi}     e^{i\Bell\cdot \mathbf x}
         e^{i\mathbf k\cdot \mathbf y}   \varphi_{\Bell}\varphi_{\mathbf k}
        \left[ \int \frac{d^2\mathbf x'}{2\pi}  e^{-i(\Bell + \mathbf k)\cdot \mathbf x'} \delta^2(\mathbf x') \right]\\
    &= \Delta_{\rm P}^2 \int \frac{d^2\Bell}{(2\pi)^2}
    \frac{d^2\mathbf k}{2\pi}     e^{i\Bell\cdot \mathbf x}
         e^{i\mathbf k\cdot \mathbf y}   \varphi_{\Bell}\varphi_{\mathbf k}\
          (\delta^2)_{\Bell + \mathbf k} \\
    &= \Delta_{\rm P}^2 \int \frac{d^2\Bell}{(2\pi)^2}
    e^{i\Bell\cdot \mathbf x} \varphi_{\Bell}
          \int \frac{d^2\mathbf k}{2\pi}
               e^{i\mathbf k\cdot \mathbf y}   \varphi_{\mathbf k}\
                (\delta^2)_{\Bell + \mathbf k}
\end{aligned}
\ee

\end{widetext}

\section{Inverse of Covariance Matrix}
\label{sec:app3}
The inverse covariance matrix $\Sigma_r^{-1}$ evaluation  is the key to
the $r$ likelihood in Equation~(\ref{eq:likeli}).
To avoid repeating the similar computation for every different $r$, we can single out the $r$ dependence
rewriting the covariance matrix in the form
$\Sigma_r = \Sigma^{\rm en} + r \Sigma^{\rm b}$,
where

\[
\begin{aligned}
\Sigma^{\rm en}
&=
\left(
\begin{tabular}{cc}
    $\tilde \Sigma^{CE,CE} + \Sigma^{NQ,NQ}$ & $\tilde\Sigma^{CE,SE}$ \\
    $\tilde \Sigma^{CE,SE}$ & $\tilde\Sigma^{SE,SE}+\Sigma^{NU, NU}$
\end{tabular}
\right), \\
\Sigma^{\rm b}
&=
\left(
\begin{tabular}{cc}
    $\tilde \Sigma^{SB^0,SB^0}$ & $\tilde \Sigma^{CB^0,SB^0}$ \\
    $\tilde \Sigma^{CB^0,SB^0}$ & $\tilde \Sigma^{CB^0,CB^0}$
\end{tabular}
\right).
\end{aligned}
\]

Both $\Sigma^{\rm en}$ and $\Sigma^{\rm b}$ are symmetric and positive definite.
We first decompose $\Sigma^{\rm b}$ as $\Sigma^{\rm b} = V\Lambda V^\intercal$,
with $\Lambda$ being a diagonal matrix composed of its eigenvalues,
and $V$ being a matrix composed of its eigenvectors.
Now we do a little manipulation to the covariance matrix
\be
\begin{aligned}
\Sigma_r
&= \Sigma^{\rm en}  + r V\Lambda V^\intercal \\
&= V\sqrt{\Lambda} \left(\sqrt{\Lambda^{-1}}V^\intercal \Sigma^{\rm en}V\sqrt{\Lambda^{-1}}  + r I\right) \sqrt{\Lambda} V^\intercal,
\end{aligned}
\ee
where we have used the orthogonality $V^\intercal = V^{-1}$. One more eigendecomposition,
$\sqrt{\Lambda^{-1}}V^\intercal \Sigma^{\rm en} V\sqrt{\Lambda^{-1}} = \hat V \hat \Lambda \hat V^\intercal$,
enables us further transform $\Sigma_r$ as
\be
\begin{aligned}
\Sigma_r
&= V\sqrt{\Lambda}\hat V \left( \hat \Lambda + r I\right)  \hat V^\intercal \sqrt{\Lambda} V^\intercal\\
&= V\sqrt{\Lambda}\hat V \left( \hat \Lambda + r I\right)  (V\sqrt{\Lambda}\hat V )^\intercal.
\end{aligned}
\ee
Here we can obtain the inverse matrix $\Sigma_r^{-1}$ at little cost, using the orthogonality of $V$ and $\hat V$.
And more beautifully,  all the matrices $V, \Lambda$ and $\hat V, \hat\Lambda$ have no $r$ dependence,
hence we obtain the inverse covariance matrix as a function of $r$ at the same computation cost
of a single inverse matrix computation.

\end{document}


%!TEX root = ../main.tex
\section{Future Work}
\label{sec:future_work}
The above sections give rise to several directions for future work. Specifically, we will have to:
\begin{itemize}
\item Formalize the productivity algorithm presented in Section~\ref{sec:productivity}.
\item Show the correctness of the productivity algorithm.
\item Investigate further the internals of the Idris implementation.
\item Find out how codata definitions by observations and corecursive functions with copatterns can be elaborated to \TT.
\end{itemize}
Although the productivity algorithm was described in natural language in Section~\ref{sec:productivity}, a more operational formalization of the algorithm is needed if we are to implement it. A possible step on the way to implementing the algorithm in Idris would be to extend \textit{findus} with dependent types in order to get a realistic testing environment, and then incorporate the productivity algorithm for copatterns into this system. Then, once the algorithm works in this setting, it should be easier to realize in Idris.

To ensure that our productivity algorithm is usable, we will need to prove its correctness. This could possibly be done by reducing the system of time measurement to a subset of sized types.

Since the constructs described in Section~\ref{sec:copatterns_in_idris} must be added to Idris, we will need to delve deeper into the Idris implementation. In particular, we need to investigate how to elaborate these constructs to the core type theory. Additionally, the productivity algorithm must be fit into the system alongside the size-change termination checker.


%% amssamp1.tex is nearly identical to amssamp2.tex, except
%% that amssamp2.tex uses the [twocol] option to produce
%% two-column text.

%\documentclass{ametsoc}

\documentclass[twocol]{ametsoc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% To be entered only if twocol option is used

\journal{jtech}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{hyperref}
\usepackage{url}
%  Please choose a journal abbreviation to use above from the following list:
%
%   jamc     (Journal of Applied Meteorology and Climatology)
%   jtech     (Journal of Atmospheric and Oceanic Technology)
%   jhm      (Journal of Hydrometeorology)
%   jpo     (Journal of Physical Oceanography)
%   jas      (Journal of Atmospheric Sciences)
%   jcli      (Journal of Climate)
%   mwr      (Monthly Weather Review)
%   wcas      (Weather, Climate, and Society)
%   waf       (Weather and Forecasting)
%   bams (Bulletin of the American Meteorological Society)
%   ei    (Earth Interactions)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Citations should be of the form ``author year''  not ``author, year''
\bibpunct{(}{)}{;}{a}{}{,}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{A report on progress on Corrected Moments in Antenna Coordinates 2.0}

\authors{Scott Collis\correspondingauthor{Scott Collis, Argonne National Laboratory,
Environmental Science division,
9700 South Cass Ave, Argonne, IL 60514}
and Jonathan Helmus}

\affiliation{Environmental Science Division, Argonne National Laboratory}

\email{scollis@anl.gov}

%\extraauthor{Extra Author}
%\extraaffil{Affiliation, City, State/Province, Country}

\abstract{In 2010 the Atmospheric Radiation Measurement program procured a number of 3 and 5cm wavelength radars for documenting the macrophysical, microphysical and dynamical structure of precipitating systems. In order to maximize the scientific impact the program supported the development of an application chain to correct for various phenomena in order to retrieve the "point" values of moments of the radar spectrum and polarimetric measurements. This report details the motivation, science and progress to date as well as charting a path forward.}

\begin{document}

\maketitle

\section{Introduction}
\label{sec:intro}
The Atmospheric Radiation Measurement Program (\cite{mather_arm_2012}) (ARM) has a long history of sensing clouds in the column using the Millimeter
Cloud Radar (MMCR, Now Ka-Band Zenith Radar or KaZR). Starting in 2010 ARM embarked on program to better characterize the domain surrounding the
column using scanning radars at millimeter and centimeter wavelengths. Processing for the shorter wavelengths has been previously published  \cite{kollias_scanning_2013}
this report is limited to 5 and 3cm wavelengths. Due to the agility and lower cost per radar the program opted not to operate the common wavelength of
10cm (S-Band) which is  robust to liquid water path attenuation in all but the most severe storms. This necessitates the development of robust code for the
correction of issues due to the two way propagation of the radar through medium that both scatters and attenuates. In addition, the trade off between wavelength,
maximum unambiguous range and Doppler nyquist velocity means the radars alias at 12.4 and 16.52 $\mathrm{ms^{-1}}$ for 3 and 5cm respectively when
operating in a baseline mode (such as during the Mid-Latitude  Convective Continental Clouds Experiment $\mathrm{MC^3E} $ (\cite{jensen_midlatitude_2015}).
 Due to extreme velocities of scatterers aloft and, in places such as Oklahoma, at the surface, aliasing is common and requires post moment calculation dealiasing.
 There are many techniques for dealiasing Doppler velocities (eg \cite{james_real-time_2001}) however on testing we found these techniques to be either
 difficult to implement in an operational chain or lacking in robustness.

When we first attempted to build a processing chain each step made its own decision on where to conditionally run based on various measurements
 of "quality"  such as the co-polar (zero lag) correlation coefficient $\mathrm{\rho_{HV}}$ and Normalized Coherent Power (NCP, also referred to as
 Signal Quality Index or SQI). These are defined as:
\begin{align}
\rho_{HV}(0) &= \frac{|<S_{VV}S_{hh}^*>|}{\sqrt{<|S_{HH}|^2><|S_{VV}|^2>}}\\
NCP &= \frac{P_{coh}}{P_{DC}}.
\end{align}

Where the $S$ terms are elements of the scattering matrix, $P_{coh}$ is the coherent part of the doppler spectrum and $P_{DC}$ is the incoherent part.
 Since ARM radars use magnetron transmitters the phase is randomized from pulse to pulse so when a first trip return is mixed with a return from a scatterer
  beyond the maximum unambiguous range the derived radar Doppler spectrum when averaged over many pulses is flat and the NCP is low. While the
  Doppler spectrum from a first trip has structure from which (depending on the method) a peak can be found and Doppler velocity determined and the NCP
   approaches 1.0. However, the usefulness of NCP alone in second trip detection breaks down in regions of high spectral width. When the spectral width
    approaches the nyquist velocity, even in areas of purely first trip, the NCP decreases. This is especially troublesome in regions of high convergence
    and divergence in convective storms, often causing false flagging of these regions.

To overcome the issues of arbitrary decision making and faults in using NCP alone to detect multiple trips our application chain, Corrected Moments in
 Antenna Coordinates first attempts to identify the nature of the scattering medium at the gate. This gate-ID is performed before any corrections are
  applied so it is different to hydrometeor identification codes (eg \cite{dolan_theory-based_2009}, \cite{wen_cluster-based_2015}, \cite{al-sakka_new_2013} etc.)
  that seek to gain microphysical insight. Gate-ID is performed for the purpose of objectively determining where future algorithms should be applied.
  Since we are implementing CMAC2.0 using the Python-ARM Radar Toolkit (Py-ART, \cite{heistermann_emergence_2014}, \cite{pyartjors}) we can use the the
   identifications to construct a \href{https://github.com/ARM-DOE/pyart/blob/master/pyart/filters/gatefilter.py#L111 }{gate filter}.

\section{Application chain}
There exists many algorithms in the scientific literature for the quality control and correction of radar data. Far to many to adequately
asses and implement. However, given Py-ART's data model driven approach it is possible to design an application chain that is highly
modular and task based. Each component has a particular job and can be replaced as better algorithms are published (and, ideally, code shared).
As stated in the previous section, the overarching idea behind CMAC2.0 is a gate-ID is created and determines the conditional
 application of algorithms. At the time of writing implemented classes are: Rain, melting layer, ice, second trip and no significant
 scatterer. Dealiasing, for example would run on the set of all classes except "no significant return" while retrievals of specific
 attenuation would run on the class of "rain". This approach requires that the gate-ID is run on the pre-corrected data. However,
  as discussed in sec \ref{sec:intro}, radar provided measurements alone are not sufficient to constrain the problem of gate-ID,
  especially the identification of multiple trips. There are a number of pre-ID retrievals and inputs we can generate to constrain
   the problem, however, and these are described in \ref{ssec:precalc}.

The Application chain for CMAC2.0 is shown in fig ~\ref{fig:chain} and can be broken down to:
\begin{itemize}
\item Pre-ID calculations of texture and mapping sounding data to radar gates
\item Ascribing membership functions to gate classes, scoring of gates and classification at the gate of predominate scatterer.
\item Dealiasing of Doppler velocities.
\item Extraction of propagation differential polarimetric phase from instrument measured differential polarimetric phase.
\item Calculation of specific differential phase.
\item Calculation of specific attenuation.
\item Integrate and apply to reflectivity.
\item Calculate rain rate for liquid precipitation using specific attenuation.
\end{itemize}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.9\columnwidth]{application_chain.png}
    \caption{The Application chain for Corrections in Antenna Coordinates 2.0}
     \label{fig:chain}
\end{figure}

\subsection{Calculations performed to aid identification of scatterers at gate}
\label{ssec:precalc}
There are two steps to add information in order to determine
dominant scattering process at the gate:
 Mapping temperature to gate locations and using texture of
 radial velocity as a discriminant of significant scattering.

Since Py-ART already ascribes a cartesian displacement
from the radar for each gate using a simple
 $\mathrm{\frac{4}{3}R_e}$ standard atmosphere
 propagation model CMAC2.0 simply interpolates
  sonde data available from ARM soundings (via the
   interpolated sonde product DOI).

The idea behind texture is that when second trips (or no-trips) dominate, due to the pulse-to-pulse
randomized phase of a magnetron transmitter, radial velocity should vary, from gate to gate, between
 nyquist and negative nyquist randomly. As long as there is some structure to the radar Doppler spectrum
  the signal processor should be able to pick a peak and determine the 1$\mathrm{^{st}}$ moment
  being the radial velocity. Thus the gate-to-gate and azimuth to azimuth variation, or texture of Doppler
  velocity should be able to act as a good discriminant of significant returns.
  The abstract concept is for a central pixel, (i,j) in \ref{fig:grid},
 the points surrounding in a n by m kernel are collected
 then the statistic (eg variance) is calculated on the set of
 points and is returned as the (i,j)$\mathrm{^{th}}$ value in
 the resultant 2D (range, time/azimuth) array.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.8\columnwidth]{grid.png}
    \caption{Illustration of the concept of a moving filter over range gates of adjacent rays.
    The center element, $\mathrm{(i,j)}$ is calculated by passing surrounding elements.
    The footprint of the surrounding elements is determined by the kernel. In many cases we use a 3x3 kernel}
    \label{fig:grid}
\end{figure}

The challenge comes from the desire to calculate this pre-correction. Doppler folding will generate a
significant signal in the texture field if done purely on radial velocity values. However projection of radial
velocity values onto a unit circle allows a smooth transition from positive nyquist to negative nyquist
and there is a branch of mathematics dealing with the statistics of directions and magnitudes known
 as directional statistics (\cite{wiki:dstats}). Values from positive nyquist to negative nyquist are projected
  onto a circle with $\theta$ = 0 to $\mathrm{\pi}$ and the standard deviation is given by:

\begin{align}
x &= \cos{\theta}\\
y &= \sin{\theta}\\
R &= \sqrt{\bar{x}^2 + \bar{y}^2}\\
S &= \sqrt{-2 * \log{R}}
\label{eq:tex}
\end{align}

Figure \ref{fig:textcalc:vr} shows a typical radial velocity field, with folds, from the ARM C-SAPR at the Southern Great Plains. Figure \ref{fig:textcalc:tx} shows the texture field calculated by passing eq. \ref{eq:tex} over data in \ref{fig:textcalc:vr} using a 3x3 kernel as shown in fig \ref{fig:grid}.

\begin{figure}[h]
    \centering
    \begin{subfigure}[b]{0.4\columnwidth}
        \includegraphics[width=\columnwidth]{radial_velocity.png}
        \caption{Radial velocity}
        \label{fig:textcalc:vr}
    \end{subfigure}
     %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc.
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.4\columnwidth}
        \includegraphics[width=\columnwidth]{texture.png}
        \caption{Texture}
        \label{fig:textcalc:tx}
    \end{subfigure}
    \caption{Calculations of texture of radial velocity from the C-Band Scanning ARM Precipitation Radar (C-SAPR) using circular statistic to avoid false texture on folds}
\end{figure}

There are clearly higher values of texture where there are no significant returns while texture falls
quickly over the precipitation echo boundaries. However the exact values of texture to be used
in the membership function to delineate between significant and non-significant will depend on
many factors that influence texture including number of samples, signal to noise etcetera.
 Plotting a histogram of texture values yields  two distinctly separated populations of gates.
 To find the discrimination point we use Scientific Python's (\cite{scipy}) continuous wavelet transform-based
 peak finding algorithm (\cite{Du01092006}) to find the location of the left and right peak. The cut off is then
 decided by finding the minimum value, or valley, between the two peaks. Ad-hoc testing shows this to be robust
 even when changing radar types. We tested with X,C and Ka band radars all using different configurations.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{peak_finding.png}
    \caption{Histogram of texture values from the volume shown in fig \ref{fig:textcalc:vr}. The left hand peak corresponds to
    significant returns, the right hand to noise. The black and red lines are the peak center guess by a wavelet based technique.
    The green line is the minimum value between the two peaks. }
    \label{fig:grid}
\end{figure}

\subsection{Fuzzy logic based identification of scatterers at gate}
As previously discussed the aim of this step is to identify the dominant scatterer at each gate to aid in decision making
upchain. While fuzzy logic has been used for particle identification extensively few investigators have done this as a first step (pre $K_{dp}$ etc). A Notable exception is work by
  \cite{gourley_fuzzy_2007}. Preprocessing ID depends on using the moments and derived products assuming they contain all the issues associated with unprocessed data.
  We use a simple scheme which associates a membership with each classification of: Melting layer, Multi-trip, Rain and Snow. We have future plans to include gates that are contaminated
  by hail in the propagation path. Membership functions are shown in table \ref{tab:mbf}. At the moment, with the exception of texture as referenced in sec \ref{ssec:precalc}, these are determined using
  trail and error. As we have set up a robust codebase using Py-ART and Scikits Fuzzy we can revisit the membership functions at any time using better formulations
  determined using mixtures of machine learning and other techniques.

\begin{table*}[ht]
\caption{Inputs for trapezoidal membership functions for various classes }
\label{tab:mbf}
\centering
\begin{tabular}{p{0.05\linewidth}p{0.12\linewidth}p{0.16\linewidth}p{0.12\linewidth}p{0.14\linewidth}p{0.12\linewidth}p{0.14\linewidth}}
\hline
Class & Tex (m/s)& $\rho_{HV} $ &NCP & Temperature (C) &height (km)  & SNR (dB)\\
\hline
melting & [0, 0, 4, 6], 1.5& [0.6, 0.65, 0.9, 0.96], 3.5& [0.4, 0.5, 1, 1], 0& [0, 0.5, 6, 7], 1& [0, 0, 25, 25], 0& [8, 10, 1000, 1000], 0 \\
multi trip &[5, 6, 130, 130], 5&[0.5, 0.7, 1, 1], 0&[0, 0, 0.5, 0.6], 0&[-100, -100, 100, 100], 0&[0, 0, 5, 8], 0&[15, 20, 1000, 1000], 1\\
rain &[0, 0, 4, 6], 1& [0.97, 0.98, 1, 1],1& [0.4, 0.5, 1, 1], 1& [2, 5, 100, 100], 2& [0, 0, 5, 6], 0]& [8, 10, 1000, 1000], 1\\
snow &[0, 0, 4, 6], 1& [0.65, 0.9, 1, 1],1& [0.4, 0.5, 1, 1], 1& [-100, -100, 0.5, 4], 2& [0, 0, 25, 25], 0& [8, 10, 1000, 1000], 1\\
\hline
\end{tabular}
\end{table*}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{flog.png}
    \caption{Highest score determined categories with hard constraints for the dominant scattering process for each gate from the C-SAPR alongside with (clockwise) reflectivity factor,
    Texture and cross correlation ratio. These values will be used to determine what post-processing will  be applied gate-to-gate.  }
    \label{fig:flog}
\end{figure}

Figure \ref{fig:flog} shows an example of scatterer at gate identification from the 1.9 degree PPI tilt from the C-SAPR during MC3E as a organized linear convective system passed over the site.
Regions of snow scatterers are shown in cyan, rain in green, multi-trip in red, mixed scattering in yellow (eg melting layer) and no significant return in grey. Work is proceeding on determining if
a radial is hail contaminated as is work on clutter identification and tagging.  Figure \ref{fig:xfuz} shows an example of scatterer at gate identification from the 37.3 degree horizon to horizon
RHI from the X-SAPR during for the stratiform region of the same system. The high elevation "stripe" is an artifact likely caused by near field distortion of the antenna pattern by a metal object
(powerline) causing the bright band to be present at those angles.

Gate, or scatter ID, is used to form Py-ART Gate-filter objects which can be the passed to subsequent processing algorithm. For example Linear programming (see sec \ref{sssec:lp}) filtering of $\phi_{DP}$
would be performed gates identified as rain and attenuation correction (offset) on the union of rain, melting layer and snow.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{xsaprfuz.png}
    \caption{Highest score determined categories with hard constraints for the dominant scattering process for each gate from the X-SAPR alongside with reflectivity factor }
    \label{fig:xfuz}
\end{figure}

\subsection{Corrections and retrievals}
In order to have the greatest impact to stakeholders the ARM radars need to provide high quality calibrated and corrected moments and measurements. By measurements we mean the {\it intrisnsic} value.
That is the measurement corrected for all the issues of propagation and processing. In CMAC2.0 this means:
\begin{itemize}
\item Dealiased doppler velocities
\item $\phi_{DP}$ corrected for non-uniform beam filling and phase shift on backscatter
\item Specific differential phase $K_{DP}$
\item Specific Attenuation
\item Reflectivity corrected for liquid water path attenuation
\end{itemize}
\subsubsection{Dealiasing}
Originally the Four Dimensional Dealiasing, (4DD, \cite{james_real-time_2001} ) was wrapped into Py-ART using NASA's Radar Software Library (RSL). Issues with the implementation of the paper into
code led to a long discussion on issues in Dealising (see https://github.com/ARM-DOE/pyart/issues/119). Discussions led to two new solutions in doppler velocity unfolding: Fringe pattern based and region based. Unlike
the dealiasing of cloud radar data where it can be assumed scatterers move purely with the wind storm dynamics creates radial velocity patterns that can move counter flow. The fringe or "phase based" technique is an image analysis technique designed for removing fringe patters from interferometric images. Early tests were sub-par and while the technique is added to Py-ART it is rarely used. The region based technique performs Doppler velocity dealiasing by finding regions of similar velocities and unfolding and merging pairs of regions until all regions are unfolded. Unfolding and merging regions is accomplished by modeling the problem as a dynamic network reduction.
\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{deal.png}
    \caption{Raw and dealiased radial velocities from the ARM C-SAPR radar collected during MC3E. Unfolding was performed using the region based approach.}
    \label{fig:deal}
\end{figure}
Figure \ref{fig:deal} shows raw and unfolded radial velocities from the ARM C-SAPR radar collected during MC3E. Unfolding was performed using the region based technique. Since the technique has been optimized it takes just under 10 seconds to compete a full volume like the one shown given an appropriate gatefilter is provided. Currently the algorithm does not require a sounding, so it will unfold to the nearest whole nyquist interval. In the rare occasion where the whole scene is moving in bulk at above a nyquist the unfolding will be incorrect but simply fixed by minimizing compared to a synthetic volume generated by a sounding.  Long term testing of the algorithm is underway in collaboration with the University of Barcelona and the Catalan Meteorological Service.

\subsubsection{Filtering of measured phase shift between vertical and horizontal polarization}
\label{sssec:lp}
Raw polarimetric phase shift $\Psi_{DP}$ can be broken down into a component due to differential liquid water path  ($\Phi_{DP}$) and other, specific terms, due to partial beam filling ($NBF$) and phase shift on backscatter ($\delta$). Mathematically:
\begin{align}
\Psi_{DP} = \Phi_{DP} + \delta + NBF
\end{align}
see \cite{gian_2008} and references therein. In order to extract microphysical insight into the liquid (precipitating) liquid water path it is desirable to retrieve $\Phi_{DP}$ from the measured signal. Taking advantage of the fact that liquid water content can not be negative and therefore we expect $\Phi_{DP}$ do be strictly increasing we can construct a filter to extract $\Phi_{DP}$ from $\Psi_{DP}$.  \cite{giangrande_application_2013} outlines an objective technique that uses Linear Programming  (LP, see, for example, \cite{hell_lp}) to create a $\Phi_{DP}$ that is piecewise increasing and (importantly) is non-biased. That is, given a $\Psi_{DP} $ that contains a smoothly increasing signal and a short term variation the algorithm will fit through the base rather than the mid-point or peak of the variation. The strength of the fit is influenced by the local reflectivity as a weak constraint. Where reflectivity is high positivity in the gradient of $ \Phi_{DP}$ is enforced (see  \cite{gian_2008} for details).  Once $\Phi_{DP}$ is retrieved the specific differential phase, $K_{DP}$ is retrieved by convoluting $\Phi_{DP}$ with a 20 point linear ramp (a sobel filter). This is similar in nature and ad-hoc experimentation shows it to closely mimic a moving linear fit similar to that used in \cite{bringi_methodology_2002}.
\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{lp1.png}
    \caption{A single radial of data from C-SAPR highlighting the LP technique. Raw $\Psi_{DP}$ is shown in green, retrieved $\Phi_{DP}$ in black, $K_{DP}$ in red and reflectivity (divided by 10) in blue.}
    \label{fig:lp1}
\end{figure}

Figure \ref{fig:lp1} shows a single radial of data from C-SAPR highlighting the LP technique. Raw $\Psi_{DP}$ is shown in green, retrieved $\Phi_{DP}$ in black, $K_{DP}$ in red and reflectivity (divided by 10) in blue. The retrieved  $\Phi_{DP}$ is strictly increasing resulting in a strictly positive $K_{DP}$. LP minimization is achieved by using the CoinLP library. Initially PyGLPK was used but with a very welcome contribution to Py-ART from Kai M{\"u}hlbauer from the University of Bonn switching to CoinLP reduced volume processing time from 8 minutes to under a minute.

\subsubsection{Retrieval of specific attenuation}
\label{sssec:ac}
Specific attenuation, $A$ was retrieved using an adaptation of an iterative "hotspot" method as outlined in \cite{gu_polarimetric_2011}. Using the aforementioned gate ID a gatefilter is constructed that only calculates $A$ in regions of liquid precipitation assuming attenuation due to ice is negligible and in mixed phase regions intractable. Occasionally clutter can throw off the $\phi_{dp}$ calculation which becomes apparent in the $K_{dp}$ and specific attenuation fields. to mitigate this we can $K_{dp}$ to 15 degrees per km.

\begin{figure}[h]
    \centering
    \includegraphics[width=0.95\columnwidth]{refl_before_and_after.png}
    \caption{Reflectivity as measured by the radar and disdrometer offset adjusted attenuation corrected reflectivity with the significant feature detection mask applied}
    \label{fig:zfix}
\end{figure}

Prior to the application of the attenuation correction we apply a reflectivity offset. For the data from MC3E we scale by comparing to a disdrometer measurement, in the future data will be provided calibrated using end-to-end means.  Figure \ref{fig:zfix} shows the original  reflectivity as produced by the radar on the left and the scaled and then corrected reflectivity on the right. The impact is particularly visible in the stratiform region (large drops from melted aggregates) behind the squall line.

%\begin{table*}
%\centering
%\begin{tabular*}{lcr}
%1 & 2 & 3 \        4 & 5 & 6 \        7 & 8 & 9
%%\topline
%%Class & Tex& $\rho_{HV}$ &NCP & height & Temperature & SNR\\
%%1 & 2 & 3 & 4 & 5& 6\
%%\midline
%%[[5.,6.,130.,130.], 5.0] & [[.5,.7,1,1], 0.0] & [[0,0,.5,.6], 0.0] & [[0,0,5000,8000], 0.0] & [[-100,-100,100,100], 0.0] & [[15,20, 1000,1000],1.0] \
%%\botline
%\end{tabular*}
%\end{table*}

\section{Challenges}
Initial robustness tests show we have a lot of work to do in the detection and tagging of clutter returns. Tests of the procedures on X-SAPR data show an even greater impact from clutter. We are currently working on techniques that look at the mean and variance of reflectivity in non-precipitating regions to diagnose clutter. However this is challenging as anomalous propagation exacerbates the clutter issue and is often present as a convective system cools and moistens the boundary layer.
The other challenge is in the software engineering of the LP method. It has been discovered that in regions of extended $\delta_{dp}$ the LP technique as it is in \cite{gian_2008} underperforms. The Author has a nice solution we have had difficulty implementing with the currently supported LP packages. We are still actively working on this issue.

\section{Future work}
The current CMAC framework will be frozen as is and implemented into a data pipeline for the C-SAPR1 at the southern great plains. We will be coupling with the ARM Data Integrator (ADI, \cite{ADI}) to produce routine products. This will help identify both science and computational issues with the code and allow these to be fixed. We will also be working on clutter detection and tagging as well as revisiting attenuation correction including differential attenuation (correction of $Z_{dr}$, something we have not touched on yet. As well as looking at data going forward we will be revisiting the rich MC3E data set with weeks of radar data and corresponding disdrometer data. This will allow us to benchmark the performance of the underlying techniques.

%%%%%%%%%%%%%%%%%
%ACKNOWLEDGMENTS
%%%%%%%%%%%%%%%%%

\acknowledgments{}
This work would not have been possible without the support and patience of the scientific community. Specifically want to thank Scott Giangrande for his contributions of the LP code, all the radar mentors and specifically Nitin Bharadwaj for his tireless support. Kai M{\"u}hlbauer was instrumental in accelerating the LP method to the point of usability. And we greatly appreciate the support and advice of the  ASR Radar Science group specifically the chair, Pavlos Kollias.

%%%%%%%%%%%%%%%%%
%APPENDIXES
%%%%%%%%%%%%%%%%%
%\appendix
%\appendixtitle{Appendix Title}
%
%\subsection*{Appendix section head}
%
%Here is a sample appendix.
%\begin{equation}
%\frac{
%pf \cos\phi}
%{p^0|\nabla h\bar q|(d\theta_0/dz)}
%\end{equation}
%
%\appendix[B]
%\appendixtitle{Second Appendix Title}
%\subsection{Sample appendix section head}
%Second appendix example.
%\subsection{Sample appendix section head}
%\begin{equation}
%\left(\frac{\partial\bar q}{\partial x}
%\overline{U'\theta'} +
%\frac{\partial\bar q}{\partial y}
%\overline{V'\theta'}\right)
%\end{equation}

%%%%%%%%%%%%%%%%%
%REFERENCES
%%%%%%%%%%%%%%%%%

\bibliographystyle{ametsoc2014}
\bibliography{zotero}

%%%%%%%%%%%%%%%%%
% TABLES
%%%%%%%%%%%%%%%%%

%\begin{table}
%\caption{Percentage of variance explained by the first four
%EOFs for the North Pacific Bx. The degree of separation between
%EOF1 and EOF2 and EOF2 and EOF3, based on the North et al.
%(1982) criterion, is indicated by good (GD) and not good or marginal
%(NG).}
%\begin{tabular*}{\hsize}{@{\extracolsep\fill}lcccccc@{}}
%\topline
%Month& EOF1& Split &EOF2& Split& EOF3& EOF4\\
%\midline
%\ Jan& 29& NG& 24& GD& 10& 5\\
%\ Feb& 39& GD& 20& GD& \phantom{1}7 &6\\
%\ Mar& 31& GD& 14& NG& 10& 6\\
%\ Apr& 23& GD& 14& NG& 10& 7\\
%\ May& 19& GD& 12& NG& 10& 7\\
%\ Jun& 19& GD& 12& NG& 10& 9\\
%\ Jul& 18& NG &13& NG& \phantom{1}9& 7\\
%\ Aug& 18& NG& 13& NG& 11& 9\\
%\ Sep &17& NG& 13& NG& 10& 8\\
%\ Oct &16& NG& 13& GD& \phantom{1}8& 7\\
%\ Nov &19 &NG& 16& NG& 11& 8\\
%\ Dec& 33& GD& 18& GD& 10& 6\\
%\botline
%\end{tabular*}
%\end{table}

%
%
%\begin{table}
%\centering
%\caption{Years selected for anomaly composites for the positive
%phase of $B^x$ EOF1.}
%\begin{tabular}{lc}
%\topline
%Month& Yr of positive phase\\
%\midline
%\ \ Jan& 1961, 1969, 1978, 1979, 1988, 1990, 1992, 1994\\
%\ \ Feb& 1964, 1977, 1978, 1980, 1983, 1986, 1988, 2000, 2001\\
%\ \ Mar& 1970, 1973, 1979, 1980, 1984, 1988, 2000\\
%\ \ Apr& 1959, 1961, 1962, 1963, 1968, 1972, 1983, 2002\\
%\ \ May& 1971, 1984, 1993, 1996, 2000\\
%\ \ Jun& 1981, 1983, 1984, 1993, 1998\\
%\ \ Jul& 1961, 1972, 1973, 1978, 1994, 2000\\
%\ \ Aug& 1967, 1970, 1973, 1978, 1994, 1999\\
%\ \ Sep& 1975, 1977, 1988, 1989, 1994, 1998, 1999\\
%\ \ Oct& 1962, 1977, 1998, 1999, 2001\\
%\ \ Nov& 1985, 1986, 1987, 1988, 1991, 1998\\
%\ \ Dec& 1957, 1968, 1972, 1978, 1979, 1990\\
%\botline
%\end{tabular}
%\end{table}
%
%\begin{table}
%\centering
%\caption{Years selected for anomaly composites for the negative
%phase of $B^x$ EOF1.}
%\begin{tabular}{lc}
%\topline
%Month& Yr of negative phase\\
%\midline
%\ \ Jan&1962, 1963, 1968, 1974, 1991, 1996, 1997\\
%\ \ Feb& 1959, 1963, 1971, 1974, 1976, 1979, 1985, 1989, 1990, 1994\\
%\ \ Mar& 1963, 1968, 1972\\
%\ \ Apr& 1984, 1988, 1993, 1996, 1999, 2000\\
%\ \ May& 1961, 1963, 1983, 1987, 1997\\
%\ \ Jun& 1961, 1972, 1978, 1980, 1982, 1986\\
%\ \ Jul& 1964, 1974, 1980, 1983, 1986, 1988, 1993\\
%\ \ Aug& 1980, 1987, 1991, 1993, 1997\\
%\ \ Sep& 1959, 1963, 1969, 1983, 1985, 1993\\
%\ \ Oct& 1957, 1986, 1993, 1996, 1997\\
%\ \ Nov& 1958, 1968, 1970, 1982, 1997\\
%\ \ Dec& 1969, 1974, 1976, 1985, 1998, 1999, 2000, 2001\\
%\botline
%\end{tabular}
%\end{table}

%%%%%%%%%%%%%%%%%
% FIGURES
%%%%%%%%%%%%%%%%%

%\begin{figure}[t]
%\centerline{\includegraphics[width=\textwidth]{figone.pdf}}
%
%\caption{Climatology of $Bx (10^{-6} s^{-1}$, color) and $U^{200}$(m s$^-1$,
%contours) for (a) February and (b) August; $\overline{V'\theta'}^{850}$
%(K m s$^-1$, color) and
%$\overline{V'V'}^{200}$
%(m$^2$ s$^{-1}$, contours) for (c) February and (d) August; MR$^{z850}$
%(10$^{-3}$ m$^2$ s$-2$, color) and $U^{1000}$ (m s$^{-1}$, contours)
%for (e) February and (f) August;
%and SST (K, color) and $F_h$ [10$^5$ J m$^{-2}$ (6 h)$^{-1}$] for (g)
%February and (h) August. Red rectangles indicate the domain of EOF
%calculations.} \label{fig1}
%\end{figure}
%
%\begin{figure}[p]
%\centerline{\includegraphics{FigTwo.pdf}}
%\caption{As in Fig.~10, but for (a),(b) September EOF1; (c),(d) September EOF2; (e),(f) October EOF1; (g),(h) October EOF2; and
%(i),(j) December EOF2.}
%\end{figure}
%
%\begin{figure}
% \centerline{\includegraphics[width=19pc]{figure01.pdf}}
%\appendcaption{A1}{Here is an appendix, single column figure caption.}
%\end{figure}
%

\end{document}