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_fluxscale 00013 def fluxscale(vis='', caltable='', fluxtable='', reference=[''], transfer=[''], listfile='', append=False, refspwmap=[-1], incremental=False): 00014 00015 """Bootstrap the flux density scale from standard calibrators 00016 00017 After running gaincal on standard flux density calibrators (with or 00018 without an image model), and other calibrators with unknown flux 00019 densities (assumed 1 Jy), fluxscale applies the constraint that 00020 net system gain was, in fact, independent of field, on average, 00021 and that field-dependent gains in the input caltable are solely 00022 a result of the unknown flux densities for the calibrators. 00023 Using time-averaged gain amplitudes, the ratio between 00024 each ordinary calibrator and the flux density calibrator(s) is 00025 formed for each antenna and polarization (that they have in 00026 common). For incremetal=False(default), the median of 00027 this ratio over antennas and polarizations yields a correction 00028 factor that is applied to the ordinary calibrators' gains. For 00029 incremental=True, only the correction factors are written out 00030 to the output fluxtable. 00031 00032 The square of the gain correction factor for each calibrator 00033 and spw is the presumed flux density of that calibrator, and is 00034 reported in the logger. The errors reported with this value 00035 reflect the scatter in gain ratio over antennas and 00036 polarizations, divided by the square root of the number of 00037 antennas and polarizations available. If the flux densities 00038 for multiple spws exist, fitted spectral index and (for nspw>2) 00039 curvature are also reported. The MODEL_DATA column 00040 is currently _not_ revised to reflect the flux densities 00041 derived by fluxscale. Use setjy to set the MODEL_DATA column, 00042 if necessary. 00043 00044 The constant gain constraint is usually a reasonable assumption 00045 for the electronic systems on typical antennas. It is 00046 important that external time- and/or elevation-dependent 00047 effects are separately accounted for when solving for the gain 00048 solution supplied to fluxscale, e.g., gain curves, 00049 opacity, etc. The fluxscale results can also be degraded 00050 by poor pointing during the observation. 00051 00052 00053 Keyword arguments: 00054 vis -- Name of input visibility file 00055 default: none; example: vis='ngc5921.ms' 00056 caltable -- Name of input calibration table 00057 default: none; example: caltable='ngc5921.gcal' 00058 This cal table was obtained from task gaincal. 00059 fluxtable -- Name of output, flux-scaled calibration table 00060 default: none; example: fluxtable='ngc5921.gcal2' 00061 The gains in this table have been adjusted by the 00062 derived flux density each calibrator. The MODEL_DATA 00063 column has NOT been updated for the flux density of the 00064 calibrator. Use setjy to do this if it is a point source. 00065 reference -- Reference field name(s) 00066 The names of the fields with a known flux densities or 00067 visibilties that have been placed in the MODEL column 00068 by setjy or ft for a model not in the CASA system. 00069 The syntax is similar to field. Hence field index or 00070 names can be used. 00071 default: none; example: reference='1328+307' 00072 transfer -- Transfer field name(s) 00073 The names of the fields with unknown flux densities. 00074 These should be point-like calibrator sources 00075 The syntax is similar to field. Hence source index or 00076 names can be used. 00077 default: '' = all sources in caltable that are not specified 00078 as reference sources. Do not include unknown target sources 00079 example: transfer='1445+099, 3C84'; transfer = '0,4' 00080 00081 NOTE: All fields in reference and transfer must have solutions 00082 in the caltable. 00083 00084 listfile -- Fit listfile name 00085 The list file contains the flux density, flux density error, 00086 S/N, and number of solutions (all antennas and feeds) for each 00087 spectral window. NOTE: The nominal spectral window frequencies 00088 will be included in the future. 00089 default: '' = no fit listfile will be created. 00090 00091 append -- Append fluxscaled solutions to the fluxtable. 00092 default: False; (will overwrite if already existing) 00093 example: append=True 00094 refspwmap -- Vector of spectral windows enablings scaling across 00095 spectral windows 00096 default: [-1]==> none. 00097 Example with 4 spectral windows: 00098 if the reference fields were observed only in spw=1 & 3, 00099 and the transfer fields were observed in all 4 spws (0,1,2,3), 00100 specify refspwmap=[1,1,3,3]. 00101 This will ensure that transfer fields observed in spws 0,1,2,3 00102 will be referenced to reference field solutions only in 00103 spw 1 or 3. 00104 00105 incremental -- Create an incremental caltable containing only gain correction 00106 factors ( flux density= 1/(gain correction factor)**2) 00107 default: False; (older behavior = create flux-scaled gain table) 00108 example: incremental=True (output a caltable containing flux scale factors.) 00109 00110 NOTE: If you use the incremental option, note that BOTH this incremental 00111 fluxscale table AND an amplitude vs. time table should be supplied in applycal. 00112 00113 00114 """ 00115 if type(reference)==str: reference=[reference] 00116 if type(transfer)==str: transfer=[transfer] 00117 if type(refspwmap)==int: refspwmap=[refspwmap] 00118 00119 # 00120 # The following is work around to avoid a bug with current python translation 00121 # 00122 mytmp = {} 00123 00124 mytmp['vis'] = vis 00125 mytmp['caltable'] = caltable 00126 mytmp['fluxtable'] = fluxtable 00127 mytmp['reference'] = reference 00128 mytmp['transfer'] = transfer 00129 mytmp['listfile'] = listfile 00130 mytmp['append'] = append 00131 mytmp['refspwmap'] = refspwmap 00132 mytmp['incremental'] = incremental 00133 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00134 trec = casac.utils().torecord(pathname+'fluxscale.xml') 00135 00136 casalog.origin('fluxscale') 00137 if trec.has_key('fluxscale') and casac.utils().verify(mytmp, trec['fluxscale']) : 00138 result = task_fluxscale.fluxscale(vis, caltable, fluxtable, reference, transfer, listfile, append, refspwmap, incremental) 00139 00140 else : 00141 result = False 00142 return result