%
%
%

\chapter{RO Level 1 Product Format and BUFR}\label{app:bufr}

This Appendix describes the mapping between variables in the EPS-SG RO Level 1 data format and WMO's \acrfull{bufr} format for \acrshort{ro} measurements. The full description of the RO BUFR format is outside the scope of this document; instead it is assumed that the reader is familiar with the details of the RO BUFR format as defined in [RO-BUFR]. The recommendations of IROWG (see [IROWG-BUFR]) were taken into account, assuming they will be implemented in the foreseeable future.

\section{BUFR Sections 1 (Identification) and 3 (Data Description)}

BUFR sections 1 is filled with meta data as described in the [RO-BUFR] specification using Edition 4 messages. The time information ``most typical for [the] BUFR message content'' contained in octet numbers 16-17 (year) and 18--22 (month, day, hour, minute and second) are derived from the georeferencing time, i.e. from the variables \texttt{utc_georef_absdate} and \texttt{utc_georef_absdate} in the \texttt{/data/occultation} group.

Section 3 is to be set dynamically from the number of profiles (usually 1 in a single BUFR message) and the message size. Note that there is no Section 2 (Optional Data) in RO BUFR products.


\section{BUFR Section 4 (Data Template)}

In BUFR, quality information is stored in a single 16-bit data field (octet number 18), where the detailed meaning of each flag is defined in Table 8 of [RO-BUFR]. The mapping between BUFR and EPS-SG RO Level 1 product quality flags is described in Tab.~\ref{tab:bufr_quality_flags}. Note that values stored in BUFR products matching the BUFR conventions , in some cases requiring a translation from the logical values used in the EPS-SG RO Level 1 data format as described in section~\ref{sec:conventions}. For example, in case on Bit 1, the global attribute \texttt{environment} may exhibit values of ``Operational'', ``Validation'', ``Development'', ``Offline'',``Integration \& Verification'', and ``Support'' (see section~\ref{sec:attributes_global}). Values of  ``Operational'' and ``Validation'' will be mapped to ``NRT product'', while the remaining ones will be mapped to ``Offline product'' (TBD). On the other hand, the excess phase processing flag is calculated as the logical \texttt{and} of the \texttt{/quality\_snr\_ca\_ok}, \texttt{/quality\_snr\_p1\_ok}, and \texttt{/quality\_snr\_p2\_ok} flags in the EPS-SG RO Level 1 product. Equivalent rules for data exploiting signals from other GNSS constellations and frequencies are TBD.

\begin{table}[thb]
	\centering
	\footnotesize
	\begin{tabularx}{0.95\textwidth}{cX>{\texttt\bgroup}l<{\egroup}}
		\toprule
		\multicolumn{1}{c}{\textbf{Bit}} &
		\multicolumn{1}{c}{\textbf{Description}} & 
		\multicolumn{1}{c}{\textbf{Variable}}  \\
		\midrule
		1 & Nominal / non-nominal quality            & /quality/overall\_quality \\
		2 & NRT / Offline product                    & /environment \\
		3 & Descending / ascending occultation       & /data/occultation/occultation\_type \\
		4 & Excess phase processing (non-) nominal   & /quality/cl\_snr\_[ca|p1|p2]\_ok \\
		5 & Bending angle processing (non-) nominal  & /quality/thinned\_ok \\
		6 & Refractivity processing (non-) nominal   & \textrm{\emph{Unused}} \\
		7 & Meteorological processing (non-) nominal & \textrm{\emph{Unused}} \\
		8 & Closed / open loop data only / included  & /quality/ol\_data\_available \\
		9 & (No) Surface reflections detected        & \textrm{\emph{Unused}} \\
		10 & L2P / L2C GPS signals used              & \textrm{\emph{TBD}} \\
		11-13 & Reserved                             & \textrm{\emph{Unused}} \\
		14 & Background profile (non-) nominal       & \textrm{\emph{Unused}} \\
		15 & Retrieved / background profile          & \textrm{\emph{Unused}} \\
		\bottomrule
	\end{tabularx}
	\caption{Mapping between BUFR Section 4 quality flags for RO and EPS-SG RO L1 data format quality flags.\label{tab:bufr_quality_flags}}
\end{table}

Tab.~\ref{tab:bufr_variable_mapping} links data fields as used in BUFR Section 4 (see Table 5 of [RO-BUFR]) entries to the corresponding variables in the EPS-SG RO L1 Data Format. Note that BUFR products generated by EUMETSAT do not contain ``Step 2a'',  ``Level2a'' or ``Level2b'' data.

Note that this table is based on GRAS data products which contain measurements taken at the L1 and L2 frequency bands of the GPS constellation. The impact of the availability of measurements from other GNSS constellations and from other frequency bands (e.g., L5) on the WMO BUFR format definition are currently TBD.

\afterpage{
\clearpage
\footnotesize
%\begin{longtable}{>{\setlength\hangindent{5mm}}p{0.075\textwidth}p{0.4\textwidth}p{0.4\textwidth}}     %\begin{longtable}{>{\setlength\hangindent{5mm}}cp{0.4\textwidth}p{0.4\textwidth}}
\begin{longtable}{cp{0.4\textwidth}p{0.4\textwidth}}

       % Define the header
       \toprule
       %\multicolumn{1}{p{0.1\textwidth}}{\textbf{Octet}} & 
       \multicolumn{1}{c}{\textbf{Octet}} & 
          \multicolumn{1}{c}{\textbf{Variable(s)}} & 
          \multicolumn{1}{c}{\textbf{Remarks}} \\
       \midrule
       \endhead

       % Define the footer and caption
       \bottomrule
       \caption{Mapping between BUFR Section 4 data fields and EPS-SG RO Level 1 data format variables.\label{tab:bufr_variable_mapping}} \\
       \endfoot

       % Table rows
       \\
       \multicolumn{3}{l}{\textbf{Nominal Reporting Time}}\\
       \midrule
       7-12   & \texttt{/data/occultation/utc\_georef\_absdate} \newline 
                \texttt{/data/occultation/utc\_georef\_abstime} 
              & Assumes [IROWG-BUFR] is implemented \\
       
       \\
       \multicolumn{3}{l}{\textbf{RO Summary Quality Information}}\\
       \midrule
       13     & \textrm{\emph{various}}
              & see Tab.~\ref{tab:bufr_quality_flags}\\
       14     & \texttt{/quality/overall\_quality\_ok}
              & 100\% if True, 0\% otherwise \\
       
       \\
       \multicolumn{3}{l}{\textbf{LEO \& GNSS POD -- Location of Platform}}\\
       \midrule
       15-17  & \texttt{/data/occultation/position\_rec\_fixed} & Antenna phase centre positions\ldots \\
       18-20  & \texttt{/data/occultation/velocity\_rec}        & \ldots{}and velocities at georeferencing time \\
       21     & \texttt{/data/occultation/prn}                  & First letter, e.g. \texttt{G01} $\rightarrow$ 401 (for GPS)\\
       22     & \texttt{/data/occultation/prn}                  & Integer part, e.g. \texttt{G01} $\rightarrow$ 1 (for PRN 01) \\
       23-25  & \texttt{/data/occultation/position\_gns\_fixed} &  Positions\ldots \\
       26-28  & \texttt{/data/occultation/velocity\_gns}        & \ldots{}and velocities at georeferencing time \\
       
       \\
       \multicolumn{3}{l}{\textbf{Local Earth Parameters}}\\
       \midrule
       29     & \textrm{\emph{always zero}}    & Assumes [IROWG-BUFR] is implemented \\
       30     & \texttt{/data/occultation/latitude} & Valid at georeferencing time \\
       31     & \texttt{/data/occultation/longitude} & \hspace{1em} \emph{ditto} \\
       32-34  & \texttt{/data/occultation/r\_curve\_centre\_fixed} &  \hspace{1em} \emph{ditto}\\
       35     & \texttt{/data/occultation/r\_curve} &  \hspace{1em} \emph{ditto}\\
       36     & \texttt{/data/occultation/azimuth\_north} &  \hspace{1em} \emph{ditto}\\
       37     & \texttt{/data/occultation/undulation} & \hspace{1em} \emph{ditto} \\
       
       \\
       \multicolumn{3}{l}{\textbf{RO Step 1b Data}}\\
       \midrule
       38     &  \texttt{len(/data/level\_1b/thinned/impact)} & Fixed number of levels; same for all products\\
       39     & \texttt{/data/level\_1b/thinned/lat\_tp} & \\
       40     & \texttt{/data/level\_1b/thinned/lon\_tp} & \\
       41     & \texttt{/data/level\_1b/thinned/azimuth\_tp} & \\
       42     & \texttt{3}                                   & for ionospheric corrected, L1, and (L2 or L5) data \\
       43     & \texttt{0} or nominal carrier frequencies & 0 for ionospheric corrected bending angles \\
       44     & \texttt{/data/level\_1b/thinned/impact} & \\
       45     & \texttt{/data/level\_1b/thinned/bangle} \newline
                \texttt{/data/level\_1b/thinned/bangle\_ca} \newline
                \texttt{/data/level\_1b/thinned/bangle\_p2} \newline & L1/L2 based, TBD for L1/L5\\
       46-48  & \textrm{\emph{Currently unused}}                     & \\
\end{longtable}
\normalsize
\clearpage
}
