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_peel 00013 def peel(vis='', dirs="", remove=True, calmode='p'): 00014 00015 """Do direction dependent selfcal(s) and optionally remove annoying sources. 00016 Unfortunately at some level gains are direction-dependent, typically 00017 because of either deviations between the true antenna voltage patterns and 00018 the models being used, and/or fluctuations in one layer or another of the 00019 Earth's atmosphere. Bright sources located in the edges of the primary 00020 beam therefore corrupt images of the central portions of the primary beam 00021 in two ways. The most obvious way is by throwing a corrupted version of 00022 the PSF across the image. Since it is corrupted, it cannot be deconvolved 00023 away without first correcting the gains. The second problem is that a 00024 bright source can dominate the solutions of "classical" selfcalibration, 00025 essentially forcing it to solve the gains for the direction of the bright 00026 source instead of the pointing center. 00027 00028 Solving for and removing the effects of direction-dependent gains is known 00029 in various forms as "peeling", "modcal", or most prosaically, 00030 direction-dependent selfcalibration. This task attempts 00031 direction-dependent selfcalibration in the requested list of directions, 00032 and optionally removes the associated sources. 00033 00034 The usual risks of selfcalibration (imperfect model and possibly 00035 insufficient constraints) are particularly severe for peeling. Approach it 00036 with trepidation and stop as soon as possible. Peeling can ameliorate the 00037 effects of heterogeneous arrays, but it is better to use the right antenna 00038 voltage patterns a priori. 00039 00040 Do not peel unless necessary. 00041 00042 Still here? All right...read carefully... 00043 00044 Your desire to peel probably stems from the center of your "science field" 00045 being spoiled by the distorted PSFs of bright sources near the edge of the 00046 primary beam. The fact that their PSFs are interfering with your field of 00047 interest means that your science sources are interfering with the sources 00048 to be peeled! Thus before doing any peeling you should remove a model of 00049 your science field from the visibilities. However, the model should not 00050 include any artifacts from the sources to be peeled. The easiest way to 00051 produce such a model is to clean down to the threshhold of the brightest 00052 artifacts. peel does not (yet) do this for you! You are also of course 00053 responsible for returning the model of your science field to the 00054 visibilities once you have finished peeling. Obviously, if your science 00055 sources are fainter than the artifacts, removing them and replacing them is 00056 not necessary. 00057 00058 If more than one source must be peeled there is a chance (calculated using 00059 Murphy's Law) that they are interfering with each other. peel does not yet 00060 simultaneously solve for the gains in more than direction, so interfering 00061 sources must be approached by peeling the brightest source down to the 00062 level of the brightest artifacts in its vicinity, and next peeling whatever 00063 is currently causing the worst artifacts, continuing as necessary. 00064 00065 If the interactions are especially strong, the cycle will have to be 00066 iterated, refining the model(s) along the way. The convergence is often 00067 safer and faster if the first iteration of the cycle only solves for the 00068 phases, and leaves phase + amplitude selfcalibration to the final 00069 iteration. 00070 00071 Any given run of peel is nearly guaranteed to reduce the artifacts from the 00072 source being peeled, so it can be tempting to continue peeling until the 00073 artifacts drop below the noise. Resist that temptation! The number of 00074 fitted parameters accumulates with each peel, so repeated peels force the 00075 image toward the originally assumed model. Even if the total number of 00076 fitted parameters remains much smaller than the number of visibilities, the 00077 interactions between peeled sources and the central field take their toll 00078 on the science field. peel sees residual PSF sidelobes from the science 00079 region as artifacts that must be minimized. Whether removing some flux 00080 from the science source(s) is a risk or a certainty, the number of peels 00081 should be kept down. Overpeeling becomes easier to spot with experience, 00082 but the symptoms are strongly telescope-dependent. 00083 00084 00085 00086 00087 Example: 00088 00089 # Start with a phase-only peel, and keep the source so it can be phase + 00090 # amplitude peeled if necessary. 00091 peel(vis='my.ms', calmode="p", remove=False) 00092 00093 # Examine the result with viewer. 00094 00095 # OK, do a phase + amplitude removal. 00096 peel(vis='my.ms', calmode="pa") 00097 00098 """ 00099 00100 # 00101 # The following is work around to avoid a bug with current python translation 00102 # 00103 mytmp = {} 00104 00105 mytmp['vis'] = vis 00106 mytmp['dirs'] = dirs 00107 mytmp['remove'] = remove 00108 mytmp['calmode'] = calmode 00109 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00110 trec = casac.utils().torecord(pathname+'peel.xml') 00111 00112 casalog.origin('peel') 00113 if trec.has_key('peel') and casac.utils().verify(mytmp, trec['peel']) : 00114 result = task_peel.peel(vis, dirs, remove, calmode) 00115 00116 else : 00117 result = False 00118 return result