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_deconvolve 00013 def deconvolve(imagename='', model='', psf=[''], alg='clark', niter=10, gain=0.1, threshold='0.0mJy', mask='', scales=[0, 3, 10], sigma='0.0mJy', targetflux='1.0Jy', prior=''): 00014 00015 """Image based deconvolver 00016 00017 Several algorithms are available to deconvolve an image with a 00018 known psf (dirty beam), or a Gaussian beam. The algorithms 00019 available are clark and hogbom clean, a multiscale clean and a 00020 mem clean. For more deconvolution control, use clean. 00021 00022 Keyword arguments: 00023 imagename -- Name of input image to be deconvolved 00024 model -- Name of output image containing the clean components 00025 psf -- Name of psf image (dirty beam) to use 00026 example: psf='casaxmlf.image' . 00027 If the psf has 3 parameter, then a Gaussian 00028 psf is assumed with the values representing 00029 the major , minor and position angle values 00030 e.g psf=['3arcsec', '2.5arcsec', '10deg'] 00031 alg -- algorithm to use: default = 'clark' 00032 options: clark, hogbom, multiscale or mem. 00033 niter -- Maximum number of iterations 00034 gain -- CLEAN gain parameter; fraction to remove from peak 00035 threshold -- Halt deconvolution if the maximum residual image is 00036 below this threshold. 00037 default = '0.0Jy' 00038 mask -- mask image (same shape as image and psf) to limit region 00039 where deconvoltion is to occur 00040 00041 ------parameters useful for multiscale only 00042 scales -- in pixel numbers; the size of component to deconvolve. 00043 default value [0,3,10] 00044 recommended sizes are 0 (point), 3 (points per clean beam), and 00045 10 (about a factor of three lower resolution) 00046 ------parameters useful for mem only 00047 sigma -- Estimated noise for image 00048 targetflux -- Target total flux in image 00049 prior -- Prior image to guide mem 00050 00051 00052 00053 """ 00054 if type(psf)==str: psf=[psf] 00055 if type(scales)==int: scales=[scales] 00056 00057 # 00058 # The following is work around to avoid a bug with current python translation 00059 # 00060 mytmp = {} 00061 00062 mytmp['imagename'] = imagename 00063 mytmp['model'] = model 00064 mytmp['psf'] = psf 00065 mytmp['alg'] = alg 00066 mytmp['niter'] = niter 00067 mytmp['gain'] = gain 00068 if type(threshold) == str : 00069 mytmp['threshold'] = casac.quanta().quantity(threshold) 00070 else : 00071 mytmp['threshold'] = threshold 00072 mytmp['mask'] = mask 00073 mytmp['scales'] = scales 00074 if type(sigma) == str : 00075 mytmp['sigma'] = casac.quanta().quantity(sigma) 00076 else : 00077 mytmp['sigma'] = sigma 00078 if type(targetflux) == str : 00079 mytmp['targetflux'] = casac.quanta().quantity(targetflux) 00080 else : 00081 mytmp['targetflux'] = targetflux 00082 mytmp['prior'] = prior 00083 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00084 trec = casac.utils().torecord(pathname+'deconvolve.xml') 00085 00086 casalog.origin('deconvolve') 00087 if trec.has_key('deconvolve') and casac.utils().verify(mytmp, trec['deconvolve']) : 00088 result = task_deconvolve.deconvolve(imagename, model, psf, alg, niter, gain, threshold, mask, scales, sigma, targetflux, prior) 00089 00090 else : 00091 result = False 00092 return result