Getting Started in CASA: Difference between revisions

From CASA Guides
Jump to navigationJump to search
No edit summary
No edit summary
 
(46 intermediate revisions by 5 users not shown)
Line 6: Line 6:
<source lang="bash">
<source lang="bash">
## From a UNIX shell prompt
## From a UNIX shell prompt
casapy
casa
</source>
</source>
on the Unix command line. CASA is built in iPython, and you will see a number of initialization messages, a list of available tasks, and, finally, a Python command line prompt:
on the Unix command line. CASA is built in iPython, and you will see a number of initialization messages, a list of available tasks, and, finally, a Python command line prompt:
Line 12: Line 12:
CASA <1>:
CASA <1>:
</source>
</source>
CASA will also spawn a separate logger window, which logs messages from various tasks. Logger messages are saved in a file 'casapy.log', in your local directory. Whenever you start CASA, the previous log is renamed (based on the date and time), and a new 'casapy.log' is opened. In addition, your command line history is automatically maintained and stored as 'ipython.log' in your local directory.  
CASA will also spawn a separate logger window, which logs messages from various tasks. Logger messages are saved in a file 'casapy.log', in your local directory. Whenever you start CASA, the previous log is renamed (based on the date and time), and a new 'casapy.log' is opened.  
<!-- In addition, your command line history is automatically maintained and stored as 'ipython.log' in your local directory. -->


Note that on startup, CASA adopts current settings of environment variables, so set them before starting CASA. For example, PAGER regulates the help display. The <tt>cat</tt> option works well in both interactive and script mode. In bash, use <tt>PAGER=cat</tt>. In csh or tcsh, use <tt>setenv PAGER cat</tt>.
Note that on startup, CASA adopts current settings of environment variables, so set them before starting CASA. For example, PAGER regulates the help display. The <tt>cat</tt> option works well in both interactive and script mode. In bash, use <tt>PAGER=cat</tt>. In csh or tcsh, use <tt>setenv PAGER cat</tt>.
Line 35: Line 36:
== Getting Help on a Task ==
== Getting Help on a Task ==


Let's get some exhaustive help on the CASA imaging task [[clean]].
Let's get some exhaustive help on the CASA imaging task {{tclean}}.


<source lang="python">
<source lang="python">
# From within CASA
# From within CASA
help clean
help tclean
</source>
</source>


Line 46: Line 47:
There are two basic ways to execute a task in CASA.  
There are two basic ways to execute a task in CASA.  


1) The first is to list the task parameters and set them one by one. Let's say we would like to run the task [[importasdm]]. To load this task's parameters, type:
'''1) Tasking Interface:''' The first is to list the task parameters and set them one by one. Let's say we would like to run the task {{importasdm}}. To load this task's parameters, type:
<source lang="python">
<source lang="python">
tget importasdm
tget importasdm
Line 56: Line 57:
to view this task's parameters. They'll look something like this:
to view this task's parameters. They'll look something like this:


XXXX INPUT SCREEN SHOT HERE XXXXX
[[Image:intro_importasdm.png|700px|Importasdm parameters.]]


Note that <tt>tget</tt> will recall the parameters from the last time you've run [[importasdm]] in your current working directory (it reads a file called 'importasdm.last'). If [[importasdm]] has not been run before, it will just use the default parameters.
Note that <tt>tget</tt> will recall the parameters from the last time you've run {{importasdm}} in your current working directory (it reads a file called 'importasdm.last'). If {{importasdm}} has not been run before, it will just use the default parameters.


You can now set individual parameters from the command line, simply using a Python <tt><parameter>=<value></tt> syntax.  
You can now set individual parameters from the command line, simply using a Python <tt><parameter>=<value></tt> syntax.  
<source lang="python">
<source lang="python">
asdm = 'TOSR0005_sb1475761_1.55351.74409018519'
asdm='leo2pt.55183.452640752315'  
vis = 'awesome_data.ms'
vis = 'awesome_data.ms'
</source>
</source>
Line 71: Line 72:
and check your logger to make sure things are proceeding smoothly.
and check your logger to make sure things are proceeding smoothly.


2) The second strategy for executing tasks is critical for scripting, because it can be non-interactive. You'll type:
 
'''2) Scripting Interface:''' The second strategy for executing tasks is critical for scripting, because it can be non-interactive. You'll type:
<source lang="python">
<source lang="python">
importasdm(asdm = 'TOSR0005_sb1475761_1.55351.74409018519', vis = 'awesome_data.ms')
importasdm(asdm='leo2pt.55183.452640752315', vis='awesome_data.ms')
</source>
</source>
and then simply press enter. This will both set the parameters for [[importasdm]] and run the task, all in one go. Note that any parameters you have ''not'' explicitly set in the parentheses will be set to their defaults.
and then simply press enter. This will both set the parameters for {{importasdm}} and run the task, all in one go. Note that any parameters you have ''not'' explicitly set in the parentheses will be set to their defaults.


== More Detail on Setting Parameters ==
== More Detail on Setting Parameters ==
Line 83: Line 85:
The ways to save and restore parameters are:
The ways to save and restore parameters are:
* <tt>tget <taskname></tt>: retrieves parameters from <taskname>.last;
* <tt>tget <taskname></tt>: retrieves parameters from <taskname>.last;
* <tt>tput <taskname></tt>: put current parameters into <taskname>.last;
* <tt>default('<taskname>')</tt>: restores the default parameters;
* <tt>default('<taskname>')</tt>: restores the default parameters;
* <tt>saveinputs(<taskname>,<filename>)</tt>: saves the current set of parameters into <filename>;
* <tt>saveinputs('<taskname>','<filename>)'</tt>: saves the current set of parameters into <filename>;
* <tt>execfile '<filename>'</tt>: retrieves a set of parameters.  
* <tt>execfile '<filename>'</tt>: retrieves a set of parameters.  


CASA uses multiple font colors and highlighting to give more information about the parameters and their current values. Some parameters are expandable and have sub-parameters: an <tt>inp</tt> listing will show these on a gray background. If a gray parameter is set to a value that allows sub-parameters, then the sub-parameters are listed in the next instance of <tt>inp</tt> in green. Otherwise, the sub-parameters remain hidden. A blue parameter has been altered from its default value. Pay particular attention if the text color is red: the value of the parameter is invalid, and the task will not run.
CASA uses multiple font colors and highlighting to give more information about the parameters and their current values. A blue parameter has been altered from its default value. Some parameters are expandable and have sub-parameters: an <tt>inp</tt> listing will show these on a gray background. If a gray parameter is set to a value that allows sub-parameters, then the sub-parameters are listed in the next instance of <tt>inp</tt> in green. Otherwise, the sub-parameters remain hidden. Pay particular attention if the text color is red: the value of the parameter is invalid, and the task will not run. Here are some examples of colored parameters for {{importasdm}}:


XXXXX SCREEN SHOT FOR PARAMETER COLORS XXXXXXXXXXX
[[Image:intro_importasdm_colors.png|700px|Importasdm parameters.]]


Be wary of a parameter's type. Strings will always have quotes around them (although sometimes they can be numbers! e.g., <tt>spw = '0'</tt>), while floats and integers never will (e.g., <tt>diameter=25.0</tt>). Boolean variables will be <tt>True</tt> or <tt>False</tt> with no quotes around them. One common reason a parameter might turn red under <tt>inp</tt> is quotation marks which have been mistakenly added or forgotten.
Be wary of a parameter's type. Strings will always have quotes around them (although sometimes they can be numbers! e.g., <tt>spw = '0'</tt>), while floats and integers never will (e.g., <tt>diameter=25.0</tt>). Boolean variables will be <tt>True</tt> or <tt>False</tt> with no quotes around them. One common reason a parameter might turn red under <tt>inp</tt> is quotation marks which have been mistakenly added or forgotten.


You can also use <tt>go</tt> to invoke a task without changing the current task. For example, you may be setting parameters for [[plotcal]], and wish to verify an antenna name. Typing <tt>go listobs</tt> will list the observations in the logger, but will not change the current task to [[listobs]]. Typing <tt>inp</tt> after this will give the inputs list for [[plotcal]], since the current task has not been changed.
You can also use <tt>go</tt> to invoke a task without changing the current task. For example, you may be setting parameters for {{plotcal}}, and wish to verify an antenna name. Typing <tt>go listobs</tt> will list the observations in the logger, using the parameters that you had set for {{plotcal}} (for example, it will use the same measurement set you had set as <tt>vis</tt>. This is what we mean when we say parameters in the tasking interface of CASA are global. Note that typing <tt>go</tt> in this case will not change the current task to {{listobs}}. Typing <tt>inp</tt> after this will still give the inputs list for {{plotcal}}, since the current task has not been changed.
 
== The Measurement Set ==
 
Your data in CASA will be in a format called a measurement set (ms for short). The measurement set is a directory on disk. If you type an <tt>ls</tt> on your measurement set, you'll see something like this:
<source lang="python">
CASA <55>: ls awesome_data.ms
ANTENNA/          OBSERVATION/  SPECTRAL_WINDOW/  table.f10_TSM1  table.f3_TSM1  table.f7_TSM1  table.lock
DATA_DESCRIPTION/  POINTING/      STATE/            table.f11      table.f4      table.f8
FEED/              POLARIZATION/  table.dat        table.f11_TSM1  table.f5      table.f8_TSM1
FIELD/            PROCESSOR/    table.f0          table.f2        table.f6      table.f9
FLAG_CMD/          SORTED_TABLE/  table.f1          table.f2_TSM1  table.f6_TSM0  table.f9_TSM1
HISTORY/          SOURCE/        table.f10        table.f3        table.f7      table.info
</source>
The files called 'table.*' represent the MAIN table. The measurement set also contains many sub-tables (which are also sub-directories; e.g. FIELD, SOURCE, ANTENNA, etc.):
<source lang="python">
CASA <56>: ls awesome_data.ms/FIELD
table.dat  table.f0  table.f0i  table.info  table.lock
</source>
If you want to investigate a measurement set and its sub-tables in more detail, try the {{browsetable}} task.
 
To copy a measurement set, you must use the recursive option:
<source lang="python">
cp -r awesome_data.ms mind_blowing_data.ms
</source>
This could be done either from within CASA or at the UNIX shell prompt. But be careful; renaming a ms can sometimes break dependencies with other tables, like calibration tables.
 
The safest way to remove a measurement set is with {{rmtables}}:
<source lang="python">
rmtables('mind_blowing_data.ms')
</source>
 
It's probable that your data won't arrive at your computer in ms format, and you'll have to import it. Check out this write-up on [[Importing Data into CASA]].
 
== Data Selection Syntax ==
 
In the course of your data reduction, you'll probably want to select a subset of your data for certain tasks---let's say you only want to plot up Antenna #5, or you want to calibrate only using channels 5 through 50 of spectral window 1:
 
<source lang="python">
antennas='5'
spw='1:5~50'
</source>
 
The procedure for selecting parts of your data is described in the following [https://casa.nrao.edu/casadocs-devel/stable/calibration-and-visibility-data/data-selection-in-a-measurementset CASA Docs pages], and further information is provided in a [https://casa.nrao.edu/casadocs-devel/stable/knowledgebase-and-memos/casa-memos/casa_memo1_msselection_bhatnagar.pdf/view CASA memo by S. Bhatnagar on data selection]. Below are links for specific cuts on data:
 
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/AntennaBaselineSelection.html#x11-100003 Selecting Antennas and/or Baselines]
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/FrequencySelection.html#x15-230006 Selecting Spectral Windows, Channels, and/or Frequencies]
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/FieldSelection.html#x12-190004 Selecting Fields]
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/ScanSubarraySelection.html#x21-350009 Selecting Scans] and [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/ScanintentBasedSelection.html#x20-320008 Scan Intent]
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/TimeSelection.html#x10-80002 Selecting Time Ranges]
* [http://www.aoc.nrao.edu/~sbhatnag/misc/msselection/UVDistanceSelection.html#x14-210005 Selecting UV Ranges]


== Quitting CASA ==
== Quitting CASA ==
Line 99: Line 152:
You can exit CASA by typing:
You can exit CASA by typing:
<source lang="python">
<source lang="python">
# From within CASA
quit
quit
</source>
</source>
or
or
<source lang="python">
<source lang="python">
# From within CASA
exit
exit
</source>
</source>
or CTRL-D at the casapy prompt.
If you don't want to see the question "Do you really want to exit [y]/n?", then just type
<source lang="python">
# From within CASA
Exit
</source>
and CASA will stop right then and there.


== What If Something Goes Wrong? ==
== What If Something Goes Wrong? ==
Line 134: Line 177:
help par.selectdata
help par.selectdata
</source>
</source>
will give guidance on the use of this parameter (and in this case its sub-parameters). One common source of confusion is parameter format---should it be entered as a string or as a float/integer? For example, in [[flagdata]], antenna diameter should be entered as a float (<tt>diam = 28.0</tt> in <tt>mode = 'shadow'</tt>. Note there are no quotes around <tt>28.0</tt>); antenna name, on the other hand, is a string (even though it may look like a simple number---<tt>antenna = '3'</tt>. Note the quotes around '3').
will give guidance on the use of this parameter (and in this case its sub-parameters).


If something has gone wrong and you want to stop what is executing, then typing CTRL-C will usually cleanly abort the application. Alert: you may lose contact with the logger GUI if you have one, in which case you will want to restart CASA.
If something has gone wrong and you want to stop what is executing, then typing CTRL-C will usually cleanly abort the application. Alert: you may lose contact with the logger GUI if you have one, in which case you will want to restart CASA.
Line 200: Line 243:
</source>
</source>


== Additional Tips ==
== Further Help ==
 
=== New Startup Screen ===
 
* When you started CASA, it gave you a lot of useful information. But now you've been mucking around for a while, and that info is lost. How do you get it back? Just rerun the startup screen.
<source lang="python">
startup
</source>
 
=== Setting Up the Available Memory ===
 
CASA's default is to use 90% of the  memory available. This should be a good setting for most users.
 
However, if this does not suit your needs, you can set the amount of memory that CASA will use, either in absolute or relative units.
 
To do so, create a '~/.casarc' file in your home directory (if you still have an '~/.aipsrc' in your home directory, it would be wise to remove it).
 
Within '~/.casarc' add the following variable:
<source lang="bash">
system.resources.memory: <absolute_number>
</source>
or
<source lang="bash">
system.resources.memfrac: <relative_number>
</source>
where <tt><absolute_number></tt> stands for the allocated memory in units of MB. e.g. for 16GB of memory the number would be 16000. <tt><relative_number></tt> stands for the percentage of memory that CASA can access, e.g. a value of 80 corresponds to 80% of the memory installed. 
 
Now restart CASA.


=== Starting CASA Without the Logger ===
The step-by-step tutorials on this Wiki will walk you through reducing data. Keep in mind that the official CASA Documentation is provided in [https://casa.nrao.edu/casadocs/ CASA Docs]. Also check out the [[CASA Hints, Tips, and Tricks]] page---it might contain the answer to your question!
 
You also have the option of starting CASA without the logger, for example if you are running remotely in a terminal window without an X11 connection, or if you just do not want to see the logger GUI. In this case use the <tt>--nologger</tt> option:
<source lang="bash">
casapy --nologger
</source>
The logger messages will still go into the 'casapy.log' file. If you want to see these at your terminal, use the <tt>--log2term</tt> option also:
<source lang="bash">
casapy --nologger --log2term
</source>
 
=== Capturing Return Values ===
 
Some tasks return information to the interface. For example, the [[imstat]] task returns a Python dictionary with the image statistics in it. To catch these return statistics, you must assign a variable to the task call. For example:
<source lang="python">
xstat=imstat('ngc5921.clean.image')
</source>
To see what is in the dictionary, type the variable name (in this case, <tt>xstat</tt>) at the command line.
 
=== NRAO Access to Stable Version (Not Release) ===
 
At NRAO you will have access to the current stable version of CASA. This will exceed the capabilities of the release but it will see changes on faster timescales. This version can be started via:
<source lang="bash">
## From a UNIX shell prompt
casapy-test
</source>


--[[User:Jgallimo|Jack Gallimore]] 14:42, 30 October 2009 (UTC)
If you still have questions or think you might have found a bug, feel free to contact us at the NRAO helpdesk. The helpdesk can be accessed through [https://my.nrao.edu my.nrao.edu] (you will need to be registered with an NRAO account first).

Latest revision as of 12:09, 14 December 2018

Getting Started

Starting CASA

Navigate to your working directory in an xterm window. Start CASA by typing:

## From a UNIX shell prompt
casa

on the Unix command line. CASA is built in iPython, and you will see a number of initialization messages, a list of available tasks, and, finally, a Python command line prompt:

CASA <1>:

CASA will also spawn a separate logger window, which logs messages from various tasks. Logger messages are saved in a file 'casapy.log', in your local directory. Whenever you start CASA, the previous log is renamed (based on the date and time), and a new 'casapy.log' is opened.

Note that on startup, CASA adopts current settings of environment variables, so set them before starting CASA. For example, PAGER regulates the help display. The cat option works well in both interactive and script mode. In bash, use PAGER=cat. In csh or tcsh, use setenv PAGER cat.

Listing Available Tasks and Tools

CASA processes are organized into tasks and tools. Tools are the underlying functionality of CASA, intended for expert users participating in development. New users should ignore the tools. Tasks utilize a number of tools and accomplish a specific data analysis or calibration goal. To get information about tasks while in CASA, use:

# From within CASA
tasklist()

A more exhaustive summary can be obtained as follows:

taskhelp

For a similar summary of the CASA tools, type:

toolhelp

Getting Help on a Task

Let's get some exhaustive help on the CASA imaging task tclean.

# From within CASA
help tclean

Task Execution

There are two basic ways to execute a task in CASA.

1) Tasking Interface: The first is to list the task parameters and set them one by one. Let's say we would like to run the task importasdm. To load this task's parameters, type:

tget importasdm

and then type

inp

to view this task's parameters. They'll look something like this:

Importasdm parameters.

Note that tget will recall the parameters from the last time you've run importasdm in your current working directory (it reads a file called 'importasdm.last'). If importasdm has not been run before, it will just use the default parameters.

You can now set individual parameters from the command line, simply using a Python <parameter>=<value> syntax.

asdm='leo2pt.55183.452640752315' 
vis = 'awesome_data.ms'

Do another inp to see the updated parameters and make sure everything looks ok. Now you're ready to run the task! Type

go

and check your logger to make sure things are proceeding smoothly.


2) Scripting Interface: The second strategy for executing tasks is critical for scripting, because it can be non-interactive. You'll type:

importasdm(asdm='leo2pt.55183.452640752315', vis='awesome_data.ms')

and then simply press enter. This will both set the parameters for importasdm and run the task, all in one go. Note that any parameters you have not explicitly set in the parentheses will be set to their defaults.

More Detail on Setting Parameters

If a task is successfully executed, then the successful parameter set is stored in a '.last' file in the working directory.

The ways to save and restore parameters are:

  • tget <taskname>: retrieves parameters from <taskname>.last;
  • tput <taskname>: put current parameters into <taskname>.last;
  • default('<taskname>'): restores the default parameters;
  • saveinputs('<taskname>','<filename>)': saves the current set of parameters into <filename>;
  • execfile '<filename>': retrieves a set of parameters.

CASA uses multiple font colors and highlighting to give more information about the parameters and their current values. A blue parameter has been altered from its default value. Some parameters are expandable and have sub-parameters: an inp listing will show these on a gray background. If a gray parameter is set to a value that allows sub-parameters, then the sub-parameters are listed in the next instance of inp in green. Otherwise, the sub-parameters remain hidden. Pay particular attention if the text color is red: the value of the parameter is invalid, and the task will not run. Here are some examples of colored parameters for importasdm:

Importasdm parameters.

Be wary of a parameter's type. Strings will always have quotes around them (although sometimes they can be numbers! e.g., spw = '0'), while floats and integers never will (e.g., diameter=25.0). Boolean variables will be True or False with no quotes around them. One common reason a parameter might turn red under inp is quotation marks which have been mistakenly added or forgotten.

You can also use go to invoke a task without changing the current task. For example, you may be setting parameters for plotcal, and wish to verify an antenna name. Typing go listobs will list the observations in the logger, using the parameters that you had set for plotcal (for example, it will use the same measurement set you had set as vis. This is what we mean when we say parameters in the tasking interface of CASA are global. Note that typing go in this case will not change the current task to listobs. Typing inp after this will still give the inputs list for plotcal, since the current task has not been changed.

The Measurement Set

Your data in CASA will be in a format called a measurement set (ms for short). The measurement set is a directory on disk. If you type an ls on your measurement set, you'll see something like this:

CASA <55>: ls awesome_data.ms
ANTENNA/           OBSERVATION/   SPECTRAL_WINDOW/  table.f10_TSM1  table.f3_TSM1  table.f7_TSM1  table.lock
DATA_DESCRIPTION/  POINTING/      STATE/            table.f11       table.f4       table.f8
FEED/              POLARIZATION/  table.dat         table.f11_TSM1  table.f5       table.f8_TSM1
FIELD/             PROCESSOR/     table.f0          table.f2        table.f6       table.f9
FLAG_CMD/          SORTED_TABLE/  table.f1          table.f2_TSM1   table.f6_TSM0  table.f9_TSM1
HISTORY/           SOURCE/        table.f10         table.f3        table.f7       table.info

The files called 'table.*' represent the MAIN table. The measurement set also contains many sub-tables (which are also sub-directories; e.g. FIELD, SOURCE, ANTENNA, etc.):

CASA <56>: ls awesome_data.ms/FIELD
table.dat  table.f0  table.f0i  table.info  table.lock

If you want to investigate a measurement set and its sub-tables in more detail, try the browsetable task.

To copy a measurement set, you must use the recursive option:

cp -r awesome_data.ms mind_blowing_data.ms

This could be done either from within CASA or at the UNIX shell prompt. But be careful; renaming a ms can sometimes break dependencies with other tables, like calibration tables.

The safest way to remove a measurement set is with rmtables:

rmtables('mind_blowing_data.ms')

It's probable that your data won't arrive at your computer in ms format, and you'll have to import it. Check out this write-up on Importing Data into CASA.

Data Selection Syntax

In the course of your data reduction, you'll probably want to select a subset of your data for certain tasks---let's say you only want to plot up Antenna #5, or you want to calibrate only using channels 5 through 50 of spectral window 1:

antennas='5'
spw='1:5~50'

The procedure for selecting parts of your data is described in the following CASA Docs pages, and further information is provided in a CASA memo by S. Bhatnagar on data selection. Below are links for specific cuts on data:

Quitting CASA

You can exit CASA by typing:

quit

or

exit

What If Something Goes Wrong?

First, always check that your inputs are correct; use

inp <taskname>

Next, check the inline documentation using the help facility:

help <taskname>

or

help par.<parameter_name>

to review the allowed parameters. For example,

help par.selectdata

will give guidance on the use of this parameter (and in this case its sub-parameters).

If something has gone wrong and you want to stop what is executing, then typing CTRL-C will usually cleanly abort the application. Alert: you may lose contact with the logger GUI if you have one, in which case you will want to restart CASA.

If CASA crashes, then usually restarting it is sufficient to get you going again. Note that there may be spawned subprocesses still running, such as the casaviewer or the logger. These can be dismissed manually in the usual manner. After a crash, there may also be hidden processes. You can find these by listing processes, e.g. in linux:

ps -elf | grep casa

or on MacOSX (or other BSD Unix):

ps -aux | grep casa

You can then kill these, for example using the Unix kill or killall commands. This may be necessary if you are running remotely using ssh, as you cannot logout until all your background processes are terminated. For example,

killall ipcontroller

or

killall Python

will terminate the most common post-crash zombies.

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

You can access most system commands (ls, rm, mv, pwd, less) directly from the CASA command line; no need for a bang (!). However, for some, like cp, you will need to use a !:

!cp vla evla

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')

Further Help

The step-by-step tutorials on this Wiki will walk you through reducing data. Keep in mind that the official CASA Documentation is provided in CASA Docs. Also check out the CASA Hints, Tips, and Tricks page---it might contain the answer to your question!

If you still have questions or think you might have found a bug, feel free to contact us at the NRAO helpdesk. The helpdesk can be accessed through my.nrao.edu (you will need to be registered with an NRAO account first).