Python Basics:
Typing help at the CASA prompt with no arguments will bring up the native Python help, which has information about Python commands and keywords. Hitting <RETURN> at the Python help> prompt will return you to CASA.
Command-line Completion and Recall:
Hitting the <TAB> key completes unambiguous commands or variable names and shows you a list of the possible completions, if there are more than one. It also completes filenames from the working directory if no CASA or Python commands match. Once you have typed enough of a command to make it unique, <TAB> will complete it. This will help you avoid errors due to typos. You can also use up and down arrow command line recall in the CASA interface. Begin typing a command, and then use the up arrow; you will navigate back and edit commands matching what you typed.
Setting Variables:
Set Python variables using <parameter>=<value> syntax. Python assigns the type dynamically as you set the value, and will allow you to assign an integer value to a string parameter. However, CASA will check types before running a task, and alert you if you have made a mistake. Python variable names are case sensitive. Also note that mis-spelling a variable assignment will not be noticed by the interface. For example, you might wish to set correlation='RR', but instead type corellation='RR'. You will find correlation unset, and a new variable, corellation will exist, with value RR. Using command-line completion and recall helps avoid these errors.
Lists and Ranges:
The Python range function give a task a list of indices. For example, iflist=range(4,8) will set iflist = [4, 5, 6, 7].
Indexes:
Python indices are 0-based. The first element in the list antlist is antlist[0]. CASA also uses 0-based indexing. Field or antenna IDs, for example, start at 0. The first field in a measurement set has FIELD_ID==0
Indentation:
Python uses indentation to determine the level of nesting in loops. Be careful when cutting and pasting, you may get an error (or an erroneous result).
System shell access:
To access system commands from CASA, precede your command with a bang (!). For example, to remove the file mydata.ms, type !rm -r mydata.ms This is inconsistent. Some commands (ls, pwd, less) can be executed without the '!'. The cp command must use the '!', and the cd command must NOT use the '!'. Note: to access a Unix environment variable from CASA, you will need to use $$ instead of $.
Running Scripts:
You may wish to run scripts which contain series of commands for data calibration, etc. To execute the script contained in the text file myscript.py, type execfile('myscript.py').
End-to-end: An overview of the process from Loading to Imaging:
Importing Data and Images:
Data is initially loaded into CASA using one of three import tasks, importuvfits, importvla, importasdm. These import UVFITS, VLA and ALMA data, respectively. Two other related tasks are available: importfits can be used to import a FITS image into a CASA image format table; and concat can be used to concatenate a second measurement set into a given MS.
Examing, Editing and Flagging:
There are several tasks to list, plot and/or flag data in a MS:
- listobs: summarizes the contents of a MS;
- flagmanager: saves and manages versions of the flagging entries in the MS;
- flagautocorr: non-interactively flags auto-correlations;
- plotxy: interactively plots and flags visibility data in 2-D;
- flagdata: non-interactively flags and unflags specified data;
- viewer: displays MS data, with some editing capabilities.