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_imcontsub 00013 def imcontsub(imagename='', linefile='', contfile='', fitorder=0, region='', box='', chans='', stokes=''): 00014 00015 """Estimates and subtracts continuum emission from an image cube 00016 00017 For each (x, y) column in imagename (or a subset selected by region and/or 00018 box), this estimates the continuum by fitting a polynomial to one or more 00019 subsets of the channels. The continuum estimate is saved in contfile, and 00020 subtracted from imagename (or its subset) to make a spectral line estimate, 00021 which is saved in linefile. 00022 00023 00024 00025 00026 Keyword arguments: 00027 imagename -- Input image cube 00028 Default: none; Example: imagename='ngc5921_task.im' 00029 linefile -- Name of output spectral line cube 00030 Default: none; Example: outline='ngc5921_line.im' 00031 contfile -- Name of output continuum cube 00032 Default: none; Example: contfile='ngc5921_cont.im' 00033 fitorder -- Polynomial order for the continuum estimation. 00034 Default: 0; Example fitorder=2 00035 region -- ImageRegion file to select a portion of the cube for output. 00036 Default: '' (= everything) 00037 Example: region='myimage.im.rgn' 00038 region='region1' 00039 Use the viewer on the image cube to define the continuum 00040 regions. This is more general than box but still experimental. 00041 N.B. This is NOT for selecting a subset of the input for 00042 fitting the continuum! Only pixels that are in region 00043 will be considered, however. 00044 00045 box -- A [blcx, blcy, trcx, trcy] region on the directional plane for 00046 selecting a subset for output. 00047 ONLY pixel values are acceptable at this time. 00048 Default: none (whole 2-D plane); Example: box='10,10,50,50' 00049 N.B. This is NOT for selecting a subset of the input for 00050 fitting the continuum! Only pixels that are in region 00051 will be considered, however. 00052 chans -- line-free channel numbers to fit the continuum to. 00053 N.B.: This is currently the _only_ way to specify what is 00054 continuum vs. line emission. 00055 ONLY channel numbers accepted at this time, i.e. there is no 00056 'spw:' as in the spw parameter of other tasks. For 00057 a multi-spw image, the channelization must be the same for all. 00058 Default: '' (all) 00059 Example: chans='3~6;>40' 00060 stokes -- Stokes parameters to image, may or may not be separated 00061 by commas but best if you use commas. 00062 Default: none (all); Example: stokes='IQUV'; 00063 Options: 'I','Q','U','V','RR','RL','LR','LL','XX','YX','XY','YY', ... 00064 00065 00066 00067 """ 00068 00069 # 00070 # The following is work around to avoid a bug with current python translation 00071 # 00072 mytmp = {} 00073 00074 mytmp['imagename'] = imagename 00075 mytmp['linefile'] = linefile 00076 mytmp['contfile'] = contfile 00077 mytmp['fitorder'] = fitorder 00078 mytmp['region'] = region 00079 mytmp['box'] = box 00080 mytmp['chans'] = chans 00081 mytmp['stokes'] = stokes 00082 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00083 trec = casac.utils().torecord(pathname+'imcontsub.xml') 00084 00085 casalog.origin('imcontsub') 00086 if trec.has_key('imcontsub') and casac.utils().verify(mytmp, trec['imcontsub']) : 00087 result = task_imcontsub.imcontsub(imagename, linefile, contfile, fitorder, region, box, chans, stokes) 00088 00089 else : 00090 result = False 00091 return result