Image Analysis with CASA - ESO
Image Analysis with CASA - ESO
Image Analysis with CASA - ESO
- TAGS
- image
- analysis
- casa
- www.eso.org
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Extract a spectrum – Script mode<br />
Use the following set of <strong>CASA</strong> commands to extract a spectrum and output in an ascii file:<br />
<strong>CASA</strong>> imgname = 'your_image.image' # specify input image cube<br />
cubestat=imstat(imagename=imgname)<br />
import numpy # make sure vector and array arithmetic options are loaded<br />
cubeheader = imhead(imagename=imgname, mode="list") # set header variables<br />
nspec = cubestat['trc'][3] + 1 # get the number of frequency channels.<br />
f0 = float(cubeheader['crval4']) # reference freq in Hz<br />
df = float(cubeheader['cdelt4']) # channel width in Hz<br />
i0 = cubeheader['crpix4'] # reference pixel<br />
freqspec = ((numpy.arange(nspec) i0)*df + f0)<br />
valspec = imval(imagename=imgname,box='128,128') # e.g. extract spec @ pixel 128,128<br />
outspec = 'spec.txt' # specify name of output spectrum file<br />
spectrum = numpy.vstack((freqspec, valspec['data']))<br />
numpy.savetxt(outspec, numpy.transpose(spectrum)) # save the spectrum in ascii file<br />
You can simply copy/paste these lines in your script, and adapt the parts in red<br />
Note the use of imhead, imval <strong>with</strong> Python dictionaries<br />
23