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_imsubimage 00013 def imsubimage(imagename='', outfile='', region='', mask='', dropdeg=False, overwrite=False, verbose=True, stretch=False, wantreturn=True): 00014 00015 """Create a (sub)image from a region of the image 00016 PARAMETER SUMMARY 00017 imagename Name of the input image 00018 outfile Name of output file. Empty means create a temporary image and return it. 00019 region Region of interest. See help par.region for specification options. Default ("") is entire image. 00020 mask Mask to use. See help par.mask. Default ("") is none. 00021 dropdeg If True, all degenerate axes in the input image will be excluded in the output image. 00022 overwrite If True, a pre-existing file of the same name as outfile will be overwritten. 00023 verbose Post additional informative messages to the logger. 00024 stretch Stretch the input mask if necessary and possible. Only used if a mask is specified. 00025 See help par.stretch. 00026 00027 OVERVIEW 00028 00029 This task copies all or part of the image to another on-the-fly Image tool. 00030 If {\stfaf outfile} is given, the subimage is written to the specified 00031 disk file. If {\stfaf outfile} is unset, the returned Image \tool\ actually 00032 references the input image file (i.e. that associated with the Image 00033 \tool\ to which you are applying this function). So if you deleted the 00034 input image disk file, it would render this \tool\ useless. When you destroy this 00035 \tool\ (with the done function) 00036 the reference connection is broken. 00037 00038 Sometimes it is useful to drop axes of length one (degenerate axes). 00039 Set {\stfaf dropdeg} equal to True if you want to do this. 00040 00041 The output mask is the combination (logical OR) of the default input 00042 \pixelmask\ (if any) and the OTF mask. Any other input \pixelmasks\ 00043 will not be copied. Use function maskhandler if you 00044 need to copy other masks too. 00045 00046 If the mask has fewer dimensions than the image and if the shape 00047 of the dimensions the mask and image have in common are the same, 00048 the mask will automatically have the missing dimensions added so 00049 it conforms to the image. 00050 00051 If stretch is true and if the number of mask dimensions is less than 00052 or equal to the number of image dimensions and some axes in the 00053 mask are degenerate while the corresponding axes in the image are not, 00054 the mask will be stetched in the degenerate dimensions. For example, 00055 if the input image has shape [100, 200, 10] and the input 00056 mask has shape [100, 200, 1] and stretch is true, the mask will be 00057 stretched along the third dimension to shape [100, 200, 10]. However if 00058 the mask is shape [100, 200, 2], stretching is not possible and an 00059 error will result. 00060 00061 00062 """ 00063 00064 # 00065 # The following is work around to avoid a bug with current python translation 00066 # 00067 mytmp = {} 00068 00069 mytmp['imagename'] = imagename 00070 mytmp['outfile'] = outfile 00071 mytmp['region'] = region 00072 mytmp['mask'] = mask 00073 mytmp['dropdeg'] = dropdeg 00074 mytmp['overwrite'] = overwrite 00075 mytmp['verbose'] = verbose 00076 mytmp['stretch'] = stretch 00077 mytmp['wantreturn'] = wantreturn 00078 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00079 trec = casac.utils().torecord(pathname+'imsubimage.xml') 00080 00081 casalog.origin('imsubimage') 00082 if trec.has_key('imsubimage') and casac.utils().verify(mytmp, trec['imsubimage']) : 00083 result = task_imsubimage.imsubimage(imagename, outfile, region, mask, dropdeg, overwrite, verbose, stretch, wantreturn) 00084 00085 else : 00086 result = False 00087 return result