\documentclass[11pt,a4paper]{article}
\pagestyle{plain}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\textwidth}{16.5cm}
\setlength{\topmargin}{-2.0cm}
\setlength{\headheight}{0.0cm} % Change for draft
\setlength{\textheight}{26.5cm} % Change to 22.0 from 24.5
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt}

\newcommand{\kview}{\texttt{kview}~}
\begin{document}
\begin{centering}
{\Large
{\bf
Fourier Transforms Tutorial\\ Narrabri Synthesis Workshop \\ Sep 2001\\
}
}
\end{centering}
\vspace*{3em}

In this tutorial I am hoping to show you four essential properties of the
Fourier plane, as it relates to interferometry.
The treatment is not exact, but tries to develop your inituitive sense
of how Fourier transforms work.

\section*{Tools}
You should have an X windows session open in front of you with some
terminal windows, and a \kview window, for viewing images.

To load an image into \kview, you need to click on the \textbf{Set~1} button
at top left. Then go to the \textbf{Intensity} menu and select the
\textbf{Iscale for set 1} entry. This shows a histogram of the brightness
values in the image. Click the \textbf{99\%} near the top to set the greyscale
display to reasonable values.

You can load a second image into \textbf{Set~2} and blink between them;
choose \textbf{View}$->$\textbf{Display Mode: blink}, then click on the
\textbf{Blink} button.

Make sure you are in the \texttt{fourier} directory, e.g.
\begin{verbatim}
unix% pwd
/n/synwork/fourier/group1/
\end{verbatim}


We're going to use the \textsc{miriad} package to manipulate the images.
I have written some helper programs that will simplify things.
Run the \texttt{SETUP} program to make sure you have access to them.
\begin{verbatim}
unix% source SETUP
unix% which complex_multiply
/n/synwork/fourier/group1/bin/complex_multiply
\end{verbatim}
You will need:
\texttt{forward}, \texttt{backward}, \texttt{complex\_multiply},
\texttt{complex\_divide} and \texttt{delimage}.
We will use one \textsc{miriad} task, \texttt{maths}, directly.

\textsc{miriad}-format images are unix directories containing the image, 
some data about the image (the header) and other stuff like a history of
what has happened to the image.

\section*{Working with Fourier transform images}
There are two parts to the fourier transform of an image,
the \emph{real} and \emph{imaginary} parts.
This form is most useful for mathematical manipulations.

But for thinking about interferometers and visualising Fourier transforms,
it is often easier to look at the \emph{amplitude} and \emph{phase}.
These can be derived from the real and imaginary parts, and \textit{vice versa}.
In most of the following, we will be looking at the amplitude images.
The central parts correspond to the largest scales, finer details are stored
in the pixels out toward the edge of the image.

The \texttt{forward} transform program creates all four images.
These have the suffices \texttt{.rf} (real), \texttt{.if} (imaginary),
\texttt{.af} (amplitude) and \texttt{.pf} (phase).
You only need to give it a real image, it will assume the imaginary part
to be zero.

The \texttt{backward} transform will look for the amplitude and phase
parts, and if it can't find them will try to use the real and imaginary parts.
It produces a real (\texttt{.rb}) and imaginary (\texttt{.ib}) images.
In many cases the latter will be zero.

For all the fourier plane images the coordinates are $u,v$, with units of
wavelength.

\section*{Procedure}
You don't have to complete this today, just get as far as you can.
And you can come back to it during the workshop.

\begin{enumerate}
\item \textbf{Spatial Frequencies}\\
The first thing to learn is the relationship between angular scale in the
image plane and location in the Fourier plane.
Change to the \texttt{part1} directory, and forward transform an image.

Look at the image, and then at the amplitude part (\texttt{.af}) with \kview.

Describe: the difference between the transforms of the two gaussians.\\
Explain: why the amplitude is larger toward the centre.

\item \textbf{Why phase matters}\\
Roughly speaking, phase in the Fourier plane relates to location
in the image plane.

Change to \texttt{part2}. forward-transform two of the gaussian images.
Compare the amplitudes of the transform. Now compare the phase images.

Now zero the phase and back-transform:
\begin{verbatim}
unix% maths exp="<gauss_w10_o30.pf>*0" out=zerophase.pf
unix% maths exp="<gauss_w10_o30.af>*1" out=zerophase.af
unix% backward zerophase
\end{verbatim}
Now look at the \texttt{.rb} image. What has changed?

% this doesn't work.
%
%Now add a constant (10$^\circ$) to the phase and back-transform:
%\begin{verbatim}
%unix% maths exp="<gauss_w10_o30.pf>+10" out=offsetphase.pf
%unix% maths exp="<gauss_w10_o30.af>*1" out=offsetphase.af
%unix% backward zerophase
%\end{verbatim}
%

\item \textbf{Convolution and Deconvolution}\\
These operations can be accomplished by multiplication and division in the
Fourier plane.

Change to the \texttt{part3} directory.
Take one of the real-world images and multiply it by the fourier transform of
a gaussian. Transform back.

Now take the \texttt{smooth} image. Which of the gaussians was it convolved with?\\


Lastly, take the interferometer beam image and convolve it with a real-world
image.\\
%TODO: uvgen a beam map. find a face image.

\item \textbf{Incomplete measurement of the Fourier plane}\\
This is almost always the situation in radio astronomy.
The interferometer measures the Fourier transform of the sky above it,
but only at particular points set by the baseline lengths.
It also cannot measure the centre of the plane, the \emph{zero-spacing}.
Why not? How do you measure it?

If the object you are imaging has a simple structure, incomplete information
does not matter that much. But it does make it difficult to deconvolve by
division in the fourier plane. Why?

The statement above has a corollary: it possible to ignore bits
of the Fourier plane. That means you can filter out, or \emph{edit} out
some aspects of the image you find distracting.

Change to the \texttt{part4} directory.
Try applying some masks to the transforms of some images, and back-transforming.
\begin{verbatim}
unix% maths exp="<object.rf>*0+1" out=mask.xaxis
unix% immask in=mask.xaxis region="abspix,box(1,120,256,136)"

unix% maths exp="<object.rf>*<mask.xaxis>" out=object.m.rf
unix% maths exp="<object.if>*<mask.xaxis>" out=object.m.if
or
unix% maths exp="<object.af>*<mask.xaxis>" out=object.m.af
unix% maths exp="<object.pf>*1" out=object.m.pf
\end{verbatim}
%TODO: insert bad spot in ft of something. make a mask for it.\\
%TODO: notch for garage or mesh images.\\
%TODO: 'cuts' mask for multiple point source images.Use cgcurs.

\item \textbf{Advanced concepts}\\
Change to the \texttt{part5} directory.
Try transforming an image containing two sources.
Look at the amplitudes; what caused \emph{that}?
There are two things to explain.

Now try an image with three sources. What do you think is happening?

Make an amplitude image with constant level and zero phase.
Back-transform this combination.
Think about what this means if you wanted to measure the brightness of
a source, with a limited amount of telescope time, too short to image it
properly.


Ok hotshot --- the interferometer makes a fairly noisy measurement of the
amplitude and phase.
Can you:\\
simulate a phase error? How big can the error get before the image degrades?\\
simulate the effect of amplitude errors on one baseline of the interferometer.\\
Hint: You may need to use the \texttt{imgen} task in \textsc{miriad}.
\end{enumerate}

\end{document}
