Difference between revisions of "Capturing Return Values"

From CASA Guides
Jump to navigationJump to search
Line 37: Line 37:
 
  'trcf': '10:45:01.025, +12.16.00.831, I, 1.417193e+09Hz'}
 
  'trcf': '10:45:01.025, +12.16.00.831, I, 1.417193e+09Hz'}
 
</source>
 
</source>
 
 
[[Main Page | &#8629; '''CASAguides''']] <br>
 
[[Main Page | &#8629; '''CASAguides''']] <br>

Revision as of 17:12, 6 June 2010

Hints, Tips, and Tricks

Some tasks return information in the form of Python dictionaries to the interface. For example, the imstat task returns a dictionary with image statistics in it. If you just run

imstat('ngc5921.clean.image')

image statistics will be listed in your logger.

However, you might want to catch these return statistics for later reference---in this case, simply assign a variable to the task call. For example:

xstat=imstat('ngc5921.clean.image')

You'll still get handy output in the logger, but now this information is also saved in xstat. To see what is in the dictionary, type the variable name at the command line:

CASA <49>: xstat
  Out[49]:
{'blc': array([0, 0, 0, 0], dtype=int32),
 'blcf': '10:48:29.468, +11.25.00.788, I, 1.415435e+09Hz',
 'flux': array([-4.81267573]),
 'max': array([ 0.10524261]),
 'maxpos': array([131, 135,   0, 191], dtype=int32),
 'maxposf': '10:46:42.548, +11.52.01.999, I, 1.416927e+09Hz',
 'mean': array([ -1.06455120e-05]),
 'medabsdevmed': array([ 0.00505883]),
 'median': array([ -7.22291297e-05]),
 'min': array([-0.0433579]),
 'minpos': array([132, 101,   0, 217], dtype=int32),
 'minposf': '10:46:41.731, +11.45.13.999, I, 1.41713e+09Hz',
 'npts': array([ 14811136.]),
 'quartile': array([ 0.01011763]),
 'rms': array([ 0.00774033]),
 'sigma': array([ 0.00774032]),
 'sum': array([-157.67212591]),
 'sumsq': array([ 887.37451309]),
 'trc': array([255, 255,   0, 225], dtype=int32),
 'trcf': '10:45:01.025, +12.16.00.831, I, 1.417193e+09Hz'}

CASAguides