casa
$Rev:20696$
|
00001 # 00002 # This file was generated using xslt from its XML file 00003 # 00004 # Copyright 2008, Associated Universities Inc., Washington DC 00005 # 00006 import sys 00007 import os 00008 #from casac import * 00009 import casac 00010 import string 00011 import time 00012 import inspect 00013 import gc 00014 import numpy 00015 from odict import odict 00016 from taskmanager import tm 00017 from task_imfit import imfit 00018 class imfit_cli_: 00019 __name__ = "imfit" 00020 __async__ = {} 00021 rkey = None 00022 i_am_a_casapy_task = None 00023 # The existence of the i_am_a_casapy_task attribute allows help() 00024 # (and other) to treat casapy tasks as a special case. 00025 00026 def __init__(self) : 00027 self.__bases__ = (imfit_cli_,) 00028 self.__doc__ = self.__call__.__doc__ 00029 00030 self.parameters={'imagename':None, 'box':None, 'region':None, 'chans':None, 'stokes':None, 'mask':None, 'includepix':None, 'excludepix':None, 'residual':None, 'model':None, 'estimates':None, 'logfile':None, 'append':None, 'newestimates':None, 'complist':None, 'overwrite':None, 'dooff':None, 'offset':None, 'fixoffset':None, 'stretch':None, 'async':None} 00031 00032 00033 def result(self, key=None): 00034 #### here we will scan the task-ids in __async__ 00035 #### and add any that have completed... 00036 if key is not None and self.__async__.has_key(key) and self.__async__[key] is not None: 00037 ret = tm.retrieve(self.__async__[key]) 00038 if ret['state'] == "done" : 00039 self.__async__[key] = None 00040 elif ret['state'] == 'crashed' : 00041 self.__async__[key] = None 00042 return ret 00043 return None 00044 00045 00046 def __call__(self, imagename=None, box=None, region=None, chans=None, stokes=None, mask=None, includepix=None, excludepix=None, residual=None, model=None, estimates=None, logfile=None, append=None, newestimates=None, complist=None, overwrite=None, dooff=None, offset=None, fixoffset=None, stretch=None, async=None): 00047 00048 """Fit one or more elliptical Gaussian components on an image region(s) 00049 PARAMETER SUMMARY 00050 imagename Name of the input image 00051 box One or more box regions to use for fitting, 00052 eg "100, 120, 200, 220, 300, 300, 400, 400" 00053 to use two boxes. If both box and region 00054 parameters are specified, box is used. 00055 region Region of interest. See help par.region for specification options. 00056 stokes Stokes parameter to fit. If blank, first polarization plane is used. 00057 mask Mask to use. See help par.mask. Default is none. 00058 includepix Range of pixel values to include for fitting. Array of two numeric 00059 values assumed to have same units as image pixel values. Only one 00060 of includepix or excludepix can be specified. 00061 excludepix Range of pixel values to exclude for fitting. Array of two numeric 00062 values assumed to have same units as image pixel values. Only one 00063 of includepix or excludepix can be specified. 00064 residual Name of the residual image to write. 00065 model Name of the model image to write. 00066 estimates Name of file containing initial estimates of component parameters 00067 (see below for formatting details). 00068 logfile Name of file to write fit results. 00069 append If logfile exists, append to it (True) or overwrite it (False). 00070 newestimates File to write fit results which can be used as initial estimates 00071 for next run. 00072 complist Name of output component list table. 00073 overwrite Overwrite component list table if it exists? 00074 dooff Simultaneously fit a zero-level offset? 00075 offset Initial estimate for the zero-level offset. Only used if dooff is True. 00076 fixoffset Hold zero-level offset constant during fit? Only used if dooff is True. 00077 stretch Stretch the input mask if necessary and possible. Only used if a mask is specified. 00078 See help par.stretch. 00079 00080 OVERVIEW 00081 imfit is used to fit one or more gaussians to sources in an image as 00082 well as an optional zero-level offset. Fitting is limited to a single polarization 00083 but can be performed over several contiguous spectral channels. 00084 If the image has a clean beam, the report will contain both the convolved 00085 and the deconvolved fit results. It is a simple wrapper around the ia.fitcomponents() 00086 tool method. 00087 00088 When dooff is False, the method returns a dictionary with two keys, 'converged' and 'results'. 00089 The value of 'converged' is a boolean array which indicates if the fit converged 00090 on a channel by channel basis. 00091 The value of 'results' is a dictionary representing a component list reflecting the 00092 fit results. In the case of a deconvolved image, the sizes and position angles are those 00093 of the source convolved with the restoring beam. For convenience, the 'results' dictionary can 00094 be read into a compoenent list tool (default tool is named cl) using the fromrecord() method 00095 for easier inspection using tool methods, eg 00096 00097 cl.fromrecord(res['results']) 00098 00099 If dooff is True, in addtion to the specified number of 00100 gaussians, a zero-level offset will also be fit. The initial estimate for this 00101 offset is specified using the offset parameter. Units are assumed to be the 00102 same as the image brightness units.The zero level offset can be held constant during 00103 the fit by specifying fixoffset=True. In the case of dooff=True, the returned 00104 dictionary contains two additional keys, 'zerooff' and 'zeroofferr', which are both 00105 arrays containing the the fitted zero level offset value and its error, respectively, 00106 for each channel. Both sets of values are in image brightness units. 00107 In cases where the fit did not converge, these values are set to NaN. 00108 00109 The region can either be specified by a box(es) or a region (there is no 00110 garauntee which will be used if both are specified, so be certain only one is). 00111 If specified using the box parameter, multiple boxes can be given using the format 00112 box="blcx1, blcy1, trcx1, trcy1, blcx2, blcy2, trcx2, trcy2, ... , blcxN, blcyN, trcxN, trcyN" 00113 where N is the number of boxes. In this case, the union of the specified boxes will be used. 00114 00115 Ranges of pixel values can be included or excluded from the fit via includepix and excludepix. 00116 00117 If specified, the task will write the residual and/or model images for 00118 successful fits. 00119 00120 If an estimates file is not specified, the task will attempt to estimate 00121 initial parameters and fit a single Gaussian. If a multiple Gaussian fit 00122 is desired, the user must specify initial estimates via a text file 00123 (see below for details). 00124 00125 The user has the option of writing the result of the fit to a log file, 00126 and has the option of either appending to or overwriting an existing file. 00127 00128 The user has the option of writing the (convolved) parameters of a successful 00129 fit to a file which can be fed back to imfit as the estimates file for a 00130 subsequent run. 00131 00132 FITTING OVER MULTIPLE CHANNELS 00133 00134 For fitting over multiple channels, the result 00135 of the previous successful fit is used as the estimate for the next channel. The number 00136 of gaussians fit cannot be varied on a channel by channel basis. Thus the variation 00137 of source structure should be reasonably smooth in frequency to produce reliable fit 00138 results. 00139 00140 MASK SPECIFICATION 00141 00142 Mask specification can be done using an LEL expression. For example 00143 00144 mask = '"myimage">5' will use only pixels with values greater than 5. 00145 00146 INCLUDING AND EXCLUDING PIXELS 00147 00148 Pixels can be included or excluded from the fit based on their values 00149 using includepix and excludepix. Note that specifying both is not permitted 00150 and will result in an error. If specified, both take an array of two numeric 00151 values. 00152 00153 ESTIMATES 00154 00155 Initial estimates of fit parameters may be specified via an estimates 00156 text file. Each line of this file should contain a set of parameters for 00157 a single gaussian. Optionally, some of these parameters can be fixed during 00158 the fit. The format of each line is 00159 00160 peak intensity, peak x-pixel value, peak y-pixel value, major axis, minor axis, position angle, fixed 00161 00162 The fixed parameter is optional. The peak intensity is assumed to be in the 00163 same units as the image pixel values (eg Jy/beam). The peak coordinates are specified 00164 by pixel values. The major and minor axes and the position angle are the convolved 00165 parameters if the image has been convolved with a clean beam and are specified as quantities. 00166 The fixed parameter is optional and is a string. It may contain any combination of the 00167 following characters 'f' (peak intensity), 'x' (peak x position), 'y' (peak y position), 00168 'a' (major axis), 'b' (minor axis), 'p' (position angle). 00169 00170 In addition, lines in the file starting with a "#" are considered comments. 00171 00172 An example of such a file is: 00173 00174 # peak intensity must be in map units 00175 120, 150, 110, 23.5arcsec, 18.9arcsec, 120deg 00176 90, 60, 200, 46arcsec, 23arcsec, 140deg, fxp 00177 00178 This is a file which specifies that two gaussians are to be simultaneously fit, 00179 and for the second gaussian the specified peak intensity, x position, and position angle 00180 are to be held fixed during the fit. 00181 00182 ERROR ESTIMATES 00183 00184 The reported estimated errors are the maxima from two methods. In the first method, errors are calculated 00185 according to the description given in AIPS++ Note 224: AIPS++ Least Squares Background available at 00186 http://www.astron.nl/casacore/trunk/casacore/doc/notes/224.html . In the second method (Condon et al 00187 1998AJ.115.1693; Richards et al. 1999MNRAS.306..954), the following algorithms are used to compute the 00188 various errors. 00189 00190 R = rms of residual image 00191 P = fitted peak intensity 00192 S = P/R (signal to noise) 00193 00194 longitude error = (FWHM beam width in longitude direction)/(2*S) 00195 latitude error = (FWHM beam width in latitude direction)/(2*S) 00196 FWHM of major axis error = (FWHM beam along major axis)/S 00197 FWHM of minor axis error = (FWHM beam along minor axis)/S 00198 position angle error is calculated via standard error propogation of the FWHM major and minor axes sizes and errors 00199 flux error is computed via standard error propogation of the peak intensity and its error and the FWHM major 00200 and minor axes sizes and their errors. 00201 00202 In the case where the image has no beam, the pixel width is used as the diameter of the resolution element. 00203 00204 In the vast majority of (and perhaps all) cases, the errors reported come from the second method. 00205 00206 The deconvolved size and position angle errors are computed by taking the maximum of the absolute values of the 00207 differences of the best fit deconvolved value of the given parameter and the deconvolved size of the eight 00208 possible combinations of (FWHM major axis +/- major axis error), (FWHM minor axis +/- minor axis error), 00209 and (position andle +/- position angle error). 00210 00211 CAUTIONARY NOTES ON ERRORS 00212 imfit makes the following implicit assumptions: 00213 00214 1. The noise associated with the pixels it is given to fit is truly random and gaussian 00215 2. There is no offset (constant (unless one is fit), gradient, or more complex function) in pixel values. 00216 3. The things that are trying to be fit are bona-fide gaussians. 00217 00218 If any of these assumptions is not true, the errors reported will in general be lower limits. These 00219 assumptions do not hold if for example, there is structure in the noise of the image (eg the residual map produced 00220 by deconvolution has structure), the area being fit lies in a negative bowl, in extended emission, or on an image 00221 artifact (eg ripple), or the source(s) is nongaussian (eg a disk or more complex function convolved with a gaussian; 00222 just because something looks gaussian to the human image analysis system does not necessarily mean it is). 00223 In addition, in the case of an image produced from interferometric observations, the errors given are appropriate 00224 for good uv plane coverage. They may be a factor of two or more higher for sparse arrays or snapshots. 00225 In short, imfit is not a silver bullet for determining parameters in flawed images and reported errors 00226 should be interpreted cautiously in the vast majority of all "real life" cases. The closer the source being fit is to 00227 fulfilling these assumptions the more realistic reported errors will be. 00228 00229 EXAMPLE: 00230 00231 Here is how one might fit two gaussians to multiple channels of a cube using the fit 00232 from the previous channel as the initial estimate for the next. It also illustrates 00233 how one can specify a region in the associated continuum image as the region to use 00234 as the fit for the channel. 00235 00236 default imfit 00237 imagename = "co_cube.im" 00238 # specify region using region from continuum 00239 region = "continuum.im:source.rgn" 00240 chans = "2~20" 00241 # only use pixels with positive values in the fit 00242 excludepix = [-1e10,0] 00243 # estimates file contains initial parameters for two Gaussians in channel 2 00244 estimates = "initial_estimates.txt" 00245 logfile = "co_fit.log" 00246 # append results to the log file for all the channels 00247 append = "True" 00248 imfit() 00249 00250 00251 """ 00252 if not hasattr(self, "__globals__") or self.__globals__ == None : 00253 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00254 #casac = self.__globals__['casac'] 00255 casalog = self.__globals__['casalog'] 00256 #casalog = casac.casac.logsink() 00257 self.__globals__['__last_task'] = 'imfit' 00258 self.__globals__['taskname'] = 'imfit' 00259 ### 00260 self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__) 00261 ### 00262 ### 00263 #Handle globals or user over-ride of arguments 00264 # 00265 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00266 useLocalDefaults = False 00267 00268 for item in function_signature_defaults.iteritems(): 00269 key,val = item 00270 keyVal = eval(key) 00271 if (keyVal == None): 00272 #user hasn't set it - use global/default 00273 pass 00274 else: 00275 #user has set it - use over-ride 00276 if (key != 'self') : 00277 useLocalDefaults = True 00278 00279 myparams = {} 00280 if useLocalDefaults : 00281 for item in function_signature_defaults.iteritems(): 00282 key,val = item 00283 keyVal = eval(key) 00284 exec('myparams[key] = keyVal') 00285 self.parameters[key] = keyVal 00286 if (keyVal == None): 00287 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00288 keyVal = eval(key) 00289 if(type(keyVal) == dict) : 00290 if len(keyVal) > 0 : 00291 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00292 else : 00293 exec('myparams[key] = ' + key + ' = {}') 00294 00295 else : 00296 async = self.parameters['async'] 00297 myparams['imagename'] = imagename = self.parameters['imagename'] 00298 myparams['box'] = box = self.parameters['box'] 00299 myparams['region'] = region = self.parameters['region'] 00300 myparams['chans'] = chans = self.parameters['chans'] 00301 myparams['stokes'] = stokes = self.parameters['stokes'] 00302 myparams['mask'] = mask = self.parameters['mask'] 00303 myparams['includepix'] = includepix = self.parameters['includepix'] 00304 myparams['excludepix'] = excludepix = self.parameters['excludepix'] 00305 myparams['residual'] = residual = self.parameters['residual'] 00306 myparams['model'] = model = self.parameters['model'] 00307 myparams['estimates'] = estimates = self.parameters['estimates'] 00308 myparams['logfile'] = logfile = self.parameters['logfile'] 00309 myparams['append'] = append = self.parameters['append'] 00310 myparams['newestimates'] = newestimates = self.parameters['newestimates'] 00311 myparams['complist'] = complist = self.parameters['complist'] 00312 myparams['overwrite'] = overwrite = self.parameters['overwrite'] 00313 myparams['dooff'] = dooff = self.parameters['dooff'] 00314 myparams['offset'] = offset = self.parameters['offset'] 00315 myparams['fixoffset'] = fixoffset = self.parameters['fixoffset'] 00316 myparams['stretch'] = stretch = self.parameters['stretch'] 00317 00318 if type(includepix)==int: includepix=[includepix] 00319 if type(excludepix)==int: excludepix=[excludepix] 00320 00321 result = None 00322 00323 # 00324 # The following is work around to avoid a bug with current python translation 00325 # 00326 mytmp = {} 00327 00328 mytmp['imagename'] = imagename 00329 mytmp['box'] = box 00330 mytmp['region'] = region 00331 mytmp['chans'] = chans 00332 mytmp['stokes'] = stokes 00333 mytmp['mask'] = mask 00334 mytmp['includepix'] = includepix 00335 mytmp['excludepix'] = excludepix 00336 mytmp['residual'] = residual 00337 mytmp['model'] = model 00338 mytmp['estimates'] = estimates 00339 mytmp['logfile'] = logfile 00340 mytmp['append'] = append 00341 mytmp['newestimates'] = newestimates 00342 mytmp['complist'] = complist 00343 mytmp['overwrite'] = overwrite 00344 mytmp['dooff'] = dooff 00345 mytmp['offset'] = offset 00346 mytmp['fixoffset'] = fixoffset 00347 mytmp['stretch'] = stretch 00348 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00349 trec = casac.casac.utils().torecord(pathname+'imfit.xml') 00350 00351 casalog.origin('imfit') 00352 try : 00353 #if not trec.has_key('imfit') or not casac.casac.utils().verify(mytmp, trec['imfit']) : 00354 #return False 00355 00356 casac.casac.utils().verify(mytmp, trec['imfit'], True) 00357 scriptstr=[''] 00358 saveinputs = self.__globals__['saveinputs'] 00359 saveinputs('imfit', 'imfit.last', myparams, self.__globals__,scriptstr=scriptstr) 00360 if async : 00361 count = 0 00362 keybase = time.strftime("%y%m%d.%H%M%S") 00363 key = keybase + "_" + str(count) 00364 while self.__async__.has_key(key) : 00365 count += 1 00366 key = keybase + "_" + str(count) 00367 result = tm.execute('imfit', imagename, box, region, chans, stokes, mask, includepix, excludepix, residual, model, estimates, logfile, append, newestimates, complist, overwrite, dooff, offset, fixoffset, stretch) 00368 print "Use: " 00369 print " tm.retrieve(return_value) # to retrieve the status" 00370 print 00371 self.rkey = key 00372 self.__async__[key] = result 00373 else : 00374 tname = 'imfit' 00375 spaces = ' '*(18-len(tname)) 00376 casalog.post('\n##########################################'+ 00377 '\n##### Begin Task: ' + tname + spaces + ' #####') 00378 casalog.post(scriptstr[1][1:]+'\n', 'INFO') 00379 result = imfit(imagename, box, region, chans, stokes, mask, includepix, excludepix, residual, model, estimates, logfile, append, newestimates, complist, overwrite, dooff, offset, fixoffset, stretch) 00380 casalog.post('##### End Task: ' + tname + ' ' + spaces + ' #####'+ 00381 '\n##########################################') 00382 00383 except Exception, instance: 00384 if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) : 00385 raise 00386 else : 00387 #print '**** Error **** ',instance 00388 tname = 'imfit' 00389 casalog.post('An error occurred running task '+tname+'.', 'ERROR') 00390 pass 00391 00392 gc.collect() 00393 return result 00394 # 00395 # 00396 # 00397 def paramgui(self, useGlobals=True, ipython_globals=None): 00398 """ 00399 Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00400 """ 00401 import paramgui 00402 if not hasattr(self, "__globals__") or self.__globals__ == None : 00403 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00404 00405 if useGlobals: 00406 if ipython_globals == None: 00407 myf=self.__globals__ 00408 else: 00409 myf=ipython_globals 00410 00411 paramgui.setGlobals(myf) 00412 else: 00413 paramgui.setGlobals({}) 00414 00415 paramgui.runTask('imfit', myf['_ip']) 00416 paramgui.setGlobals({}) 00417 00418 # 00419 # 00420 # 00421 def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None): 00422 if not hasattr(self, "__globals__") or self.__globals__ == None : 00423 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00424 if ipython_globals == None: 00425 myf=self.__globals__ 00426 else: 00427 myf=ipython_globals 00428 00429 a = odict() 00430 a['imagename'] = '' 00431 a['box'] = '' 00432 a['region'] = '' 00433 a['chans'] = '' 00434 a['stokes'] = '' 00435 a['mask'] = '' 00436 a['includepix'] = [] 00437 a['excludepix'] = [] 00438 a['residual'] = '' 00439 a['model'] = '' 00440 a['estimates'] = '' 00441 a['logfile'] = '' 00442 a['newestimates'] = '' 00443 a['complist'] = '' 00444 a['dooff'] = False 00445 00446 a['async']=False 00447 a['mask'] = { 00448 0:odict([{'notvalue':''}, {'stretch':False}])} 00449 a['logfile'] = { 00450 0:odict([{'notvalue':''}, {'append':True}])} 00451 a['complist'] = { 00452 0:odict([{'notvalue':''}, {'overwrite':False}])} 00453 a['dooff'] = { 00454 0:odict([{'notvalue':False}, {'offset':0.0}, {'fixoffset':False}])} 00455 00456 ### This function sets the default values but also will return the list of 00457 ### parameters or the default value of a given parameter 00458 if(param == None): 00459 myf['__set_default_parameters'](a) 00460 elif(param == 'paramkeys'): 00461 return a.keys() 00462 else: 00463 if(paramvalue==None and subparam==None): 00464 if(a.has_key(param)): 00465 return a[param] 00466 else: 00467 return self.itsdefault(param) 00468 else: 00469 retval=a[param] 00470 if(type(a[param])==dict): 00471 for k in range(len(a[param])): 00472 valornotval='value' 00473 if(a[param][k].has_key('notvalue')): 00474 valornotval='notvalue' 00475 if((a[param][k][valornotval])==paramvalue): 00476 retval=a[param][k].copy() 00477 retval.pop(valornotval) 00478 if(subparam != None): 00479 if(retval.has_key(subparam)): 00480 retval=retval[subparam] 00481 else: 00482 retval=self.itsdefault(subparam) 00483 else: 00484 retval=self.itsdefault(subparam) 00485 return retval 00486 00487 00488 # 00489 # 00490 def check_params(self, param=None, value=None, ipython_globals=None): 00491 if ipython_globals == None: 00492 myf=self.__globals__ 00493 else: 00494 myf=ipython_globals 00495 # print 'param:', param, 'value:', value 00496 try : 00497 if str(type(value)) != "<type 'instance'>" : 00498 value0 = value 00499 value = myf['cu'].expandparam(param, value) 00500 matchtype = False 00501 if(type(value) == numpy.ndarray): 00502 if(type(value) == type(value0)): 00503 myf[param] = value.tolist() 00504 else: 00505 #print 'value:', value, 'value0:', value0 00506 #print 'type(value):', type(value), 'type(value0):', type(value0) 00507 myf[param] = value0 00508 if type(value0) != list : 00509 matchtype = True 00510 else : 00511 myf[param] = value 00512 value = myf['cu'].verifyparam({param:value}) 00513 if matchtype: 00514 value = False 00515 except Exception, instance: 00516 #ignore the exception and just return it unchecked 00517 myf[param] = value 00518 return value 00519 # 00520 # 00521 def description(self, key='imfit', subkey=None): 00522 desc={'imfit': 'Fit one or more elliptical Gaussian components on an image region(s)', 00523 'imagename': 'Name of the input image', 00524 'box': 'Specify one or more box regions for the fit.', 00525 'region': 'Region. See help par.region for specs.', 00526 'chans': 'Spectral channels on which to perform fit.', 00527 'stokes': 'Stokes parameter to fit. If blank, first stokes plane is used.', 00528 'mask': 'Mask to use. See help par.mask. Default is none.', 00529 'includepix': 'Range of pixel values to include for fitting.', 00530 'excludepix': 'Range of pixel values to exclude for fitting.', 00531 'residual': 'Name of output residual image.', 00532 'model': 'Name of output model image.', 00533 'estimates': 'Name of file containing initial estimates of component parameters.', 00534 'logfile': 'Name of file to write fit results.', 00535 'append': 'If logfile exists, append to it if True or overwrite it if False', 00536 'newestimates': 'File to write fit results which can be used as initial estimates for next run.', 00537 'complist': 'Name of output component list table.', 00538 'overwrite': 'Overwrite component list table if it exists?', 00539 'dooff': 'Also fit a zero level offset? Default is False', 00540 'offset': 'Initial estimate of zero-level offset. Only used if doff is True. Default is 0.0', 00541 'fixoffset': 'Keep the zero level offset fixed during fit? Default is False ', 00542 'stretch': 'Stretch the mask if necessary and possible? See help par.stretch ', 00543 00544 'async': 'If true the taskname must be started using imfit(...)' 00545 } 00546 00547 # 00548 # Set subfields defaults if needed 00549 # 00550 00551 if(desc.has_key(key)) : 00552 return desc[key] 00553 00554 def itsdefault(self, paramname) : 00555 a = {} 00556 a['imagename'] = '' 00557 a['box'] = '' 00558 a['region'] = '' 00559 a['chans'] = '' 00560 a['stokes'] = '' 00561 a['mask'] = '' 00562 a['includepix'] = [] 00563 a['excludepix'] = [] 00564 a['residual'] = '' 00565 a['model'] = '' 00566 a['estimates'] = '' 00567 a['logfile'] = '' 00568 a['append'] = True 00569 a['newestimates'] = '' 00570 a['complist'] = '' 00571 a['overwrite'] = False 00572 a['dooff'] = False 00573 a['offset'] = 0.0 00574 a['fixoffset'] = False 00575 a['stretch'] = False 00576 00577 #a = sys._getframe(len(inspect.stack())-1).f_globals 00578 00579 if self.parameters['mask'] != '': 00580 a['stretch'] = False 00581 00582 if self.parameters['logfile'] != '': 00583 a['append'] = True 00584 00585 if self.parameters['complist'] != '': 00586 a['overwrite'] = False 00587 00588 if self.parameters['dooff'] != False: 00589 a['offset'] = 0.0 00590 a['fixoffset'] = False 00591 00592 if a.has_key(paramname) : 00593 return a[paramname] 00594 imfit_cli = imfit_cli_()