casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
imregrid.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2009, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from  casac import *
00009 import string
00010 from taskinit import casalog
00011 #from taskmanager import tm
00012 import task_imregrid
00013 def imregrid(imagename='', template='get', output='', asvelocity=False, axes=[-1], shape=[-1]):
00014 
00015         """regrid an image onto a template image
00016 
00017 imregrid: regrid an image to a new coordinate system.
00018 
00019 Keyword arguments:
00020 imagename   Name of the image that needs to be regridded
00021             default: none; example: imagename='orion.image'
00022 template    Dictionary, reference code, or imagename defining the new
00023             shape and coordinate system, or 'get' to return the template
00024             dictionary for imagename.  Recognized reference codes are:
00025             'J2000', 'B1950', 'B1950_VLA', 'GALACTIC', 'HADEC', 'AZEL',
00026             'AZELSW', 'AZELNE', 'ECLIPTIC', 'MECLIPTIC', 'TECLIPTIC',
00027             and 'SUPERGAL'.
00028             default: 'get'; example: template='orion_j2000.im'
00029 shape       Shape of the output image. Only used if template is an image.
00030             If not specified (-1), the output image shape is set equal to
00031             the input image shape.
00032 output      Name for the regridded image
00033             default: imagename + '.regridded'; example: imagename='orion_shifted.im'
00034 asvelocity  Regrid spectral axis with respect to velocity, not frequency?
00035             default: False
00036 axes        The pixel axes to regrid. -1 => all.
00037 async       Run task in a separate process (return CASA prompt)
00038             default: False; example: async=True
00039                 
00040 The new coordinate system is defined by the template parameter,
00041 which can be:
00042     * a recognized reference code string (see below),
00043     * a {'csys': csys_record, 'shap': shape} dictionary,
00044     * 'get', which does not regrid but returns the template dictionary
00045       for imagename, suitable for modification and reuse, or
00046     * the name of an image to get the coordinate system and shape
00047       from.  The input and template images must have the same
00048       coordinate structure.
00049       
00050 If one of the axes to be regridded is a spectral axis and asvelocity=T,
00051 the axis will be regridded to match the velocity, not the frequency,
00052 description of the template coordinate system. Thus the output pixel
00053 values will correspond only to the velocity, not the frequency, of the
00054 output axis.
00055 
00056 If an image has per-plane beams and one attempts to regrid the spectral axis,
00057 an exception is thrown.
00058 
00059 
00060 
00061         """
00062         if type(axes)==int: axes=[axes]
00063         if type(shape)==int: shape=[shape]
00064 
00065 #
00066 #    The following is work around to avoid a bug with current python translation
00067 #
00068         mytmp = {}
00069 
00070         mytmp['imagename'] = imagename
00071         mytmp['template'] = template
00072         mytmp['output'] = output
00073         mytmp['asvelocity'] = asvelocity
00074         mytmp['axes'] = axes
00075         mytmp['shape'] = shape
00076         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00077         trec = casac.utils().torecord(pathname+'imregrid.xml')
00078 
00079         casalog.origin('imregrid')
00080         if trec.has_key('imregrid') and casac.utils().verify(mytmp, trec['imregrid']) :
00081             result = task_imregrid.imregrid(imagename, template, output, asvelocity, axes, shape)
00082 
00083         else :
00084           result = False
00085         return result