casa
$Rev:20696$
|
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_impbcor 00013 def impbcor(imagename='', pbimage="", outfile='', overwrite=False, box='', region="", chans='', stokes='', mask='', mode='divide', cutoff=-1.0, wantreturn=False, stretch=False): 00014 00015 """Construct a primary beam corrected image from an image and a primary beam pattern. 00016 PARAMETER SUMMARY 00017 imagename Name of the input (CASA, FITS, MIRIAD) image 00018 pbimage Name of the image (CASA, FITS, MIRIAD) of the primary beam pattern or an array of pixel values. 00019 outfile Name of output CASA image. If not specified, no image is written 00020 but an image analysis tool which references the output image is returned. 00021 overwrite If output file is specified, controls if an already existing file by the 00022 same name can be overwritten. If true, the user is not prompted, the file 00023 if it exists is automatically overwritten. 00024 box Direction plane box specification, "blcx, blcy, trcx, trcy". Only one box 00025 may be specified. If not specified, region is used if specified. If region 00026 is also not specified, entire directional plane unioned with any chans and 00027 stokes specification determines the region. 00028 region Optional region file to use. 00029 chans Optional contiguous frequency channel number specification. Not used if 00030 region is specified. Default is all channels. 00031 stokes Contiguous stokes planes specification. Not used if region is specified. 00032 Default is all stokes. 00033 mask Mask to use. See help par.mask. Default is none. 00034 stretch Stretch the input mask if necessary and possible. See help par.mask. 00035 mode Divide or multiply the image by the primary beam image. Minimal match supported. Default "divide" 00036 cutoff PB cutoff. If mode is "d", all values less than this will be masked. If "m", all values greater will be masked. Less than 0, no cutoff. Default no cutoff 00037 wantreturn If true, return an image analysis tool referencing the collapsed image, if 00038 false, return false. 00039 00040 00041 DESCRIPTION 00042 Correct an image for primary beam attenuation using an image of the primary beam pattern. 00043 The primary beam pattern can be provided as an image, in which case 1. it must have the same 00044 shape as the input image and its coordinate system must be the same, or 2. it must 00045 be a 2-D image in which case its coordinate system must consist of a (2-D) direction 00046 coordinate which is the same as the direction coordinate in the input image and 00047 its direction plane must be the same shape as that of the input image. Alternatively, 00048 pbimage can be an array of pixel values in which case the same dimensionality and 00049 shape constraints apply. 00050 An image tool referencing the corrected image is returned if wantreturn=True. The corrected image will also 00051 be written to disk if outfile is not empty (and overwrite=True if outfile already exists). 00052 One can choose between dividing the image by the primary beam pattern (mode="divide") or 00053 multiplying the image by the primary beam pattern (mode="multiply"). One can also choose 00054 to specify a cutoff limit for the primary beam pattern. For mode="divide", for all pixels 00055 below this cutoff in the primary beam pattern, the output image will be masked. In the 00056 case of mode="multiply", all pixels in the output will be masked corresponding to pixels 00057 with values greater than the cutoff in the primary beam pattern. A negative value for 00058 cutoff means that no cutoff will be applied, which is the default. 00059 00060 EXAMPLE 00061 impbcor(imagename="attunuated.im", pbimage="mypb.im", outname="pbcorred.im", mode="divide", cutoff=0.1) 00062 00063 """ 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['pbimage'] = pbimage 00072 mytmp['outfile'] = outfile 00073 mytmp['overwrite'] = overwrite 00074 mytmp['box'] = box 00075 mytmp['region'] = region 00076 mytmp['chans'] = chans 00077 mytmp['stokes'] = stokes 00078 mytmp['mask'] = mask 00079 mytmp['mode'] = mode 00080 mytmp['cutoff'] = cutoff 00081 mytmp['wantreturn'] = wantreturn 00082 mytmp['stretch'] = stretch 00083 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00084 trec = casac.utils().torecord(pathname+'impbcor.xml') 00085 00086 casalog.origin('impbcor') 00087 if trec.has_key('impbcor') and casac.utils().verify(mytmp, trec['impbcor']) : 00088 result = task_impbcor.impbcor(imagename, pbimage, outfile, overwrite, box, region, chans, stokes, mask, mode, cutoff, wantreturn, stretch) 00089 00090 else : 00091 result = False 00092 return result