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_uvmodelfit 00013 def uvmodelfit(vis='', field='', spw='', selectdata=True, timerange='', uvrange='', antenna='', scan='', msselect='', niter=5, comptype='P', sourcepar=[1.0, 0.0, 0.0], varypar=[], outfile=''): 00014 00015 """Fit a single component source model to the uv data 00016 00017 Fit a single component source model to the uv data. Three models 00018 are available: P=point; G=Gaussian; D=Disk. Fitting parameters can 00019 be held fixed. The results are given in the log and placed in a 00020 components file. 00021 00022 Keyword arguments: 00023 vis -- Name of input visibility file 00024 default: none; example: vis='ngc5921.ms' 00025 00026 --- Data Selection 00027 field -- Select data based on field id(s) or name(s) 00028 default: '' (all); example: field='1' 00029 field='0~2' # field ids inclusive from 0 to 2 00030 field='3C*' # all field names starting with 3C 00031 spw -- Select data based on spectral window 00032 default: '' (all); example: spw='1' 00033 spw='<2' #spectral windows less than 2 00034 spw='>1' #spectral windows greater than 1 00035 selectdata -- Select a subset of the visibility using MSSelection 00036 default: False; example: selectdata=True 00037 timerange -- Select data based on time range: 00038 default = '' (all); example, 00039 timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss' 00040 Note: YYYY/MM/DD can be dropped as needed: 00041 timerange='09:14:0~09:54:0' # this time range 00042 timerange='09:44:00' # data within one integration of time 00043 timerange='>10:24:00' # data after this time 00044 timerange='09:44:00+00:13:00' #data 13 minutes after time 00045 uvrange -- Select data within uvrange (default units kilo-lambda) 00046 default: '' (all); example: 00047 uvrange='0~1000kl'; uvrange from 0-1000 kilo-lamgda 00048 uvrange='>4kl';uvranges greater than 4 kilo lambda 00049 uvrange='0~1000km'; uvrange in kilometers 00050 antenna -- Select data based on antenna/baseline 00051 default: '' (all); example: antenna='5&6' baseline 5-6 00052 antenna='5&6;7&8' #baseline 5-6 and 7-8 00053 antenna='5' # all baselines with antenna 5 00054 antenna='5,6' # all baselines with antennas 5 and 6 00055 scan -- Select data based on scan number - New, under developement 00056 default: '' (all); example: scan='>3' 00057 msselect -- Optional data selection (field,spw,time,etc) 00058 default:'' means select all; example:msselect='FIELD_ID==0', 00059 msselect='FIELD_ID IN [0,1,2]' means select fields 0,1 and 2 00060 msselect='FIELD_ID <= 1 means select fields 0, 1 00061 msselect='FIELD_ID==0 && ANTENNA1 IN [0] && ANTENNA2 IN [2:26]' 00062 means select field 0 and antennas 0 to 26, except antenna 1. 00063 Other msselect fields are: 'DATA_DESC_ID', 'SPECTRAL_WINDOW_ID', 00064 'POLARIZATION_ID', 'SCAN_NUMBER', 'TIME', 'UVW' 00065 See ccokbook for more details 00066 00067 niter -- Number of fitting iterations to execute 00068 default: 5; example: niter=20 00069 comptype -- component model type 00070 default: 'P'; 00071 Options: 'P' (point source), 'G' (elliptical gaussian), 00072 'D' (elliptical disk) 00073 sourcepar -- Starting guess for component parameters 00074 default: [1,0,0]; (for comptype='P') 00075 IF comptype = 'P' then 00076 sourcepar = [flux,xoff,yoff] where 00077 flux = Jy, xoff = arcsec-east, yoff = arcsec-north. 00078 IF comptype = 'G' or 'D', then 00079 sourcepar = [flux,xoff,yoff,majax,axrat,pos] where 00080 majax = arcsec, axrat < 1, pos=angle in deg 00081 varypar -- Control which parameters to let vary in the fit 00082 default: [] (all vary); 00083 example: vary=[F,T,T] 00084 00085 examples: 00086 00087 fit a point: 00088 comptype = 'P' 00089 sourcepar = [0.4,0.2,-0.3]; 00090 varypar = [T,T,T] 00091 00092 fit a circular Gaussian: 00093 comptype = 'G' 00094 sourcepar = [1.4,0.3,-0.2,0.3, 1, 0] 00095 varypar = [ T , T , T , T , F, F] 00096 00097 00098 outfile -- Optional output component list table 00099 default: ''; example: outfile='componentlist.cl' 00100 00101 00102 How to get the output values: 00103 00104 cl.open('componentlist.cl') 00105 fit = cl.getcompoent() stores component information 00106 fit to see the whole mess 00107 flux = fit['flux']['value'] to store the I,Q,U,V, flux 00108 print flux 00109 00110 ra = fit['shape']['direction']['m0']['value'] 00111 dec =fit['shape']['direction']['m1']['value'] 00112 print ra, dec 00113 00114 bmaj = fit['shape']['majoraxis']['value'] to get major axis 00115 bmin = fit['shape']['minoraxis']['value'] to get minor axis 00116 00117 00118 00119 """ 00120 if type(sourcepar)==float: sourcepar=[sourcepar] 00121 if type(varypar)==bool: varypar=[varypar] 00122 00123 # 00124 # The following is work around to avoid a bug with current python translation 00125 # 00126 mytmp = {} 00127 00128 mytmp['vis'] = vis 00129 mytmp['field'] = field 00130 mytmp['spw'] = spw 00131 mytmp['selectdata'] = selectdata 00132 mytmp['timerange'] = timerange 00133 mytmp['uvrange'] = uvrange 00134 mytmp['antenna'] = antenna 00135 mytmp['scan'] = scan 00136 mytmp['msselect'] = msselect 00137 mytmp['niter'] = niter 00138 mytmp['comptype'] = comptype 00139 mytmp['sourcepar'] = sourcepar 00140 mytmp['varypar'] = varypar 00141 mytmp['outfile'] = outfile 00142 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00143 trec = casac.utils().torecord(pathname+'uvmodelfit.xml') 00144 00145 casalog.origin('uvmodelfit') 00146 if trec.has_key('uvmodelfit') and casac.utils().verify(mytmp, trec['uvmodelfit']) : 00147 result = task_uvmodelfit.uvmodelfit(vis, field, spw, selectdata, timerange, uvrange, antenna, scan, msselect, niter, comptype, sourcepar, varypar, outfile) 00148 00149 else : 00150 result = False 00151 return result