|
|||
NRAO Home > CASA > CASA Cookbook and User Reference Manual |
|
B.6.1 Conditionals
The standard if block handles conditional execution or branches in Python:
<statements>
elif <expression>:
<statements>
elif <expression>:
<statements>
...
else:
<statements>
Insert a pass statement if you want no action to be taken for a particular clause. The <expression> should reduce down to True or False.
For example,
# Import the data from VLA Export to MS
default(’importvla’)
print "Use importvla to read VLA Export and make an MS"
archivefiles = datafile
vis = msfile
bandname = exportband
autocorr = False
antnamescheme = ’new’
project = exportproject
importvla()
elif ( importmode == ’fits’ ):
# Import the data from VLA Export to MS
default(’importuvfits’)
print "Use importuvfits to read UVFITS and make an MS"
fitsfile = datafile
vis = msfile
async = False
importuvfits()
else:
# Copy from msfile
print "Copying "+datafile+" to "+msfile
os.system(’cp -r ’+datafile+’ ’+msfile)
vis = msfile
chooses branches based on the value of the importmode Python variable (set previously in script).
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