casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
drawmaskinimage.py
Go to the documentation of this file.
00001 from casa import imager as im
00002 from casa import image as ia
00003 from casa import regionmanager as rg
00004 import os 
00005 import shutil
00006 
00007 def drawmaskinimage(image='', maskname='maskoo', makedefault=True):
00008     """
00009     Till casa think graphical interaction is important.
00010     Ugly Function that uses interactive clean image mask  to 
00011     allow users to draw a mask and store it as a bit mask in the image 
00012     so it can be used by imageanalysis methods or to mask an image
00013 
00014     Parameters
00015 
00016     image: is the image to put a bit mask in
00017     maskname: name of bit mask 
00018     makedefault: if True will make new bit mask drawn be the default mask
00019 
00020     """
00021     if(not os.path.exists(image)):
00022         return
00023     tmpmaskimage='__muluktani'
00024     if(os.path.exists(tmpmaskimage)):
00025         shutil.rmtree(tmpmaskimage, True)
00026     im.drawmask(image=image, mask=tmpmaskimage)
00027     ia.open(image)
00028     ia.calcmask(mask='__muluktani < 0.5', name=maskname, asdefault=makedefault)
00029     ia.done()
00030     print 'regions/mask in ', image, rg.namesintable(image)
00031     shutil.rmtree(tmpmaskimage, True)