casa
$Rev:20696$
|
00001 import os 00002 from taskinit import * 00003 00004 def fluxscale(vis=None,caltable=None,fluxtable=None,reference=None,transfer=None,listfile=None,append=None,refspwmap=None,incremental=None): 00005 """Bootstrap the flux density scale from standard calibrators: 00006 00007 After running gaincal on standard flux density calibrators (with or 00008 without a model), and other calibrators with unknown flux densities, 00009 fluxscale will determine the flux density of the unknowns calibrators 00010 that are most consistent with the standard calibrator antenna gains. 00011 00012 Keyword arguments: 00013 vis -- Name of input visibility file 00014 default: none; example: vis='ngc5921.ms' 00015 caltable -- Name of input calibration table 00016 default: none; example: caltable='ngc5921.gcal' 00017 This cal table was obtained from task gaincal. 00018 fluxtable -- Name of output, flux-scaled calibration table 00019 default: none; example: fluxtable='ngc5921.gcal2' 00020 The gains in this table have been adjusted by the 00021 derived flux density each calibrator. The MODEL_DATA 00022 column has NOT been updated for the flux density of the 00023 calibrator. Use setjy to do this if it is a point source. 00024 reference -- Reference field name(s) 00025 The names of the fields with a known flux densities or 00026 visibilties that have been placed in the MODEL column 00027 by setjy or ft for a model not in the CASA system. 00028 The syntax is similar to field. Hence field index or 00029 names can be used. 00030 default: none; example: reference='1328+307' 00031 transfer -- Transfer field name(s) 00032 The names of the fields with unknown flux densities. 00033 These should be point-like calibrator sources 00034 The syntax is similar to field. Hence source index or 00035 names can be used. 00036 default: '' = all sources in caltable that are not specified 00037 as reference sources. Do not include unknown target sources 00038 example: transfer='1445+099, 3C84'; transfer = '0,4' 00039 00040 NOTE: All fields in reference and transfer must have solutions 00041 in the caltable. 00042 00043 listfile -- Fit listfile name 00044 The list file contains the flux density, flux density error, 00045 S/N, and number of solutions (all antennas and feeds) for each 00046 spectral window. NOTE: The nominal spectral window frequencies 00047 will be included in the future. 00048 default: '' = no fit listfile will be created. 00049 00050 append -- Append fluxscaled solutions to the fluxtable. 00051 default: False; (will overwrite if already existing) 00052 example: append=True 00053 refspwmap -- Vector of spectral windows enablings scaling across 00054 spectral windows 00055 default: [-1]==> none. 00056 Example with 4 spectral windows: 00057 if the reference fields were observed only in spw=1 & 3, 00058 and the transfer fields were observed in all 4 spws (0,1,2,3), 00059 specify refspwmap=[1,1,3,3]. 00060 This will ensure that transfer fields observed in spws 0,1,2,3 00061 will be referenced to reference field solutions only in 00062 spw 1 or 3. 00063 00064 incremental -- Create an incremental caltable containing only the gain correction 00065 factors. 00066 default: False; (older behavior, produces flux scaled gain table) 00067 """ 00068 00069 try: 00070 casalog.origin('fluxscale') 00071 00072 mycb = cbtool() 00073 mycb.open(filename=vis,compress=False,addcorr=False,addmodel=False) 00074 output = mycb.fluxscale(tablein=caltable,tableout=fluxtable,reference=reference, 00075 transfer=transfer,listfile=listfile,append=append, 00076 refspwmap=refspwmap,incremental=incremental) 00077 mycb.close() 00078 00079 #write history 00080 try: 00081 param_names = fluxscale.func_code.co_varnames[:fluxscale.func_code.co_argcount] 00082 param_vals = [eval(p) for p in param_names] 00083 write_history(mstool(), vis, 'fluxscale', param_names, 00084 param_vals, casalog) 00085 except Exception, instance: 00086 casalog.post("*** Error \'%s\' updating HISTORY" % (instance), 00087 'WARN') 00088 00089 except Exception, instance: 00090 print '*** Error ***',instance 00091 mycb.close() 00092 raise Exception, instance 00093 00094 return output