\chapter{Weighting functions: clear-sky conditions}
 \label{sec:wfuns}

 \starthistory
 110826 & First complete version by Patrick Eriksson.\\
 \stophistory

\graphicspath{{Figs/wfuns/}}


Inversions of both OEM and Tikhonov type require that the ``weighting
functions'' can be provided by the forward model \citep[see
e.g.][]{eriksson:analy:00}. A retrieval characterisation following
\citet{rodgers:90,rodgers:00} raises the same demand. A weighting function is
defined as
\begin{equation}
  \frac{\partial \MsrVct}{\partial x_p}
  \label{eq:wfuns:ki}
\end{equation}
where \MsrVct\ is the vector of measurement data and $x_p$ is one forward model
(scalar) variable. See further Sec.~\ref{T-sec:formalism:wfuns} of \theory.
The nomenclature of that section is also used here.

A weighting function forms a column of the complete weighting function matrix,
\aWfnMtr{\SttVct}. The usage of the name weighting function is maybe restricted
just to atmospheric sounding and the Jacobian is a more commonly encountered
name for \aWfnMtr{\SttVct}, in the general scientific literature. In the
documentation of ARTS you find both terms. Also the term ``the Jacobians'' is
used, which shall be interpreted as ``the weighting functions''. These names
refer normally to \aWfnMtr{\SttVct}, the partial derivatives with respect to
the variables to be retrieved, forming the state vector \SttVct. However, in
the context of retrieval characterisation, the same matrix for the remaining
model parameters is of equally high interest, denoted as \aWfnMtr{\FrwMdlVct}.
In the same manner, the terms inversion and retrieval are used interchangeably.
``Weighting function'' is below shortened as WF.

The main task of the user is to select which quantities that shall be
retrieved, and to define the associated retrieval grids. These aspects must be
considered for successful inversions, but are out of scope for this document.
Beside for the most simple retrievals, it is further important to understand
how the different WFs are calculated. A practical point is the calculation
speed, primarily determined if perturbations or analytical expressions are used
(Sec.~\ref{sec:wfuns:intro}). The derivation of the WFs involves some
approximations due to theoretical and practical considerations. Such
approximations can be accepted, if of low or moderate size, but will result in
a slower convergence (the inversion will require more iterations). Due to these
later aspects, and to meet the needs of more experienced users, this section is
relatively detailed and contains a (high?) number of equations.

This section is restricted to WFs for clear-sky conditions, i.e.\ to be applied
outside the cloudbox. As the basic radiative transfer expressions, the complete
Stokes vector is considered, to correctly handle polarisation signatures
created by the surface. So far none of the scattering methods provide WFs.

Sections \ref{sec:wfuns:intro}\,-\,\ref{sec:wfuns:basis} contain information
of general character, while the available quantities are discussed in the
remaining sections (Section~\ref{sec:wfuns:absspecies} and forward).



\section{Introduction}
%==============================================================================
\label{sec:wfuns:intro}
%
There are two main approaches for calculating the WFs, by analytical
expressions and by perturbations. We start with the conceptually simplest one,
but also the more inefficient approach.



\subsection{Perturbations}
%==============================================================================
\label{sec:wfuns:pert}
%
The most straightforward method to determine a WF is by perturbing the model
parameter of concern. For example, the WF for the state variable $p$ can always
be calculated as
\begin{equation}
  \aWfnMtr{\SttVct}^p = \frac{\FrwMdl(\SttVct+\Delta x\VctStl{e}^p,\FrwMdlVct)-
                              \FrwMdl(\SttVct,\FrwMdlVct)}{\Delta x}
 \label{eq:wfuns:perturb}
\end{equation}
where $(\SttVct,\FrwMdlVct)$ is the linearization state, $\VctStl{e}^p$ is a
vector of zeros except for the $p$:th component that is unity, and
$\Delta x$ is a small disturbance (but sufficiently large to avoid
numerical instabilities).

However, it is normally not needed to make a recalculation using the total
forward model as the variables are either part of the atmospheric or the sensor
state, but not both. In addition, in many cases it is possibly to find
short-cuts. For example, the perturbed state can be approximated by an
interpolation of existing data (such as for a perturbed zenith angle). Such
short-cuts are discussed separately for each retrieval quantity.


\subsection{Analytical expressions}
%==============================================================================
\label{sec:wfuns:anal}
%
For most atmospheric variables, such as species abundance, it is possible to
derive an analytical expression for the WFs. This is advantageous because they
result in faster and more accurate calculations. Such expressions are derived
below. Some of the terms involved are calculated as a perturbation. This is
partly a consequence of the flexibility of ARTS. The high-level radiative
transfer methods (e.g.\ \builtindoc{iyEmissionStandardClearsky}) do not know
how the low-level methods are defining all quantities, and a fixed analytical
expression can not be used (see e.g.\ Sec.~\ref{sec:wfuns:atmtemp}). So, in
practise, the calculations are ``semi-analytical''.

To understand the analytical expressions, it is important to remember that ARTS
covers the sensor by a response matrix:
\begin{equation}
  \MsrVct = \SnsMtr\MpiVct.
  \label{eq:wfuns:Hi}
\end{equation}
This equation covers a single measurement block (cf.\
Eq.~\ref{eq:fm_defs:measseq}).


\subsection{Workspace variables and methods}
%==============================================================================
\label{sec:wfuns:wsm}
%
As a workspace variable, the WF matrix is denoted as \wsvindex{jacobian}.
Auxiliary information is provided by \wsvindex{jacobian\_quantities} and
\wsvindex{jacobian\_indices}. The actual calculations are made as part of
\builtindoc{yCalc}. 

The retrieval quantities are defined separately, before calling
\builtindoc{yCalc}. This process is started by calling \wsmindex{jacobianInit}.
The retrieval quantities are then introduced through workspace methods named as
jacobianAdd{\it Something}. For example, for atmospheric temperature the method
is \builtindoc{jacobianAddTemperature}. The order in which these ``add
methods'' is called does not matter.

Finalise the definition of retrieval quantities by calling
\wsmindex{jacobianClose}. To disable the calculation of WFs, skip all above,
and just use \wsmindex{jacobianOff}. The methods named jacobianCalc{\it
  Something} shall never be used directly. Neither needs the user to consider
\wsvindex{jacobian\_agenda}.

The input to the ``add methods'' differs. In some cases you can select between
the analytical and perturbation options. For all perturbation calculations you
must specify the size of the perturbation. For atmospheric gases you can use
different units. For atmospheric fields, and some other quantities, you must
define the retrieval grid(s) to use.



 
\section{Basis functions}
%==============================================================================
\label{sec:wfuns:basis}

A forward model must use a discrete representation: it describes each quantity
with one or several variables. This is unproblematic for quantities that are of
discrete nature (including scalar variables). However, for atmospheric fields
and other continuous model quantities, the discrete representation inside the
forward model requires consideration. To avoid inconsistencies between model
input and output it is important that the mapping from the discrete variables
to the ``continuous view'' of the quantity is well defined, and applied
consistently through the forward model . This mapping is given by the basis
functions\index{basis function}. Similar arguments and nomenclature are found
in \citet{read:thecl:06}.

The basis functions are discussed explicitly in few places in this user
guide, but it shall be noted that all interpolations imply an underlying set
of basis functions. On the other hand, an understanding of both the derivation
and the obtained WFs require direct consideration of the basis functions. ARTS
operates with two types of basis functions.




\subsection{Basis functions for piece-wise linear quantities}
\label{sec:wfuns:basis1}
%
To treat an one-dimensional quantity to be piece-wise linear, or to say that a
linear interpolation shall be applied, are identical definitions. The basis
functions matching this definition have triangular shape, sometimes denoted as
``tenth functions''. Such functions are exemplified in
Fig.~\ref{fig:wfuns:zbasis}, see also \citet{buehler:artst:05}.

\begin{figure}[t]
 \begin{center}
  \includegraphics*[width=0.7\hsize]{fig_absbasis_z}
  \caption{Examples on 1d basis functions for a vertical grid with a 1 km
           spacing: \lsolid~30~km, \ldashed~31~km and \ldashdot~32~km.}
  \label{fig:wfuns:zbasis}  
 \end{center}
\end{figure}

In most cases, the quantity is considered to be undefined outside the end
points of the grid. Hence, the basis function for a grid end point is then just
``half a tenth''. The exception to this rule is retrieval grids of piece-wise
linear variables. To avoid that retrieval grids must cover the complete
atmosphere, end point values are assumed to be valid to the end of the
atmosphere (or data range of concern). That is, the basis functions for end
points of retrieval grids follow the tenth shape inside the grid range, and
have a constant value of 1 outside. In terms of interpolation, this matches to
allow extrapolation, the applying a ``nearest'' interpolation for positions
outside the covered range (the end values are valid all the way to
$\pm$infinity).

The basis functions are defined likewise for higher dimensions, but the
tenth functions are then 2D or 3D ``tenths''.




\subsection{Polynomial basis functions}
\label{sec:wfuns:basis2}
%
Some retrieval quantities are expressed using a polynomial basis. Sensor zenith
angle pointing off-set is one such quantity. The off-set is then treated to
have a polynomial variation as a function of time. If the offset is assumed to
be constant in time, a zero order polynomial shall be selected. If there is
also a linear drift with time, use a first order polynomial, etc.

For these basis functions, the explanatory variable (time in the example above)
is normalised to cover the range [-1,1], here denoted as $z$, and the
continuous representation ($f$) of the variable of concern can be written as
\begin{equation}
  f(z) = x_0 + x_1(z-b_1) + x_2(z^2-b_2) + x_3(z^3-b_3) + x_4(z^3-b_4) + \dots  
\end{equation}
where $x_0, x_1, \dots$ are the coefficients to be retrieved (elements of
\SttVct). The interpretation of a retrieval is simplified if the average of $f$
equals $x_0$, and the scalars $b_1, b_2, \dots$ are selected, schematically, as
\begin{equation}
  0 = \int_{-1}^1 \!\left(z^n-b_n\right) \, \DiffD z, \quad n>0.
\end{equation}
According to this expression, $b_n$ is zero for odd $n$. However, $z$ is in
practise a discrete variable ($z_i$, not necessarily symmetric around 0), and
$b_n$ is taken as the average of $z_i^n$: all $b_n$ can be non-zero. The
normalisation of $z$ is not only made for interpretation reasons, it can be
required for pure numerical reasons, such as when $z$ represent frequency (in
Hz).

In practise, the basis functions are vectors, denoted below as $\VctStl{z}_i$.
Element $j$ of $\VctStl{z}_i$ is
\begin{equation}
  \VctStl{z}_i(j) = z(j)^i - b_i.
\end{equation}





\section{Absorption species}
%==============================================================================
\label{sec:wfuns:absspecies}

\subsection{Common practicalities}
%
To obtain WFs for absorption species, use \wsmindex{jacobianAddAbsSpecies}. The
method handles one species at the time. The calculations can either be done in
in ``analytical'' or ``perturbation'' manner.

For gases, the WFs can be provided for several units of the gas abundance:
\begin{description}
\item[vmr] Volume mixing ratio (a value between 0 and 1). The WF divided by
  $10^6$ corresponds to that 1 ppm of the gas is added to the atmospheric
  volume of concern.
\item[nd] Number density. The WF corresponds here to that one molecule is added.
\item[rel] Relative/fractional change. In a perfectly linear case, the WF
  corresponds here to that the gas amount is doubled.
\item[logrel] This option returns the same WFs as ``rel'', but is included to
  flag that the natural logarithm of the ``rel'' unit is retrieved.
\end{description}
For the ``rel'' and ``logrel'' options it is important to note that ARTS
calculate the WFs with respect to the given state, ARTS does not know anything
about the actual reference state for which the ``rel'' unit is valid (where
normally the a priori state is selected). For iterative inversions, a rescaling
of the WFs provided by ARTS is likely needed, to make the WFs valid with
respect to the (original) reference state. For the assumption made inside ARTS,
the WFs for ``rel'' and ``logrel'' are identical.

A second main consideration is to select the retrieval grids. For analytical
calculations there are no other selections to be made. 


\subsection{Perturbation calculations}
%
For these pure numerical calculations, also the size of the perturbation must
be specified ($\Delta x$ in Eq.~\ref{eq:wfuns:perturb}). The perturbation shall
given following the unit selected. The same value is applied for all WFs (which
can cause practical problems \dots).


\subsection{Analytical expressions}
%
The final radiance obtained through Eq.~\ref{eq:fm_defs:rte_step} can be
expressed as
\begin{equation}
  \label{eq:I4J}
  I = I'+ e^{-\Oth'}\!\left[ \bar{B}_i(1-e^{-\aOth{i}})+I_ie^{-\aOth{i}}\right]
\end{equation}
where $\Oth'$ is the optical thickness between the sensor and point $i+1$
and $I'$ is all emission generated along the same distance.

Let $x$ be one element of $\SttVct$, representing the amount of
some gas at some point in the atmosphere. The contribution to the weighting
function for $x$, originating from the radiative transfer step covered by
Eq.~\ref{eq:I4J}, is calculated by applying the chain rule:
\begin{equation}
  \label{eq:chainrule}
  \frac{\PartD \MsrVct}{\PartD x} =  
  \frac{\PartD \MsrVct}{\PartD \MpiVct}
  \frac{\PartD \MpiVct}{\PartD I} \frac{\PartD I}{\PartD \aOth{i}}
  \left[\frac{\PartD \aOth{i}}{\PartD k_i}\frac{\PartD k_i}{\PartD x_i} 
        \frac{\PartD x_i}{\PartD x} +
        \frac{\PartD \aOth{i}}{\PartD k_{i+1}}\frac{\PartD k_{i+1}}{\PartD x_{i+1}}
        \frac{\PartD x_{i+1}}{\PartD x} \right],
\end{equation}
where $x_i$ and $x_{i+1}$ is the amount of the gas at point $i$ and $i+1$,
respectively. Some of these terms can be expressed explicitly:
\begin{eqnarray}
  \frac{\PartD \MsrVct}{\PartD \MpiVct} &=& \SnsMtr,
               \qquad \mathrm{(cf.\ Eq.\ \ref{eq:wfuns:Hi})} \\
  \frac{\PartD I}{\PartD \aOth{i}} 
      &=& e^{-\Oth'}\!\left( \bar{B}_i-I_i\right)e^{-\aOth{i}}, \\
  \frac{\PartD \aOth{i}}{\PartD k_i}=\frac{\PartD \aOth{i}}{\PartD k_{i+1}} 
      &=& \Delta s_i/2, \qquad \mathrm{(cf.\ Eq.\ \ref{eq:taustep})} \\
  \frac{\PartD k_i}{\PartD x_i}
      &=& \sigma_i, 
\end{eqnarray}
where $\sigma_i$ is the absorption cross-section for the species (at point $i$
and in a unit matching the unit of $x$). The term $\PartD \MpiVct/\PartD I$
gives the position in \MpiVct\ where the $I$ of concern is stored. For clarity
and efficiency reasons, the following nomenclature is used in the source code:
\begin{eqnarray}
  X &=& \frac{\Delta s_i}{2} e^{-\Oth'} e^{-\aOth{i}}, \\
  Y &=& \frac{\PartD I}{\PartD \aOth{i}}\frac{\PartD \aOth{i}}{\PartD k_i}
    \qquad \left( = X(\bar{B}_i-I_i) \right).
\end{eqnarray}
The term $\PartD x_i/\PartD x$ appears due to the fact that $x_i$ and $x$ are
placed at different positions, and the representation of the atmospheric fields
must be considered here. In practise, the term is calculated as the value of
the basis function for $x$ at the location of $x_i$ (further discussed in
\citet{buehler:artst:05}). This is a slight approximation with respect to the
goal of fully incorporating the piece-wise linear representation in the
weighting functions \citep{buehler:artst:05}. A low value of $\Delta s_i$
decreases the degree of approximation.

It can be noted that $\PartD x_i/\PartD x$ is normally non-zero for more than
one element of \SttVct. The exception is if the positions of $x_i$ and $x$ are
identical. Reversely, the weighting function for element $x$ can have
contributions from several propagation path points ($x_i$), as well as from
several radiance spectra.
The expressions above are implemented in \wsmindex{iyEmissionStandardClearsky}.

For higher Stokes components, or if emission is ignored, Eq.~\ref{eq:I4J} is
simplified to
\begin{equation}
  \label{eq:Q4J}
  I = e^{-\Oth'}\!I_ie^{-\aOth{i}}.
\end{equation}
This affects only one of the chain rule terms:
\begin{equation}
  \frac{\PartD I}{\PartD \aOth{i}} 
      = -e^{-\Oth'}\!I_i e^{-\aOth{i}},
\end{equation}
giving
\begin{equation}
  \frac{\PartD I}{\PartD \aOth{i}}\frac{\PartD \aOth{i}}{\PartD k_i} =
  -X I_i.
\end{equation}
This later form is used for Stokes element 2 to 4 in
\wsmindex{iyEmissionStandardClearsky} and for all components in
\wsmindex{iyBeerLambertStandardClearsky}.

In practise, all Stokes components are treated in parallel, to simply
incorporate surface scattering (and in the future possibly also cloud
scattering). Transmission $e^{-\Oth'}$ must then be expressed as a matrix,
$\MtrStl{T}'$. For scattered down-welling radiation ($\StoVec^d_i$) the
effective transmission matrix is
\begin{equation}
  \MtrStl{T}' = \MtrStl{T}_2\MtrStl{R}_i\MtrStl{T}_1,
\end{equation}
where $\MtrStl{T}_2$ is the transmission between the surface and the sensor,
$\MtrStl{R}_i$ is defined in Eq.~\ref{eq:fm_defs:surfacerefl} and
$\MtrStl{T}_1$ is the transmission between the point $i+1$ and the surface.


\subsubsection{Limitations}
%
A constraint for the analytical expressions above is that the effect of the
variable must only be local. Main examples on non-local effects should occur
through hydrostatic equilibrium applies and refraction. Significant impact of a
gas through these mechanisms should only be found for water vapour in the
(lower?) troposphere.





\section{Atmospheric temperatures}
%==============================================================================
\label{sec:wfuns:atmtemp}

\subsection{Common practicalities}
%
To obtain WFs for absorption species, use \wsmindex{jacobianAddTemperature}.
The calculations can either be done in ``analytical'' or ``perturbation''
manner. Retrieval grids must be specified.

A special consideration for temperature is hydrostatic equilibrium. If effects
origination through hydrostatic equilibrium shall be included in the WFs, or
not, is selected by an argument denoted as \verb|hse|. A full account of
hydrostatic equilibrium is possible for perturbation calculations, while the
analytical approach only treats the local effect (see further below).


\subsection{Perturbation calculations}
%
The size of the perturbation must be selected (in K).

Complete radiative transfer calculations are done after perturbing the
temperature field. Hence, all possible effects are included, such as changed
propagation paths through the impact of temperature on the refractive index.
Please, note that hydrostatic equilibrium comes in during the perturbation. If
\verb|hse| is set to ``on'', also \builtindoc{z\_field} is recalculated as part
of the temperature perturbation (Section~\ref{sec:fm_defs:hse}). If set to
``off'', there is no change of \builtindoc{z\_field}. That is, you must make an
active choice regarding hydrostatic equilibrium, while others effects are
included automatically.


\subsection{Analytical expressions}
%
As for gases, only local effects are considered by the analytical expressions.
A changed temperature is not just affecting the absorption, but also the Planck
function:
\begin{equation}
  \frac{\PartD \MsrVct}{\PartD T} =  
  \frac{\PartD \MsrVct}{\PartD \MpiVct} \frac{\PartD \MpiVct}{\PartD I} 
  \left[
  \frac{\PartD I}{\PartD \aOth{i}}\frac{\PartD \aOth{i}}{\PartD T} + 
  \frac{\PartD I}{\PartD \bar{B}_i}\frac{\PartD \bar{B}_i}{\PartD T}
  \right].
 \label{eq:wfuns:t1}
\end{equation}
The partial derivative of $\aOth{i}$ must
now also consider the term $\Delta s_i$ due to the possible constrain of
hydrostatic equilibrium:
\begin{eqnarray}
  \frac{\PartD \aOth{i}}{\PartD T} &=&
  \frac{\PartD \aOth{i}}{\PartD k_i}\frac{\PartD k_i}{\PartD T_i} 
  \frac{\PartD T_i}{\PartD T} +
  \frac{\PartD \aOth{i}}{\PartD k_{i+1}}\frac{\PartD k_{i+1}}{\PartD T_{i+1}}
  \frac{\PartD T_{i+1}}{\PartD T} + \nonumber \\ &&
  \quad + \frac{\PartD \aOth{i}}{\PartD \Delta s_i}
  \left[
    \frac{\PartD \Delta s_i}{\PartD T_i} \frac{\PartD T_i}{\PartD T} +
    \frac{\PartD \Delta s_i}{\PartD T_{i+1}} \frac{\PartD T_{i+1}}{\PartD T}
  \right].
\end{eqnarray}
Several of these terms are already derived in
Section~\ref{sec:wfuns:absspecies} (where $\PartD T_i/\PartD T$ and $\PartD
x_i/\PartD x$ are identical terms). The temperature derivative of the
absorption ($\PartD k_i/\PartD T_i$) must be calculated numerically. This
derivative depends on if gas species concentrations are given as volume mixing
ratio (VMR) or number density. As ARTS uses VMR, the term above will be
calculated with the constrain of fixed VMR. A consequence of this is that it is
not possible to mix retrieval of temperature and number densities.

Eq.~\ref{eq:taustep} gives
\begin{equation}
  \frac{\PartD \aOth{i}}{\PartD \Delta s_i} = \frac{k_i+k_{i+1}}{2}. 
\end{equation}
The path length ($\Delta s_i$), for a given pressure, is linearly proportional
to the temperature, and if $\bar{T}$ is the average temperature along the path
step:
\begin{equation}
  \frac{\PartD \Delta s_i}{\PartD \bar{T}} =   \frac{\Delta s_i}{\bar{T}} 
\end{equation}
Following the other variables, we set $\bar{T}=(T_i+T_{i+1})/2$, and
\begin{equation}
  \frac{\PartD \Delta s_i}{\PartD T_i} = \frac{\Delta s_i}{2T_i}.
\end{equation}
Going back to Equation~\ref{eq:wfuns:t1}, the terms involving $\bar{B}_i$ are
\begin{eqnarray}
   \frac{\PartD I}{\PartD \bar{B}_i} &=&
   e^{-\Oth'}\!\left(1-e^{-\aOth{i}}\right), \\
   \frac{\PartD \bar{B}_i}{\PartD T} &=& \frac{1}{2}\left[
    \frac{\PartD B}{\PartD T_i} \frac{\PartD T_i}{\PartD T} +
    \frac{\PartD B}{\PartD T_{i+1}} \frac{\PartD T_{i+1}}{\PartD T}
  \right].
\end{eqnarray}
The term $\PartD B(T)/\PartD T_i$ can be expressed analytically
\citep{eriksson:studi:02}, but as $B$ is provided by an agenda this term must
anyhow be determined in a pure numerical manner; it is likely the derivative of
the Planck function, but if the Rayleigh-Jeans approximation is for some reason
selected ($B=T$) the term is just 1.

For higher Stokes components, or if emission is ignored:
\begin{eqnarray}
   \frac{\PartD I}{\PartD \bar{B}_i} &=& 0 \quad \mathrm{and} \\
   \frac{\PartD I}{\PartD \aOth{i}}  &=& -e^{-\Oth'}\!I_i e^{-\aOth{i}}.
\end{eqnarray}



\subsubsection{Hydrostatic equilibrium and limitations}
%
A changed temperature has non-local effects, originating from refraction and
hydrostatic equilibrium. The expressions above ignore totally refraction
effects. 

If \verb|hse| is set to ``off'', the term $\PartD \Delta s_i/\PartD T_i$ is set
to zero. That is, the path length through the layer is not affected by a
temperature change. With \verb|hse| set to ``on'', the complete expressions
above are used. 

If this treatment of hydrostatic equilibrium is sufficient or not depends on
the observation geometry. It is not sufficient for e.g.\ limb sounding, where
changes even at altitudes below the tangent point will have an influence as the
geometrical altitudes of all higher layers is changed through hydrostatic
equilibrium. This coupling between temperature changes at altitudes below the
tangent point originates from the geometrical calculations, mapping the sensor
viewing angles to a propagation path through the atmosphere. If the sensor's
viewing direction instead would have been specified as a tangent pressure, there
would not be such a coupling. However, this effect vanishes for ground-based
observations at zenith and satellite measurements at nadir, giving a full
account of hydrostatic equilibrium even with the analytical expressions. In
practise it should be possible to apply the expressions outside zenith and
nadir, as long as the observations are of ``up'' or ``down-ward'' type. The
same applies to measurements from inside the atmosphere, (e.g.\ aircraft ones),
if the reference pressure for hydrostatic equilibrium (\builtindoc{p\_hse})
is matched to the pressure of the observation point.





\section{Sensor pointing}
%==============================================================================
\label{sec:wfuns:sensorpointing}

The term ``sensor pointing'' pointing refers to deviations between nominal and
actual viewing direction of the sensor. So far, only deviations in zenith angle
can be considered. The workspace method to initiate such WFs is
\wsmindex{jacobianAddPointingZa}.

The pointing deviation is treated as a time varying variable, then having a
polynomial variation. hence, the basis functions described in
Section~\ref{sec:wfuns:basis2} are applied. The time is taken from
\wsvindex{sensor\_time}. If the pointing error is assumed to be constant with
time, the polynomial order to select is 0, and so on. As a special case, the
polynomial order -1 signifies here that the pointing off-set is totally
uncorrelated between the spectra (sometime called ``pointing jitter'').

The WFs can be calculated in two manners:
\begin{description}
\item[recalc] If this option is selected, radiative transfer calculations are
  performed for a shift of \builtindoc{sensor\_los} (perturbation size selected
  by \verb|dza|). Only a ``one-sided'' perturbation is applied.
\item[interp] The WFs are derived from existing data, by an interpolation of
  existing data. This achieved by interpolating pencil beam data to a shifted
  zenith angle grid. This will involve some extrapolation of the data, and this
  aspect should be considered when selecting \builtindoc{mblock\_za\_grid}. The
  average of a positive and negative shift. The shift to apply (\verb|dza|)
  should be smaller than the minimum spacing of \builtindoc{mblock\_za\_grid}
  for accurate results. As interpolation is a relative fast operation and a
  ``double-sided'' disturbance is used, this option should in general be
  preferred.
\end{description}




\section{Sensor frequencies}
%==============================================================================
\label{sec:wfuns:sensorfreq}

This class of WFs treats deviations between nominal and actually recorded
frequencies. Such differences can originate in several ways, but the exact
origin can normally be ignored and the effect can be modelled as the backend
(spectrometer, filter bank \dots) channels are shifted from their nominal
position. The workspace method to define these WFs is
\wsmindex{jacobianAddFreqShiftAndStretch}. The WFs can so far only be
determined by applying an interpolation of existing monochromatic data
(``interp''), then shifted \verb|df| from the nominal values.

The method operates with two terms, ``shift'' and ``stretch''. This follows
standard nomenclature. A ``shift'' is an off-set that is of the same size for
all backend channels. That is, if only a shift is assumed, the nominal
distances between the channels are assumed to be valid. The shift term is
always included. The ``stretch'' term considers the distance between the
channels. For a backend with all channels equally spaced, a stretch signifies
that the spacing deviates from the nominal value (but all channels still
equally spaced). More generally, a stretch means that the deviation from the
nominal channel position increases linearly from the middle point of the
backend. In terms of the basis functions Section~\ref{sec:wfuns:basis2}, shift
and stretch correspond to polynomial order 0 and 1.




\section{Polynomial baseline fit}
%==============================================================================
\label{sec:wfuns:polyfit}

A ``baseline'' is microwave jargon for a disturbance of the spectrum that is
not covered by the common sensor characteristics. The most common case is that
the local oscillator signal leaks into the measurement by reflections occurring
inside the sensor, causing a pattern in the spectrum of standing-wave type.
Such effects are difficult to model in a physical manner, and a more general
fitting procedure must be applied. A common option is then to model the
baseline as a polynomial, of a specified order. That is, assuming a measurement
giving a single spectrum, the measured spectrum \MsrVct\ is modelled as
\begin{equation}
  \label{eq:polyfit}
  \MsrVct = \MsrVct' + \sum_{i=0}^n x_i\VctStl{z}_i,
\end{equation}
where $\MsrVct'$ is the ``baseline free'' spectrum.

WFs for such baseline models are obtained by \wsmindex{jacobianAddPolyfit}. For
single spectra measurements, the only consideration is the polynomial order to
use. For measurements where several spectra are appended to form the measurement
vector, the default option is that baseline can vary between all spectra. In
some cases, it could be assumed that the baseline is common between data for
different polarisations, viewing directions or measurement blocks, and flags
can be set to mimic such assumptions.


