% Created 2024-05-17 Fri 17:22
% Intended LaTeX compiler: pdflatex
\documentclass[usenames,dvipsnames,colorlinks,aspectratio=169]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{color}
\usepackage{listings}
\usepackage{pdfpages}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{libertine}
\usepackage{fontawesome}
\mode<beamer>{\usetheme{Boadilla}}
\setbeamertemplate{navigation symbols}{}
\setbeamerfont{alerted text}{series=\bfseries}
\setbeamercolor{alerted text}{fg=blue}
\usecolortheme{default}
\usefonttheme{serif}
\usefonttheme{professionalfonts}
\lstloadlanguages{[ISO]C++}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.50,0,0.82}
\definecolor{codeorange}{rgb}{0.95,0.3,0.1}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
commentstyle=\color{codegreen},
keywordstyle=\color{codeorange},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\usepackage{siunitx}
\usepackage{multirow}
\usetheme{default}
\author{Brett Viren}
\date{\today}
\title{Refresher of LMN Resampling}
\hypersetup{
 pdfauthor={Brett Viren},
 pdftitle={Refresher of LMN Resampling},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 29.3 (Org mode 9.7-pre)}, 
 pdflang={English}}
\begin{document}

\maketitle
\begin{frame}[label={sec:org5a40820}]{LArTPC samplings}
\begin{center}
\begin{tabular}{|c|r|r|r|}
\hline
Detector & T (ns) & F (MHz) & ADC (bits)\\
\hline
\hline
past (PD-1,MB) & 500 & 2.000000 & 12\\
\hline
\hline
DUNE FD &  &  & \\
\hline
VD TDE & 500 & 2.000000 & 14\\
\hline
VD BDE & 512 & 1.953125 & 14\\
\hline
HD & 512 & 1.953125 & 14\\
\hline
\end{tabular}
\end{center}
\note{This is a note.}
\end{frame}
\begin{frame}[label={sec:org15640b5}]{Proposal}
Inside the \alert{offline WCT Noise Filter} we will \alert{upsample} the waveforms:
\[T=\qty{512}{ns} \to T=\qty{500}{ns}\]

Comments:

\begin{itemize}
\item Upsampling is \alert{information-lossless} from a sampling-theory view.
\begin{itemize}
\item The particular technique must take care to minimize \alert{time-domain artifacts}.
\end{itemize}
\item Can be performed \alert{cost-free}  inside existing WCT NF frequency domain and with a ``trick''.
\item Apply \alert{far-upstream} to provide \qty{500}{ns} to (almost) all offline software.
\begin{itemize}
\item Allows field-response and simulation to be at \qty{500}{ns}.
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org9d7621d}]{Conventional resampling \(N \to N'\)}
\begin{center}
``rational interpolation'' = ``integral upsample'' + ``integral downsample''.
\end{center}

\begin{itemize}
\item \alert{integral upsample} \(N \to N^{iu} = LN\)
\item \alert{integral downsample}  \(N \to N^{id} = N/M\)
\item \alert{rational interpolation} \(N \to N^{ri} = RN,\ R\equiv \frac{L}{M}\)
\end{itemize}

\vfill

\small Comments

\begin{itemize}
\item \scriptsize Integral downsample allows for non integer \(N/M\) by selecting every \(M^{th}\) time sample and ignoring the fact that the last selection represents fewer discarded samples than prior selections.

\item Depending on original signal bandwidth, downsampling may require a low-pass filter to avoid aliasing.
\end{itemize}
\end{frame}
\begin{frame}[label={sec:orgf7ab2cc}]{The LMN trick}
\begin{quote}
Choose \(N\) to minimize \(L\) and \(M\) while keeping \(\frac{LN}{M} \in \mathbb{N}\).
\end{quote}

We want to shift the Nyquist frequency by:

\[ \Delta F= F_{nyquist} - F'_{nyquist} = \frac{T-T'}{2TT'}\]

And we want that shift to be covered by an integral number \(n\) of bins of size \(\delta F = \frac{1}{NT}\).

So, we want \(n\cdot\delta F = \Delta F\) which is solved by:

\[ N = \frac{2nT'}{T-T'} = \frac{n}{3}\cdot 250\]

With the last term having plugged in DUNE numbers.

Thus for \(N\) any multiple of 250, we can assure the downsampling will be exactly integral.
\end{frame}
\begin{frame}[label={sec:org0f3b7b2}]{LMN procedure}
\begin{enumerate}
\item Calculate a desired \(N\) and \(n\).
\item Truncate or pad original signal to \(N\) while mitigating \alert{artifacts}.
\item Apply \(DFT\).
\item Insert \(2n\ (R>1)\) or remove \(2n\ (R<1)\) frequency samples.
\item Apply \(DFT^{-1}\).
\item Fix normalization.
\end{enumerate}
\end{frame}
\begin{frame}[label={sec:org223a43b}]{Resampling artifacts}
\begin{itemize}
\item Any interpolation produces artifacts in time or frequency or both.
\item Fourier-based interpolation does not distort frequency domain spectrum (other
than the intentional spectral truncation/extension) but can distort time
domain waveform.
\begin{itemize}
\item Violating periodicity assumptions can lead to artifacts near endpoints.
\item Mitigate by padding via simple linear/cubic time-domain extension of waveform?
\end{itemize}
\end{itemize}
\begin{center}
\begin{center}
\includegraphics[height=0.6\textheight]{scipy-signal-resample-1.png}
\end{center}

\tiny \url{https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.resample.html}
\end{center}
\end{frame}
\begin{frame}[label={sec:orgfdd22fb}]{Links}
repo

\url{https://github.com/BNLIF/lmn/} 

paper

\url{https://www.overleaf.com/project/65525feda20cdec448ee4390} 
\end{frame}
\end{document}
