Getting Started in CASA: Difference between revisions

From CASA Guides
Jump to navigationJump to search
Lchomiuk (talk | contribs)
No edit summary
Lchomiuk (talk | contribs)
Line 191: Line 191:
help par.selectdata
help par.selectdata
</source>
</source>
will give guidance on the use of this parameter (and in this case its sub-parameters).
will give guidance on the use of this parameter (and in this case its sub-parameters). One common source of confusion is if a parameter should be entered as a string or as a number. 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 simplet number (<tt>antenna = '3'</tt>. Note the quotes around '3').


If something has gone wrong and you want to stop what is executing, then typing CNTL-C will usually cleanly abort the application. Alert: Note that you will likely lose contact with the logger GUI if you have one, so you will then want to restart CASA.
If something has gone wrong and you want to stop what is executing, then typing CNTL-C will usually cleanly abort the application. Alert: Note that you will likely lose contact with the logger GUI if you have one, so you will then want to restart CASA.

Revision as of 00:46, 27 March 2010

Getting Started

Installing CASA

CASA is available via the NRAO portal http://my.nrao.edu. You may need to register if you have not been using NRAO services in the past. CASA is available for MacOS X and Linux platforms and installation instructions are provided at https://safe.nrao.edu/wiki/bin/view/Software/ObtainingCASA

Installing CASA on Ubuntu

The following method worked for Ubuntu 9.04 (Jaunty).

sudo mkdir /usr/local/bin/CASA
sudo mv casapy-30.0.9860-001-64b.tar.gz /usr/local/bin/CASA # this is for 64-bit installation; substitute the appropriate tarball here
cd /usr/local/bin/CASA
sudo tar zxvf casapy-30.0.9860-001-64b.tar.gz
  • Add the following environment variable to your .bashrc (or the equivalent command for your preferred shell startup script).
export PATH=$PATH:/usr/local/bin/CASA/casapy-30.0.9860-001-64b
  • Test it out!
source ~/.bashrc # or open a new terminal
casapy

Starting CASA

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.

Navigate to your working directory in an xterm window. (NOTE: some tasks may crash if the working directory name has a space in it, so please avoid that if possible.) Start CASA by typing:

## From a UNIX shell prompt
casapy

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. You can annotate, search and filter the logger messages. 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. This file can be edited and re-executed using execfile '<filename>'.

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

Some commands are hidden away as methods under various objects. For example, to take a look at options under the imager object:

help im

Notice that the method mem appears here, but not under tasklist.

Getting Help on a Command

Let's get some exhaustive help on clean.

# From within CASA
help clean

Setting Parameters

Each task has a set of parameters. If a task is successfully executed, then the successful parameter set is stored in a '.last' file in the working directory. Other ways to save and restore parameters are available:

  • tget <taskname>: retrieves parameters from <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.

Parameters are set using the Python <parameter>=<value> syntax. Some parameters 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. Otherwise, the sub-parameters remain hidden. CASA uses multiple font colors and highlighting to give more information about the parameters and their current values. Pay particular attention if the text color is red: the value of the parameter is invalid, and the task will not run.

CASA has two distinct ways of running tasks, one sets parameters globally (so that all tasks will use the same values), and the other does not. This is helpful when writing scripts that you may wish to use more than once. To set global parameters, set each parameter, and then invoke the task:

#from within CASA
CASA <1>: default('plotxy')

CASA <2>: vis='ngc5921.ms'

CASA <3>: xaxis='channel'

CASA <4>: yaxis='amp'

CASA <5>: go

To set parameters for a single instance of a single task, call it as a function:

#from within CASA
CASA <1>: plotxy(vis='ngc5921.ms',xaxis='channel',yaxis='amp')

Other tasks will revert to global values of the parameters (these may be the defaults). When a task is invoked in this way, unspecified values use the defaults, not the global values!

The go command may also be used 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, but will not change the current task to listobs. Typing inp after this will give the inputs list for plotcal, since the current task has not been changed.

Quitting CASA

You can exit CASA by typing:

# From within CASA
quit

or

# From within CASA
exit

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

# From within CASA
Exit

and CASA will stop right then and there.

Crashing CASA

If something has gone wrong, and you want to halt execution, CTRL-C will usually cleanly abort the application.

Simply restarting will get you going again if CASA crashes. Some spawned windows, such as the logger, may need to be closed separately. In Linux, you can find any remaining hidden processes with ps -elf | grep casa (In MacOSX, use ps -aux | grep casa). Kill them with the Unix commands kill or killall.

Additional Tips

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.
startup

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:

system.resources.memory: <absolute_number>

or

system.resources.memfrac: <relative_number>

where <absolute_number> stands for the allocated memory in units of MB. e.g. for 16GB of memory the number would be 16000. <relative_number> 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 or log messages to terminal

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 --nologger option:

casapy --nologger

The logger messages will still go into the 'casapy.log' file. If you want to see these at your terminal, use the --log2term option also:

casapy --nologger --log2term

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). One common source of confusion is if a parameter should be entered as a string or as a number. For example, in flagdata, antenna diameter should be entered as a float (diam = 28.0 in mode = 'shadow'. Note there are no quotes around 28.0); antenna name, on the other hand, is a string (even though it may look like a simplet number (antenna = '3'. Note the quotes around '3').

If something has gone wrong and you want to stop what is executing, then typing CNTL-C will usually cleanly abort the application. Alert: Note that you will likely lose contact with the logger GUI if you have one, so you will then want to restart CASA.

If CASA crashes, then usually restarting casapy 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.

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


## From a UNIX shell prompt
casapy-test

--Jack Gallimore 14:42, 30 October 2009 (UTC)