NRAO Home > CASA > CASA Cookbook and User Reference Manual
1.5.3.1 How do I get rid of my data in CASA?

Note that when you delete a measurement set, calibration table, or image, which are in fact directories, you must delete this and all underlying directories and files. If you are not running casapy, this is most simply done by using the file delete method of the operating system you started CASA from. For example, when running CASA on a Linux system, in order to delete the measurement set named AM675.ms type:

  CASA <5>: !rm -r AM675.ms

from within CASA. The ! tells CASA that a system command follows (see § 1.3.7.5), and the -r makes sure that all subdirectories are deleted recursively.

It is convenient to prefix all MS, calibration tables, and output files produced in a run with a common string. For example, one might prefix all files from VLA project AM675 with AM675, e.g. AM675.ms, AM675.cal, AM675.clean. Then,

  CASA <6>: !rm -r AM675*

will clean up all of these.

In scripts, the ! escape to the OS will not work. Instead, use the os.system() function (Appendix B.7.1) to do the same thing:

   os.system(’rm -r AM675*’)

If you are within casapy, then the CASA system is keeping a cache of tables that you have been using and using the OS to delete them will confuse things. For example, running a script that contains rm commands multiple times will often not run or crash the second time as the cache gets confused. The clean way of removing CASA tables (MS, caltables, images) inside casapy is to use the rmtables task:

  rmtables(’AM675.ms’)

and this can also be wildcarded

  rmtables(’AM675*’)

(though you may get warnings if it tries to delete files or directories that fit the name wildcard that are not CASA tables).

ALERT: Some CASA processes lock the file and forget to give it up when they are done (plotxy is usually the culprit). You will get WARNING messages from rmtables and your script will probably crash second time around as the file isn’t removed. The safest thing is still to exit casapy and start a new session for multiple runs.


More information about CASA may be found at the CASA web page

Copyright © 2010 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search