├── Casa_Cook.pdf ├── images ├── DSCF3329.JPG ├── casa_cal.png ├── casa_flag.png ├── casa_begin.png ├── CirX1_uvplot.png ├── Do_not_disturb.png ├── doppler_shift.png ├── plotbandpass_b.png ├── doppler_corrected.png ├── plotbandpass_bpoly.png └── plotms_phas_v_channel_bl1.png ├── README.md ├── Makefile ├── casa-bib.bib ├── casadoc.sty └── Casa_Cook.tex /Casa_Cook.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/Casa_Cook.pdf -------------------------------------------------------------------------------- /images/DSCF3329.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/DSCF3329.JPG -------------------------------------------------------------------------------- /images/casa_cal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/casa_cal.png -------------------------------------------------------------------------------- /images/casa_flag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/casa_flag.png -------------------------------------------------------------------------------- /images/casa_begin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/casa_begin.png -------------------------------------------------------------------------------- /images/CirX1_uvplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/CirX1_uvplot.png -------------------------------------------------------------------------------- /images/Do_not_disturb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/Do_not_disturb.png -------------------------------------------------------------------------------- /images/doppler_shift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/doppler_shift.png -------------------------------------------------------------------------------- /images/plotbandpass_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/plotbandpass_b.png -------------------------------------------------------------------------------- /images/doppler_corrected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/doppler_corrected.png -------------------------------------------------------------------------------- /images/plotbandpass_bpoly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/plotbandpass_bpoly.png -------------------------------------------------------------------------------- /images/plotms_phas_v_channel_bl1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ska-sa/casa_cookbook/master/images/plotms_phas_v_channel_bl1.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | casa_cookbook 2 | ============= 3 | 4 | Cookbook for KAT-7 data processing using CASA 5 | 6 | An introduction workbook to illustrate how to reduce KAT-7 data using CASA. 7 | 8 | Files contained in this directory: 9 | - Casa_Cook.tex : LaTex master document 10 | - Casa_Cook.pdf : PDF viewable version of the Cookbook 11 | - casa-bib.bib : LaTeX specific file containing references 12 | - casadoc.sty : LaTeX specific file defining command and environments used in the LaTeX master. 13 | - Makefile : Make script for easy rendering of the PDF from the LaTeX master. 14 | 15 | How to use the Makefile: 16 | - make : Executes pdflatex and generates Casa_Cook.pdf file 17 | - make clobber : Clean up directory by removing LaTeX generated temporary files 18 | - make realclean : Same as for 'make clobber', but also removes the Casa_Cook.pdf file file. 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.2 2002/11/15 17:45:27 dsm Exp $ 2 | 3 | ## don't use builtin implicit rules 4 | 5 | MAKEFLAGS = -r 6 | 7 | 8 | ## define custom suffixes 9 | 10 | .SUFFIXES: 11 | .SUFFIXES: .tex .dvi .ps 12 | 13 | 14 | ## LaTeX 15 | 16 | LATEX = latex 17 | BIBTEX = bibtex 18 | PDFLATEX = pdflatex 19 | 20 | 21 | ## default target 22 | 23 | DOC = \ 24 | Casa_Cook.pdf 25 | 26 | 27 | .PHONY: all 28 | all: $(DOC) 29 | 30 | 31 | ## dependencies 32 | 33 | Casa_Cook_v2_1.pdf: casadoc.sty 34 | 35 | #file.ps: picture.eps 36 | #file.pdf: picture.pdf 37 | 38 | 39 | ## miscellaneous targets 40 | 41 | .PHONY: spell 42 | spell: 43 | @aspell -c -t --lang=en_UK *.tex 44 | 45 | .PHONY: clean 46 | clean: 47 | @rm -f *~ *.log 48 | 49 | .PHONY: squeaky 50 | squeaky: clean 51 | @rm -f *.aui *.aux *.out *.idx 52 | 53 | .PHONY: clobber 54 | clobber: squeaky 55 | @rm -f *.dvi *.bak *.toc *.bbl *.blg 56 | 57 | .PHONY: distclean 58 | distclean: clobber 59 | @rm -f $(DOC) 60 | 61 | .PHONY: realclean 62 | realclean: distclean 63 | @ 64 | 65 | 66 | ## implicit rules 67 | 68 | %.ps: %.dvi 69 | dvips $< -o 70 | 71 | %.dvi: %.tex 72 | $(LATEX) $< && $(BIBTEX) $< && $(LATEX) $< && $(LATEX) $< 73 | 74 | # %.pdf: %.tex 75 | # $(PDFLATEX) $< && $(BIBTEX) $< && $(PDFLATEX) $< && $(PDFLATEX) $< 76 | 77 | ## implicit rules 78 | 79 | %.pdf: %.tex 80 | $(PDFLATEX) $* 81 | $(BIBTEX) $* 82 | $(PDFLATEX) $* 83 | $(PDFLATEX) $* 84 | 85 | ## don't try to make the makefile.. 86 | 87 | Makefile: ; 88 | 89 | 90 | ## -fin- 91 | # vim:set syntax=make: 92 | -------------------------------------------------------------------------------- /casa-bib.bib: -------------------------------------------------------------------------------- 1 | @BOOK{Tufte2006, 2 | author = {Edward R. Tufte}, 3 | title = {Beautiful Evidence}, 4 | year = {2006}, 5 | publisher = {Graphics Press, {LLC}}, 6 | month = {May}, 7 | edition = {First}, 8 | place = {Cheshire, Connecticut}, 9 | isbn = {0-9613921-7-7} 10 | } 11 | @INPROCEEDINGS{HamakerBS1999, 12 | AUTHOR = {{Sault}, R.~J. and {Cornwell}, T.~J.}, 13 | TITLE = {{The Hamaker-Bregman-Sault Measurement Equation}}, 14 | BOOKTITLE = {ASP Conf. Ser. 180: Synthesis Imaging in Radio Astronomy II}, 15 | YEAR = 1999, 16 | EDITOR = {{Taylor}, G.~B. and {Carilli}, C.~L. and {Perley}, R.~A.}, 17 | PAGES = {657-669}, 18 | ADSURL = {http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=1999ASPC..180..657S&db_key=AST} 19 | } 20 | @ARTICLE{Hogbom1974, 21 | author = {{H{\"o}gbom}, J.~A.}, 22 | title = "{Aperture Synthesis with a Non-Regular Distribution of Interferometer Baselines}", 23 | journal = {\aaps}, 24 | year = 1974, 25 | month = jun, 26 | volume = 15, 27 | pages = {417}, 28 | adsurl = {http://adsabs.harvard.edu/abs/1974A%26AS...15..417H}, 29 | adsnote = {Provided by the SAO/NASA Astrophysics Data System} 30 | } 31 | @INPROCEEDINGS{Napier1999, 32 | author = {{Napier}, P.~J.}, 33 | title = "{The Primary Antenna Elements}", 34 | booktitle = {Synthesis Imaging in Radio Astronomy II}, 35 | year = 1999, 36 | series = {Astronomical Society of the Pacific Conference Series}, 37 | volume = 180, 38 | editor = {{Taylor}, G.~B. and {Carilli}, C.~L. and {Perley}, R.~A.}, 39 | pages = {37}, 40 | adsurl = {http://adsabs.harvard.edu/abs/1999ASPC..180...37N}, 41 | adsnote = {Provided by the SAO/NASA Astrophysics Data System} 42 | } 43 | -------------------------------------------------------------------------------- /casadoc.sty: -------------------------------------------------------------------------------- 1 | % File: casadoc.sty 2 | % Subject: Stylesheet for CASA Cookbook 3 | % Author: R van Rooyen. Based on template by A. Pinska; based on template by R.T. Lord and J.C. Guzman 4 | \ProvidesPackage{casadoc} 5 | 6 | %% 7 | % If they're installed, use Bergamo and Chantilly from www.fontsite.com. 8 | % They're clones of Bembo and Gill Sans, respectively. 9 | \IfFileExists{bergamo.sty}{\usepackage[osf]{bergamo}}{}% Bembo 10 | \IfFileExists{chantill.sty}{\usepackage{chantill}}{}% Gill Sans 11 | 12 | %% Usepackage includes 13 | \usepackage{url} 14 | \usepackage{units} 15 | %\usepackage{microtype} 16 | \usepackage{amssymb} 17 | %\usepackage{showframe} 18 | %\usepackage[force,almostfull]{textcomp} 19 | \usepackage{xcolor} 20 | \usepackage{xstring} 21 | \usepackage{natbib} 22 | %% 23 | % Just some sample text 24 | \usepackage{lipsum} 25 | %% 26 | % For nicely typeset tabular material 27 | \usepackage{booktabs} 28 | %% 29 | % For graphics / images 30 | \usepackage{graphicx} 31 | \setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio} 32 | \graphicspath{{graphics/}} 33 | % The fancyvrb package lets us customize the formatting of verbatim 34 | % environments. We use a slightly smaller font. 35 | %\usepackage{fancyvrb} 36 | %\fvset{fontsize=\normalsize} 37 | 38 | \usepackage{tikz} 39 | \usetikzlibrary{shapes,snakes} 40 | %% 41 | % Prints a trailing space in a smart way. 42 | \usepackage{xspace} 43 | %% 44 | % Generates the index 45 | \usepackage{makeidx} 46 | \makeindex 47 | 48 | 49 | \setcounter{tocdepth}{2} 50 | \setcounter{secnumdepth}{2} 51 | 52 | %% tikz box styles 53 | \tikzset{redbox/.style = {draw=red, fill=white, very thick, 54 | rectangle, rounded corners, inner sep=10pt, inner ysep=20pt}} 55 | \tikzset{bluebox/.style = {draw=red, fill=blue!20, very thick, 56 | rectangle, rounded corners, inner sep=10pt, inner ysep=20pt}} 57 | \tikzset{fancytitle/.style = {fill=red, text=white}} 58 | 59 | %% Newcommand definitions 60 | \newcommand*\circled[1]{\tikz[baseline=(char.base)]{ 61 | \node[shape=circle,draw,inner sep=2pt] (char) {#1};}} 62 | 63 | %% Feedback box definition 64 | \newcommand{\drawbox}[3]{ 65 | \vspace{1ex} 66 | \begin{tikzpicture} 67 | \node[#1](box){ 68 | \begin{minipage}{0.90\textwidth} 69 | #2 70 | \end{minipage} 71 | }; 72 | \node[fancytitle, right=10pt] at (box.north west) { #3 }; 73 | \end{tikzpicture} 74 | \vspace{-1ex} 75 | } 76 | \newcommand{\info}[1]{ \drawbox{bluebox}{#1}{\circled{i}} } 77 | \newcommand{\caution}[1]{ \drawbox{bluebox}{#1}{\circled{!}} } 78 | \newcommand{\comment}[1]{ \drawbox{bluebox}{#1}{\circled{\#}} } 79 | \newcommand{\pause}[1]{ \drawbox{bluebox}{#1}{\circled{\textmusicalnote}} } 80 | 81 | %% CASA command environment for verbatim text 82 | \newenvironment{casacmd}{ 83 | \vspace{1.5ex} 84 | \begin{tikzpicture} 85 | \node[redbox](box)\bgroup 86 | \begin{minipage}{0.90\textwidth} 87 | } 88 | { 89 | \end{minipage} 90 | \egroup; 91 | \node[fancytitle, right=10pt] at (box.north west) { CASA command: }; 92 | \end{tikzpicture} 93 | \vspace{-1.5ex} 94 | } 95 | \newenvironment{casaoutput}{ 96 | \vspace{1.5ex} 97 | \begin{tikzpicture} 98 | \node[redbox](box)\bgroup 99 | \begin{minipage}{1.43\textwidth} 100 | \footnotesize 101 | } 102 | { 103 | \end{minipage} 104 | \egroup; 105 | \node[fancytitle, right=10pt] at (box.north west) { CASA output: }; 106 | \end{tikzpicture} 107 | \vspace{-1ex} 108 | } 109 | 110 | %% Standard command line text without verbatim text 111 | \newcommand{\cmdbox}[2]{ 112 | \vspace{1.5ex} 113 | \begin{tikzpicture} 114 | \node [redbox] (box){ 115 | \begin{minipage}{0.90\textwidth} 116 | \footnotesize 117 | \StrSubstitute{#2}{--}{-{}-}[\mystr] 118 | \texttt{\StrSubstitute{\mystr}{'}{$'$}} 119 | \end{minipage} 120 | }; 121 | \node[fancytitle, right=10pt] at (box.north west) { #1 command: }; 122 | \end{tikzpicture} 123 | \vspace{-1ex} 124 | } 125 | \newcommand{\linuxcmd}[1]{\cmdbox{linux}{#1}} 126 | 127 | \newcommand{\arcdeg}{\mbox{$^\circ$}} 128 | \newcommand{\arcmin}{\mbox{$^\prime$}} 129 | \newcommand{\arcsec}{\mbox{$^{\prime\prime}$}} 130 | 131 | % this is MFB's kluge - not sure what this command was supposed 132 | % to do, but it seems to work out without it doing anything 133 | %\newcommand{\forceversofloat}{} 134 | %\newcommand{\'}{\textquotesingle} 135 | 136 | %% 137 | % Prints argument within hanging parentheses (i.e., parentheses that take 138 | % up no horizontal space). Useful in tabular environments. 139 | \newcommand{\hangp}[1]{\makebox[0pt][r]{(}#1\makebox[0pt][l]{)}} 140 | %% 141 | % Prints an asterisk that takes up no horizontal space. 142 | % Useful in tabular environments. 143 | \newcommand{\hangstar}{\makebox[0pt][l]{*}} 144 | % Prints the month name (e.g., January) and the year (e.g., 2008) 145 | \newcommand{\monthyear}{% 146 | \ifcase\month\or January\or February\or March\or April\or May\or June\or 147 | July\or August\or September\or October\or November\or 148 | December\fi\space\number\year 149 | } 150 | 151 | % Prints an epigraph and speaker in sans serif, all-caps type. 152 | \newcommand{\openepigraph}[2]{ 153 | %\sffamily\fontsize{14}{16}\selectfont 154 | \begin{fullwidth} 155 | \sffamily\large 156 | \begin{doublespace} 157 | \noindent\allcaps{#1}\\% epigraph 158 | \noindent\allcaps{#2}% author 159 | \end{doublespace} 160 | \end{fullwidth} 161 | } 162 | 163 | % Inserts a blank page 164 | \newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage} 165 | % Typesets the font size, leading, and measure in the form of 10/12x26 pc. 166 | %\newcommand{\measure}[3]{#1/#2$\times$\unit[#3]{pc}} 167 | 168 | % Macros for typesetting the documentation 169 | \newcommand{\hlred}[1]{\textcolor{Maroon}{#1}}% prints in red 170 | \newcommand{\hangleft}[1]{\makebox[0pt][r]{#1}} 171 | \newcommand{\hairsp}{\hspace{1pt}}% hair space 172 | \newcommand{\hquad}{\hskip0.5em\relax}% half quad space 173 | \newcommand{\TODO}{\textcolor{red}{\bf TODO!}\xspace} 174 | \newcommand{\ie}{\textit{i.\hairsp{}e.}\xspace} 175 | \newcommand{\eg}{\textit{e.\hairsp{}g.}\xspace} 176 | \newcommand{\na}{\quad--}% used in tables for N/A cells 177 | \providecommand{\XeLaTeX}{X\lower.5ex\hbox{\kern-0.15em\reflectbox{E}}\kern-0.1em\LaTeX} 178 | \newcommand{\tXeLaTeX}{\XeLaTeX\index{XeLaTeX@\protect\XeLaTeX}} 179 | % \index{\texttt{\textbackslash xyz}@\hangleft{\texttt{\textbackslash}}\texttt{xyz}} 180 | \newcommand{\tuftebs}{\symbol{'134}}% a backslash in tt type in OT1/T1 181 | \newcommand{\doccmdnoindex}[2][]{\texttt{\tuftebs#2}}% command name -- adds backslash automatically (and doesn't add cmd to the index) 182 | \newcommand{\doccmddef}[2][]{% 183 | \hlred{\texttt{\tuftebs#2}}\label{cmd:#2}% 184 | \ifthenelse{\isempty{#1}}% 185 | {% add the command to the index 186 | \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name 187 | }% 188 | {% add the command and package to the index 189 | \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name 190 | \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name 191 | }% 192 | }% command name -- adds backslash automatically 193 | \newcommand{\doccmd}[2][]{% 194 | \texttt{\tuftebs#2}% 195 | \ifthenelse{\isempty{#1}}% 196 | {% add the command to the index 197 | \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2}}% command name 198 | }% 199 | {% add the command and package to the index 200 | \index{#2 command@\protect\hangleft{\texttt{\tuftebs}}\texttt{#2} (\texttt{#1} package)}% command name 201 | \index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}% package name 202 | }% 203 | }% command name -- adds backslash automatically 204 | \newcommand{\sectionbf}[1]{\section{\emph{\textbf{#1}}}} 205 | \newcommand{\docopt}[1]{\ensuremath{\langle}\textrm{\textit{#1}}\ensuremath{\rangle}}% optional command argument 206 | \newcommand{\docarg}[1]{\textrm{\textit{#1}}}% (required) command argument 207 | \newenvironment{docspec}{\begin{quotation}\ttfamily\parskip0pt\parindent0pt\ignorespaces}{\end{quotation}}% command specification environment 208 | \newcommand{\docenv}[1]{\texttt{#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name 209 | \newcommand{\docenvdef}[1]{\hlred{\texttt{#1}}\label{env:#1}\index{#1 environment@\texttt{#1} environment}\index{environments!#1@\texttt{#1}}}% environment name 210 | \newcommand{\docpkg}[1]{\texttt{#1}\index{#1 package@\texttt{#1} package}\index{packages!#1@\texttt{#1}}}% package name 211 | \newcommand{\doccls}[1]{\texttt{#1}}% document class name 212 | \newcommand{\docclsopt}[1]{\texttt{#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name 213 | \newcommand{\docclsoptdef}[1]{\hlred{\texttt{#1}}\label{clsopt:#1}\index{#1 class option@\texttt{#1} class option}\index{class options!#1@\texttt{#1}}}% document class option name defined 214 | \newcommand{\docmsg}[2]{\bigskip\begin{fullwidth}\noindent\ttfamily#1\end{fullwidth}\medskip\par\noindent#2} 215 | \newcommand{\docfilehook}[2]{\texttt{#1}\index{file hooks!#2}\index{#1@\texttt{#1}}} 216 | \newcommand{\doccounter}[1]{\texttt{#1}\index{#1 counter@\texttt{#1} counter}} 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /Casa_Cook.tex: -------------------------------------------------------------------------------- 1 | \documentclass[force,almostfull,justified]{tufte-book} 2 | % ------------------history of CASA for Dummies: 3 | % V1.0 Nadeem 4 | % V1.1 edited by MBietenholz 5 | % V1.2 replaced the ^M, use ``verbatim''; not complete!! 6 | % V1.3 further modified by MBietenholz; repl ``STAGE'' w/ ``STEP'' 7 | % V1.4 further modified by MBietenholz 8 | % **** handed out at 2012 Oct workshop 9 | % V1.5 further corrections + justify document class added 10 | % V1.7 edit and update of spectral line chapter for by S Goedhard 11 | % V2.0 edited by MFB and others 2013 Aug. 12 | % V2.1 added stylesheet and references, bug fixing and cleaning up by R van Rooyen (Jan 2014) 13 | 14 | \hypersetup{colorlinks}% uncomment this line if you prefer colored hyperlinks (e.g., for onscreen viewing) 15 | 16 | % Book metadata 17 | % \title{CASA for Dummies:\\ A KAT-7 Data Reduction Guide} 18 | \title{Introduction to CASA: \\ A KAT-7 Data Reduction Guide} 19 | \author[Nadeem Oozeer]{N. Oozeer, M. Bietenholz \& S. Goedhart} 20 | 21 | \usepackage{casadoc} 22 | 23 | \begin{document} 24 | 25 | % Front matter 26 | \frontmatter 27 | 28 | % r.3 full title page 29 | \maketitle 30 | 31 | \vfill 32 | \openepigraph{ 33 | \ldots You cannot acquire experience by making experiments. You cannot create experience. You must undergo it.}{Albert Camus.} 34 | 35 | % r.5 contents 36 | \tableofcontents 37 | %\listoffigures 38 | %\listoftables 39 | 40 | % r.7 dedication 41 | %\cleardoublepage 42 | %~\vfill 43 | %\begin{doublespace} 44 | %\noindent\fontsize{18}{22}\selectfont\itshape 45 | %\nohyphenation 46 | %Dedicated to those who dare to stop going Aips 47 | %\end{doublespace} 48 | %\vfill 49 | %\vfill 50 | 51 | 52 | % r.9 introduction 53 | %\cleardoublepage 54 | 55 | %% 56 | % Start the main matter (normal chapters) 57 | \mainmatter 58 | 59 | 60 | \chapter{Why do you want to learn CASA?} 61 | \label{ch:introduction} 62 | 63 | For quite some decades, radio astronomy data reduction has been performed using AIPS, Miriad and other 64 | packages. The coming online of new and substantially enhanced radio interferometers like ALMA, LOFAR 65 | and the JVLA has driven the development of a new software package for interferometric data named CASA. 66 | CASA is better suited to the complexity and data-volume from these instruments than previous existing 67 | packages. CASA was developed by NRAO, and was built on the Aips++ codebase. It seems to be becoming 68 | the software suite of choice for radio interferometric data. KAT-7 is a small interferometer array 69 | and this tutorial presents a guide to reducing the Karoo Array Telescope (KAT-7) data using CASA. 70 | % We will not go into comparing the various packages but rather 71 | % just provide a guide to reducing the Karoo Array Telescope (KAT-7) data 72 | % using CASA. 73 | 74 | \begin{marginfigure} 75 | \includegraphics{images/DSCF3329} 76 | \caption{One of the KAT-7 dishes.} 77 | \forceversofloat 78 | \label{fig:marginfig}\end{marginfigure} 79 | 80 | Producing an image from interferometer data is not straightforward: an interferometer does not form an 81 | image in the way an optical telescope does, but rather the observations are made in a spatial 82 | frequency space, called the u-v or visibility plane, which is essentially a Fourier transform of the 83 | image plane. So, in order to make an image, the interferometer measurements must be Fourier 84 | transformed. 85 | 86 | Due to the nature of the interferometer, the $(u, v)$ plane is not fully sampled. The presence of 87 | unsampled regions in the $(u, v)$ causes artifacts to appear in the image plane. The actual 88 | measurements made by the interferometer are called visibility measurements. In particular, the 89 | geometry of the telescopes in relation to the direction to the source determines the instantaneous u-v 90 | coverage of an interferometer. Often the source is observed for some time, and as the earth and the 91 | telescopes on it rotate with respect to the source, the pattern of $(u, v)$ coverage also rotates, 92 | allowing more parts of the $(u, v)$ plane to be sampled. The Fourier transform of this sampling 93 | function is the point-spread function of the instrument, called the ``dirty beam'' in radio 94 | interferometry. 95 | 96 | An interferometer is inherently a somewhat complex instrument, and modern radio interferometers all 97 | produce multi-layered data sets which have visibility measurements from all the different baselines 98 | forming the interferometer, possibly of several different polarization products, and in addition, they 99 | often have a large number of independent frequency channels. Depending in the science aims, these 100 | independent channels can be combined to form a single-channel image, or they can be used to produce a 101 | multi-channel image cube. 102 | 103 | However, before the visibility measurements can be sensibly Fourier transformed to the image plane, 104 | they must be calibrated. Each telescope has a complex gain which is not known a priori, but must be 105 | determined from the observations. Often specific sources with known properties, called calibrator 106 | sources, are observed with the express purpose of determining these gain factors. The visibility 107 | measurements on any baseline are affected by the complex gains of both telescopes making up that 108 | baseline. The first stage of data processing in aperture synthesis is to determine the amplitude gain 109 | and the phase-shift due to each individual telescope (and the atmosphere above it), which together 110 | form the complex gain for that telescope. Although an interferometer is designed to keep these gains 111 | as stable as possible, they do vary with time, in particular the phase part. 112 | 113 | Data sets often also contain some bad or corrupted data, most commonly due to radio frequency 114 | interference (RFI\footnote{\url{http://pos.sissa.it/archive/conferences/107/001/RFI2010_001.pdf}}) or 115 | to malfunction of some part of the antenna electronics. This bad data should be removed, and the 116 | process of removing them is known as flagging. If the calibration is to be determined from 117 | observations of calibrator sources, then any bad data for the calibrator sources should ideally be 118 | removed before determining the calibration solutions. For other sources it is generally easier to 119 | identify bad data after the calibration is applied. 120 | 121 | Once the visibility data are properly calibrated and edited, they can then be Fourier transformed to 122 | make an image. However, due to the incomplete sampling in the image plane, the image so produced is 123 | the convolution of the sky brightness with the point spread function of the interferometer, which is 124 | called the ``dirty beam''. The second part of the data reduction is to try and correct the image, to 125 | the extent possible, for the effects of this incomplete sampling. Unlike data at some other 126 | wavelengths, radio data can require hours to days of reduction to achieve the highest dynamic range. 127 | Ideally, the image meets the constraints of physical consistency as well as plausibility. This 128 | document will attempt to explain the various stages for getting radio images from KAT-7 data. 129 | 130 | 131 | \section{How to use this document} 132 | 133 | This document assumes that you are conversant with Linux and Python. If not, then the book ``SAMS 134 | teach yourself Linux in 10 minutes'' will be a good start even though you will take more than 10 135 | minutes to read the whole book. Reading ``Python for Dummies'' will also help. We will also not cover 136 | all the fundamentals of radio astronomy, but from time to time we shall try to discuss some concepts 137 | before proceeding so that the user is aware of what we are doing. For a thorough introduction to the 138 | fundamentals of radio astronomy, we recommend the NRAO Essential Radio Astronomy online course 139 | (\url{http://www.cv.nrao.edu/course/astr534/ERA.shtml}). 140 | 141 | The procedures consist of various steps and each step generally depends on the previous ones. So avoid 142 | skipping to the next step if you have warnings and errors, without clearing them. We will note those 143 | steps that are independent of the preceding ones. 144 | 145 | 146 | \section{Conventions used} 147 | We have tried to use the following conventions through this document: 148 | 149 | \begin{itemize} 150 | 151 | \item A {\tt typewriter font} is used for CASA tasknames and variables in the main text, and for CASA 152 | input and outputs given in a red box, for example: 153 | 154 | \begin{casacmd} 155 | \begin{verbatim} 156 | prefix = 'CirX1' 157 | msfile = prefix+'.ms' 158 | \end{verbatim} 159 | \end{casacmd} 160 | 161 | \item The Return key is synonymous with the ENTER key or $\hookleftarrow$ 162 | 163 | \end{itemize} 164 | 165 | \info{Tips: lead to shortcuts that we find useful} 166 | 167 | \caution{Cautions: Avoid pitfalls} 168 | 169 | \comment{Comments: explain the relevant procedure} 170 | 171 | \pause{Pause: Time for a break} 172 | 173 | 174 | \section{Methodology} 175 | 176 | In this document we will review the data reduction procedures that we will use during the in-house 177 | workshop on CASA. 178 | 179 | \begin{figure*} 180 | \includegraphics[width=12cm]{images/casa_begin} 181 | % \checkparity This is an \pageparity\ page.% 182 | \caption[Mind map.]{This mindmap shows the routes for getting your data into CASA} 183 | \forceversofloat 184 | \label{fig:casa_begin} 185 | %\zsavepos{pos:textfig} 186 | \end{figure*} 187 | 188 | Before you begin in this long journey of data reduction, make sure you have enough time to spend. It 189 | can get very crazy; get lot of snacks, coffee and put THE sign (Figure~\ref{fig:marginfig_disturb}) in 190 | a place clearly visible to the rest of the world. Basically we expect for a newbie to spend around 3-5 191 | days to successfully reduce a KAT-7 dataset. However, this documentation will allow you to get a 192 | clean image in a day, the target is within 10 hours of CONTINUOUS work. 193 | 194 | It is not that hard but requires lot of attention and concentration. The process will become quicker 195 | after you've worked with a few data sets and have become familiar with it. 196 | 197 | OK let us get serious now. 198 | 199 | \caution{ 200 | Python is case sensitive (as is Linux). Always ensure 201 | you using the correct case. 202 | } 203 | \begin{marginfigure}[-5.0cm] 204 | \begin{center} 205 | \includegraphics[width=7.5cm,height=9.5cm]{images/Do_not_disturb} 206 | \caption{THE sign} 207 | \forceversofloat 208 | \label{fig:marginfig_disturb} 209 | \end{center}\end{marginfigure} 210 | 211 | %% - RVR -- Remove chapter = Section 1.1 refers to python references 212 | % \chapter{Python a crash tour} 213 | % \label{ch:python} 214 | % \TODO 215 | 216 | 217 | \chapter{Let us get serious} 218 | \label{ch:let_get_serious} 219 | 220 | 221 | \bigskip 222 | \section{Overview of Calibration} 223 | % the \emph *turns off* the italic here 224 | 225 | The visibility measurement made by the interferometer are complex values, having either real and 226 | imaginary parts, or an amplitude and a phase. The calibration process consists mostly of finding a 227 | set of time and frequency dependent complex gain factors, by which our visibilities need to be 228 | multiplied. 229 | 230 | We develop our complex gain solution in stages. Some parts vary with time but not so much with 231 | frequency, for example transmission through the atmosphere causes both phase shifts and attenuation. 232 | However, the variation of the atmospheric part of the complex gain across the observing band is 233 | usually small. Therefore, a combined solution for all the different frequency channels of 234 | observations is usually possible. The bandpass response of the instrument, by contrast, varies across 235 | the frequency band, but is usually quite stable in time, so that it needs to be solved for only once 236 | in an observing run. 237 | 238 | So our whole set of complex gain factors is usually broken up into several pieces, each of which is 239 | solved for separately. This division is not necessarily unique, in the end all that matters is the 240 | complex product of the individual parts of the calibration. 241 | 242 | % MFB removed this 2013 Aug 21 - I think its leftover from somewhere 243 | %The typical bits are usually these: 244 | % 245 | %\begin{itemize} 246 | %\item{Delay calibration} Large changes in the propagation delay 247 | %of the signals to different antennas. For KAT-7 data this usually 248 | %only needs to be solved for once, as the delays are expected to be 249 | %\end{itemize} 250 | 251 | \bigskip 252 | \section{STEP 1... Converting the hdf5 file to a MS} 253 | 254 | Note that for the data set we are using for the tutorial, this step has already been done, so you can 255 | skip ahead to the next section. If you need to do this step, go to the KAT-7 archive to search for 256 | your file. Then check the eLog to see if the telescope operator entered any information during the 257 | observations, and take note of any if they did. Then, proceed to converting the archive file to a 258 | Measurement Set (ms). An ms is the form in which CASA will work on your data. Also remember at the 259 | end of the data reduction to add an entry in the eLog of the results. Convert the hdf5 archive file 260 | to an ms using the in-house script {\tt h5toms} as follows: 261 | 262 | \bigskip 263 | \linuxcmd{h5toms.py -f --no-auto -C '199,799' --flags='all' -r ant5 myfile.h5} 264 | 265 | The {\tt -f} flag causes {\tt h5toms.py} to produce a full-polarization output file, while the {\tt 266 | no-auto} causes {\tt h5toms} to load only cross-correlations, but not the auto-correlations. The {\tt 267 | -C 199,799} flag causes {\tt h5toms} to load only channels 199 to 799 (inclusive) of the original 1024 268 | channels. The $\sim$200 channels at either edge of the band are known to be bad, so we do not load 269 | them. We have also applied the online flagging using the {\tt -{-}flags='all'}. The {\tt -r ant5} 270 | causes it to use antenna 5 as the reference antenna (although you can change this later if required). 271 | 272 | The output will be a directory {\tt myfile.full\_pol.ms}. This directory is your CASA measurement set. 273 | More options are available for {\tt h5toms.py}\footnote{{\tt h5toms.py -h} lists the additional 274 | options e.g. for {\tt h5toms}}. Once the data has been successfully converted into an ms, one can 275 | start CASA from the computer kat-imager2 (assuming you are running on the SKA Pinelands server), and 276 | then proceed with the data reduction. 277 | 278 | It's probably a good idea to rename your ms to something a little more descriptive at this stage. 279 | 280 | \bigskip 281 | \linuxcmd{mv myfile.full\_pol.ms School\_data\_av.ms}. 282 | 283 | Of course if you're looking at real data its probably a good idea to use a name for the ms which 284 | reflects what the observations are. 285 | 286 | \bigskip 287 | \section{STEP 2... Loading and inspecting the data} 288 | 289 | It is probably best to create a specific directory which will contain the working CASA data. We will 290 | use the directory ``my\_working\_directory''. 291 | 292 | %% Added by Ruby, seems to be a missing step of creating the directory 293 | \linuxcmd{mkdir my\_working\_directory} 294 | 295 | \smallskip 296 | The first main step is to move the ms into your chosen working directory, and then also to make the 297 | working directory your current directory. For the workshop, you may have downloaded the file \\ {\tt 298 | School\_data\_av.ms.tar.gz}, which you would unpack with the linux command: 299 | 300 | \smallskip 301 | \linuxcmd{tar -zxf School\_data\_av.ms.tar.gz} 302 | 303 | \medskip 304 | It should produce a directory called {\tt School\_data\_av.ms}. This directory is your CASA 305 | measurement set. 306 | 307 | \smallskip 308 | \bigskip 309 | \comment{ 310 | Locate the ms directory from the previous step and move it 311 | into the working directory. 312 | 313 | \texttt{mv myfile.full\_pol.ms my\_working\_directory} \\ 314 | \texttt{cd my\_working\_directory} 315 | } 316 | 317 | \bigskip 318 | \comment{ 319 | Although CASA measurements sets (ms) are ordinary linux directories, and can be renamed, moved, 320 | delected or copied like any other directories, there are probably restrictions you should observe: 321 | \begin{itemize} 322 | 323 | \item Do not move, delete etc.\ directories from the operating system 324 | {\em while casapy is running}, as casapy does some ms caching, and 325 | will likely get confused. You can remove an ms from within casapy by 326 | typeing e.g., \texttt{rmtables('crappy-data.ms')} and it will be fine, 327 | or you can just exit casapy and then delete it. 328 | 329 | \item Do not alter the {\em contents} of the ms. While renaming or 330 | moving the ms directory is fine, its probably not a good idea to add 331 | or delete any files to the ms, or to alter or rename any of the 332 | files contined within it. 333 | \end{itemize} 334 | } 335 | 336 | \bigskip 337 | \bigskip 338 | Most of the data reduction will be done from within casapy, which provides an interactive shell 339 | (essentially the equivalent of interactive python or ipython). From the Linux prompt you will 340 | therefore first run casapy. You will then give the commands to run various CASA programs from within 341 | casapy. In casapy you can also create variables, assign values to them, and then subsequently use 342 | them at any time during the processing. It is generally convenient to define some variables to hold 343 | the names of ms's and tables. The sequence of casapy commands can then be re-used for a different 344 | data set by merely changing the values assigned to these variables. 345 | 346 | \bigskip 347 | \caution{ 348 | Do NOT abort running programs by pressing Ctrl+C as CASA has a bug and 349 | will screw up all your visibilities. Rather wait for the command to be 350 | over and then undo the wrong steps. 351 | } 352 | 353 | \bigskip 354 | In fact, CASA is designed to be highly script-able, and sequences of commands could be placed in a 355 | script and run automatically. In this session, however, we shall be using step-by-step commands. 356 | 357 | \bigskip 358 | \caution{ 359 | Never delete the ms file unless you have finished splitting your 360 | relevant data and are sure you do not need the ms anymore. 361 | } 362 | 363 | \bigskip 364 | Below we define a variable to hold the ms (directory) name but without the ``ms'' extension. We will 365 | use this variable to refer to the ms and to various associated tables. The ms we are using in the 366 | tutorial is called {\tt Cirx1\_school.ms}, so we define the following variables in casapy: 367 | 368 | \bigskip 369 | \begin{casacmd} 370 | \begin{verbatim} 371 | prefix = 'Cirx1_school' 372 | msfile = prefix+'.ms' 373 | \end{verbatim} 374 | \end{casacmd} 375 | 376 | \bigskip 377 | We now define variables that hold the names of various tables that will be used during the reduction. 378 | The table names could be specified directly, but if you do it by means of variables, the subsequent 379 | commands we use can be copied and pasted and re-used for some other reduction with the only 380 | modification required being the re-definition of these variables. 381 | 382 | \begin{casacmd} 383 | \begin{verbatim} 384 | bandpass_table0 = prefix +'_spw0.B0' 385 | gain_table0 = prefix+'_spw0.G0' 386 | gain_table1 = prefix+'_spw0.G1' 387 | flux_table1 = prefix+'_spw0.fluxscale1' 388 | \end{verbatim} 389 | \end{casacmd} 390 | % %MFB removed defn. of bandpass_table10 as it is never used 391 | 392 | We chose antenna {\tt ant5} as our reference antenna when we first converted the data-set to an ms, 393 | because it seems to have more shielding for RFI from the pedestal. Since it is best to use a 394 | consistent reference antenna throughout, we again define a variable whose value is the current 395 | reference antenna. 396 | 397 | \begin{casacmd} 398 | \begin{verbatim} 399 | reference_antenna= 'ant5' 400 | \end{verbatim} 401 | \end{casacmd} 402 | 403 | Next, we use the task {\tt listobs} to print out a summary of the observations in the ms (similar to 404 | the AIPS task LISTR with OPTY='SCAN'): 405 | 406 | \begin{casacmd} 407 | \begin{verbatim} 408 | listobs(vis=msfile) 409 | \end{verbatim} 410 | \end{casacmd} 411 | 412 | % okay new data set 413 | % all ants have data for two calibratro srcs 414 | %\begin{fullwidth} 415 | 416 | \begin{casaoutput} 417 | (we have removed the leading part of the lines of the {\tt listobs} output 418 | for clarity.) 419 | \begin{verbatim} 420 | ================================================================================ 421 | MeasurementSet Name: /home/michael/casa-workshop2012/CirX1.ms MS Version 2 422 | ================================================================================ 423 | Observer: lindsay Project: 20120701-0006 424 | Observation: KAT-7 425 | Data records: 71904 Total integration time = 56296.5 seconds 426 | Observed from 01-Jul-2012/13:57:43.4 to 02-Jul-2012/05:35:59.9 (UTC) 427 | 428 | ObservationID = 0 ArrayID = 0 429 | Date Timerange (UTC) Scan FldId FieldName nRows Int(s) SpwIds 430 | 01-Jul-2012/13:57:43.4 - 13:59:27.9 1 0 PKS 1934-638 168 14.1 [0] 431 | 14:00:13.4 - 14:04:58.4 2 1 Circinus X-1 420 14.8 [0] 432 | 14:05:28.4 - 14:06:21.4 3 2 PKS 1613-586 105 11.6 [0] 433 | 14:06:44.5 - 14:11:30.5 4 1 Circinus X-1 420 14.8 [0] 434 | 14:12:00.5 - 14:12:45.5 5 2 PKS 1613-586 84 14.5 [0] 435 | \end{verbatim} 436 | \dots (we omit the bulk of the detailed scan listing here) 437 | \begin{verbatim} 438 | 05:29:53.8 - 05:30:38.9 328 2 PKS 1613-586 84 15 [0] 439 | 05:30:56.9 - 05:31:41.4 329 2 PKS 1613-586 84 14.5 [0] 440 | 05:31:58.9 - 05:32:43.9 330 2 PKS 1613-586 84 15 [0] 441 | 05:33:01.9 - 05:33:46.9 331 2 PKS 1613-586 84 14.8 [0] 442 | 05:34:04.9 - 05:34:49.4 332 2 PKS 1613-586 84 14.8 [0] 443 | 05:35:06.9 - 05:35:59.9 333 2 PKS 1613-586 105 12 [0] 444 | (nRows = Total number of rows per scan) 445 | Fields: 3 446 | ID Code Name RA Decl Epoch nRows 447 | 0 T PKS 1934-638 19:39:25.03058 -63.42.45.6999 J2000 2709 448 | 1 T Circinus X-1 15:20:40.85208 -57.10.00.1048 J2000 52542 449 | 2 T PKS 1613-586 16:17:17.89966 -58.48.07.8890 J2000 16653 450 | Spectral Windows: (1 unique spectral windows and 1 unique polarization setups) 451 | SpwID #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs 452 | 0 19 REST 1938.21094 -12500 234765.625 XX XY YX YY 453 | The SOURCE table is empty: see the FIELD table 454 | Antennas: 7: 455 | ID Name Station Diam. Long. Lat. 456 | 0 ant1 ant1 12.0 m +021.24.39.4 -30.33.10.2 457 | 1 ant2 ant2 12.0 m +021.24.41.9 -30.33.09.1 458 | 2 ant3 ant3 12.0 m +021.24.38.6 -30.33.09.1 459 | 3 ant4 ant4 12.0 m +021.24.37.7 -30.33.09.1 460 | 4 ant5 ant5 12.0 m +021.24.37.1 -30.33.10.0 461 | 5 ant6 ant6 12.0 m +021.24.36.2 -30.33.12.5 462 | 6 ant7 ant7 12.0 m +021.24.35.2 -30.33.07.5 463 | \end{verbatim} 464 | \end{casaoutput} 465 | 466 | It is a good idea to save the {\tt listobs} output for future reference, as it gives the basic 467 | structure of the observations, indicating for example which source was observed at what time. You can 468 | either copy the {\tt listobs} output from the casapy log file, or rerun {\tt listobs} with extra 469 | parameter {\tt listfile=}[insert the name of the textfile you want to save the output here]. \\ 470 | 471 | \bigskip 472 | \noindent\textbf{What can you deduce from this listing of the data set?} 473 | 474 | \begin{itemize} 475 | \item The observations started at 14:00 on 01-Jul-2012 and continued 476 | till 04:15 on 02 Jul 2012 (UTC times) 477 | \item Three sources were observed, with field names ``PKS~1934-638'', 478 | ``Circinus~X-1'' and ``PKS~1613-586'' and source IDs 0, 1, and 2 479 | respectively. 480 | \item The reference frequency 1938.21094~MHz; One spectral window, 481 | SPW, was used, with SpwID = 0. This SPW had 19 frequency channels 482 | (note that this data-set has already been averaged in frequency, raw 483 | data KAT-7 data sets typically have 1024 channels 484 | \item The number of antennas taking part was 7 485 | \end{itemize} 486 | 487 | The science target in these observations was Circinus~X-1 (ID=1), with PKS~1934-638 and PKS~1613-586 488 | (ID 0 and 2 respectively) being the calibrators. The source PKS~1934-638 will be used as a flux 489 | density calibrator, while PKS~1613-586 will be used to calibrate the antenna phases. 490 | 491 | In CASA, it is the {\tt field} parameter which is generally used to specify the source, and one can 492 | use either the source name (e.g., {\tt field = 'Circinus X-1'}) or the Source ID (e.g., {\tt field = 493 | '2'}) to specify a particular source. Note that the value of {\tt field} is a string, and therefore 494 | enclosed in quotes ({\tt ' '}) even when it is specifying the numeric source ID. 495 | 496 | CASA can automatically set the flux densities for the flux-density calibrator sources, but they need 497 | to have field names in the correct format for this to work. In this case, our flux-density calibrator 498 | source has the form of the name recognized by CASA ``PKS~1939-638''. However, if your flux-density 499 | calibrator source does not have a name of the recognized form, for example, ``3C~48'', then you need 500 | to use {\tt browsetable} to replace it with, e.g., ``3C48''. In a future version of the {\tt h5toms} 501 | script this will be fixed automatically. {\tt browsetable} will produce a GUI where you can edit the 502 | ms tables. Check the link 503 | \mbox{\url{http://casa.nrao.edu/docs/UserMan/UserMansu193.html}} for details. 504 | 505 | It is good practice to plot the antenna positions and check that everything being read properly and 506 | your antennas are where they should be. This is done using: 507 | 508 | \begin{casacmd} 509 | \begin{verbatim} 510 | plotants(vis=msfile) 511 | \end{verbatim} 512 | \end{casacmd} 513 | 514 | From the above antenna plots, we can see that {\tt ant4} was not used in this observation and also 515 | that the plots show the expected positions of the KAT-7 antennas. 516 | 517 | 518 | \section{STEP 3... Flagging} 519 | 520 | The majority of interferometric data sets contain some corrupted data, with the most common reason 521 | being failures of an antenna or some of its associated electronics and radio frequency interference 522 | (RFI). The process of editing out this data is generally called ``flagging'', and is usually the most 523 | boring and tedious part of the data reduction process. Flagging is somewhat of an art and there are 524 | no hard rules. However, most modern instruments, KAT-7 in particular, produce fairly clean data (at 525 | least at frequencies above 1 GHz), so once you have removed the data from any malfunctioning antennas, 526 | you should not have to flag any more than 10\% of your data, and often much less than that. If 527 | possible you should flag either all visibilities for some time interval, or all by antenna, rather 528 | than flagging individual baselines. The reason for this is twofold: firstly, its more efficient, and 529 | secondly its less biased. Although different interactive flagging tools are available, for the 530 | initial flagging the best approach is usually to first make several passes through the data, using 531 | various plotting and listing tools, to identify the bad data. Once you have identified some sections 532 | of bad data, you then flag them explicitly using {\tt flagdata}. This allows you to keep a detailed 533 | record of what was flagged, and to easily redo the flagging if required. Going through your 534 | visibility data set point by point and picking out individual points is rarely productive. 535 | 536 | %\begin{figure*} 537 | % \includegraphics[width=12.0cm]{casa_flag.png} 538 | % \checkparity This is an \pageparity\ page.% 539 | % \caption[Mind map.]{} 540 | % \forceversofloat 541 | % \label{fig:casa_flag} 542 | % %\zsavepos{pos:textfig} 543 | %\end{figure*} 544 | 545 | The following tasks are available for flagging data in CASA: 546 | 547 | \begin{itemize} 548 | \item {\tt flagmanager}: save and manage versions of the flagging entries in the ms 549 | \item {\tt flagautocorr}: noninteractive flagging of auto-correlations 550 | \item {\tt plotms}: interactive XY plotting and flagging of visibility data 551 | \item {\tt plotxy}: interactive XY plotting and flagging of visibility data - 552 | note that plotxy is slower than plotms and will eventually be phased out 553 | \item {\tt viewer}: can display (as a raster image) ms data, with some editing capabilities 554 | \item {\tt flagdata}: This is the new non-interactive flagging (and 555 | unflagging) of specified data in CASA 3.4 onwards. It has other 556 | flagging options such as antenna shadowing, elevation flagging, etc. 557 | % Note that in future releases of CASA, this task will likely be 558 | % renamed just {\tt flagdata} and replace the older task of that name which 559 | % is still available the current (3.4.0) release of CASA. 560 | \end{itemize} 561 | 562 | We will mostly use the task {\tt plotms} to examine the data. It is a very flexible tool that allows 563 | you to interactively plot your visibility data in a wide variety of ways. We will use it to identify 564 | the bad data. We will then use the task {\tt flagdata} to actually flag it. Although data {\em can} 565 | be flagged directly in {\tt plotms}, we suggest that it is better to actually identify which antennas, 566 | baselines and times are responsible for bad data before flagging them until you have some experience. 567 | Flagging data {\em only} on the basis of e.g., low visibility amplitude can lead to serious biases: if 568 | you expect a flux density of 1~Jy and you flag all the visibilities outside the range 0.9 to 1.1 Jy, 569 | you would likely find the remaining visibilities suggested a source of 1~Jy. However, you're not 570 | learning about the sky, you're learning about the flagging you already did! 571 | 572 | Calibrator sources are much easier to flag than program sources, because we largely know what kind of 573 | source they are, and therefore what to expect from the visibility measurements. In particular, 574 | calibrators are generally point-like, which means the true visibility amplitude is independent of 575 | baseline (and of time), and the phase should be 0\arcdeg. Unfortunately, all we have available at 576 | this point is the {\em uncalibrated} visibilities. However, for an instrument like KAT-7, where all 577 | the dishes, and thus all the baselines have approximately equal sensitivity, even for the uncalibrated 578 | data for a point-like source, we can say this: the (uncalibrated) visibility amplitude on all 579 | baselines should be approximately the same, say within a factor of 2 or so, and the (uncalibrated) 580 | visibility phases should be fairly stable, although they do not need to be near 0\arcdeg. 581 | 582 | The two most common failures to identify are probably ``dead'' or malfunctioning antennas, and 583 | channels which are corrupted by RFI, which is usually very narrow bandwidth. Even though automatic 584 | flagging has already been done by {\tt h5toms.py}, and may well have removed most of the strong RFI, 585 | you should nonetheless always examine your data. 586 | 587 | However, first let us remove some bits data which is known to be bad. The KAT-7 correlator is known 588 | to produce some visibilities with spurious amplitudes of exactly 0. We will use {\tt flagdata} to 589 | delete these. We will also use a second invocation of the {\tt flagdata} to flag any data taken at 590 | antenna elevations below 10\arcdeg. Data taken at very low antenna elevations is often unreliable and 591 | noisy, so unless much of your data is taken at low elevations, its often easier to just delete the 592 | small fraction with antenna elevations below about 10\arcdeg. 593 | 594 | \begin{casacmd} 595 | \begin{verbatim} 596 | flagdata(vis=msfile,mode='clip',field ='', 597 | clipzeros=True, flagbackup = False) 598 | 599 | flagdata(vis=msfile,mode='elevation', 600 | lowerlimit=10.0, flagbackup=True) 601 | \end{verbatim} 602 | Note that in ``elevation'' mode, the elevation limits provided are those of the {\em good} data, 603 | rather than those of the data to be flagged, so in this case any data below an elevation of 10\arcdeg\ 604 | will be flagged. We do not need to set an upper elevation limit. 605 | \end{casacmd} 606 | 607 | Now lets plot the remaining visibilities. Phase stability, both in frequency and time, is probably 608 | the most important thing to check first: unless the visibility phases for the calibrator sources are 609 | reasonably stable in time and across the different channels, calibration will likely prove impossible. 610 | 611 | Each visibility point is associated with one baseline, that is some {\em pair} of antennas. However, 612 | instrumental failures are almost always antenna-dependent, that is, due to a failure of some 613 | particular antenna, and therefore {\em all} the baselines involving the bad antenna will have bad 614 | visibility data. When identifying data to flag, it is best to try first to establish whether it is 615 | some antenna that is bad, and if so flag all the data to that antenna. Some bad data, however, in 616 | particular that due to RFI, may not be antenna-dependent, and may have to be flagged individually per 617 | baseline. 618 | 619 | For starters, let us look at the phase as a function of frequency on a per-baseline basis. We will 620 | start with just one example scan of our strongest calibrator, {\tt PKS 1934-638}, pick one scan from 621 | the listing above, somewhere near the middle of the run. In this case we will pick scan ID = 57, 622 | occurring between times 17:01:16.3 and 17:03:01.3. 623 | 624 | Before you carry on, do spend some time getting to know the GUI behind 625 | {\tt plotms} and how to use it: \\ 626 | \mbox{\url{http://casaguides.nrao.edu/index.php?title=Data_flagging_with_plotms}}. 627 | For axis definition in plotms check this link : \\ 628 | \url{http://casaguides.nrao.edu/index.php?title=What\%27s_the_difference_between_Antenna1_and_Antenna2\%3F_Axis_definitions_in_plotms}. 629 | Now actually run plotms to bring up the plot window and get a first look at part of our visibility 630 | data. Note that the {\tt iteraxis='baseline'} tells {\tt plotms} to plot each baseline individually. 631 | Pressing the green arrow at the bottom of the {\tt plotms} interface will allow you to step through 632 | the individual baseline plots interactively. 633 | 634 | \begin{casacmd} 635 | \begin{verbatim} 636 | plotms(vis=msfile, xaxis='channel', yaxis='phase', 637 | correlation='XX,YY', scan='57', field='PKS 1934-638', 638 | iteraxis='baseline', coloraxis = 'corr', 639 | plotrange=[0,0,-180,180]) 640 | \end{verbatim} 641 | \end{casacmd} 642 | 643 | Your screen will look similar to this: 644 | \begin{figure*} 645 | \includegraphics[width=10cm]{images/plotms_phas_v_channel_bl1} 646 | % \checkparity This is an \pageparity\ page.% 647 | \caption[Mind map.]{The output of plotms showing phase versus channel 648 | for one baseline.} 649 | \forceversofloat 650 | \label{fig:plotms_amp_v_channel} 651 | %\zsavepos{pos:textfig} 652 | \end{figure*} 653 | 654 | The two different colours represent the two correlations or polarization products ({\tt XX,YY}) which 655 | we have plotted. Note that the purple points, which correspond to {\tt XX}, hang together well, 656 | sloping slightly from channel 0 to channel 19. They are fine. The tan-coloured points for the other 657 | polarization, however, are scattered randomly, and will not be usable. This plot is for the baseline 658 | between {\tt Ant1} and {\tt Ant2}. Hitting the right arrow button at the bottom will show the plot 659 | for the next baseline {\tt Ant1, Ant3}, where both polarizations look fine. The next plot, {\tt Ant1, 660 | Ant4} again shows the {\tt XX} points are fine, while the {\tt YY} points show strong variation across 661 | the band. 662 | 663 | These effects are almost certainly due to an {\em antenna}, rather than a single baseline, and the 664 | trick is to identify which of the antennas is the one that is affected. By stepping through the 665 | baseline you will see that the {\tt YY} phases for all baselines involving {\tt ant2} look quite 666 | random, while those involving {\tt ant4} are somewhat less random, but nonetheless show large 667 | variation from channel to channel. In other words, at least for this scan, there is a problem with 668 | the phase stability for the {\tt YY} polarization of {\tt Ant2} and {\tt Ant4}. 669 | 670 | Let us check for phase stability against time. We will only plot one channel by specifying {\tt 671 | spw='*:9'} for this purpose. (Seeing as the phase will vary both with time and channel, its hard to 672 | determine the phase stability by looking at all channels and times simultaneously, that's why we've 673 | taken the approach of first taking a ``slice'' in time, and looking at only one scan but all channels. 674 | Now we take a ``slice'' in frequency, and look at only one channel but at all times). 675 | 676 | \begin{casacmd} 677 | \begin{verbatim} 678 | plotms(vis=msfile, xaxis='time', yaxis='phase', 679 | correlation='XX,YY', spw='*:9', field='PKS 1934-638', 680 | iteraxis='baseline', coloraxis = 'corr', 681 | plotrange=[0,0,-180,180]) 682 | \end{verbatim} 683 | \end{casacmd} 684 | 685 | Again you will see a similar pattern. The visibility phases for {\tt XX} are quite stable in time, 686 | showing only small variations from scan to scan and within each scan (mostly, the $\sim$10 or so 687 | visibility points within a scan are so close together that the whole scan appears as a single point in 688 | the plot). However, again, the visibility phases for the {\tt YY} polarization (tan colour) for {\tt 689 | ant2} and {\tt ant4} are quite unstable. 690 | 691 | Since we have shown that the visibility phases for {\tt YY, ant2} and {\tt ant4} are quite unstable 692 | both in time and across channels, we will delete these points. Note, however, that so far, we have 693 | only examined the data for one source, namely {\tt PKS 1934-638}. Perhaps the data for the other 694 | sources are fine! Before throwing out all the data, its worth checking. In the {\tt plotms} window, 695 | change ``field'' to {\tt PKS 1613-586} and hit ``plot''. There are more data for this source, but you 696 | will see the exact same pattern. Since the data for {\tt YY, ant2} and {\tt ant4} are bad for both 697 | our calibrator sources, we have no choice but to flag all these data, including that for our target 698 | source {\tt Circinus X-1}. Very likely the target source data would also be bad, but in any case it 699 | cannot be calibrated so we cannot use it. You {\em could} plot also the visibility data for {\tt 700 | Circinus X-1}, however since its not known to be a compact source we do not know what to expect from 701 | the visibility phases. They may vary strongly because the source is complex. It is only for 702 | calibrator sources, where the actually visibility phase should be constant that we can judge stability 703 | by plotting the visibility phases as we have done. 704 | 705 | At present CASA has the limitation that it cannot calibrate one of the {\tt XX, YY} polarizations when 706 | the second one is missing, so we will actually have to flag all the polarizations for {\tt ant2} and 707 | {\tt ant4}, even though the {\tt XX} polarization data does not have any problem. (There are four 708 | total correlations, {\tt XX, YY, XY, YX}. We will deal only with first two, whose sum represents the 709 | unpolarized intensity. The calibration of the polarized parts, {\tt XY,YX} involves extra steps, and 710 | is not yet implemented in CASA for linearly polarized feeds like those of KAT-7). Having identified 711 | the bad data, we once again turn to {\tt flagdata} to actually flag it. We do not specify either {\tt 712 | field} or {\tt correlation} so {\tt flagdata} flags the requested data for all fields and 713 | correlations. 714 | 715 | \begin{casacmd} 716 | \begin{verbatim} 717 | flagdata(vis=msfile, antenna='ant2,ant4', 718 | flagbackup=True) 719 | \end{verbatim} 720 | \end{casacmd} 721 | 722 | \comment{ 723 | Referring to an antenna can be kind of confusing in CASA. Like sources, CASA can refer to antennas by 724 | their IDs or numbers, or by their names. The confusing thing is that the antenna names often look 725 | very similar to IDs, with KAT antennas having names like, e.g., ``ant1''. However, the antenna IDs 726 | start with 0, while the names start with the number 1. You have to keep track of whether you are 727 | referring to the antenna by ID or by name. In this case, the antenna ID=0 has the name ``ant1'' (as 728 | can be seen from the {\tt listobs} output). So it is antennas {\tt ant2} and {\tt ant4}, also known 729 | as {\tt ID = 1} and {\tt 3}, which have the bad data in this case. 730 | } 731 | 732 | If you now repeat the above {\tt plotms} commands, you will see that the visibility phases are now 733 | nicely coherent for all the plotted baselines, and the baselines we have flagged no longer show up. 734 | 735 | Now lets turn to the visibility amplitudes. Again we make use of the fact that for continuum 736 | calibrator sources, the expected values are known and should be the same on all baselines, and vary 737 | only slightly across the channels. This time we can plot all the baselines together, rather than 738 | iterating through them as we did before: 739 | 740 | \begin{casacmd} 741 | \begin{verbatim} 742 | plotms(vis=msfile, xaxis='channel', yaxis='amp', 743 | correlation='XX,YY', field='PKS 1934-638', 744 | coloraxis='corr') 745 | \end{verbatim} 746 | \end{casacmd} 747 | 748 | You will see that for most channels there is only a relatively small variation of the visibility 749 | amplitude with channel for PKS~1934-638 (note the amplitude scale on the left). This small variation 750 | will be corrected later with {\tt bandpass}. However, channel {\tt ID=6} shows a much larger scatter 751 | than any of the others, which is indicative that there may be RFI in this channel. Switching to the 752 | other calibrator source shows the same pattern. It is sometimes diagnostic to also examine the {\tt 753 | XY, YX} polarizations here. For calibrator sources, we expect the polarized flux density to be a 754 | relatively small fraction of the unpolarized (i.e., {\tt XX, YY}) one, whereas RFI is often strongly 755 | polarized. We conclude that channel {\tt ID=6} is likely affected by RFI, and therefore we will 756 | proceed to flag it also, once again using {\tt flagdata}. Once again, we will flag that channel also 757 | for the target source data, since even if the target source data were not also affected by the RFI, 758 | the data would be uncalibratable. 759 | 760 | \begin{casacmd} 761 | \begin{verbatim} 762 | flagdata(vis=msfile, spw='0:6', flagbackup=True) 763 | \end{verbatim} 764 | \end{casacmd} 765 | 766 | We have now flagged most of the bad data affecting this run, in particular the bad data for the 767 | calibrator sources, and can now proceed to the actual calibration. 768 | 769 | 770 | \section{STEP 4... Calibration} 771 | 772 | In order to explain calibration, we must first explain briefly the nature of the visibility 773 | measurements we are trying to calibrate. If the field of view is small enough so that it can be 774 | represented as a plane (rather than as a curved part of the celestial sphere), then the sky brightness 775 | can be written as $I(l,m)$, where $l$ and $m$ are the two orthogonal coordinates (typically RA and 776 | decl). The visibility function measured by an ideal interferometer, $V$, is given by a 777 | two-dimensional Fourier transform of this sky brightness: 778 | 779 | \begin{equation} 780 | V(u,v)=\int\int I(l,m)e^{j2\pi(ul+vm)}dl dm 781 | \end{equation} 782 | 783 | where $u, v$ represent the coordinates in the Fourier transform plane. At any given instant, each 784 | baseline, or pair of telescopes, in the interferometer measures this visibility function at a point in 785 | the Fourier transform plane whose $u, v$ coordinates are determined by the length and orientation of 786 | the baseline, as projected onto the sky plane. Since the telescopes rotate with the earth, each 787 | baseline typically sweeps out an elliptical path in the $u, v$ plane as the earth rotates. Although 788 | $I$ is real, $V(u,v)$ is generally complex, with non-zero values for both real and imaginary parts. 789 | $V(u,v)$ is often described as an amplitude and a phase, rather than by its real and complex parts. 790 | Note that $V(u,v)$ is symmetric with $V(u,v) = V(-u,-v)$: generally the Fourier transform of a real 791 | function, like $I$, is complex but symmetric. 792 | 793 | The correlator output differs from the $V$ measured by an ideal interferometer for a variety of 794 | reasons, to do with both instrumental effects as well as propagation effects in the earth's atmosphere 795 | and ionosphere\footnote{At low frequencies, such as those observed by KAT-7, the effect of the 796 | ionosphere is usually the dominant one}. The relationship between the observed and the true visibility 797 | on the baseline between two telescopes, $i$ and $j$, can be written in a very general way as: 798 | 799 | \begin{equation} 800 | V_{ij}^{\rm observed}=J_{ij}V_{ij}^{\rm true} 801 | \end{equation} 802 | 803 | $J_{ij}$ represents the accumulation of all corruptions affecting the visibility measurement on 804 | baseline $ij$. Both $V$ and $J$ have complex values and are generally functions of frequency, 805 | polarization and time, but we have suppressed the additional indices pertaining to frequency, 806 | polarization and time for clarity. 807 | 808 | Calibration involves determining the values of $J_{ij}$, in order to invert the above equation and to 809 | determine the best approximation possible of $V_{ij}^{\rm true}$ from the observed values of 810 | $V_{ij}^{\rm observed}$. 811 | 812 | This task of determining $J_{ij}$ is made considerably easier by the fact that most of the effects 813 | contained in $J_{ij}$ are {\em antenna}-based. In other words, $J_{ij}$ can be factored into $J_i 814 | \otimes J_j^*$ (where $J_j^*$ is the complex conjugate of $J_j$. For an array consisting of $N_{\rm 815 | ant}$ antennas there are therefore only $N_{\rm ant}$ unknown values of $J_i$ which need to be 816 | determined, rather than the approximately $N_{\rm ant}^2$ values of $J_{ij}$ which would be required 817 | otherwise. Bear in mind that we have suppressed the time and frequency dependence here, so $J_i$ is 818 | not a single complex number, but a function describing the complex response of antenna $i$ in both 819 | time and frequency over the time-range and bandwidth of the observations. 820 | 821 | The factorization occurs because the bulk of $J_{ij}$ has its origin in effects which corrupt the 822 | radio signal as it travels through the atmosphere and the antenna electronics, these effects are 823 | therefore due to an individual antenna $i$, but do not depend on the other antenna $j$ which makes up 824 | that particular baseline. Although there are baseline-dependent effects, they are mostly very small, 825 | and for most purposes, can be ignored. 826 | 827 | It is practical to further factor the $J_i$ into different components, representing different factors 828 | affecting the radio signal, each of which can be determined independently. Some of the components, 829 | for example, are time-invariant, and therefore need to be determined only once for the observing run, 830 | while others are time-variable. In our calibration process, we will first factor $J_{ij}$ into the 831 | antenna-dependent $J_i$ and thenceforth into a series of different factors, and each factor will be 832 | determined in a different step. Our approach is similar to the so-called ``Measurement Equation'', 833 | which is a more formal approach to factoring $J_{ij}$ described in \citep{HamakerBS1999}, but we 834 | factor $J_{ij}$ into slightly different components. 835 | 836 | So we can write: 837 | 838 | \begin{equation} 839 | V_{ij}^{\rm observed} = J_{ij} V_{ij}^{\rm true} 840 | = (J_i \otimes J_j^*) V_{ij}^{\rm true} 841 | \end{equation} 842 | 843 | where 844 | \begin{equation} 845 | J_i = A_i B_i G_i \dots 846 | \end{equation} 847 | 848 | For example, $A_i$ might be corrections for some effect known a priori, such as an error in one of the 849 | antenna positions used in the correlator, and $B_i$ might be to describe the bandpass response of the 850 | antennas, in other words the variation in sensitivity and phase between the different channels, which 851 | is taken to not vary with time, while $G_i$ provides the variation in amplitude and phase response as 852 | a function of time, but taken not to be a function of frequency, i.e., determined for all frequency 853 | channels simultaneously. Note that the separation of these effects is not unique, however, we want to 854 | ensure that the final product $J_i$ must be correct. 855 | 856 | Some parts of $J_i$ can be calculated without any reference to the visibility data. However, most of 857 | $J_i$ will be determined from the values of $V^{\rm observed}$ for calibrator sources, where we know 858 | what the values of $V^{\rm true}$ should be and can therefore invert the equation above. In 859 | particular, most of the parts of $J_i$ due to the atmosphere and ionosphere cannot be known in 860 | advance. The values of $J_i$ (recall that $J_i$ in general depend on time, but we have suppressed 861 | this dependence in the notation), determined from the observations of calibrator sources are then 862 | interpolated (or extrapolated) to the times corresponding to the observations of the intended target 863 | source(s). The various calibration programs perform the function of estimating the antenna-based 864 | calibration factors (e.g., $A_i, B_i$ etc., from above) from the (baseline-based) calibrator source 865 | visibility measurements. 866 | 867 | For example, the antenna-based bandpass response, $B_i$ is typically treated as being independent of 868 | time (although it is by definition a function of observing frequency). It is typically determined by 869 | examining the visibilities for a strong calibrator source of known spectrum (the simplest case would 870 | be a source with a flat spectrum, with true flux density independent of the particular frequency or 871 | channel under consideration). Often this is the first step in the calibration, since once this 872 | bandpass correction is known, we can use an average across the channels to determine the remaining 873 | parts of $J_i$, rather than having to do it for each channel independently. 874 | 875 | In order to use the visibility data from calibrator sources to calculate calibration quantities, such 876 | as the bandpass response, one should edit out the bad visibility data first. This is why we started 877 | above with examining the data and flagging bad points or antennas. 878 | 879 | The typical sequence is to first use observations of a strong calibrator, often the flux-density 880 | calibrator, to determine the bandpass response. With that in hand, we no longer have to make separate 881 | solutions for every channel, but can combine them. One then uses the observations of calibrator 882 | sources to determine the variation of $J_i$ with time. Many calibrator sources are variable on 883 | timescales of weeks or longer and their flux densities are therefore not accurately known. In order 884 | to set the flux density scale correctly, one needs observations of at least one flux density 885 | calibrator source, whose flux density {\em is} known. Typically, one uses one or a few scans of a flux 886 | density calibrator source for this purpose, and then the remainder of the $J_i$ can be obtained from 887 | other calibrator sources whose flux density is not known (although it should not vary during the 888 | observing run), but which {\em are} known to be point-like. These secondary calibrators are known as 889 | phase calibrators or secondary amplitude calibrators. 890 | 891 | So, lets begin the calibration. For safety and sanity, one should begin by ``clearing the 892 | calibration''. The data structure of CASA measurement sets (ms) is that the observed data are stored 893 | in a {\tt DATA} column of the ms, while the corrected data (i.e., those multiplied by $J_{ij}$) are 894 | stored in the {\tt CORRECTED\_DATA} column once they become available. The values from which $J_{ij}$ 895 | are constructed are stored in various calibration tables. There is a further column of visibility 896 | data called {\tt MODEL\_DATA} where model values, if available, such as the expected visibility values 897 | for a calibrator of known structure, are stored. The task {\tt clearcal} initializes the {\tt 898 | CORRECTED\_DATA} and {\tt MODEL\_DATA} columns and therefore clears calibrated data from any previous 899 | attempts at calibration from them. 900 | 901 | \begin{casacmd} 902 | \begin{verbatim} 903 | clearcal(vis=msfile,field='') 904 | \end{verbatim} 905 | \end{casacmd} 906 | 907 | \begin{figure*} 908 | \includegraphics[width=10.0cm]{images/casa_cal} 909 | % \checkparity This is an \pageparity\ page.% 910 | \caption[Mind map.]{A schematic diagram of the calibration process.} 911 | \label{fig:textfig} 912 | %\zsavepos{pos:textfig} 913 | \end{figure*} 914 | 915 | \bigskip 916 | \pause{ Time to take a break and have some coffee... The steps after will need more attention.} 917 | 918 | % \medskip 919 | \bigskip 920 | 921 | There are few sources whose flux density is known reliably which can be used as primary amplitude 922 | calibrators. The task {\tt setjy} knows about the most common of these, and will insert the correct 923 | flux density for the frequency of the observations as well as entering the model into the {\tt 924 | MODEL\_DATA} column for subsequent use. 925 | 926 | \caution{ 927 | These primary flux density calibrators are often somewhat resolved, and thus source models should be 928 | used to represent the source structure. The task {\tt setjy} can be invoked to list the available 929 | source models (with {\tt listmodels=True}). However, the flux density calibrator for our observations 930 | is {\tt PKS~1939-638}, which is one that is close to ideal in that it has no structure on scales 931 | larger than 1\arcsec. The default point model is therefore adequate and no further source model is 932 | required in our case. 933 | } 934 | 935 | We still have to enter the actual flux density for {\tt PKS~1939-638} for the actual frequency of the 936 | observations. In general the flux density varies with frequency, and {\tt setjy} will calculate a 937 | slightly different value for each channel from the known spectrum. (In the case that a model image is 938 | used for the flux-density calibrator, {\tt setjy} will also scale the model image to the total flux 939 | density for each channel in the ms, and then enter the Fourier transform of the scaled model image 940 | into the MODEL\_DATA column for that source and channel.) Setting {\tt fluxdensity = -1} causes {\tt 941 | setjy} to look up the flux density for flux density calibrators and enter the standard value. 942 | 943 | %1934 - 4.2mas double 944 | 945 | \begin{casacmd} 946 | \begin{verbatim} 947 | setjy(vis=msfile, field='PKS 1934-638', 948 | scalebychan=True, standard='Perley-Butler 2010', 949 | fluxdensity=-1) 950 | \end{verbatim} 951 | \end{casacmd} 952 | 953 | \medskip 954 | {\tt setjy} should produce the following output in the logger, from which one can see that it has 955 | identified calibrator source {\tt PKS~1934-638} and filled in the known flux density of $\sim$13~Jy in 956 | I (the exact flux density will vary somewhat and be slightly different in the different channels, with 957 | the listed value being that for the channel at the reference frequency of 1932~MHz). If you see the 958 | message that your source ``{\tt is not recognized by Perley-Butler 2010}'', then {\tt setjy} will have 959 | entered a default flux density of 1.0 Jy for your flux calibrator and you have to fix the problem 960 | otherwise your flux density scale could be wrong by a large factor. 961 | %MFB: I have taken out mention of the VLA calibrator manual as 962 | %MFB: 1934-638 does not seem to be in there! 963 | 964 | % % for CirX1.ms 965 | \begin{casaoutput} 966 | \begin{verbatim} 967 | setjy::::casa ##### Begin Task: setjy ##### 968 | ...... 969 | setjy::imager::setjy() Using channel dependent flux densities 970 | setjy::imager::data selection Selected 2709 out of 71904 rows. 971 | setjy::imager::setjy() PKS 1934-638 (fld ind 0) spw 0 [I=13.182, Q=0, U=0, V=0] Jy, (Perley-Butler 2010) 972 | .... 973 | \end{verbatim} 974 | \end{casaoutput} 975 | 976 | \medskip 977 | Once we are happy that the correct flux density has been entered for the flux-density calibrator, we 978 | can proceed to the next step, which is to solve for the bandpass response, in other words for the 979 | variation of the complex antenna gains across the different channels. (Note that {\tt setjy} above 980 | did not yet solve for any part of $J_i$, it only entered the flux density of our calibrator, 981 | essentially the value of $V^{\rm true}$ into the ms so that we {\em can} start solving for $J_i$ in 982 | the next steps. The variation of the gains across the observing band is largely due to instrumental 983 | effects and usually quite stable, so we only need to solve for it once. Once we have solved for the 984 | bandpass response, we can combine all the channels in a single solution for the subsequent steps. 985 | 986 | However, we have the problem that the phase part of $J_i$ can be quite rapidly time-variable even 987 | though the amplitude part is not. In order to properly calculate the bandpass response, we therefore 988 | want to do some temporary phase-calibration for that scan which we intend to use for the bandpass 989 | calibration, to prevent decorrelation when vector averaging the data in computing the bandpass 990 | solutions. In other words, to obtain the bandpass solution, we will average the complex visibility 991 | data in time over a whole scan. If there is any variation on phase over the scan, we want to 992 | calibrate that out before performing the bandpass solution. 993 | 994 | We do this phase calibration using {\tt gaincal}, and using only a portion of the band, in this case 995 | the six channels from 7 to 11. These solutions for the antenna phases as a function of time can then 996 | be used to calibrate out any variation in the phase during the scan for the purposes of the subsequent 997 | bandpass solution. The rapid phase variation we are calibrating out here are due mostly to the 998 | atmosphere, and are not expected to vary significantly between the channels. Therefore, although 999 | these phase solutions are determined from only a central portion of the band, they are applicable to 1000 | the whole band (i.e., to all 19 channels). The choice of the particular channels (7 to 11) is 1001 | relatively arbitrary, but usually its best to use a few channels near the centre of the band, which 1002 | were found to be relatively free from interference in the editing steps earlier. 1003 | 1004 | For this next step, we need to specify a reference antenna. When we ran {\tt h5toms} we chose 1005 | reference antenna 5. However, its possible that antenna 5 was not present at all during the run, or 1006 | that we removed some of its data in flagging. You can use {\tt plotms} to plot {\tt antenna1} against 1007 | {\tt time} for all fields to quickly identify which antennas were present during which parts of the 1008 | run. In this case you should see that antenna ID=0 is missing during the first part of the run, 1009 | because we flagged it earlier. Antenna ID=5 seems to be present throughout, and can therefore serve 1010 | as our reference antenna for the rest of the calibration. Note that it is possible to use different 1011 | reference antennas for different parts of the calibration, but if possible you should use the same 1012 | antenna throughout. It is also desirable to choose a reference antenna which is known to be stable 1013 | and fairly sensitive (in the case of KAT-7 the sensitivities of the 7 antennas is very similar, so the 1014 | only real criterion for picking the reference antenna is stability). 1015 | 1016 | \begin{casacmd} 1017 | \begin{verbatim} 1018 | gaincal(vis=msfile, caltable=gain_table0, 1019 | field='PKS 1934-638', refant=reference_antenna, 1020 | spw='0:7~11', calmode='p', solint='int', 1021 | minsnr=4, minblperant=4, solnorm=T, gaintable='') 1022 | \end{verbatim} 1023 | Remember that we defined the variables {\tt refant} and {\tt gain\_table0} earlier to hold the name of 1024 | the reference antenna and gain table, respectively, that we're using for this particular ms. 1025 | \end{casacmd} 1026 | %MFB: i've changed minsnr to 4 here, if we're getting SNR<3 1027 | %MFB: on this for some vis, we're probably better off just 1028 | %MFB: not using them for bandpass calibration; I've also 1029 | %MFB: just arbitrarily picked channels 7~11 1030 | 1031 | After having determined the solutions, we should examine them using {\tt plotcal}. The task {\tt 1032 | plotcal} can plot a variety of gain solutions in a variety of ways, check {\tt help plotcal} to find 1033 | out more. We remind you that {\tt gaincal} has factored $J_{ij}$ into antenna-based components, so 1034 | you don't see a set of values for each baseline, but rather only one for each antenna ($J_i$), and the 1035 | CASA programs will calculate the full value of $J_{ij}$ as needed when calibrating the visibility 1036 | values. 1037 | 1038 | \begin{casacmd} 1039 | \begin{verbatim} 1040 | plotcal(caltable=gain_table0, xaxis='time', 1041 | yaxis='phase', field='PKS 1934-638', 1042 | iteration='antenna', plotrange=[0,0,-180,180]) 1043 | \end{verbatim} 1044 | \end{casacmd} 1045 | 1046 | On the {\tt plotcal} plot, you should see that the gain-table phases (antenna phases, or the 1047 | phase-component to $J_i$) should be fairly stable during the minute or two of the scan-length. Small 1048 | variations are fine, indeed the point of running {\tt gaincal} was exactly to find these small 1049 | variations so that they can subsequently be calibrated out from the visibilities. However, if the 1050 | antenna phase appears random from one point to the next then something has likely gone wrong. 1051 | 1052 | Now we can run {\tt bandpass} to solve for the complex gain as a function of channel across the 1053 | observing band. Specifying {\tt gaintable=[gain\_table0]} causes bandpass to apply the time-dependent 1054 | antenna phase calibration we determined in the previous step before forming the bandpass solutions. 1055 | 1056 | \begin{casacmd} 1057 | \begin{verbatim} 1058 | bandpass(vis=msfile, caltable=bandpass_table0, 1059 | field='PKS 1934-638', refant=reference_antenna, 1060 | solnorm=True, combine='scan', solint='inf', 1061 | bandtype='B', gaintable=[gain_table0]) 1062 | \end{verbatim} 1063 | \end{casacmd} 1064 | 1065 | You will see the message: 1066 | \begin{verbatim} 1067 | Insufficient unflagged antennas to proceed with this solve. 1068 | (time=2012/07/01/22:08:07.6 field=0 spw=0 chan=6) 1069 | \end{verbatim} 1070 | 1071 | Since we flagged channel 6 or {\tt spw=0:6} earlier on, this is not something to worry about, its just 1072 | telling us that there is no solution for that particular channel, but that doesn't matter because we 1073 | have no visibility left for that channel. A message like this about some channel for which there {\em 1074 | was} visibility data left would be a problem. 1075 | 1076 | The task {\tt plotcal} can also be used to display the bandpass solution: 1077 | 1078 | \begin{casacmd} 1079 | \begin{verbatim} 1080 | plotcal(caltable=bandpass_table0, xaxis='chan', 1081 | yaxis='amp', subplot=222, iteration='antenna') 1082 | \end{verbatim} 1083 | \end{casacmd} 1084 | % hmm, there only seem to be solutions for some antennas 1085 | % no solns for ant2 or ant4; strangeness: plotcal plots 1086 | % ant1-6, then leaves ant2-6 plots up but replaces 1087 | % ant1 plot with ant7 one! 1088 | % It does not get a solution for ant2,4 1089 | % aha- ant2-4 have no data for the longer flux-cal scan 1090 | % at end; neither of these antennas have any data for 1091 | % 1939! 1092 | 1093 | First note that plots for the antennas for which the data have been flagged ({\tt ant2, ant4}) are 1094 | blank, which is as expected. For the others the gain amplitude varies only by 10\% to 20\% across the 1095 | channels, which is in the expected range. Since we asked {\tt bandpass} to normalize the solution, 1096 | the average gain for each antenna is 1.0 --- at this point we're only after the variation across the 1097 | band. If any of the gains were to differ from unity by more than a factor of 2 or so, then may be 1098 | more bad data to flag. One would then have to flag that bad data, and then re-start the calibrations 1099 | from the {\tt clearcal()} step. 1100 | 1101 | The next step derive the main, time-variable, part of $J_i$, which we term $G_i$. This is done for 1102 | each source individually, by comparing the observed visibilities $V_{ij}^{\rm observed}$ to the 1103 | expected visibilities $V_{ij}^{\rm true}$. For the flux density calibrator, we have determined the 1104 | latter values, and we can get the correct values for $G_i$. For the phase calibrator sources, we 1105 | assume a point source model, so we know the phase part of all the $V_{\rm true}$ is 0. We {\em 1106 | assume} for now that the unknown flux-density of the phase-calibrator sources is exactly 1.0 Jy 1107 | (typically they are of this order). If we then solve for $G_i$, we will obtain complex values whose 1108 | amplitudes differ from the correct ones by a factor depending only on the true source flux density (by 1109 | ([1 Jy]/[true source flux density])$^{0.5}$). We can then compare the $G_i$ obtained for the 1110 | secondary calibrators, and scale them so that they match as well as possible the correctly-scaled 1111 | amplitudes of $G_i$ obtained for the primary flux-density calibrator. The scaling required gives us 1112 | the true flux density of the secondary calibrator source in terms of the originally assumed one, i.e., 1113 | 1 Jy. This process is known as ``flux density bootstrapping''. 1114 | 1115 | The reason for this complicated procedure is that there are only a handful of flux-density 1116 | calibrators, so it is generally impossible to choose a flux density calibrator close to the target 1117 | source on the sky. There are many phase calibrator sources, however, so a phase calibrator can be 1118 | chosen that is much closer on the sky (typically a few degrees~\arcdeg\ away). The flux density 1119 | bootstrapping allows us to use the phase and amplitude calibration (i.e. $G_i$) from these much nearer 1120 | calibrator sources, which will provide a much better calibration for the target source, but to set the 1121 | flux density scale accurately from observations of the flux density calibrator. The flux density 1122 | scale is usually stable for hours, so once we have transferred the flux density scale to the phase 1123 | calibrator sources by flux density bootstrapping, the solutions we obtain for the phase calibrator 1124 | sources are equivalent to those which would have been obtained if we'd known the flux density of the 1125 | phase-calibrators to begin with. 1126 | 1127 | First we determine the values of $G_i$, also called the complex gains, for the flux-density 1128 | calibrator: 1129 | 1130 | \begin{casacmd} 1131 | \begin{verbatim} 1132 | gaincal(vis=msfile, caltable=gain_table1, 1133 | field='PKS 1934-638', solint='inf', 1134 | refant=reference_antenna, gaintype='G', 1135 | calmode='ap', gaintable=[bandpass_table0]) 1136 | \end{verbatim} 1137 | Note that the a new solution is started for each scan, the {\tt solint='inf'} only means that the 1138 | solution interval can be arbitrarily long {\em up to} the next scan boundary. 1139 | \end{casacmd} 1140 | 1141 | Next we determine the complex gains for the phase calibrator (so far under the assumption that it has 1142 | a flux density of 1~Jy). 1143 | 1144 | \begin{casacmd} 1145 | \begin{verbatim} 1146 | gaincal(vis=msfile, caltable=gain_table1, 1147 | field='PKS 1613-586', solint='inf', 1148 | refant=reference_antenna, gaintype='G', calmode='ap', 1149 | append=True, gaintable=[bandpass_table0]) 1150 | \end{verbatim} 1151 | Note that the {\tt append=True} causes {\tt gaincal} to append to the specified gain table, rather 1152 | than over-writing it. 1153 | \end{casacmd} 1154 | 1155 | Plotting again to have a look at the solutions: 1156 | 1157 | \begin{casacmd} 1158 | \begin{verbatim} 1159 | plotcal(caltable=gain_table1, xaxis='time', 1160 | yaxis='amp', iteration ='antenna') 1161 | \end{verbatim} 1162 | \end{casacmd} 1163 | 1164 | Notice that, for each antenna, there are two sets of points. The lower set, in this case with gain 1165 | amplitudes near $\sim$0.1 corresponds to our flux density calibrator ({\tt PKS 1934-638}). Since we 1166 | were working with the correct flux density for this source ($\sim$13 Jy), these gains already have the 1167 | correct values. The other set of points, with values near $\sim$0.2, are those for {\tt PKS 1168 | 1613-586}, which differ from the true values by a scale factor. The next step is to derive this scale 1169 | factor, so as to make the two sets of points match as well as possible. The true flux density of {\tt 1170 | PKS 1613-586} can be trivially determined from the derived scale factor. 1171 | 1172 | The task {\tt fluxscale} calculates the scale factor, thus performing the bootstrapping, and will 1173 | output a correctly scaled version of the calibration table, which we can then use to calibrate the 1174 | data, as well as printing out the derived value for {\tt PKS 1613-586}'s flux density. 1175 | 1176 | \begin{casacmd} 1177 | \begin{verbatim} 1178 | fluxscale(vis=msfile, caltable=gain_table1, 1179 | fluxtable=flux_table1, reference=['PKS 1934-638'], 1180 | transfer=['PKS 1613-586']) 1181 | \end{verbatim} 1182 | \end{casacmd} 1183 | 1184 | \begin{casaoutput} 1185 | \begin{verbatim} 1186 | INFO fluxscale ##### Begin Task: fluxscale ##### 1187 | INFO fluxscale Opening MS: CirX1.ms for calibration. 1188 | INFO fluxscale Initializing nominal selection to the whole MS. 1189 | INFO fluxscale Beginning fluxscale--(MSSelection version)------- 1190 | INFO fluxscale Found reference field(s): PKS 1934-638 1191 | INFO fluxscale Found transfer field(s): PKS 1613-586 1192 | INFO fluxscale Flux density for PKS 1613-586 in SpW=0 is: 4.6868 +/- 0.012777 (SNR = 366.816, N = 10) 1193 | INFO fluxscale Storing result in CirX1_spw0.fluxscale1 1194 | \end{verbatim} 1195 | \end{casaoutput} 1196 | 1197 | % \bigskip 1198 | {\bf What is it we can deduce from this output? How do we know everything is fine?} First, we can 1199 | examine the messages produced by {\tt fluxscale}. It has determined a flux density for {\tt PKS 1200 | 1613-586} of $4.687 \pm 0.013$~Jy, making it a fairly strong source. For a strong source like this, 1201 | the uncertainty in the bootstrapped flux density should be $<1$\%, which indeed it is. You can also 1202 | check that the flux density is within the range of values usually seen for your particular source at 1203 | this frequency. For example, our source, {\tt PKS 1613-586}, is listed in the ATCA calibrator list at 1204 | (\url{http://www.narrabri.atnf.csiro.au/calibrators}) as having flux density of 4.21~Jy at 1.75~GHz 1205 | (the closest of the listed frequencies to ours), so our value of 4.687~Jy is quite reasonable, as its 1206 | only 16\% higher. Variations of a factor of 2 are not uncommon, if you get a flux density more than a 1207 | factor of 2 different than the listed, you may want to double check. 1208 | 1209 | If you use {\tt plotcal} as above, but on the new version of the table produced by {\tt fluxscale}, 1210 | i.e. {\tt caltable=flux\_table1}), you will see that the gain amplitudes for {\tt PKS 1913-638} are no 1211 | longer readily distinguishable from those for {\tt PKS 1613-586}, which was the goal (the gain of the 1212 | antennas should not depend on which source you are observing!). You may also plot the gain phases 1213 | with: 1214 | 1215 | \begin{casacmd} 1216 | \begin{verbatim} 1217 | plotcal(caltable=flux_table1, xaxis='time', 1218 | yaxis='phase', iteration ='antenna', 1219 | plotrange=[0,0,-180,180]) 1220 | \end{verbatim} 1221 | \end{casacmd} 1222 | 1223 | And you should see that the gain phases are in fact very stable in time, and relatively consistent 1224 | between our two calibrator sources. For {\tt ant5} the gain phases will be exactly 0\arcdeg\ as this 1225 | was our reference antenna, so it has a gain phase of 0\arcdeg\ by definition. In order to calibrate 1226 | the visibility data for our target source, we have to interpolate between the calibrator gain values. 1227 | Since the gain phases for our phase calibrator source {\tt PKS 1613-586} form a nice smooth line (in 1228 | fact the individual points may not be distinguishable on your plot), the interpolation should yield an 1229 | accurate value. If, on the other hand, the gain phases (or amplitudes) differ drastically from one 1230 | point to the next, then interpolation to the intervening target-source observations will be dubious. 1231 | 1232 | Our calibration therefore is looking good. The next step is to actually use it to calibrate the 1233 | visibility data and produce our estimates of $V_{ij}^{\rm true}$. Here is where we calculate the 1234 | $V_{ij}^{\rm true} = V_{ij}^{\rm observed} J_{ij}^{-1}$. This is where we want to be careful about 1235 | how we interpolate our gain solutions ($J_i$). For example, on the plot of gain phase against time, 1236 | you could see the gain phases for {\tt PKS 1613-586} all lay on a fairly smooth curve, while those for 1237 | {\tt PKS 1934-638} did not quite lie on the curve. Since {\tt PKS 1613-586} is much closer on the sky 1238 | to our target source ({\tt Circinus X-1}) the gain values (i.e., values of $J_i$) derived from {\tt 1239 | PKS 1613-586} are better for interpolating to the target. However, we also want to calibrate the 1240 | visibility data for {\tt PKS 1934-638}, and of course here we're much better of using the gain 1241 | solutions derived from {\tt PKS 1934-638} itself. (Note that although at this point, we're largely 1242 | done with our calibrator sources, and will not have any immediate further use for the 1243 | calibrator-source visibilities, its probably a good idea to apply the calibration properly to the 1244 | calibrator sources as well as the target source). 1245 | 1246 | The easiest way to keep it straight is to apply the calibration separately to each source. The task 1247 | that applies the calibration is called {\tt applycal}. It combines the requested gain tables, 1248 | interpolates or extrapolates as required to determine the full antenna-based $J_i$, calculates the 1249 | baseline-based $J_{ij}$ values as needed for each visibility measurement, and then writes out the 1250 | properly calibrated visibility data (our estimate of $V_{ij}^{\rm true}$) into the {\tt 1251 | CORRECTED\_DATA} column of the ms. You can specify the {\tt field}, which determines which source's 1252 | visibility data get corrected, and {\tt gainfield}, which specifies from which source's gain table 1253 | entries the required correction is determined. The best calibration is usually when the {\tt field} 1254 | entry is the same as the {\tt gainfield} entry, but usually one does not have calibration solutions 1255 | for the target sources, so for the target source, {\tt gainfield} must necessarily be different than 1256 | {\tt field}. Note that as {\tt applycal} can simultaneously apply several calibration tables, {\tt 1257 | gainfield} can have multiple entries, one for each calibration table to be applied. The two 1258 | calibration tables we want to apply are the bandpass table, {\tt bandpass\_table0}, and the gain table 1259 | with the correct flux density scaling for {\tt PKS 1613-586} or {\tt flux\_table1}. Since there are 1260 | two tables to apply, we need two entries in {\tt gainfield}. 1261 | 1262 | Lets just start with the first source: {\tt PKS 1934-638}. We want to calibrate its visibility data 1263 | and therefore set {\tt field} to {\tt PKS 1934-638}. Since the {\tt bandpass\_table0} contains only 1264 | entries for {\tt PKS 1934-638} anyway, there is no choice and we can just leave the corresponding {\tt 1265 | gainfield} entry blank -- this will apply all sources in the table. For the {\tt flux\_table}, we 1266 | want to use only the entries derived from {\tt PKS 1934-638} itself, so the second {\tt gain\_field} 1267 | entry should be {\tt PKS 1934-638}. The parameter {\tt interp} specifies the nature of the 1268 | interpolation used in gain table in a manner analogous to {\tt gainfield} (see {\tt help applycal} for 1269 | details). In this case we will just choose the entry nearest in time to the particular visibility to 1270 | be calibrated in {\tt bandpass\_table0} and interpolate linearly in {\tt flux\_table1}. 1271 | 1272 | \begin{casacmd} 1273 | \begin{verbatim} 1274 | applycal(vis=msfile, 1275 | gaintable=[bandpass_table0,flux_table1], 1276 | field='PKS 1934-638', 1277 | gainfield=['', 'PKS 1934-638'], 1278 | interp=['nearest','']) 1279 | \end{verbatim} 1280 | \end{casacmd} 1281 | 1282 | Next we turn to our phase calibrator. {\tt field} should now be set to {\tt PKS 1613-586}. Again we 1283 | can leave the first entry in {\tt gainfield} blank, since we again want to use any solutions in the 1284 | bandpass table. However, this time we want the second {\tt gainfield} entry to be {\tt PKS 1613-586}. 1285 | 1286 | \begin{casacmd} 1287 | \begin{verbatim} 1288 | applycal(vis=msfile, 1289 | gaintable=[bandpass_table0,flux_table1], 1290 | field='PKS 1613-586', 1291 | gainfield=['', 'PKS 1613-586'], 1292 | interp=['nearest','']) 1293 | \end{verbatim} 1294 | \end{casacmd} 1295 | 1296 | Finally, we apply the calibration to the target field. Now {\tt field} becomes {\tt Circinus X-1}. 1297 | The first entry of {\tt gainfield} again can stay blank (we're again using the bandpass solution from 1298 | {\tt PKS 1934-634}). For the second entry in {\tt gainfield}, however, we cannot use the same value 1299 | as {\tt field} like we did above, because we have no gain solutions for {\tt Circinus X-1}. Since 1300 | {\tt PKS 1613-586} is much closer on the sky, we want to use its entries from {\tt flux\_table1}, but 1301 | not those from {\tt PKS 1934-634}, so the second {\tt gainfield} entry should again be {\tt PKS 1302 | 1934-634}. 1303 | 1304 | \begin{casacmd} 1305 | \begin{verbatim} 1306 | applycal(vis=msfile, 1307 | gaintable=[bandpass_table0,flux_table1], 1308 | field='Circinus X-1', 1309 | gainfield=['','PKS 1613-586'], 1310 | interp=['nearest','']) 1311 | \end{verbatim} 1312 | \end{casacmd} 1313 | 1314 | 1315 | \section{STEP 5... Splitting the data} 1316 | 1317 | We are now almost ready to split the calibrated visibility data for our target source into separate ms 1318 | file. Note that this step is convenient, rather than necessary. One could just as well make images 1319 | (and even proceed to self-calibration) using the original ms, but often it is convenient to split out 1320 | the data of interest at this point. This particular data set has already been averaged in frequency 1321 | to reduce the size for the purposes of the workshop. These days most raw data sets you encounter will 1322 | likely have far more than 19 channels, and data sets from interferometers with more telescopes than 1323 | KAT-7, such as JVLA, ALMA, LOFAR and MeerKAT once it comes online, will have far more visibility 1324 | measurements at each time-stamp. In such cases one might average down in frequency to reduce the size 1325 | of the data set and make for faster processing. It is not necessary in this case, so our {\tt split} 1326 | output file will have the same number of channels as our original ms. 1327 | 1328 | However, {\em before} you do any averaging, it is a good idea to briefly examine the calibrated 1329 | visibility data for the target source in case there is more bad data we need to flag. Recall that so 1330 | far we have only examined the data for our calibrator sources, but not yet that for {\tt Circinus 1331 | X-1}. Lets turn again to {\tt plotms}. We will now plot correlated flux density against baseline 1332 | length in wavelengths ({\tt uvwave}). Such plots are commonly made to diagnose the nature of the 1333 | source structure. We now have to specify that we want the {\tt CORRECTED\_DATA} column: we've gone to 1334 | all this trouble to determine how to calibrate our visibilities, so we want to make sure we're 1335 | enjoying the fruits of our labours. 1336 | 1337 | \begin{casacmd} 1338 | \begin{verbatim} 1339 | plotms(vis=msfile, field='Circinus X-1', 1340 | xaxis='uvwave', yaxis='amp', 1341 | correlation='XX,YY', ydatacolumn='corrected', 1342 | coloraxis = 'corr') 1343 | \end{verbatim} 1344 | \end{casacmd} 1345 | 1346 | You should see something like this: 1347 | \begin{figure*} 1348 | \includegraphics[width=10cm]{images/CirX1_uvplot} 1349 | % \checkparity This is an \pageparity\ page.% 1350 | \caption[Mind map.]{Plot of visibility amplitude against 1351 | baseline-length for our target source, {\tt Circinus X-1}.} 1352 | \forceversofloat 1353 | \label{fig:CygX1_upvlot} 1354 | %\zsavepos{pos:textfig} 1355 | \end{figure*} 1356 | 1357 | This plot mostly shows that {\tt Circinus X-1} is {\em not} a point source, since the correlated flux 1358 | density seems to vary systematically with baseline-length ($uv$-distance or {\tt uvwave}). There are, 1359 | however, a few outlier points still, with anomalously high amplitudes above 10~Jy, such as the spikes 1360 | at UVwave $\sim 140, 290 \, \lambda$. These are likely due to RFI\@. If we re-plot amplitude against 1361 | channel, you will see that all the high amplitude point are in a single channel: channel 18. To 1362 | further narrow it down, select {\tt spw = '*:18'} and {\tt xaxis='time'}. Not only do the 1363 | high-amplitude points occur in one channel, they occur at a specific time: near 25:40. By zooming in 1364 | on the plot using the ``zoom'' tool (select the magnifying glass icon, and use the mouse to draw a box 1365 | on the screen showing the region you want to zoom in on. You can zoom back out using the ``plot'' 1366 | button), to see that the bad data occurs between times of 25:32:30 and the end of the scan at 1367 | 25:34:00. Although it is possible to flag graphically directly in {\tt plotms}, I encourage you to 1368 | again use {\tt flagdata}. Firstly, it is better to positively identify the bad data to be flagged 1369 | first, rather than zapping points at random on the screen. Secondly, using the {\tt flagdata} command 1370 | means that you can, if needed, precisely and accurately repeat the operation. Note also, that we 1371 | could do more work to locate the bad data, it might for example be only one antenna or baseline which 1372 | is bad. However, since its such a small amount of data (under 1.5 minutes in one channel only), its 1373 | more expedient just to flag it all. Note also that {\tt plotms} labels time axes in a slightly 1374 | non-standard way with hours having values $>24$. For {\tt flagdata} these values have to be 1375 | translated into a more formal timerange. 1376 | 1377 | \begin{casacmd} 1378 | \begin{verbatim} 1379 | flagdata(vis=msfile, 1380 | timerange='2012/07/02/01:32:30~2012/07/02/01:34:00', 1381 | field='Circinus X-1', spw='0:18', flagbackup=True) 1382 | \end{verbatim} 1383 | \end{casacmd} 1384 | 1385 | So now we've removed those outliers, we can split the data for our source of interest, {\tt Circinus 1386 | X-1}. 1387 | 1388 | \begin{casacmd} 1389 | \begin{verbatim} 1390 | split(vis=msfile, outputvis='CirX1_split.ms', 1391 | datacolumn='corrected', field='Circinus X-1') 1392 | \end{verbatim} 1393 | \end{casacmd} 1394 | 1395 | 1396 | \section{STEP 6... CLEAN aka Deconvolution} 1397 | 1398 | For interferometric data, the $(u,v)$ coverage is virtually never complete, and therefore the 1399 | instrumental response, called the dirty beam or the point spread function, PSF, has some unwanted 1400 | secondary responses, known as side lobes. The Fourier transform of the visibilities represents the 1401 | convolution of the true image with the dirty beam. 1402 | 1403 | There are various techniques to reduce the effects of the sidelobes, in other words to effect a 1404 | deconvolution. In radio astronomy, deconvolution has been dominated by two non-linear algorithms: 1405 | CLEAN and the Maximum Entropy Method (MEM). 1406 | 1407 | The original formulation of CLEAN was by \citet{Hogbom1974}, and worked purely in the image plane. We 1408 | explain this method here as it is easier to understand. Most modern implementations of CLEAN actually 1409 | work partly in the $(u,v)$ plane to produce somewhat more accurate results than H\"{o}gbom's original 1410 | image-plane formulation, but are conceptually similar. CLEAN works iteratively, transferring flux 1411 | density from the dirty image to a set of point-like ``clean components'', which represent the true 1412 | distribution of emission on the sky or the deconvolved image. After each step, a residual image is 1413 | formed which represents the original dirty image after subtraction of the CLEAN components so far. 1414 | Initially, before the first CLEAN component is found and subtracted, the residual image is just the 1415 | dirty image. 1416 | 1417 | The H\"{o}gbom CLEAN algorithm proceeds using these steps: 1418 | \begin{enumerate} 1419 | 1420 | \item Find strength and position of the brightest point in the current residual image. CLEAN makes 1421 | the plausible assumption that this peak is mainly due to a real signal and only a minor part comes 1422 | from the sidelobe responses to other real emission farther away in the image. Note that one should 1423 | specify one or more ``clean windows'' in which to search for real emission. 1424 | \item Subtract a point source at this location. The brightness of the point source is taken to be the 1425 | brightness of the brightest point multiplied by a factor $\gamma (\leq 1)$ called the loop gain. This 1426 | point source is the CLEAN component, and it is added to the list of CLEAN components. The response of 1427 | the instrument to a point source is the dirty beam pattern. Therefore, to subtract this point source 1428 | from our dirty image, CLEAN subtracts a dirty beam pattern, scaled so that its peak is the same as 1429 | that of the point source, and centred on the location of the brightest point, from the current 1430 | residual image. 1431 | \item Go to step 1 unless any remaining point sources are below some level specified for convergence, 1432 | or the maximum number of CLEAN components is reached. 1433 | \item Convolve the accumulated CLEAN components, which represent the model of the deconvolved 1434 | emission, with an idealized ``clean'' beam (usually an elliptical Gaussian fitted to the central lobe 1435 | of the dirty beam). 1436 | \item Add the final residual image to the convolution from the previous step. The result is what is 1437 | called the CLEAN image. Note that for purposes of calibration, it is usually the CLEAN components 1438 | that are used rather than the CLEAN image. 1439 | 1440 | \end{enumerate} 1441 | 1442 | The CLEAN algorithm was designed for the case where the true brightness distribution contains only a 1443 | few unresolved sources. It works well for cases where the true emission occurs only within small, 1444 | well-separated, regions across the field of view, in other words if the field of view is {\em mostly} 1445 | empty. The following excerpt has been taken from Robert Reid's Thesis \citep{Reid2003}. ``Physics 1446 | and filled aperture measurements give us several properties that images should have. Non-negativity: 1447 | Astronomical objects, even black holes, cannot steal light away from our receivers, but raw 1448 | interferometric images abound with negative patches. Requiring the image to be non-negative is a 1449 | strong constraint on what should be used to fill in the gaps. Locality: Usually the range of 1450 | directions from which light can be received is limited by the antennas being used. The rough location 1451 | and extent of the source may also be known from observations at other wavelengths. Raw images always 1452 | have ripples going off to infinity that should be quenched. If nowhere else, nulls in the antenna 1453 | reception pattern are invalid places to receive light from. For many frequencies and parts of the sky, 1454 | bright radio sources are also quite rare and confined (as known from filled aperture measurements), so 1455 | images are expected be mostly empty. Smoothness: Sources are expected to be continuous, and usually 1456 | to have continuous derivatives. Also, it is best to minimize the effect of the unmeasured part of the 1457 | sampling plane on the final image. Perfectly sharp edges depend on the entire sampling plane, far 1458 | beyond where interferometers can make measurements. Smoothing the image concentrates its region of 1459 | dependence on the finite area that interferometers sample. Agreement with theory: At first this seems 1460 | to throw out the baby with the bathwater, since true discoveries must be novel. True discoveries, 1461 | however, must rest on true observations. Since deconvolution ideally agrees with all the measurements, 1462 | we should not let non-measurements mislead us. Another way to see this is to think of the model as 1463 | assisting us in separating reasonable interpolations from unreasonable ones for the image, but the 1464 | parameters of the model itself are determined by the measurements. For example a circle has an 1465 | infinite number of points on its circumference, but three points on its locus are enough to specify 1466 | it, if we are sure that it is a circle. In any case, images tend to be constructed before models, thus 1467 | this principle is not always applicable.'' 1468 | 1469 | Two main inputs to {\tt clean}: the image size ({\tt imsize}) and cell size ({\tt cell}), which 1470 | correspond to the size in pixels of the map, and the size in arcseconds of a pixel, respectively, must 1471 | be carefully chosen. Here we show how to calculate these two parameters. By knowing the frequency of 1472 | our observations we can calculate the primary beam (i.e., the area of the sky observed with the 1473 | telescope). 1474 | 1475 | First we choose the size of the pixels or cells. This choice is determined by the resolution of the 1476 | interferometer, which is given by the synthesized beam. The value that is usually given is the full 1477 | width at half-maximum (FWHM). Although the exact value for FWHM of the synthesized beam will depend 1478 | on the details of the $u,v$-coverage and weighting for each particular observations, and approximate 1479 | value for a given set of observations depends largely on the maximum baseline, $B_{\rm max}$, measured 1480 | in wavelengths ($\lambda$) and is given by: 1481 | 1482 | \begin{equation} 1483 | {\rm FWHM synthesized beam} \simeq \frac{1}{(B_{\rm max}/\lambda)} {\rm radians, or} 1484 | \end{equation} 1485 | \begin{equation} 1486 | {\rm FWHM synthesized beam} \simeq \frac{3438}{B_{\rm max}/\lambda} {\rm arcminutes} 1487 | \end{equation} 1488 | 1489 | You can determine $B_{\rm max}$ in $\lambda$ by using {\tt plotms} to plot the visibility amplitude as 1490 | a function of the baseline length in $\lambda$ or {\tt uvwave}. 1491 | 1492 | In order not to be limited by the pixel size, the central lobe of the dirty beam needs to be well 1493 | resolved, and therefore a value of approximately $\frac{1}{4}$ of the above FWHM of the synthesized 1494 | beam should be chosen for the cell size. When CLEAN is run, one should check that the {\em smaller}, 1495 | or minor axis of the elliptical fitted CLEAN beam is at least $3\times$ the size of the cells. If 1496 | not, CLEAN should be stopped and restarted with better-suited values for {\tt cell}. 1497 | 1498 | In our case, we get an estimate of 3.7\arcmin\ for the resolution and thus 0.92\arcmin\ for the pixel 1499 | size, which we will round down to 0.9\arcmin\ (note that since the requirement is to have pixels small 1500 | enough to resolve the beam, rounding {\em down} is okay but not rounding up). 1501 | 1502 | The other choice the user must make is the size of the region to be imaged. The maximum size of the 1503 | region that it is sensible to image is determined by the field of view of the interferometer, which is 1504 | just determined by that of individual antennas, and is independent of the array configuration. The 1505 | FWHM of primary beam of a uniformly illuminated antenna is given by \citet{Napier1999}: 1506 | % Nadeem had orig. Napier FWHPower = 1.02 lambda/D for FWHP 1507 | % Later on he gives FWHM = Primary_beam/sqrt(2) 1508 | % 1509 | % VLA - 25m, 5GHz -> FWHP = 5.9959 cm = 2.4463e-3 rads = 8.4098' 1510 | % EVLA obs status: FWHP(') = 45/nu(GHz) = = 9.0' 1511 | % my pb days 2x correction is at 265.2" = 8.8533' 1512 | % 1513 | % Now for MeerKAT 12.0m, Napier FWHP (1822 MHz) = 16.454cm 1514 | % -> FWHP = 0.8013' = 48.08' 1515 | % 1516 | % RFP says 1deg^2 at 1.4 GHz -> I get this is 62.57' FWHP 1517 | % so FOV = 1.232deg^2 1518 | 1519 | \begin{equation} 1520 | {\rm FWHM primary beam} =\frac{1.02\times(\frac{c}{\nu})}{(\rm dish diameter} {\rm radians} 1521 | \end{equation} 1522 | 1523 | In our case, the KAT-7 dishes have a diameter of 12~m, so at our observing frequency of 1822~MHz, the 1524 | FWHM of the primary beam is $\sim$48\arcmin. Of course, sources outside this field can still be seen 1525 | by the interferometer, but at reduced amplitude. In particular, a source at a distance of FWHM/2 1526 | (remember that the FWHM is a diameter, not a radius) will be attenuated by 50\% due to the primary 1527 | beam response. 1528 | 1529 | For the relatively coarse resolution offered by KAT-7, one can afford to image a relatively large 1530 | region, and a reasonable choice is to image a region with $3\times$ the diameter of primary beam FWHM. 1531 | In our case this is equal to $(3 \times 48\arcmin = 144\arcmin$. Since we have determined our pixel 1532 | size to be 0.90\arcmin, we need to image a region of $\frac{144\arcmin)}{0.90\arcmin} = 160$. It is 1533 | common to choose image sizes which are powers of 2, so we shall round this up to 256, which is the 1534 | value we use for {\tt imsize}. 1535 | 1536 | \bigskip 1537 | \textbf{When do I stop cleaning? } 1538 | 1539 | Stop cleaning when the residuals are noise like, and/or the clean has converged (the cleaned flux is 1540 | no longer increasing)! Here are some of the parameters of {\tt clean} which determine when it stops: 1541 | 1542 | {\tt niter} - Number of CLEAN iterations to do. This can be useful when you are doing tests, but this 1543 | parameter has NO physical meaning. Instead set to large number and let either threshold or do 1544 | interactive to stop the cleaning. Please also ensure you are not over cleaning your image. Have an 1545 | eye on the casapy log that the total fluxes are not decreasing drastically. 1546 | 1547 | {\tt threshold} - Stop cleaning when peak residual has this value, give units (i.e. mJy). Ideally, one 1548 | would like the image to have a noise approaching the theoretical one, in which case a threshold of 1549 | $\sim 3\times$ the theoretical rms noise is appropriate. Note: to reach this limit the data must be 1550 | well calibrated/flagged and suffer from no serious artifacts (resolved out extended structure/negative 1551 | bowls, poor PSF/($u,v$) coverage, limited dynamic range etc). 1552 | 1553 | CLEANing deeply into the noise, that is with threshold set to a value below the image rms level is 1554 | dangerous if you have a large CLEAN window. If the area of your CLEAN window is small, fewer than say 1555 | 10 times the area of the CLEAN beam, then it is fairly safe to set {\tt threshold} to some low value 1556 | and just clean deeply. If the area of your CLEAN window is larger than overcleaning can be a problem. 1557 | Basically, once you reach rms (whether close to theoretical or not), you are just picking noise up one 1558 | place and putting it down in another. With a small CLEAN window, there is not much freedom here so 1559 | nothing much can go wrong by moving a bit of noise around within your small window. With a large 1560 | window strange artefacts can arise. Remember also, that rms in an otherwise blank region of your 1561 | image represents only a {\em lower limit} to the uncertainty of the parts of your CLEAN image which 1562 | have emission. 1563 | 1564 | \medskip 1565 | 1566 | \textbf{Starting the cleaning} 1567 | 1568 | Before you proceed to make an image, you will use the CASA viewer to look and perform various tasks. 1569 | Viewer\footnote {Follow the demo from: \url{http://casa.nrao.edu/CasaViewerDemo/casaViewerDemo.html}} 1570 | is a GUI for image manipulation. 1571 | 1572 | \begin{casacmd} 1573 | \begin{verbatim} 1574 | clean(vis='CirX1_split.ms', imagename='CirX1_split.im', 1575 | niter=5000, threshold='5.0mJy', psfmode='hogbom', 1576 | interactive= True, imsize=[256,256], 1577 | cell=['0.5arcmin' ,'0.5arcmin'], stokes='I', 1578 | weighting='briggs', robust=0.0) 1579 | \end{verbatim} 1580 | \end{casacmd} 1581 | 1582 | 1583 | \chapter{Spectral line calibration and imaging} 1584 | \label{ch:spectral} 1585 | 1586 | Spectral line calibration is pretty similar to that for continuum. The real differences come in when 1587 | imaging the data. Instead of averaging together all the data before imaging, we make one image per 1588 | frequency channel, producing a \textbf{data cube}. In this tutorial we assume that you have worked 1589 | through Chapter 3 and understand the basics of CASA and calibration. 1590 | 1591 | The KAT-7 spectral line modes produce 4096 channels of data. The outer 500 channels are usually 1592 | discarded since the gain tapers off rapidly as part of the guard bands. For this tutorial we will use 1593 | a subsection of data to speed things up. (The original data file is 34 GB). 1594 | 1595 | We will be looking at a massive star forming cloud in the Galactic Plane. At L-band we see a number of 1596 | evolved HII regions (continuum) and hydroxyl masers (spectral lines). The msfile is called {\tt 1597 | G330\_OH.ms}. 1598 | 1599 | \section{Inspection and flagging} 1600 | First, let us set up all our filenames: \\ 1601 | \begin{casacmd} 1602 | \begin{verbatim} 1603 | prefix = 'G330_OH' 1604 | msfile = prefix+'.ms' 1605 | gtable0 = prefix + '.G0' 1606 | btable0 = prefix + '.B0' 1607 | gtable1 = prefix + '.G1' 1608 | ftable1 = prefix + '.fluxscale1' 1609 | \end{verbatim} 1610 | \end{casacmd} 1611 | 1612 | Lets have a look at what we have here: \\ 1613 | \begin{casacmd} 1614 | \begin{verbatim} 1615 | listobs(msfile) 1616 | \end{verbatim} 1617 | \end{casacmd} 1618 | 1619 | \begin{casaoutput} 1620 | \begin{verbatim} 1621 | ########################################## 1622 | ##### Begin Task: listobs ##### 1623 | listobs(vis="G330_OH.ms",selectdata=True,spw="",field="", 1624 | antenna="",uvrange="",timerange="",correlation="",scan="", 1625 | intent="",feed="",array="",observation="",verbose=True, 1626 | listfile="",listunfl=False,cachesize=50) 1627 | ================================================================================ 1628 | MeasurementSet Name: /home/sharmila/spec_line_tut_OH/G330_OH.ms MS Version 2 1629 | ================================================================================ 1630 | Observer: sharmila Project: 20130621-0006 1631 | Observation: KAT-7 1632 | Data records: 12327 Total integration time = 40778.8 seconds 1633 | Observed from 21-Jun-2013/14:08:01.0 to 22-Jun-2013/01:27:39.8 (UTC) 1634 | 1635 | ObservationID = 0 ArrayID = 0 1636 | Date Timerange (UTC) Scan FldId FieldName nRows SpwIds AveInts 1637 | 21-Jun-2013/14:07:45.9 - 14:12:17.7 1 0 1934-638 189 [0] [30.2] 1638 | 14:25:02.7 - 14:25:32.9 4 1 1613-586 21 [0] [30.2] 1639 | 14:26:13.2 - 14:30:45.0 5 2 G330.89-0.36 189 [0] [30.2] 1640 | 14:36:37.3 - 14:37:07.5 7 1 1613-586 21 [0] [30.2] 1641 | 14:37:47.8 - 14:42:19.6 8 2 G330.89-0.36 189 [0] [30.2] 1642 | 14:48:11.9 - 14:48:42.1 10 1 1613-586 21 [0] [30.2] 1643 | 14:49:22.3 - 14:53:54.1 11 2 G330.89-0.36 189 [0] [30.2] 1644 | ........... 1645 | ........... 1646 | ........... 1647 | 01:10:33.0 - 01:11:33.4 159 1 1613-586 42 [0] [30.2] 1648 | 01:11:48.5 - 01:16:20.3 160 2 G330.89-0.36 189 [0] [30.2] 1649 | 01:22:07.6 - 01:22:37.8 162 1 1613-586 21 [0] [30.2] 1650 | 01:23:23.1 - 01:27:54.9 163 2 G330.89-0.36 189 [0] [30.2] 1651 | (nRows = Total number of rows per scan) 1652 | Fields: 3 1653 | ID Code Name RA Decl Epoch nRows 1654 | 0 T 1934-638 19:39:25.017468 -63.42.45.60158 J2000 2079 1655 | 1 T 1613-586 16:17:17.893107 -58.48.07.88902 J2000 1176 1656 | 2 T G330.89-0.36 16:10:20.541228 -52.06.14.90063 J2000 9072 1657 | Spectral Windows: (1 unique spectral windows and 1 unique polarization setups) 1658 | SpwID Name #Chans Frame Ch1(MHz) ChanWid(kHz) TotBW(kHz) Corrs 1659 | 0 none 1001 TOPO 1665.985 0.381 381.9 XX YY 1660 | The SOURCE table is empty: see the FIELD table 1661 | Antennas: 7: 1662 | ID Name Station Diam. Long. Lat. 1663 | 1664 | 0 ant1 ant1 12.0 m +021.24.39.4 -30.33.10.2 1665 | 1 ant2 ant2 12.0 m +021.24.41.9 -30.33.09.1 1666 | 2 ant3 ant3 12.0 m +021.24.38.6 -30.33.09.1 1667 | 3 ant4 ant4 12.0 m +021.24.37.7 -30.33.09.1 1668 | 4 ant5 ant5 12.0 m +021.24.37.1 -30.33.10.0 1669 | 5 ant6 ant6 12.0 m +021.24.36.2 -30.33.12.5 1670 | 6 ant7 ant7 12.0 m +021.24.35.2 -30.33.07.5 1671 | ##### End Task: listobs ##### 1672 | ########################################## 1673 | 1674 | \end{verbatim} 1675 | \end{casaoutput} 1676 | 1677 | \newpage 1678 | We have averaged to 30 second integrations and there are 601 channels in this dataset to reduce the 1679 | size of the file. 1680 | 1681 | Now we set up our calibrator variables. We use PKS~1934-638 as the flux and bandpass calibrator and 1682 | PKS~1613-586 as the gain calibrator. Antenna 6 is usually very stable, so we will use it as our 1683 | reference antenna. 1684 | 1685 | \begin{casacmd} 1686 | \begin{verbatim} 1687 | f_cal = '1934-638' 1688 | b_cal = '1934-638' 1689 | g_cal = '1613-586' 1690 | ref_ant = 'ant6' 1691 | \end{verbatim} 1692 | \end{casacmd} 1693 | 1694 | Before we start calibration, it is vital to make sure that our calibrators are free of RFI. First we 1695 | check along the frequency axis. This is a very narrow-band observation (1.1 MHz) so we don't usually 1696 | expect to see much RFI. However, we have found self-generated RFI on some antennas, so we will look 1697 | at each baseline independently. 1698 | 1699 | \begin{casacmd} 1700 | \begin{verbatim} 1701 | plotms(vis = msfile, 1702 | field = f_cal, 1703 | xaxis = 'channel', 1704 | yaxis = 'amp', 1705 | iteraxis = 'baseline', 1706 | yselfscale = True) 1707 | \end{verbatim} 1708 | \end{casacmd} 1709 | 1710 | Did you spot the RFI? Identify the channel and use {\tt flagdata} to flag the channel for the 1711 | affected antennas. 1712 | 1713 | \begin{casacmd} 1714 | \begin{verbatim} 1715 | flagdata(vis = msfile, 1716 | spw = '0:548', 1717 | antenna = 'ant5,ant6,ant7') 1718 | \end{verbatim} 1719 | \end{casacmd} 1720 | 1721 | \section{Set up models for the calibrators} 1722 | 1723 | Now lets prepare the file for calibration. This step will clear all previous calibrations or, if it 1724 | is a freshly made ms file, will add in the MODEL and CORRECTED DATA columns. 1725 | 1726 | \begin{casacmd} 1727 | \begin{verbatim} 1728 | clearcal(msfile) 1729 | \end{verbatim} 1730 | \end{casacmd} 1731 | 1732 | Now we are going to set up models for our calibrators. First, we set up our flux calibrator: 1733 | 1734 | \begin{casacmd} 1735 | \begin{verbatim} 1736 | setjy(vis = msfile, 1737 | field = f_cal, 1738 | fluxdensity = -1, 1739 | standard = 'Perley-Taylor 99') 1740 | \end{verbatim} 1741 | \end{casacmd} 1742 | 1743 | PKS 1613-586 is not a very good calibrator, but it is difficult to find isolated sources close to the 1744 | Galactic Plane. Instead, we use a model of the field, found by imaging the calibrator. You should 1745 | have the directory {\tt 1613-586.model} in your working directory. This is a CASA model file, which 1746 | is produced by CLEAN. This will populate the MODEL column for the source with the appropriate 1747 | visibilities. 1748 | 1749 | \begin{casacmd} 1750 | \begin{verbatim} 1751 | setjy(vis = msfile, 1752 | field = '1613-586', 1753 | fluxdensity = [0,0,0,0], 1754 | modimage = '1613-586.model') 1755 | \end{verbatim} 1756 | \end{casacmd} 1757 | 1758 | 1759 | \section{Calibration} 1760 | 1761 | We first do a preliminary time-dependent phase calibration over a subset of the band. We have to find 1762 | a small section of the band that is reasonably flat, and have enough bandwidth to achieve a reasonable 1763 | signal-to-noise. The number of channels is going to depend on the total bandwidth of the observation. 1764 | In this case, we are using 1/4 of the total channels in the 1.5 MHz mode and don't expect to see much 1765 | change across the bandpass. 1766 | 1767 | \begin{casacmd} 1768 | \begin{verbatim} 1769 | plotms(vis=msfile, 1770 | field = f_cal, 1771 | xaxis = 'channel', 1772 | yaxis = 'phase', 1773 | avgtime = '1e8', 1774 | correlation = 'XX', 1775 | antenna = 'ant6', 1776 | coloraxis = 'antenna2') 1777 | \end{verbatim} 1778 | \end{casacmd} 1779 | 1780 | You will have noticed in plotms that the bandpass appears to be relatively flat across this channel 1781 | range, so we can in fact use all of the channels. Note that this is not the case for the wider HI 1782 | modes. You may find solutions failing if you use too large a channel range. 1783 | 1784 | \begin{casacmd} 1785 | \begin{verbatim} 1786 | ref_chans = '0:1~600' 1787 | gaincal(vis = msfile, 1788 | field = b_cal, 1789 | caltable = gtable0, 1790 | refant=ref_ant, 1791 | spw = ref_chans, 1792 | calmode = 'p', 1793 | solint = 'inf', 1794 | minsnr = 5, 1795 | solnorm = True, 1796 | interp = 'nearest') 1797 | \end{verbatim} 1798 | \end{casacmd} 1799 | 1800 | Inspect the solutions using plotcal. 1801 | 1802 | \begin{casacmd} 1803 | \begin{verbatim} 1804 | plotcal(caltable = gtable0, 1805 | xaxis = 'time', 1806 | yaxis = 'phase', 1807 | markersize=3, 1808 | plotsymbol='.', 1809 | iteration='antenna', 1810 | subplot=421, 1811 | fontsize=8) 1812 | \end{verbatim} 1813 | \end{casacmd} 1814 | 1815 | All looks good, so lets continue on to the bandpass calibration. We have found that in general, we do 1816 | not need to do a time-dependent bandpass calibration for KAT-7, even though we visit the bandpass 1817 | calibrator every hour in these observations (just in case), so we average over all of the bandpass 1818 | scans to increase our signal-to-noise ratio. To start with, we are going to use the normal 'per 1819 | channel' bandpass solution ie {\tt bandtype='B'}. However, if the solutions turn out to be very noisy, 1820 | it may be better to use a polynomial fit to the bandpass {\tt bandtype='BPOLY'} 1821 | 1822 | \begin{casacmd} 1823 | \begin{verbatim} 1824 | bandpass(vis = msfile, 1825 | caltable = btable0, 1826 | field = b_cal, 1827 | refant = ref_ant, 1828 | solnorm = True, 1829 | combine = 'scan', 1830 | solint = 'inf', 1831 | bandtype = 'B', 1832 | minsnr = 5, 1833 | gaintable = [gtable0], 1834 | interp = ['nearest']) 1835 | \end{verbatim} 1836 | \end{casacmd} 1837 | 1838 | If you are using CASA 4.1 and above, there is a new task to plot bandpasses. This will enable you to 1839 | see both the amplitude and phase, and overplot polynomial solutions (Figure~\ref{fig:plotbandpass_b}). 1840 | 1841 | \begin{casacmd} 1842 | \begin{verbatim} 1843 | plotbandpass(caltable = btable0, 1844 | xaxis = 'freq', 1845 | yaxis = 'both', 1846 | subplot = 42) 1847 | \end{verbatim} 1848 | \end{casacmd} 1849 | 1850 | \begin{figure} 1851 | \includegraphics[width=\textwidth]{images/plotbandpass_b} 1852 | \caption[]{The output of plotbandpass for a few antennas.} 1853 | \forceversofloat 1854 | \label{fig:plotbandpass_b} 1855 | \end{figure} 1856 | 1857 | The problem with such narrow band observations is that we have increased noise. Note that the 1858 | peak-to-peak amplitude variation is about 10\% and the phase variation is about 8 degrees. However, 1859 | there is not much variation in the bandpass, so we can use a polynomial-based bandpass calibration. 1860 | Note below that we change bandtype to {\tt 'BPOLY'}. We can specify different orders of polynomial fit 1861 | for the phase and amplitude if necessary (Figure~\ref{fig:plotbandpass_bpoly}). 1862 | 1863 | \begin{casacmd} 1864 | \begin{verbatim} 1865 | btable1 = prefix +'.B1' 1866 | bandpass(vis=msfile, 1867 | caltable = btable1, 1868 | field = b_cal, 1869 | refant =ref_ant, 1870 | solnorm = True, 1871 | combine='scan', 1872 | solint = 'inf', 1873 | bandtype = 'BPOLY', 1874 | degamp = 10, 1875 | degphase = 10, 1876 | minsnr = 5, 1877 | gaintable = [gtable0], 1878 | interp = ['nearest']) 1879 | \end{verbatim} 1880 | \end{casacmd} 1881 | 1882 | \begin{figure} 1883 | \includegraphics[width=\textwidth]{images/plotbandpass_bpoly} 1884 | \caption[]{The output of plotbandpass with B and BPOLY solutions overlaid.} 1885 | \forceversofloat 1886 | \label{fig:plotbandpass_bpoly} 1887 | \end{figure} 1888 | 1889 | Why is the bandpass calibration so important? In spectral line observations we are interested in 1890 | source structure as a function of frequency, so we want to remove any spurious variations due to the 1891 | instrumental response. We may also want to subtract off continuum emission in order to simplify our 1892 | imaging and in this case we don't want there to be any residual continuum emission. How do we know if 1893 | we have sufficient signal to noise in our bandpass calibrator? We typically want the rms noise from 1894 | the calibrator to be much less than the noise in the source. We use calibrators with reasonably high 1895 | flux density, but spend less time on them than we do on our target sources, so its good to review 1896 | whether your observations satisfy the criterion that $I_{cal} \sqrt{t_{cal}}$ should be significantly 1897 | greater than $I_{target}\sqrt{t_{target}}$. In the case of this observation, the target actually has 1898 | quite a high continuum flux, and it will not be possible to meet this requirement without spending an 1899 | impractical amount of time on the bandpass calibrator. 1900 | 1901 | Now we calibrate the gain on our flux calibrator, which in this observation happens to also be our 1902 | bandpass calibrator. 1903 | 1904 | \begin{casacmd} 1905 | \begin{verbatim} 1906 | gaincal(vis = msfile, 1907 | caltable = gtable1, 1908 | field = f_cal, 1909 | solint = 'inf', 1910 | refant = ref_ant, 1911 | gaintype = 'G', 1912 | calmode = 'ap', 1913 | solnorm = False, 1914 | minsnr = 5, 1915 | gaintable = [btable1], 1916 | interp = ['nearest']) 1917 | \end{verbatim} 1918 | \end{casacmd} 1919 | 1920 | Now check that there are no bad outliers in the gain calibration. 1921 | 1922 | \begin{casacmd} 1923 | \begin{verbatim} 1924 | plotcal(caltable = gtable1, 1925 | field = f_cal, 1926 | xaxis = 'time', 1927 | yaxis = 'amp', 1928 | markersize=3, 1929 | plotsymbol='.', 1930 | iteration='antenna', 1931 | subplot=421, 1932 | fontsize=8) 1933 | 1934 | plotcal(caltable = gtable1, 1935 | field = f_cal, 1936 | xaxis = 'time', 1937 | yaxis = 'phase', 1938 | markersize=3, 1939 | plotsymbol='.', 1940 | iteration='antenna', 1941 | subplot=421, 1942 | fontsize=8) 1943 | \end{verbatim} 1944 | \end{casacmd} 1945 | 1946 | Calibrate the gains on the phase calibrator. Note that we append the solutions to the table containing 1947 | the gains on the flux calibrator. 1948 | 1949 | \begin{casacmd} 1950 | \begin{verbatim} 1951 | gaincal(vis = msfile, 1952 | caltable = gtable1, 1953 | field = g_cal, 1954 | solint = 'inf', 1955 | refant = ref_ant, 1956 | gaintype = 'G', 1957 | calmode = 'ap', 1958 | append = True, 1959 | solnorm = False, 1960 | minsnr = 5, 1961 | gaintable = [btable1], 1962 | interp = ['nearest']) 1963 | \end{verbatim} 1964 | \end{casacmd} 1965 | 1966 | As usual, check the gain solutions and make sure that there's nothing nasty going on. Next, we 1967 | transfer the flux scale from our flux calibrator to the gain calibrator. This will automatically 1968 | transfer the flux calibration to the target when we apply the calibrations. 1969 | 1970 | \begin{casacmd} 1971 | \begin{verbatim} 1972 | fluxscale(vis=msfile, 1973 | caltable = gtable1, 1974 | fluxtable = ftable1, 1975 | reference = f_cal, 1976 | transfer = g_cal) 1977 | \end{verbatim} 1978 | \end{casacmd} 1979 | 1980 | % \bigskip 1981 | 1982 | \begin{casaoutput} 1983 | \begin{verbatim} 1984 | ########################################## 1985 | ##### Begin Task: fluxscale ##### 1986 | fluxscale(vis="G330_OH.ms",caltable="G330_OH.G1", 1987 | fluxtable="G330_OH.fluxscale1",reference="1934-638", 1988 | transfer="1613-586",listfile="",append=False,refspwmap=[-1], 1989 | incremental=False, fitorder=1) 1990 | Opening MS: G330_OH.ms for calibration. 1991 | Initializing nominal selection to the whole MS. 1992 | Beginning fluxscale--(MSSelection version)------- 1993 | Found reference field(s): 1934-638 1994 | Found transfer field(s): 1613-586 1995 | Flux density for 1613-586 in SpW=0 is: 1.01027 +/- 0.00741467 (SNR = 136.252, N = 14) 1996 | Storing result in G330_OH.fluxscale1 1997 | Writing solutions to table: G330_OH.fluxscale1 1998 | ##### End Task: fluxscale ##### 1999 | ########################################## 2000 | \end{verbatim} 2001 | \end{casaoutput} 2002 | 2003 | Check that the derived flux is close to what is expected. Now we are ready to apply the calibration 2004 | and get ready for imaging. 2005 | 2006 | \begin{casacmd} 2007 | \begin{verbatim} 2008 | target = 'G330.89-0.36' 2009 | applycal(vis=msfile, 2010 | field = target, 2011 | gaintable = [btable1, ftable1], 2012 | gainfield = [b_cal, g_cal], 2013 | interp = ['nearest', 'linear']) 2014 | \end{verbatim} 2015 | \end{casacmd} 2016 | 2017 | \begin{casacmd} 2018 | \begin{verbatim} 2019 | split_outputvis = target+'.split.ms' 2020 | split(vis = msfile, 2021 | outputvis = split_outputvis, 2022 | field = target, 2023 | datacolumn = 'corrected') 2024 | \end{verbatim} 2025 | \end{casacmd} 2026 | 2027 | 2028 | \section{Velocity rest frames} 2029 | 2030 | There are a few things that you need to do before you can dive in and start cleaning your image. 2031 | Since spectral line observations give us a lot of information about velocities of the objects that we 2032 | are observing, it is important to be clear on what reference frames we are using. The apparent 2033 | frequency of a source, also known as the 'sky frequency', is influenced by Earth's rotation and 2034 | revolution around the Sun, the motion of our Solar System around the Galaxy, the movement of our 2035 | Galaxy within the Local Group and there is also motion against the cosmic microwave background. The 2036 | various rest frames are listed in Table~\ref{tab:rest_frames}. At L-band, the sky frequency change by 2037 | up to 0.15 MHz during the course of a year. 2038 | 2039 | The KAT-7 system does not do any Doppler corrections, so its rest frame is \textbf{topocentric}. The 2040 | actual sky frequency of your source will vary from day to day and if you are observing with high 2041 | frequency resolution, you may even see your spectral line shifting during the course of a single day's 2042 | observation. This is definitely the case for these hydroxyl maser observations. We have a velocity 2043 | resolution of 68 m/s so we do see the source Doppler-shifted by Earth's rotation. 2044 | 2045 | You will usually want to have your final data cubes output into a different rest frame. The velocity 2046 | frame to use depends on your science. In the case of this dataset, we are looking at a Galactic star 2047 | formation region. It is meaningfull in this case to work in the \textbf{Local Standard of Rest (LSR) 2048 | frame}. There are actually two definitions of LSR, the kinematic LSR (LSRK) and dynamic LSR (LSRD). 2049 | Most of the time LSRK is used and is generally synomynous with LSR. The other commonly used rest 2050 | frame is \textbf{barycentric}, and has mostly replaced the old heliocentric standard. 2051 | 2052 | There are two ways to change rest frames in CASA. The CLEAN task can change the reference frame of 2053 | the spectral axis which is fine if you don't have to worry about doppler shifts during the course of 2054 | the observation. CVEL is a more general spectral regridding tool, which enables you to correct for 2055 | Doppler shifts, or change the channelisation on your data prior to imaging. Doing the spectral 2056 | regridding before running CLEAN can save you time if you think you are going to be trying different 2057 | imaging settings. 2058 | 2059 | \begin{table} 2060 | \caption{Velocity rest frames} 2061 | \label{tab:rest_frames} 2062 | \small 2063 | \begin{minipage}{1.2\textwidth} 2064 | \begin{tabular}{|l|l|l|l|} 2065 | \hline \rule[-2ex]{0pt}{5.5ex} Rest Frame Name & Rest frame & Corrects for & Max \\ 2066 | & & & (km/s) \\ 2067 | \hline \rule[-2ex]{0pt}{5.5ex} Topocentric & Telescope & Nothing &0 \\ 2068 | \hline \rule[-2ex]{0pt}{5.5ex} Geocentric & Earth Centre & Earth Rotation & 0.5 \\ 2069 | \hline \rule[-2ex]{0pt}{5.5ex} Earth-Moon & Earth-Moon & Motion about & 0.013\\ 2070 | Barycentric & centre of mass & Earth + Moon &\\ 2071 | & & centre of mass & \\ 2072 | \hline \rule[-2ex]{0pt}{5.5ex} Heliocentric & Centre of Sun & Earth orbital motion & 30 \\ 2073 | \hline \rule[-2ex]{0pt}{5.5ex} Barycentric & Earth+Sun & Earth+Sun & 0.012 \\ 2074 | & centre of mass & centre of mass & \\ 2075 | \hline \rule[-2ex]{0pt}{5.5ex} Local standard of rest& Centre of mass& Solar motion rel & 20 \\ 2076 | (LSR) & of local stars&to nearby stars &\\ 2077 | \hline \rule[-2ex]{0pt}{5.5ex} Galactocentric & Centre of & Milky Way & 230 \\ 2078 | &Milky Way & rotation &\\ 2079 | \hline \rule[-2ex]{0pt}{5.5ex}Local Group & Local Group & Milky Way& 100 \\ 2080 | Barycentric & centre of mass & motion & \\ 2081 | \hline \rule[-2ex]{0pt}{5.5ex} Virgocentric& Centre of the &Local Group & 300 \\ 2082 | & Local Virgo & motion & \\ 2083 | & Supercluster & & \\ 2084 | \hline \rule[-2ex]{0pt}{5.5ex} Cosmic Microwave & CMB & Local Supercluster & 600 \\ 2085 | Background & & motion & \\ 2086 | \hline 2087 | \end{tabular} 2088 | \end{minipage} 2089 | \end{table} 2090 | 2091 | \bigskip 2092 | 2093 | \info{You can use the viewer to look at visibilities. Lets try it now.} 2094 | 2095 | Figure~\ref{fig:doppler} shows a pretty severe shift over the course of the observations. If we had 2096 | to image this dataset without correcting for the Doppler shift, we would end up blending our spectral 2097 | features together. We are going to be using CVEL to correct for the doppler shift, and at the same 2098 | time, change the velocity reference frame to the Local Standard of Rest ($V_{LSR}$). Before we do 2099 | that, we need to set the line rest frequency in the measurement set. The KAT-7 observation framework 2100 | does not make provision for setting the rest frequency in the data files so we shall have to do it 2101 | manually. The rest frequency for this transition of OH is 1665.40184 MHz. We are going to open the 2102 | spectral window table and insert the rest frequency. The default rest frequency in the file is 2103 | usually the central observing frequency. Remember to close the file before continuing because it will 2104 | be locked until you do. 2105 | 2106 | \begin{figure} 2107 | \includegraphics[width=\textwidth]{images/doppler_shift} 2108 | \caption[]{A raster plot of visibilities on a single baseline. Note 2109 | how the spectral line is shifting through the channels over time.} 2110 | \forceversofloat 2111 | \label{fig:doppler} 2112 | \end{figure} 2113 | 2114 | \begin{casacmd} 2115 | \begin{verbatim} 2116 | restfreq=1665.40184e6 2117 | tb.open(split_outputvis+'/SPECTRAL_WINDOW', 2118 | nomodify=False) 2119 | tb.putcell('REF_FREQUENCY', 0, restfreq) 2120 | tb.close() 2121 | \end{verbatim} 2122 | \end{casacmd} 2123 | 2124 | If run {\tt listobs} now you should see that the reference frequency has changed. Next we run {\tt 2125 | cvel}. 2126 | 2127 | \begin{casacmd} 2128 | \begin{verbatim} 2129 | freq_string = str(restfreq/1e6)+'MHz' 2130 | cvel_outputvis = target+'.cvel.ms' 2131 | cvel(vis = split_outputvis, 2132 | outputvis = cvel_outputvis, 2133 | mode = 'velocity', 2134 | interpolation = 'linear', 2135 | outframe = 'LSRK', 2136 | restfreq = freq_string) 2137 | \end{verbatim} 2138 | \end{casacmd} 2139 | 2140 | \begin{figure} 2141 | \includegraphics[width=\textwidth]{images/doppler_corrected} 2142 | \caption[]{A raster plot of visibilities on a single baseline after doppler correction.} 2143 | \forceversofloat 2144 | \label{fig:doppler_corrected} 2145 | \end{figure} 2146 | 2147 | This can take some time for a large dataset. If you find yourself running low on disk space, you can 2148 | now delete the split file since we will use the cvel file from now on. Have a look at the spectral 2149 | lines using the viewer and convince yourself that we have removed the doppler shift. In 2150 | Figure~\ref{fig:doppler_corrected} you will see that the spectral lines now stay in the same channel. 2151 | Note that some of the edge channels are now missing data. Make sure that you have split off 2152 | sufficient channels to account for this before you apply cvel. We will lose about 10 channels in this 2153 | process. When you clean your datacube, you should make sure that these channels are not included. I 2154 | generally avoid this problem by setting the start velocity and number of channels for the output from 2155 | cvel such that I cover only the channels that I want to image. This trick works well if you have 2156 | observations spread over more than a month, because the channel in which a particular velocity will be 2157 | present will vary over the year. This brings your data into a common reference frame with consistent 2158 | channel numbers. If you don't know what these parameters should be, you can run cvel on the full 2159 | channel range, then examine the resulting file and rerun cvel with a smaller output range once you 2160 | know which velocity range is of interest. Remember to leave sufficient line-free channels on either 2161 | side of your dataset for continuum subtraction. 2162 | 2163 | 2164 | \section{Continuum subtraction} 2165 | 2166 | This particular field is of a massive star formation region. The one degree field of view includes 2167 | several evolved HII regions as well as younger regions containing masers. It will simplify the 2168 | cleaning process considerably if we can subtract the continuum and image it separately from the line 2169 | emission. Lets have a look at a spectrum and see if we can establish the continuum baseline. In the 2170 | case of these masers, the emission is so strong that we can see it in individual integrations, however 2171 | you need to be careful because there are also weaker features less than one Jy. In the case of weaker 2172 | sources, we would need to average together all of the data in order to spot the emission. This works 2173 | well only if the source is close to the phase centre and not too extended. The best way is to make a 2174 | dirty cube and examine this through the viewer in order to determine line channels. In the case of 2175 | extremely weak line sources you may even need to do some cleaning first before you can identify the 2176 | lines. 2177 | 2178 | Lets have a quick look at the averaged spectrum. 2179 | 2180 | \begin{casacmd} 2181 | \begin{verbatim} 2182 | plotms(vis=cvel_outputvis, 2183 | ydatacolumn = 'data', 2184 | xaxis = 'channel', 2185 | yaxis = 'amp', 2186 | avgtime='1e8', 2187 | avgscan=True) 2188 | \end{verbatim} 2189 | \end{casacmd} 2190 | 2191 | There may be some emission around the last channels. It also turns out that this plot does not show 2192 | sufficient detail to figure out where the line emission is. It will be much better to make a dirty 2193 | cube first and inspect the result to determine where we can place the continuum windows. To make a 2194 | dirty cube, we simple set the number of iterations of CLEAN to zero. 2195 | 2196 | \begin{casacmd} 2197 | \begin{verbatim} 2198 | clean(vis = cvel_outputvis, 2199 | imagename = 'dirty', 2200 | mode = 'channel', 2201 | outframe = 'LSRK', 2202 | restfreq = freq_string, 2203 | imsize = 256, 2204 | cell='30arcsec', 2205 | stokes = 'I', 2206 | niter = 0, 2207 | psfmode = 'hogbom', 2208 | interactive = False, 2209 | weighting = 'briggs') 2210 | 2211 | viewer('dirty.image') 2212 | \end{verbatim} 2213 | \end{casacmd} 2214 | 2215 | We have a reduced channel range in this dataset in order to keep the file sizes down, and as a result 2216 | most of the channels contain line emission. Continuum subtraction is a lot easier in the original 2217 | 4096 channel dataset. Careful examination of the cube will show that the only line-free channels are 2218 | around 280 to 340. The continuum subtraction task will issue a warning about extrapolating over the 2219 | outer frequency ranges but will still do it. 2220 | 2221 | \begin{casacmd} 2222 | \begin{verbatim} 2223 | cont_window = '0:280~340' 2224 | uvcontsub(vis=cvel_outputvis, 2225 | fitspw = cont_window, 2226 | fitorder = 1, 2227 | want_cont = True) 2228 | \end{verbatim} 2229 | \end{casacmd} 2230 | 2231 | Now you have two new measurement sets, one containing the continuum data, which you can image as 2232 | usual, and one containing the spectral data. We do not expect to see any absorption features in this 2233 | field, so if you do see negative features, it may mean that the continuum subtraction has failed. You 2234 | can check this before going on to the laborious task of deconvolution by making a dirty cube of the 2235 | continuum-subtracted data. 2236 | 2237 | 2238 | \section{Finally, on to imaging} 2239 | 2240 | Now we can start cleaning the spectral line cube. Masers typically have angular sizes of the order of 2241 | milli-arcseconds and therefore are not resolved with KAT-7. However, there are five individual 2242 | sources of maser emission in this field of view. Lets start the cleaning process. You will notice 2243 | that we still specify the rest frequency even though we have already set it in the measurement set. 2244 | This is because of some inconsistencies in the way CASA handles spectral velocities - for now it is 2245 | safer to always specify the rest frequencies and the required output frame. 2246 | 2247 | \begin{casacmd} 2248 | \begin{verbatim} 2249 | restfreq=1665.40184e6 2250 | freq_string = str(restfreq/1e6)+'MHz' 2251 | contsub_vis = target+'.cvel.ms.contsub' 2252 | cube_namebase = target+'.cube.clean' 2253 | 2254 | clean(vis = contsub_vis, 2255 | imagename = cube_namebase, 2256 | spw = '0:1~590', 2257 | mode = 'channel', 2258 | outframe = 'LSRK', 2259 | restfreq = freq_string, 2260 | imsize = 256, 2261 | cell='30arcsec', 2262 | stokes = 'I', 2263 | threshold = '0.15Jy', 2264 | niter = 20000, 2265 | psfmode = 'hogbom', 2266 | interactive = True, 2267 | weighting = 'briggs') 2268 | \end{verbatim} 2269 | \end{casacmd} 2270 | 2271 | If you find you are running out of time, try setting interactive to False and let CASA find its own 2272 | way. 2273 | 2274 | Optional: Try cleaning the continuum. Below are the commands to start the continuum cleaning. Note 2275 | that I have dropped the last 11 channels to get rid of the empty channels that we were left with after 2276 | {\tt CVEL}. 2277 | 2278 | \begin{casacmd} 2279 | \begin{verbatim} 2280 | cont_vis = target+'.cvel.ms.cont' 2281 | cont_image = target+'.cont.clean' 2282 | 2283 | clean(vis=cont_vis, 2284 | imagename = cont_image, 2285 | spw = '0:0~590', 2286 | imsize = 512, 2287 | cell='30arcsec', 2288 | stokes = 'I', 2289 | threshold = '10mJy', 2290 | niter = 5000, 2291 | psfmode = 'hogbom', 2292 | interactive = True, 2293 | weighting = 'briggs') 2294 | \end{verbatim} 2295 | \end{casacmd} 2296 | 2297 | You will notice that this field has a pretty complex structure, consisting of point sources as well as 2298 | more nebulous evolved HII regions. It is far better to clean this image using multi-scale clean, which 2299 | will fit for several size-scales. To set up multi-scale, we need to specify the scales, in number of 2300 | pixels, where 0 indicates a point source, 5 pixels is about one beam, and then we do a few multiples 2301 | of the beam, going up to 4 times the beam in this case. Note that CASA will complain if the scales 2302 | are too large and then drop them. If doing the cleaning non-interactively, it is good to also tell 2303 | CASA to stop when it starts creating too many negative components, otherwise things can go wrong very 2304 | quickly. 2305 | 2306 | \caution{Warning: multiscale clean is a lot slower than the conventional clean because it repeats the 2307 | clean cycle for every scale specified and needs to re-scale the psf for every scale. When setting 2308 | this task to non-interactive mode, and trying to clean down to 5 times the expected rms noise, this 2309 | takes almost 3 hours on a high-end desktop machine. This is also why we try to subtract the continuum 2310 | off in the uv-plane, since it speeds up imaging the OH masers considerably. 2311 | } 2312 | 2313 | \begin{casacmd} 2314 | \begin{verbatim} 2315 | cont_image = target+'.cont.multiscale.clean' 2316 | clean(vis=cont_vis, 2317 | imagename = cont_image, 2318 | multiscale = [0, 5, 10, 15, 20], 2319 | negcomponent = 1, 2320 | spw = '0:0~590', 2321 | imsize = 512, 2322 | cell='30arcsec', 2323 | stokes = 'I', 2324 | threshold = '10mJy', 2325 | niter = 5000, 2326 | psfmode = 'hogbom', 2327 | interactive = True, 2328 | weighting = 'briggs') 2329 | \end{verbatim} 2330 | \end{casacmd} 2331 | 2332 | 2333 | \chapter{Troubleshooting and Support} 2334 | \label{ch:troubleshooting} 2335 | 2336 | \section{Getting help} 2337 | \label{sec:getting-help} 2338 | 2339 | In casapy, you can type {\tt help [commandname]} to get help in a particular command. 2340 | 2341 | If you've encountered a problem, have a question, or would like to report a bug, please send an email 2342 | to our mailing list or visit our website. 2343 | 2344 | \backmatter 2345 | 2346 | % need this for bibtex 2347 | \newcommand{\aaps}{Astron. Astrophys. Suppl. Ser.} 2348 | \bibliographystyle{plainnat} 2349 | \bibliography{casa-bib} 2350 | 2351 | 2352 | \printindex 2353 | 2354 | \end{document} 2355 | --------------------------------------------------------------------------------