NRAO Home > CASA > CASA Cookbook and User Reference Manual

6.2.1 Examples for imhead

The following uses the example images from NGC5921 (§ F.1).

We can print the summary to the logger:

CASA <51>: imhead(’ngc5921.demo.cleanimg.image’,mode=’summary’)

prints in the logger:

##### Begin Task: imhead             #####  
  Image name       : ngc5921.demo.cleanimg.image  
  Object name      : N5921_2  
  Image type       : PagedImage  
  Image quantity   : Intensity  
  Pixel mask(s)    : None  
  Region(s)        : None  
  Image units      : Jy/beam  
  Restoring Beam   : 52.3782 arcsec, 45.7319 arcsec, -165.572 deg  
 
  Direction reference : J2000  
  Spectral  reference : LSRK  
  Velocity  type      : RADIO  
  Rest frequency      : 1.42041e+09 Hz  
  Pointing center     :  15:22:00.000000  +05.04.00.000000  
  Telescope           : VLA  
  Observer            : TEST  
  Date observation    : 1995/04/13/00:00:00  
  Telescope position: [-1.60119e+06m, -5.04198e+06m, 3.55488e+06m] (ITRF)  
 
  Axis Coord Type      Name             Proj Shape Tile   Coord value at pixel    Coord incr Units  
  ------------------------------------------------------------------------------------------------  
  0    0     Direction Right Ascension   SIN   256   64  15:22:00.000   128.00 -1.500000e+01 arcsec  
  1    0     Direction Declination       SIN   256   64 +05.04.00.000   128.00  1.500000e+01 arcsec  
  2    1     Stokes    Stokes                    1    1             I  
  3    2     Spectral  Frequency                46    8   1.41279e+09     0.00 2.4414062e+04 Hz  
                       Velocity                               1607.99     0.00 -5.152860e+00 km/s  
##### End Task: imhead

If you choose mode=’list’, you get the summary in the logger and a listing of keywords and values to the terminal:

CASA <52>: imhead(’ngc5921.demo.cleanimg.image’,mode=’list’)  
  Out[52]:  
{’beammajor’: 52.378242492675781,  
 ’beamminor’: 45.731891632080078,  
 ’beampa’: -165.5721435546875,  
 ’bunit’: ’Jy/beam’,  
 ’cdelt1’: ’-7.27220521664e-05’,  
 ’cdelt2’: ’7.27220521664e-05’,  
 ’cdelt3’: ’1.0’,  
 ’cdelt4’: ’24414.0625’,  
 ’crpix1’: 128.0,  
 ’crpix2’: 128.0,  
 ’crpix3’: 0.0,  
 ’crpix4’: 0.0,  
 ’crval1’: ’4.02298392585’,  
 ’crval2’: ’0.0884300154344’,  
 ’crval3’: ’I’,  
 ’crval4’: ’1412787144.08’,  
 ’ctype1’: ’Right Ascension’,  
 ’ctype2’: ’Declination’,  
 ’ctype3’: ’Stokes’,  
 ’ctype4’: ’Frequency’,  
 ’cunit1’: ’rad’,  
 ’cunit2’: ’rad’,  
 ’cunit3’: ’’,  
 ’cunit4’: ’Hz’,  
 ’datamax’: ’ Not Known ’,  
 ’datamin’: -0.010392956435680389,  
 ’date-obs’: ’1995/04/13/00:00:00’,  
 ’equinox’: ’J2000’,  
 ’imtype’: ’Intensity’,  
 ’masks’: ’ Not Known ’,  
 ’maxpixpos’: array([134, 134,   0,  38], dtype=int32),  
 ’maxpos’: ’15:21:53.976, +05.05.29.998, I, 1.41371e+09Hz’,  
 ’minpixpos’: array([117,   0,   0,  21], dtype=int32),  
 ’minpos’: ’15:22:11.035, +04.31.59.966, I, 1.4133e+09Hz’,  
 ’object’: ’N5921_2’,  
 ’observer’: ’TEST’,  
 ’projection’: ’SIN’,  
 ’reffreqtype’: ’LSRK’,  
 ’restfreq’: [1420405752.0],  
 ’telescope’: ’VLA’}

Note that this list is a return value and can be captured in a variable:

  mylist = imhead(’ngc5921.demo.cleanimg.image’,mode=’list’)

The values for these keywords can be queried using mode=’get’. At this point you should capture the return value:

CASA <53>: mybmaj = imhead(’ngc5921.demo.cleanimg.image’,mode=’get’,hdkey=’beammajor’)  
 
CASA <54>: mybmaj  
  Out[54]: {’unit’: ’arcsec’, ’value’: 52.378242492699997}  
 
CASA <55>: myobserver = imhead(’ngc5921.demo.cleanimg.image’,mode=’get’,hdkey=’observer’)  
 
CASA <56>: print myobserver  
{’value’: ’TEST’, ’unit’: ’’}

You can set the values for these keywords using mode=’put’. For example:

CASA <57>: imhead(’ngc5921.demo.cleanimg.image’,mode=’put’,hdkey=’observer’,hdvalue=’CASA’)  
  Out[57]: ’CASA’  
 
CASA <58>: imhead(’ngc5921.demo.cleanimg.image’,mode=’get’,hdkey=’observer’)  
  Out[58]: {’unit’: ’’, ’value’: ’CASA’}


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