0) A Miriad dataset called "wshop.uv" has been fashioned for you to
image and analyze.  Your goal is to produce a naturally weighted image
with an rms noise of ~ 4.0e-5 Jy.  You should find all the sources in
the field, and determine their coordinates, noting which sources are
extended and which are not.  This dataset simulates some problems you
would encounter in a real dataset.  Your task is to find them, deal with
them, and speed to your final image.
 
After logging in to one of the workstations, with username "synwork" and
the password as given to you, you can set yourself up with
 
% rlogin kaputar                                              # Log in to compute server
% cd data                                                     # Go to data area
% mkdir "myname"                                              # Create a directory for yourself
% cd "myname"                                                 # Go into the directory
% cp -r /DATA/KAPUTAR_3/synwork/nkilleen/wshop.uv .           # Copy workshop data set
% cp -r /DATA/KAPUTAR_3/synwork/nkilleen/helpful_commands .   # Copy cheat sheet
 
where "myname" is some string identifying the directory
you are creating as yours, such as "cjansky" (you don't include the
quotes of course).  Now enter
 
% ls
 
and you will see the files you just copied listed.
 
 



I have provided a little basic Miriad information here, and a bare-bones
outline on what you might do to work on this dataset.  The actual
commands you need to run the tasks mentioned are described in a separate
sheet.  Only use these if you really need them.  Try to use the online
"help" files, the Miriad manuals if possible, and of course your common
sense.  You will find "help select" a useful thing to do from time to
time.  It is the basic keyword that lets you select different quantities
from a visibility file.  Additionaly, "help line" is pretty
indispensable too.  It describes the keyword by which you select
spectral information from a visibility dataset (don't use the "wide"
selection, use "channel" only).  I have also listed a few useful Miriad
commands and tasks on a separate sheet.



Start the Miriad TV (used for TV display with keyword "server")
by entering, in the console window, the command

% xmtv &



The miriad shell is entered by entering the command

% miriad


giving the prompt

miriad% 


The shell is exited with the command

miriad% exit


Note that the Miriad shell is transparent to commands that it does not
understand and passes them on to the operating system.  Thus all your
favourite Unix commands are available.  Miriad uses the operating system
for its file directory structures too, so you will see the files you
create with "ls".   


All miriad tasks have on-line help activated by a command such as

miriad% help uvplt


All Miriad tasks can be executed with command line input or by 
inspecting their inputs, assigning the keywords and entering "go";
viz

miriad% inp uvindex
  Task:   uvindex
  vis      =
  interval =
  log      =

Note that the prompt changes to the task name.  You can assign 
keywords such as

uvindex% vis=wshop.uv
uvindex% log=uv.list

and then enter 

uvindex% go

to write the index of the visibility dataset to the text file called
"uv.list".   Similarly, you could have entered command line input 

miriad% uvindex vis=wshop.uv log=uv.list




1) This dataset mimics a 12 hour observation with the 3Km compact array. 
It contains 10 baselines (the 6Km antennas has not been included) and is
at a frequency of 1.4 GHz.  Only Stokes I (total intensity) is included,
and you will not need to do a basic calibration.  The dataset spans a
bandwidth of 100MHz divided into twenty five, 4MHz channels.  To see
this information use the task "prthd" (it should also have been listed
by "uvindex" above). 




2) Although the dataset contains 25 channels, it is often much faster to
average those channels together in frequency and work on the resultant
"channel-0" dataset.  As discussed in the lectures, you may incur radial
"bandwidth smearing" through doing this.  If the field of interest is
sufficiently small, this may not be a problem, and it will speed up your
processing significantly.  So let us proceed with making a channel-0
dataset and then assess whether it is satisfactory or whether you need
to go back to the spectral data.  Make the channel-0 dataset with the
task "uvaver" (hint, use the "line" keyword).




3) Now you can inspect the channel-0 data set.  You could make an image
(called the dirty image) straight away with "invert", or you might look at
the visibilities first with the plotting program "uvplt".  It is up to
you to decide the best way to examine the quality of your data. 
Generally, the more ways the better. 

If you use "uvplt", examine the plots carefully and use your knowledge
of Fourier transforms to try and guess at what the image will look like. 
The plots might look complicated, but the source is really quite
simple.  Plots such as "uv-distance" versus "amplitude" are handy for this.
You can also look at the uv coverage with "uvplt" (you can look
at lots of things with "uvplt" !).

If you use "invert", you must think a bit carefully about how you assign
the keywords "imsize" and "cell".  You should set "cell" (in arcsec) so
as to have about 3 pixels across the expected synthesised beam FWHM
(remember you have a 3Km array at 1.4 GHz; what is 1.2*lambda/B ?).  The
product of "imsize" and "cell" must cover the region of the sky you wish
to image.  Generally, it is an excellent idea to look at the full region
covered by the primary beam of one antenna (1.2*lambda/D).  Set the
keyword "sup=0" for natural weighting (all visibilities given equal
weight) and levae it to invert.  Look at the image that you have
produced, with the command "tvdisp" (put keyword
"server=xmtv@your_computer")

Having looked at your data via either "uvplt" or "invert" or both, you
must think about whether what you see is good or bad, given your
knowledge of how radio sources look and how they look when they have
been measured by a synthesis array.  Do you see anything wrong with the
data ?? If not, proceed.  If you do, then you have to think about what
is wrong.  If there is bad data, you must excise it with the task
"uvflag".  Then you can redo "uvplt" and/or "invert" and see if you have
made any improvement.  You may need to do this more than once as bad
data (should there be any), has a habit of turning up more than once in
a real dataset. 






4) If you are happy that your data are not corrupted, proceed with
improving your image.  You will have noticed that there are lots of
rings in the image (if you did not notice this then you should probably
give up your workstation to somebody else).  These are sidelobes and
arise because the synthesis array samples the uv-plane only where there
are telescope baselines.  The point-spread function of the array is the
Fourier Transform of the visibilities that arise from an observation of
a point source (which has a very simple visibility function -- what is
it ?) and these rings are that Fourier Transform.  If you are confused,
use "uvplt" to look at "uc" versus "vc" (the uv tracks) and think what
the Fourier Transform of such a pattern might be if the visibilities
were all imaginary part zero and real part unity (a point source at the
phase centre -- I have given the game away).  If you are still confused,
then look at the synthesised beam that "invert" made for you along with
the dirty image.  This is the point-spread function (dirty beam). 

We can do something about these sidelobes.  It is called deconvolution. 
The simplest algorithm to drive is called "CLEAN" and it is implemented
in Miriad in the task "clean".  This task attempts to account for the
missing measurements in the uv-plane; it essentially interpolates the
missing information, although its algorithm is conceptually image
domain bound.  

CLEAN actually iteratively subtracts away fractions of the dirty beam at
the location of the highest peak in the (residual) dirty image and
produces, at the end, what is called the model as well as the residual
image which is the dirty image minus the dirty beam convolved with the
model.  The model is an image.  You can look at it with "tvdisp".  The
CLEAN model is a collection of point sources, as you will see. 
The number of iterations (keyword "niters") that you should do depends
very much upon what the source structure is like and how good your
dynamic range is.  I suggest you start with 200 or so, and increase 
this as you improve the image.

Generally, in order to supress high spatial frequencies that the array
did not measure, this model is convolved by a Gaussian of the same width
as the main lobe of the synthesised beam.  Use task "restor" to do this. 
It also adds the residual image to the convolved CLEAN components. 




5) You will have noticed by now that the source most distant from
the centre of the observation is smeared out radially.  This is of
course bandwidth smearing and arises from assigning the wrong (u,v)
coordinate to the spectral channels -- they are all averaged together
and given the (u,v) coordinate at the centre of the spectrum (remember
u and v are in wavelengths).  You can deal with this by returning
to the spectral data, now that you have fiddled about a bit with the
channel-0 data.

Note that the VLA does not produce multiple channels in continuum mode,
whereas the ATCA does.  This is a deliberate design and offers us an
advantage (the VLA wins in other ways). 

So let us return to the dataset with all the channels; first remove any
bad data that you found in the channel-0 dataset with "uvflag" again.
Now reimage the dataset with "invert".  This time selecting all
the channels with "line=channel,0" and turning on the multi-frequency
synthesis option ("options=mfs").  This ensures that each channel
is gridded in its correct place in the uv-plane.

Then "clean" and "restor" your new image as before.




6) You can use the task "cgcurs" to measure the rms noise in a portion
of the image free from sources and uncleaned edge rubbish (why is that
there ?).  How does it compare with the theoretical value that "invert"
gave you ? Oh dear, you will find that you are not done yet.  How many
sources can you see in the image ?? Perhaps there is one that you cannot
yet see, buried in the high level noise ??




7) Examination of the image indicates that there are some errors in it. 
Basically, you can see non-physical rubbish extending out from the
bright source.  This is fairly typical of antenna based gain errors; in
this case they are phase errors.  You must use the task "selfcal" to
remove these errors so as to improve the dynamic range of the image,
hopefully achieving the theoretical result. 


This is an iterative procedure.  The way it works is that you take your
model from "clean" and give that to "selfcal".  "selfcal" then works out
what it needs to do to adjust the antenna based gains so that on
application of them to the data, the visibilties will match the model in
a least squares sense.  In this case, we will ask "selfcal" to adjust
the phases of the gains only, not the amplitudes.     "selfcal" writes
a gain table to the dataset which is applied automatically next time
you run "invert".

There is a keyword, "interval", which is the time in minutes over which
"selfcal" will solve for a gain solution.  Because there is lots of
signal in this dataset, you can set the interval to something very
short, in fact, the integration time.  Use task "uvlist" to find out
what the integration time is by listing some of the visibilities, and
then set "interval" to something smaller.  Often one must set interval
to several integrations because of insufficient signal when running
selfcal. 

Having run "selfcal", you then re-image and re-clean, and see what has
happened to your image.  Diagnostic tools to understanding whether the
procedure has improved your image or not, are the ratio of theoretical
to actual noise that "selfcal" gives, ideally, it should be close to 1. 
The rms noise of the residual image that "clean" gives you (should go
down if selfcal has helped), visual inspection of the image; does it
"look" better (we don't always know what we are looking for of course),
have what you thought were errors gone away, or improved.  Has the rms
noise of the image improved.   ALWAYS look at your image after selfcal.


You will need to go around the selfcal-invert-clean loop several times. 
Because the data only have 10 baselines, the problem of extracting the
5 antenna based gains from the 10 baselines is not enormously over
determined; it is vastly more so on the VLA with 27 antennas and 351
baselines. 

As your image improves, you can ask "clean" to clean more iterations.
With this dataset, you should not need more than 1000 or so at the
very most when you have made the very best image.




8) When CLEANing, a trick that is often very useful, is to tell "clean"
roughly where the sources are.  You do this by putting "regions" around
each source and then give those regions to "clean"; you are adding in a
priori constraints.  This helps to ensure that it does not pick up
errors or noise as true clean components, which slows down the whole
selfcal-invert-clean iteration loop.  When you first image a field, you
cannot do this as you don't know where the sources are.  But once you
get to know the field a bit, you can start to help clean by putting
regions around the sources.  If you have not included a true source, it
will not clean.  Its sidelobes will remain in place.  This alerts you to
the fact that you have not got them all.  Putting a box around something
that is not real should not matter with perfect data.  If it is a
sidelobe it should disappear as the clean progresses. 

Try defining the clean regions with "cgcurs options=region", and
then input the region into clean with "region=@cgcurs.region".  You
can look at the region file that "cgcurs" made, its just a text file.

With regions around your sources, you should be able to proceeed to the
best image possible with a few iterations of selfcal; you have
eradicated the bad data, imaged all the channels properly,
selfcalibrated out the phase errors and helped clean by putting regions
around the sources. 


9)  Now measure the locations, peak flux densities, integrated
flux densities and sizes of the sources with some combination
of  "cgcurs", "maxfit", "imfit" and possibly "impos".  Note
which sources are point sources and which are extended.



10) Write your paper and submit it to a disreputable journal.

