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_boxit 00013 def boxit(imagename='', regionfile='', threshold='0.0mJy', maskname='', chanrange='', polrange='', minsize=2, diag=False, boxstretch=1, overwrite=False): 00014 00015 """Box regions in image above given threshold value. 00016 00017 This tool finds all 2-dimensional (RA/dec) regions in the given 00018 image which are contiguous sets of pixels (islands) above the given ] 00019 threshold. It creates a box for each island, a rectangular "cutout". 00020 The boxes are stored as regions in the output regionfile. Works on 00021 multi-plane images, but only boxes 2-D regions in each plane. 00022 (Doesn't create cubes/3D boxes.) 00023 00024 imagename -- Name of input images: 00025 default: none; example: imagename='myimage.image' 00026 regionfile -- Name of output region file (adds extension .rgn). 00027 default: none; if not given uses imagename+'.rgn' 00028 threshold -- value (with units) to use for island threshold. 00029 default: 0.0. 00030 maskname -- Optional output mask name. 00031 default: '' (do not write mask image) 00032 chanrange -- Range of channel ids 00033 default: '' (find boxes for all channels) 00034 example: '5~7' (find boxes for channel 5,6,7 00035 polrange -- Range of polarization ids 00036 default: '' (find boxes for all polarizations) 00037 example: '0~1' (find boxes for polarization 0,1 00038 minsize -- minimum size of island to get a box (in number of pixels) 00039 default: 2 00040 diag -- count diagonal connections as same island or not 00041 default: False 00042 boxstretch -- number of pixels to increase outward size of each box; can 00043 range from -1 to 5. 00044 default: 1 00045 overwrite -- Overwrite existing region file and/or mask? 00046 default: False. If False, gives warning if file exists. 00047 00048 00049 """ 00050 00051 # 00052 # The following is work around to avoid a bug with current python translation 00053 # 00054 mytmp = {} 00055 00056 mytmp['imagename'] = imagename 00057 mytmp['regionfile'] = regionfile 00058 if type(threshold) == str : 00059 mytmp['threshold'] = casac.quanta().quantity(threshold) 00060 else : 00061 mytmp['threshold'] = threshold 00062 mytmp['maskname'] = maskname 00063 mytmp['chanrange'] = chanrange 00064 mytmp['polrange'] = polrange 00065 mytmp['minsize'] = minsize 00066 mytmp['diag'] = diag 00067 mytmp['boxstretch'] = boxstretch 00068 mytmp['overwrite'] = overwrite 00069 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00070 trec = casac.utils().torecord(pathname+'boxit.xml') 00071 00072 casalog.origin('boxit') 00073 if trec.has_key('boxit') and casac.utils().verify(mytmp, trec['boxit']) : 00074 result = task_boxit.boxit(imagename, regionfile, threshold, maskname, chanrange, polrange, minsize, diag, boxstretch, overwrite) 00075 00076 else : 00077 result = False 00078 return result