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_specfit import specfit 00018 class specfit_cli_: 00019 __name__ = "specfit" 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__ = (specfit_cli_,) 00028 self.__doc__ = self.__call__.__doc__ 00029 00030 self.parameters={'imagename':None, 'box':None, 'region':None, 'chans':None, 'stokes':None, 'axis':None, 'mask':None, 'ngauss':None, 'poly':None, 'estimates':None, 'minpts':None, 'multifit':None, 'model':None, 'residual':None, 'amp':None, 'amperr':None, 'center':None, 'centererr':None, 'fwhm':None, 'fwhmerr':None, 'integral':None, 'integralerr':None, 'wantreturn':None, 'stretch':None, 'logresults':None, 'pampest':None, 'pcenterest':None, 'pfwhmest':None, 'pfix':None, 'gmncomps':None, 'gmampcon':None, 'gmcentercon':None, 'gmfwhmcon':None, 'gmampest':None, 'gmcenterest':None, 'gmfwhmest':None, 'gmfix':None, 'logfile':None, 'append':None, 'pfunc':None, 'goodamprange':None, 'goodcenterrange':None, 'goodfwhmrange':None, 'sigma':None, 'outsigma':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, axis=None, mask=None, ngauss=None, poly=None, estimates=None, minpts=None, multifit=None, model=None, residual=None, amp=None, amperr=None, center=None, centererr=None, fwhm=None, fwhmerr=None, integral=None, integralerr=None, wantreturn=None, stretch=None, logresults=None, pampest=None, pcenterest=None, pfwhmest=None, pfix=None, gmncomps=None, gmampcon=None, gmcentercon=None, gmfwhmcon=None, gmampest=None, gmcenterest=None, gmfwhmest=None, gmfix=None, logfile=None, append=None, pfunc=None, goodamprange=None, goodcenterrange=None, goodfwhmrange=None, sigma=None, outsigma=None, async=None): 00047 00048 """Fit 1-dimensional gaussians and/or polynomial models to an image or image region 00049 00050 This task simultaneously fits one or more gaussian singlets lorentzian singlets, gaussian multiplets, and/or a polynomial to one dimensional profiles. 00051 00052 ARAMETER SUMMARY 00053 imagename Name of the input (CASA, FITS, MIRIAD) image 00054 box Direction plane box specification, "blcx, blcy, trcx, trcy". Only one box 00055 may be specified. If not specified, region is used if specified. If region 00056 is also not specified, entire directional plane unioned with any chans and 00057 stokes specification determines the region. 00058 region Region of interest. See help par.region for possible specifications. 00059 chans Optional contiguous frequency channel number specification. Not used if 00060 region is specified. Default is all channels. 00061 stokes Contiguous stokes planes specification. Not used if region is specified. 00062 Default is all stokes. 00063 axis Axis along which to do the fit(s). <0 means use the spectral axis or the 00064 zeroth axis if a spectral axis is not present. 00065 mask Mask to use. See help par.mask. Default is none. 00066 stretch Stretch the input mask if necessary and possible? Only used if a mask is specified. 00067 See help par.stretch. 00068 ngauss Maximum number of gaussians to fit. 00069 poly Order of polynomial to fit. <0 means do not fit a polynomial. 00070 estimates Name of file containing initial gaussian estimates. 00071 minpts Minimum number of points necessary to attempt a fit. 00072 multifit Fit models at each pixel in region (true) or average profiles and fit a single model (false). 00073 model Name of model image to write. 00074 residual Name of residual image to write. 00075 amp Name of amplitude solution image. Default: do not write the image ("") 00076 amperr Name of amplitude solution error image. Default: do not write the image ("") 00077 center Name of center solution image. Default: do not write the image ("") 00078 centererr Name of center solution error image. Default: do not write the image ("") 00079 fwhm Name of fwhm solution image. Default: do not write the image ("") 00080 fwhmerr Name of fwhm solution error image. Default: do not write the image ("") 00081 integral Name of integral solution image. Default: do not write the image ("") 00082 integralerr Name of integral solution error image. Default: do not write the image ("") 00083 wantreturn If true, return a record summarizing the fit results, if false, return false. 00084 stretch Stretch the mask if necessary and possible? See help par.stretch 00085 logresults Output results to logger? 00086 pampest Initial estimate of PCF profile (gaussian or lorentzian) amplitudes. 00087 pcenterest Initial estimate PCF profile centers, in pixels. 00088 pfwhmest Initial estimate PCF profile FWHMs, in pixels. 00089 pfix PCF profile parameters to fix during fit. 00090 pfunc PCF singlet functions to fit. "gaussian" or "lorentzian" (minimal match supported). Unspecified means all gaussians. 00091 gmncomps Number of components in each Gaussian multiplet to fit. 00092 gmampcon The amplitude ratio constraints for non-reference components to reference component in gaussian multiplets. 00093 gmcentercon The center offset constraints (in pixels) for non-reference components to reference component in gaussian multiplets. 00094 gmfwhmcon The FWHM ratio constraints for non-reference components to reference component in gaussian multiplets. 00095 gmampest Initial estimate of individual gaussian amplitudes in gaussian multiplets. 00096 gmcenterest Initial estimate of individual gaussian centers in gaussian multiplets, in pixels. 00097 gmfwhmest Initial estimate of individual gaussian FWHMss in gaussian multiplets, in pixels. 00098 gmfix Parameters of individual gaussians in gaussian multiplets to fix during fit. 00099 logfile File in which to log results. Default is not to write a logfile. 00100 append Append results to logfile? Logfile must be specified. Default is to append. False means overwrite existing file if it exists. 00101 goodamprange Acceptable amplitude solution range. 0 => all amplitude solutions are acceptable. [0.0] => All amplitude solutions are acceptable. 00102 goodcenterrange Acceptable center solution range in pixels relative to region start. [0.0] => all center solutions are acceptable. 00103 goodfwhmrange Acceptable FWHM solution range in pixels. [0.0] => all FWHM solutions are acceptable. 00104 sigma Standard deviation array or image name. 00105 outsigma Name of output image used for standard deviation. Ignored if sigma is empty. 00106 00107 This task simultaneously fits one or more gaussian singlets, one or more lorentzian singlets, one or more gaussian multiplets, 00108 and/or a polynomial to one dimensional profiles. A gaussian/lorentzian singlet is a gaussian/lorentzian whose parameters (amplitude, 00109 center position, and width) are all independent from any other feature that may be simultaneously fit. A gaussian multiplet is a set of two or 00110 more gaussian lines in which at least one (and possibly two or three) parameter of each line is dependent on the parameter of another, 00111 single (reference) profile in the multiplet. For example, one can specify a doublet in which the amplitude of the first line is 0.6 times the 00112 amplitude of the zeroth line and/or the center of the first line is 20 pixels from the center of the zeroth line, and/or the fwhm of the first 00113 line is identical (in pixels) to that of the zeroth line. There is no limit to the number of components one can specify in a multiplet 00114 (except of course that the number of parameters to be fit should be significantly less than the number of data points), but there can be only 00115 a single reference profile in a multiplet to which to tie constraints of parameters of the other profiles in the set. 00116 00117 AXIS 00118 The axis parameter indicates on which axis profiles should be fit; a value <0 indicates the spectral axis should be used, or if one does not exist, 00119 that the zeroth axis should be used. 00120 00121 MINIMUM NUMBER OF PIXELS 00122 The minpts parameter indicates the minimum number of unmasked pixels that must be present in order for a fit 00123 to be attempted. When multifit=T, positions with too few good points will be masked in any output images. 00124 00125 ONE FIT OF REGION AVERAGE OR PIXEL BY PIXEL FIT 00126 The multifit parameter indicates if profiles should be fit at each pixel in the selected region (true), or if the profiles in that region should be 00127 averaged and the fit done to that average profile (false). 00128 00129 POLYNOMIAL FITTING 00130 The order of the polynomial to fit is specified only via the poly parameter. If poly<0, no polynomial will be fit. No initial estimates of 00131 coefficients can be specified; these are determined automatically. 00132 00133 GAUSSIAN SINGLET FITTING 00134 In the absence of an estimates file and no estimates being specified by the p*est parameters, and gmncomps=0 or is empty, the ngauss parameter 00135 indicates the maximum number of gaussian singlets that should be fit. The initial estimates of the parameters for these gaussians will be attempted 00136 automatically in this case. If it deems appropriate, the fitter will fit fewer than this number. In the case where an estimates file is supplied, 00137 ngauss is ignored (see below). ngauss is also ignored if the p*est parameters are specified or if gmncomps is not an empty array or, if an integer, 00138 is greater than zero. If estimates is not specified or the p*est parameters are not specified and ngauss=0, gmncomps is empty or 0, and poly<0, 00139 an error will occur as this indicates there is nothing to fit. 00140 00141 One can specify initial estimates of gaussian singlet parameters via an estimates file or the pampest, pcenterest, pfwhmest, and optionally, the 00142 pfix parameters. The latter is the recommended way to specify these estimates as support for estimates files may be deprecated in the future. No matter 00143 which option is used, an amplitude initial estimate must always be nonzero. A negative fwhm estimate will be silently changed to positve. 00144 00145 SPECIFYING INITIAL ESTIMATES FOR GAUSSIAN AND LORENTZIAN SINGLETS (RECOMMENDED METHOD) 00146 One may specify initial estimates via the pampest, pcenterest, and pfwhmest parameters. In the case of a single gaussian or lorentzian singlet, 00147 these parameters can be numbers. pampest must be specified in image brightness units, pcenterest must be given in the number of pixels from the 00148 zeroth pixel, and pfwhmest must be given in pixels. Optionally pfix can be specified and in the case of a single gaussian or lorentzian singlet 00149 can be a string. In it is coded which parameters should be held constant during the fix. Any combination of "p" (amplitude), "c" (center), or "f" 00150 (fwhm) is allowed; eg pfix="pc" means fix both the amplitude and center during the fit. In the case of more than one gaussian and/or lorentzian 00151 singlets, these parameters must be specified as arrays of numbers. The length of the arrays indicates the number of singlets to fit and must be 00152 the same for all the p*est parameters. 00153 00154 If no parameters are to be fixed for any of the singlets, pfix can be set to the empty string. However, if at least one parameter of one singlet 00155 is to be fixed, pfix must be an array of strings and have a length equal to the p*est arrays. Singlets which are not to have any parameters fixed 00156 should be represented as an empty string in the pfix array. So, for example, if one desires to fit three singlets and fix the fwhm of the middle 00157 one, one must specify pfix=["", "f", ""], the empty strings indicating no parameters of the zeroth and second singlet should be held constant. 00158 00159 In the case of multifit=True, the initial estimates, whether from the p*est parameters or from a file (see below), will be applied to the location 00160 of the first fit. This is normally the bottom left corner of the region selected. If masked, not enough good points to perform a fit, or the 00161 attempted fit fails, the fitting proceeds to the next pixel with the pixel value of the lowest numbered axis changing the fastest. Once a 00162 successful fit has been performed, subsequent fits will use the results of a fit for a nearest pixel for which a previous fit was successful as the 00163 initial estimate for the parameters at the current location. The fixed parameter string will be honored for every fit performed when multifit=True. 00164 00165 One specifies what type of PCF profile to fit via the pfunc parameter. A PCF function is one that can be parameterized by a peak, center, and FWHM, 00166 as both gaussian and lorentzian singlets can. If all singlets to be fit are gaussians, one can set pfunc equal to the empty string and all snglets 00167 will be assumed to be gaussians. If at least one lorentzian is to be fit, pfunc must be specified as a string (in the case of a single singlet) or 00168 an array of strings (in the case of multiple singlets). The position of each string corresponds to the positions of the initial estimates in the 00169 p*est and pfix arrays. Minimal match ("g", "G", "l", or "L") is supported. So, if one wanted to simultaneously fit two gaussian and two lorentzian 00170 singlets, the zeroth and last of which were lorentzians, one would specify pfunc=["L", "G", "G", "L"]. 00171 00172 ESTIMATES FILE FOR GAUSSIAN SINGLETS (NONRECOMMENDED METHOD) 00173 Initial estimates for gaussian singlets can be specified in an estimates file. Estimates files may be deprecated in the future in favor of the 00174 p*est parameters, so it is recommended users use those parameters instead. If an estimates file is desired to be used, the p*est parameters 00175 must be 0 or empty and mgncomps must be 0 or empty. Only gaussian singlets can be specified in an estimates file. If one desires to fit one or 00176 more gaussian multiplets and/or one or more lorentzian singlets simultaneously, the p*est parameters must be used to specify the initial parameters 00177 of all gaussian singlets to fit; one cannot use an estimates file in this case. If an estimates file is specified, a polynomial 00178 can be fit simultaneously by specifying the poly parameter. The estimates file must contain initial estimates of parameters 00179 for all gaussian singlets to be fit. The number of gaussian singlets to fit is gotten from the number of estimates in the file. The file can contain 00180 comments which are indicated by a "#" at the beginning of a line. All non-comment lines will be interpreted as initial estimates. The 00181 format of such a line is 00182 00183 [peak intensity], [center], [fwhm], [optional fixed parameter string] 00184 00185 The first three values are required and must be numerical values. The peak intensity must be expressed in image brightness units, while the 00186 center must be specified in pixels offset from the zeroth pixel, and fwhm must be specified in pixels. The fourth value is optional and if present, 00187 represents the parameter(s) that should be held constant during the fit. Any combination of the characters 'p' (peak), 'c' (center), and 'f' (fwhm) are 00188 permitted, eg "fc" means hold the fwhm and the center constant during the fit. Fixed parameters will have no error associated with them. Here is an 00189 example file: 00190 00191 # estimates file indicating that two gaussians should be fit 00192 # first guassian estimate, peak=40, center at pixel number 10.5, fwhm = 5.8 pixels, all parameters allowed to vary during 00193 # fit 00194 40, 10.5, 5.8 00195 # second gaussian, peak = 4, center at pixel number 90.2, fwhm = 7.2 pixels, hold fwhm constant 00196 4, 90.2, 7.2, f 00197 # end file 00198 00199 GAUSSIAN MULTIPLET FITTING 00200 Any number of gaussian multiplets, each containing any number of two or more components, can be simultaneously fit, optionally with a 00201 polynomial and/or any number of gaussian and/or lorentzian singlets, the only caveat being that the number of parameters to be fit should be 00202 significantly less than the number of data points. The gmncomps parameter indicates the number of multiplets to fit and the number of 00203 components in each multiplet. In the case of a single multiplet, an integer (>1) can be specified. For example, mgncomps=4 means fit a 00204 single quadruplet of gaussians. In the case of 2 or more multiplets, and array of integers (all >1) must be specified. For example, 00205 gmncomps=[2, 4, 3] means 3 seperate multiples are to be fit, the zeroth being a doublet, the first being a quadruplet, and the second 00206 being a triplet. 00207 00208 Initial estimates of all gaussians in all multiplets are specified via the gm*est parameters which must be arrays of numbers. The order 00209 starts with the zeroth component of the zeroth multiplet to the last component of the zeroth multiplet, then the zeroth component of 00210 the first multiplet to the last compoenent of the first multiplet, etc to the zeroth component of the last multiplet to the last 00211 element of the last multiplet. The zeroth element of a multiplet is defined as the reference component of that multiplet and has the special 00212 significance that it is the profile to which all constraints of all other profiles in that multiplet are referenced (see below). So, 00213 in our example of gmncomps=[2, 4, 3], gmampest, gmcenterest, and gmfwhmest must each be nine (the total number of individual gaussian 00214 profiles summed over all multiplets) element arrays. The zeroth, second, and sixth elements represent parameters of the reference profiles 00215 in the zeroth, first, and second multiplet, respectively. 00216 00217 The fixed relationships between the non-reference profile(s) and the reference profile of a multiplet are specified via the gmampcon, 00218 gmcentercon, and gmfwhmcon parameters. At least one, and any combination, of constraints can be specified for any non-reference 00219 component of a multiplet. The amplitude ratio of a non-reference line to that of the reference line is set in gmampcon. The ratio of 00220 the fwhm of a non-reference line to that of the reference line is set in gmfwhmcon. The offset in pixels of the center position of 00221 a non-reference line to that of the reference line is set in gmcentercon. In the case where a parameter is not constrained for any 00222 non-reference line of any multiplet, the value of the associated parameter must be 0. In the case of 00223 a single doublet, a constraint may be specified as a number or an array of a single number. For example, mgncomps=2 and gmampcon=0.65 00224 and gmcentercon=[32.4] means there is a single doublet to fit where the amplitude ratio of the first to the zeroth line is constained 00225 to be 0.65 and the center of the first line is constrained to be offset by 32.4 pixels from the center of the zeroth line. In cases 00226 of a total of three or more gaussians, the constraints parameters must be specified as arrays with lengths equal to the total number 00227 of gaussians summed over all multiplets minus the number of reference lines (one per multiplet, or just number of multiplets, since 00228 reference lines cannot be constrained by themselves). In the cases where an array must be specified but a component in that array 00229 does not have that constraint, 0 should be specified. Here's an example 00230 00231 gmncomps=[2, 4, 3] 00232 gmampcon= [ 0 , 0.2, 0 , 0.1, 4.5, 0 ] 00233 gcentercon=[24.2, 45.6, 92.7, 0 , -22.8, -33.5] 00234 gfwhmcon="" 00235 00236 In this case we have our previous example of one doublet, one quadruplet, and one triplet. The first component of the doublet has the constraint 00237 that its center is offset by 24.2 pixels from the zeroth (reference) component. The first component of the quadruplet is constrained to have 00238 an amplitude of 0.2 times that of the quadruplet's zeroth component and its center is constrained to be offset by 45.6 pixels from the 00239 reference component. The second component of the quadruplet is constained to have its center offset by 92.7 pixels from the associated 00240 reference component and the third component is constrained to have an amplitude of 0.1 times that of the associated reference component. 00241 The first component of the triplet is constrained to have an amplitude of 4.5 times that of its associated reference component and its center 00242 is constrained to be offset by -22.8 pixels from the reference component's center. The second component of the triplet is constrained to have 00243 its center offset by -33.5 pixels from the center of the reference component. No lines have FWHM constraints, so the empty string can be given 00244 for that parameter. Note that using 0 to indicate no constraint for line center means that one cannot specify a line centered at the same 00245 position as the reference component but having a different FWHM from the reference component. If you must specify this very unusual case, 00246 try using a very small positive (or even negative) value for the center constraint. 00247 00248 Note that when a parameter for a line is constrained, the corresponding value for that component in the corresponding gm*est array is 00249 ignored and the value of the constrained parameter is automatically used instead. So let's say, for our example above, we had specified 00250 the following estimates: 00251 00252 gmampest = [ 1, .2, 2, .1, .1, .5, 3, 2, 5] 00253 gmcenterest = [20, 10 , 30, 45.2, 609 , -233, 30, -859, 1] 00254 00255 Before any fitting is done, the constraints would be taken into account and these arrays would be implicitly rewritten as: 00256 00257 gmampest = [ 1, .2, 2, .4, .1, .2, 3, 13.5, 5 ] 00258 gmcenterest = [20, 44.2, 30, 75.6, 127.7, -233, 30, 7.2, -3.5] 00259 00260 The value of gmfwhmest would be unchanged since there are no FWHM constraints in this example. 00261 00262 In addition to be constrained by values of the reference component, parameters of individual components can be fixed. Fixed parameters 00263 are specified via the gmfix parameter. If no parameters are to be fixed, gmfix can be specified as the empty string or a zero element 00264 array. In the case where any parameter is to be fixed, gmfix must be specified as an array of strings with length equal to the total number of 00265 components summed over all multiplets. These strings encode which parameters to be fixed for the corresponding components. If 00266 a component is to have no parameters fixed, an empty string is used. In other cases one or more of any combination of parameters can 00267 be fixed using "p", "c", and/or "f" described above for fixing singlet parameters. There are a couople of special cases 00268 to be aware of. In the case where a non-reference component parameter is constrained and the corresponding reference component parameter is 00269 set as fixed, that parameter in the non-reference parameter will automatically be fixed even if it was specified not to be fixed in 00270 the gmfix array. This is the only way the constraint can be honored afterall. In the converse case of when a constrained parameter of a 00271 non-reference component is specified as fixed, but the corresponding parameter in the reference component is not specified to be fixed, 00272 an error will occur. Fixing an unconstrained parameter in a non-reference component is always legal as is fixing any combination of 00273 parameters in a reference component (with the above caveat that corresponding constrained parameters in non-reference components will 00274 be silently held fixed as well). 00275 00276 The same rules that apply to singlets when multifit=True apply to multiplets. 00277 00278 LIMITING RANGES FOR SOLUTION PARAMETERS 00279 In cases of low (or no) signal to noise spectra, it is still possible for the fit to converge, but often to a 00280 nonsensical solution. The astronomer can use her knowledge of the source to filter out obviously bogus solutions. 00281 One can limit the ranges of solution parameters to known "good" values via the goodamprange, goodcenterrange, and goodfwhmrange 00282 parameters. Any combination can be specified and the limit constraints will be ANDed together. The ranges apply to all PCF components 00283 that might be fit; choosing ranges on a component by component basis is not supported. If specified, 00284 an array of exactly two numerical values must be given to indicate the range of acceptable solution values for 00285 that parameter. goodamprange is expressed in terms of image brightness units. goodcenterrange is expressed in terms of pixels 00286 from the zeroth pixel in the specified region. goodfwhmrange is expressed in terms of pixels (only non-negative values should be 00287 given for FWHM range endpoints). In the case of a multiple-PCF fit, if any of the corresponding solutions are outside the specified 00288 ranges, the entire solution is considered to be invalid. 00289 00290 In addition, solutions for which the absolute value of the ratio of the amplitude error to the amplitude exceeds 100 or the 00291 ratio of the FWHM error to the FWHM exceeds 100 are automatically marked as invalid. 00292 00293 INCLUDING STANDARD DEVIATIONS OF PIXEL VALUES 00294 If the standard deviations of the pixel values in the input image are known and they vary in the image (eg they are higher for pixels 00295 near the edge of the band), they can be included in the sigma parameter. This parameter takes either an array or an image name. The 00296 array or image must have one of three shapes: 1. the shape of the input image, 2. the same dimensions as the input image with the lengths 00297 of all axes being one except for the fit axis which must have length corresponding to its length in the input image, or 3. be one 00298 dimensional with lenght equal the the length of the fit axis in the input image. In cases 2 and 3, the array or pixels in sigma will 00299 be replicated such that the image that is ultimately used is the same shape as the input image. The values of sigma must be non-negative. 00300 It is only the relative values that are important. A value of 0 means that pixel should not be used in the fit. Other than that, if pixel 00301 A has a higher standard deviation than pixel B, then pixel A is noisier than pixel B and will receive a lower weight when the fit is done. 00302 The weight of a pixel is the usual 00303 00304 weight = 1/(sigma*sigma) 00305 00306 In the case of multifit=F, the sigma values at each pixel along the fit axis in the hyperplane perpendicular to the fit axis which includes 00307 that pixel are averaged and the resultant averaged standard deviation spectrum is the one used in the fit. Internally, sigma values are normalized 00308 such that the maximum value is 1. This mitigates a known overflow issue. 00309 00310 One can write the normalized standard deviation image used in the fit but specifying its name in outsigma. This image can then be 00311 used as sigma for subsequent runs. 00312 00313 RETURNED DICTIONARY STRUCTURE 00314 The dictionary returned (if wantreturn=True) has a (necessarily) complex structure. First, there are keys "xUnit" and "yUnit" whose values are 00315 the abscissa unit and the ordinate unit described by simple strings. Next there are arrays giving a broad overview of the 00316 fit quality. These arrays have the shape of the specified region collapsed along the fit axis with the axis corresponding to the fit 00317 axis having length of 1: 00318 00319 attempted: a boolean array indicating which fits were attempted (eg if too few unmasked points, a fit will not be attempted). 00320 converged: a boolean array indicating which fits converged. False if the fit was not attempted. 00321 valid: a boolean array indicating which solutions fall within the specified valid ranges of parameter space 00322 niter: an int array indicating the number of iterations for each profile, <0 if the fit did not converge 00323 ncomps: the number of components (gaussian singlets + lorentzian singlets + gaussian multiplets + polynomial) fit for the profile, 00324 <0 if the fit did not converge 00325 00326 There is a "type" array having number of dimensions equal to the number of dimensions in the above arrays plus one. The shape of 00327 the first n-1 dimensions is the same as the shape of the above arrays. The length of the last dimension is equal to the number of 00328 components fit. The values of this array are strings describing the components that were fit at each possition ("POLYNOMIAL", 00329 "GAUSSIAN" in the case of gaussian singlets, "LORENTZIAN" in the case of lorentzian singlets, and ""GAUSSIAN MULTPLET"). 00330 00331 If any gaussian singlets were fit, there will be a subdictionary accessible via the "gs" key which will have subkeys "amp", "ampErr", "center", 00332 "centerErr", "fwhm", "fwhmErr, "integral", and "integralErr". Each of these arrays will have one more dimension than the overview arrays described 00333 above. The shape of the first n-1 dimensions will be the same as the shape of the arrays described above, while the final dimension will 00334 have length equal to the maximum number of gaussian singlets that were fit. Along this axis will be the 00335 corresponding fit result or associated error (depending on the array's associated key) of the fit for that singlet component number. In cases where 00336 the fit did not converge, or that particular component was excluded from the fit, a value of NAN will be present. 00337 00338 If any lorentzian singlets were fit, their solutions will be accessible via the "ls" key. These arrays follow the same rules 00339 as the "gs" arrays described above. 00340 00341 If any gaussian multiplets were fit, there will be subdictionaries accessible by keys "gm0", "gm1", ..., "gm{n-1}" where n is the number of gaussian 00342 muliplets that were fit. Each of these dictionaries will have the same arrays described above for gaussian singlets. The last dimension 00343 will have length equal to the number of components in that particular multiplet. Each pixel along the last axis will be the parameter solution 00344 value or error for that component number in the multiplet, eg the zeroth pixel along that axis contains 00345 the parameter solution or error for the reference component of the multiplet. 00346 00347 The polynomial coefficient solutions and errors are not returned, although they are logged. 00348 00349 OUTPUT IMAGES 00350 In addition to the returned dictionary, optionally one or more of any combination of output images can be written. 00351 The model and residual parameters indicate the names of the model and residual images to be written; blank values inidcate that these images 00352 should not be written. 00353 00354 One can also write none, any or all of the solution and error images for gaussian singlet, lorentzian singlet, and gaussian multiplet fits 00355 via the parameters amp, amperr, center, centererr, fwhm, fwhmerr, integral, and integralerr when doing multi-pixel fits. These images simply 00356 contain the arrays described for the associated parameter solutions or errors described in previous sections. In the case of lorentzian 00357 singlets, "_ls" is appended to the image names, in the case of gaussian multiplets, "_gm0", "_gm1", etc are appended to the image names to 00358 distinguish each multiplet. Pixels for which fits were not attempted or did not converge will be masked as bad. The last axis of these images 00359 is a linear axis and repesents component number (and is named accordingly). 00360 00361 Writing analogous images for polynomial coefficients is not supported. 00362 00363 EXAMPLE 00364 res = specif(imagename="myspectrum.im", ngauss=2, box="3,3,4,5", poly=2, multifit=true, wantreturn=True) 00365 00366 """ 00367 if not hasattr(self, "__globals__") or self.__globals__ == None : 00368 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00369 #casac = self.__globals__['casac'] 00370 casalog = self.__globals__['casalog'] 00371 #casalog = casac.casac.logsink() 00372 self.__globals__['__last_task'] = 'specfit' 00373 self.__globals__['taskname'] = 'specfit' 00374 ### 00375 self.__globals__['update_params'](func=self.__globals__['taskname'],printtext=False,ipython_globals=self.__globals__) 00376 ### 00377 ### 00378 #Handle globals or user over-ride of arguments 00379 # 00380 function_signature_defaults=dict(zip(self.__call__.func_code.co_varnames,self.__call__.func_defaults)) 00381 useLocalDefaults = False 00382 00383 for item in function_signature_defaults.iteritems(): 00384 key,val = item 00385 keyVal = eval(key) 00386 if (keyVal == None): 00387 #user hasn't set it - use global/default 00388 pass 00389 else: 00390 #user has set it - use over-ride 00391 if (key != 'self') : 00392 useLocalDefaults = True 00393 00394 myparams = {} 00395 if useLocalDefaults : 00396 for item in function_signature_defaults.iteritems(): 00397 key,val = item 00398 keyVal = eval(key) 00399 exec('myparams[key] = keyVal') 00400 self.parameters[key] = keyVal 00401 if (keyVal == None): 00402 exec('myparams[key] = '+ key + ' = self.itsdefault(key)') 00403 keyVal = eval(key) 00404 if(type(keyVal) == dict) : 00405 if len(keyVal) > 0 : 00406 exec('myparams[key] = ' + key + ' = keyVal[len(keyVal)-1][\'value\']') 00407 else : 00408 exec('myparams[key] = ' + key + ' = {}') 00409 00410 else : 00411 async = self.parameters['async'] 00412 myparams['imagename'] = imagename = self.parameters['imagename'] 00413 myparams['box'] = box = self.parameters['box'] 00414 myparams['region'] = region = self.parameters['region'] 00415 myparams['chans'] = chans = self.parameters['chans'] 00416 myparams['stokes'] = stokes = self.parameters['stokes'] 00417 myparams['axis'] = axis = self.parameters['axis'] 00418 myparams['mask'] = mask = self.parameters['mask'] 00419 myparams['ngauss'] = ngauss = self.parameters['ngauss'] 00420 myparams['poly'] = poly = self.parameters['poly'] 00421 myparams['estimates'] = estimates = self.parameters['estimates'] 00422 myparams['minpts'] = minpts = self.parameters['minpts'] 00423 myparams['multifit'] = multifit = self.parameters['multifit'] 00424 myparams['model'] = model = self.parameters['model'] 00425 myparams['residual'] = residual = self.parameters['residual'] 00426 myparams['amp'] = amp = self.parameters['amp'] 00427 myparams['amperr'] = amperr = self.parameters['amperr'] 00428 myparams['center'] = center = self.parameters['center'] 00429 myparams['centererr'] = centererr = self.parameters['centererr'] 00430 myparams['fwhm'] = fwhm = self.parameters['fwhm'] 00431 myparams['fwhmerr'] = fwhmerr = self.parameters['fwhmerr'] 00432 myparams['integral'] = integral = self.parameters['integral'] 00433 myparams['integralerr'] = integralerr = self.parameters['integralerr'] 00434 myparams['wantreturn'] = wantreturn = self.parameters['wantreturn'] 00435 myparams['stretch'] = stretch = self.parameters['stretch'] 00436 myparams['logresults'] = logresults = self.parameters['logresults'] 00437 myparams['pampest'] = pampest = self.parameters['pampest'] 00438 myparams['pcenterest'] = pcenterest = self.parameters['pcenterest'] 00439 myparams['pfwhmest'] = pfwhmest = self.parameters['pfwhmest'] 00440 myparams['pfix'] = pfix = self.parameters['pfix'] 00441 myparams['gmncomps'] = gmncomps = self.parameters['gmncomps'] 00442 myparams['gmampcon'] = gmampcon = self.parameters['gmampcon'] 00443 myparams['gmcentercon'] = gmcentercon = self.parameters['gmcentercon'] 00444 myparams['gmfwhmcon'] = gmfwhmcon = self.parameters['gmfwhmcon'] 00445 myparams['gmampest'] = gmampest = self.parameters['gmampest'] 00446 myparams['gmcenterest'] = gmcenterest = self.parameters['gmcenterest'] 00447 myparams['gmfwhmest'] = gmfwhmest = self.parameters['gmfwhmest'] 00448 myparams['gmfix'] = gmfix = self.parameters['gmfix'] 00449 myparams['logfile'] = logfile = self.parameters['logfile'] 00450 myparams['append'] = append = self.parameters['append'] 00451 myparams['pfunc'] = pfunc = self.parameters['pfunc'] 00452 myparams['goodamprange'] = goodamprange = self.parameters['goodamprange'] 00453 myparams['goodcenterrange'] = goodcenterrange = self.parameters['goodcenterrange'] 00454 myparams['goodfwhmrange'] = goodfwhmrange = self.parameters['goodfwhmrange'] 00455 myparams['sigma'] = sigma = self.parameters['sigma'] 00456 myparams['outsigma'] = outsigma = self.parameters['outsigma'] 00457 00458 if type(gmampest)==float: gmampest=[gmampest] 00459 if type(gmcenterest)==float: gmcenterest=[gmcenterest] 00460 if type(gmfwhmest)==float: gmfwhmest=[gmfwhmest] 00461 if type(goodamprange)==float: goodamprange=[goodamprange] 00462 if type(goodcenterrange)==float: goodcenterrange=[goodcenterrange] 00463 if type(goodfwhmrange)==float: goodfwhmrange=[goodfwhmrange] 00464 00465 result = None 00466 00467 # 00468 # The following is work around to avoid a bug with current python translation 00469 # 00470 mytmp = {} 00471 00472 mytmp['imagename'] = imagename 00473 mytmp['box'] = box 00474 mytmp['region'] = region 00475 mytmp['chans'] = chans 00476 mytmp['stokes'] = stokes 00477 mytmp['axis'] = axis 00478 mytmp['mask'] = mask 00479 mytmp['ngauss'] = ngauss 00480 mytmp['poly'] = poly 00481 mytmp['estimates'] = estimates 00482 mytmp['minpts'] = minpts 00483 mytmp['multifit'] = multifit 00484 mytmp['model'] = model 00485 mytmp['residual'] = residual 00486 mytmp['amp'] = amp 00487 mytmp['amperr'] = amperr 00488 mytmp['center'] = center 00489 mytmp['centererr'] = centererr 00490 mytmp['fwhm'] = fwhm 00491 mytmp['fwhmerr'] = fwhmerr 00492 mytmp['integral'] = integral 00493 mytmp['integralerr'] = integralerr 00494 mytmp['wantreturn'] = wantreturn 00495 mytmp['stretch'] = stretch 00496 mytmp['logresults'] = logresults 00497 mytmp['pampest'] = pampest 00498 mytmp['pcenterest'] = pcenterest 00499 mytmp['pfwhmest'] = pfwhmest 00500 mytmp['pfix'] = pfix 00501 mytmp['gmncomps'] = gmncomps 00502 mytmp['gmampcon'] = gmampcon 00503 mytmp['gmcentercon'] = gmcentercon 00504 mytmp['gmfwhmcon'] = gmfwhmcon 00505 mytmp['gmampest'] = gmampest 00506 mytmp['gmcenterest'] = gmcenterest 00507 mytmp['gmfwhmest'] = gmfwhmest 00508 mytmp['gmfix'] = gmfix 00509 mytmp['logfile'] = logfile 00510 mytmp['append'] = append 00511 mytmp['pfunc'] = pfunc 00512 mytmp['goodamprange'] = goodamprange 00513 mytmp['goodcenterrange'] = goodcenterrange 00514 mytmp['goodfwhmrange'] = goodfwhmrange 00515 mytmp['sigma'] = sigma 00516 mytmp['outsigma'] = outsigma 00517 pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/' 00518 trec = casac.casac.utils().torecord(pathname+'specfit.xml') 00519 00520 casalog.origin('specfit') 00521 try : 00522 #if not trec.has_key('specfit') or not casac.casac.utils().verify(mytmp, trec['specfit']) : 00523 #return False 00524 00525 casac.casac.utils().verify(mytmp, trec['specfit'], True) 00526 scriptstr=[''] 00527 saveinputs = self.__globals__['saveinputs'] 00528 saveinputs('specfit', 'specfit.last', myparams, self.__globals__,scriptstr=scriptstr) 00529 if async : 00530 count = 0 00531 keybase = time.strftime("%y%m%d.%H%M%S") 00532 key = keybase + "_" + str(count) 00533 while self.__async__.has_key(key) : 00534 count += 1 00535 key = keybase + "_" + str(count) 00536 result = tm.execute('specfit', imagename, box, region, chans, stokes, axis, mask, ngauss, poly, estimates, minpts, multifit, model, residual, amp, amperr, center, centererr, fwhm, fwhmerr, integral, integralerr, wantreturn, stretch, logresults, pampest, pcenterest, pfwhmest, pfix, gmncomps, gmampcon, gmcentercon, gmfwhmcon, gmampest, gmcenterest, gmfwhmest, gmfix, logfile, append, pfunc, goodamprange, goodcenterrange, goodfwhmrange, sigma, outsigma) 00537 print "Use: " 00538 print " tm.retrieve(return_value) # to retrieve the status" 00539 print 00540 self.rkey = key 00541 self.__async__[key] = result 00542 else : 00543 tname = 'specfit' 00544 spaces = ' '*(18-len(tname)) 00545 casalog.post('\n##########################################'+ 00546 '\n##### Begin Task: ' + tname + spaces + ' #####') 00547 casalog.post(scriptstr[1][1:]+'\n', 'INFO') 00548 result = specfit(imagename, box, region, chans, stokes, axis, mask, ngauss, poly, estimates, minpts, multifit, model, residual, amp, amperr, center, centererr, fwhm, fwhmerr, integral, integralerr, wantreturn, stretch, logresults, pampest, pcenterest, pfwhmest, pfix, gmncomps, gmampcon, gmcentercon, gmfwhmcon, gmampest, gmcenterest, gmfwhmest, gmfix, logfile, append, pfunc, goodamprange, goodcenterrange, goodfwhmrange, sigma, outsigma) 00549 casalog.post('##### End Task: ' + tname + ' ' + spaces + ' #####'+ 00550 '\n##########################################') 00551 00552 except Exception, instance: 00553 if(self.__globals__.has_key('__rethrow_casa_exceptions') and self.__globals__['__rethrow_casa_exceptions']) : 00554 raise 00555 else : 00556 #print '**** Error **** ',instance 00557 tname = 'specfit' 00558 casalog.post('An error occurred running task '+tname+'.', 'ERROR') 00559 pass 00560 00561 gc.collect() 00562 return result 00563 # 00564 # 00565 # 00566 def paramgui(self, useGlobals=True, ipython_globals=None): 00567 """ 00568 Opens a parameter GUI for this task. If useGlobals is true, then any relevant global parameter settings are used. 00569 """ 00570 import paramgui 00571 if not hasattr(self, "__globals__") or self.__globals__ == None : 00572 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00573 00574 if useGlobals: 00575 if ipython_globals == None: 00576 myf=self.__globals__ 00577 else: 00578 myf=ipython_globals 00579 00580 paramgui.setGlobals(myf) 00581 else: 00582 paramgui.setGlobals({}) 00583 00584 paramgui.runTask('specfit', myf['_ip']) 00585 paramgui.setGlobals({}) 00586 00587 # 00588 # 00589 # 00590 def defaults(self, param=None, ipython_globals=None, paramvalue=None, subparam=None): 00591 if not hasattr(self, "__globals__") or self.__globals__ == None : 00592 self.__globals__=sys._getframe(len(inspect.stack())-1).f_globals 00593 if ipython_globals == None: 00594 myf=self.__globals__ 00595 else: 00596 myf=ipython_globals 00597 00598 a = odict() 00599 a['imagename'] = '' 00600 a['box'] = '' 00601 a['region'] = '' 00602 a['chans'] = '' 00603 a['stokes'] = '' 00604 a['axis'] = -1 00605 a['mask'] = '' 00606 a['poly'] = -1 00607 a['estimates'] = '' 00608 a['minpts'] = 0 00609 a['multifit'] = False 00610 a['model'] = '' 00611 a['residual'] = '' 00612 a['wantreturn'] = True 00613 a['logresults'] = True 00614 a['gmncomps'] = 0 00615 a['gmampcon'] = '' 00616 a['gmcentercon'] = '' 00617 a['gmfwhmcon'] = '' 00618 a['gmampest'] = [0.0] 00619 a['gmcenterest'] = [0.0] 00620 a['gmfwhmest'] = [0.0] 00621 a['gmfix'] = '' 00622 a['logfile'] = '' 00623 a['goodamprange'] = [0.0] 00624 a['goodcenterrange'] = [0.0] 00625 a['goodfwhmrange'] = [0.0] 00626 a['sigma'] = '' 00627 00628 a['async']=False 00629 a['mask'] = { 00630 0:odict([{'notvalue':''}, {'stretch':False}])} 00631 a['estimates'] = { 00632 0:odict([{'value':''}, {'ngauss':1}, {'pampest':''}, {'pcenterest':''}, {'pfwhmest':''}, {'pfix':''}, {'pfunc':''}])} 00633 a['multifit'] = { 00634 0:odict([{'value':True}, {'amp':""}, {'amperr':""}, {'center':""}, {'centererr':""}, {'fwhm':""}, {'fwhmerr':""}, {'integral':""}, {'integralerr':""}])} 00635 a['gmncomps'] = { 00636 0:odict([{'notvalue':0}, {'gmampcon':''}, {'gmcentercon':''}, {'gmfwhmcon':''}, {'gmampest':0.0}, {'gmcenterest':0.0}, {'gmfwhmest':0.0}, {'gmfix':''}])} 00637 a['logfile'] = { 00638 0:odict([{'notvalue':''}, {'append':True}])} 00639 a['sigma'] = { 00640 0:odict([{'notvalue':''}, {'outsigma':''}])} 00641 00642 ### This function sets the default values but also will return the list of 00643 ### parameters or the default value of a given parameter 00644 if(param == None): 00645 myf['__set_default_parameters'](a) 00646 elif(param == 'paramkeys'): 00647 return a.keys() 00648 else: 00649 if(paramvalue==None and subparam==None): 00650 if(a.has_key(param)): 00651 return a[param] 00652 else: 00653 return self.itsdefault(param) 00654 else: 00655 retval=a[param] 00656 if(type(a[param])==dict): 00657 for k in range(len(a[param])): 00658 valornotval='value' 00659 if(a[param][k].has_key('notvalue')): 00660 valornotval='notvalue' 00661 if((a[param][k][valornotval])==paramvalue): 00662 retval=a[param][k].copy() 00663 retval.pop(valornotval) 00664 if(subparam != None): 00665 if(retval.has_key(subparam)): 00666 retval=retval[subparam] 00667 else: 00668 retval=self.itsdefault(subparam) 00669 else: 00670 retval=self.itsdefault(subparam) 00671 return retval 00672 00673 00674 # 00675 # 00676 def check_params(self, param=None, value=None, ipython_globals=None): 00677 if ipython_globals == None: 00678 myf=self.__globals__ 00679 else: 00680 myf=ipython_globals 00681 # print 'param:', param, 'value:', value 00682 try : 00683 if str(type(value)) != "<type 'instance'>" : 00684 value0 = value 00685 value = myf['cu'].expandparam(param, value) 00686 matchtype = False 00687 if(type(value) == numpy.ndarray): 00688 if(type(value) == type(value0)): 00689 myf[param] = value.tolist() 00690 else: 00691 #print 'value:', value, 'value0:', value0 00692 #print 'type(value):', type(value), 'type(value0):', type(value0) 00693 myf[param] = value0 00694 if type(value0) != list : 00695 matchtype = True 00696 else : 00697 myf[param] = value 00698 value = myf['cu'].verifyparam({param:value}) 00699 if matchtype: 00700 value = False 00701 except Exception, instance: 00702 #ignore the exception and just return it unchecked 00703 myf[param] = value 00704 return value 00705 # 00706 # 00707 def description(self, key='specfit', subkey=None): 00708 desc={'specfit': 'Fit 1-dimensional gaussians and/or polynomial models to an image or image region', 00709 'imagename': 'Name of the input image', 00710 'box': 'Rectangular box in direction coordinate blc, trc. Default: entire image ("").', 00711 'region': 'Region of interest. See help par.region for possible specifications. Default: Do not use a region.', 00712 'chans': 'Channels to use. Channels must be contiguous. Default: all channels ("").', 00713 'stokes': 'Stokes planes to use. Planes must be contiguous. Default: all stokes ("").', 00714 'axis': 'The profile axis. Default: use the spectral axis if one exists, axis 0 otherwise (<0).', 00715 'mask': 'Mask to use. See help par.mask. Default is none..', 00716 'ngauss': 'Number of Gaussian elements. Default: 1.', 00717 'poly': 'Order of polynomial element. Default: do not fit a polynomial (<0).', 00718 'estimates': 'Name of file containing initial estimates. Default: No initial estimates ("").', 00719 'minpts': 'Minimum number of unmasked points necessary to attempt fit.', 00720 'multifit': 'If true, fit a profile along the desired axis at each pixel in the specified region. If false, average the non-fit axis pixels and do a single fit to that average profile. Default False.', 00721 'model': 'Name of model image. Default: do not write the model image ("").', 00722 'residual': 'Name of residual image. Default: do not write the residual image ("").', 00723 'amp': 'Name of amplitude solution image. Default: do not write the image ("").', 00724 'amperr': 'Name of amplitude solution error image. Default: do not write the image ("").', 00725 'center': 'Name of center solution image. Default: do not write the image ("").', 00726 'centererr': 'Name of center solution error image. Default: do not write the image ("").', 00727 'fwhm': 'Name of fwhm solution image. Default: do not write the image ("").', 00728 'fwhmerr': 'Name of fwhm solution error image. Default: do not write the image ("").', 00729 'integral': 'Prefix of ame of integral solution image. Name of image will have gaussian component number appended. Default: do not write the image ("").', 00730 'integralerr': 'Prefix of name of integral error solution image. Name of image will have gaussian component number appended. Default: do not write the image ("").', 00731 'wantreturn': 'Should a record summarizing the results be returned?', 00732 'stretch': 'Stretch the mask if necessary and possible? See help par.stretch ', 00733 'logresults': 'Output results to logger?', 00734 'pampest': 'Initial estimate of PCF profile (gaussian or lorentzian) amplitudes.', 00735 'pcenterest': 'Initial estimate PCF profile centers, in pixels.', 00736 'pfwhmest': 'Initial estimate PCF profile FWHMs, in pixels.', 00737 'pfix': 'PCF profile parameters to fix during fit.', 00738 'gmncomps': 'Number of components in each gaussian multiplet to fit', 00739 'gmampcon': 'The amplitude ratio constraints for non-reference components to reference component in gaussian multiplets.', 00740 'gmcentercon': 'The center offset constraints (in pixels) for non-reference components to reference component in gaussian multiplets.', 00741 'gmfwhmcon': 'The FWHM ratio constraints for non-reference components to reference component in gaussian multiplets.', 00742 'gmampest': 'Initial estimate of individual gaussian amplitudes in gaussian multiplets.', 00743 'gmcenterest': 'Initial estimate of individual gaussian centers in gaussian multiplets, in pixels.', 00744 'gmfwhmest': 'Initial estimate of individual gaussian FWHMss in gaussian multiplets, in pixels.', 00745 'gmfix': 'Parameters of individual gaussians in gaussian multiplets to fix during fit.', 00746 'logfile': 'File in which to log results. Default is not to write a logfile.', 00747 'append': 'Append results to logfile? Logfile must be specified. Default is to append. False means overwrite existing file if it exists.', 00748 'pfunc': 'PCF singlet functions to fit. "gaussian" or "lorentzian" (minimal match supported). Unspecified means all gaussians.', 00749 'goodamprange': 'Acceptable amplitude solution range. [0.0] => all amplitude solutions are acceptable.', 00750 'goodcenterrange': 'Acceptable center solution range in pixels relative to region start. [0.0] => all center solutions are acceptable.', 00751 'goodfwhmrange': 'Acceptable FWHM solution range in pixels. [0.0] => all FWHM solutions are acceptable.', 00752 'sigma': 'Standard deviation array or image name.', 00753 'outsigma': 'Name of output image used for standard deviation. Ignored if sigma is empty.', 00754 00755 'async': 'If true the taskname must be started using specfit(...)' 00756 } 00757 00758 # 00759 # Set subfields defaults if needed 00760 # 00761 00762 if(desc.has_key(key)) : 00763 return desc[key] 00764 00765 def itsdefault(self, paramname) : 00766 a = {} 00767 a['imagename'] = '' 00768 a['box'] = '' 00769 a['region'] = '' 00770 a['chans'] = '' 00771 a['stokes'] = '' 00772 a['axis'] = -1 00773 a['mask'] = '' 00774 a['ngauss'] = 1 00775 a['poly'] = -1 00776 a['estimates'] = '' 00777 a['minpts'] = 0 00778 a['multifit'] = False 00779 a['model'] = '' 00780 a['residual'] = '' 00781 a['amp'] = '' 00782 a['amperr'] = '' 00783 a['center'] = '' 00784 a['centererr'] = '' 00785 a['fwhm'] = '' 00786 a['fwhmerr'] = '' 00787 a['integral'] = '' 00788 a['integralerr'] = '' 00789 a['wantreturn'] = True 00790 a['stretch'] = False 00791 a['logresults'] = True 00792 a['pampest'] = '' 00793 a['pcenterest'] = '' 00794 a['pfwhmest'] = '' 00795 a['pfix'] = '' 00796 a['gmncomps'] = 0 00797 a['gmampcon'] = '' 00798 a['gmcentercon'] = '' 00799 a['gmfwhmcon'] = '' 00800 a['gmampest'] = [0.0] 00801 a['gmcenterest'] = [0.0] 00802 a['gmfwhmest'] = [0.0] 00803 a['gmfix'] = '' 00804 a['logfile'] = '' 00805 a['append'] = True 00806 a['pfunc'] = '' 00807 a['goodamprange'] = [0.0] 00808 a['goodcenterrange'] = [0.0] 00809 a['goodfwhmrange'] = [0.0] 00810 a['sigma'] = '' 00811 a['outsigma'] = '' 00812 00813 #a = sys._getframe(len(inspect.stack())-1).f_globals 00814 00815 if self.parameters['mask'] != '': 00816 a['stretch'] = False 00817 00818 if self.parameters['estimates'] == '': 00819 a['ngauss'] = 1 00820 a['pampest'] = '' 00821 a['pcenterest'] = '' 00822 a['pfwhmest'] = '' 00823 a['pfix'] = '' 00824 a['pfunc'] = '' 00825 00826 if self.parameters['multifit'] == True: 00827 a['amp'] = "" 00828 a['amperr'] = "" 00829 a['center'] = "" 00830 a['centererr'] = "" 00831 a['fwhm'] = "" 00832 a['fwhmerr'] = "" 00833 a['integral'] = "" 00834 a['integralerr'] = "" 00835 00836 if self.parameters['gmncomps'] != 0: 00837 a['gmampcon'] = '' 00838 a['gmcentercon'] = '' 00839 a['gmfwhmcon'] = '' 00840 a['gmampest'] = 0.0 00841 a['gmcenterest'] = 0.0 00842 a['gmfwhmest'] = 0.0 00843 a['gmfix'] = '' 00844 00845 if self.parameters['logfile'] != '': 00846 a['append'] = True 00847 00848 if self.parameters['sigma'] != '': 00849 a['outsigma'] = '' 00850 00851 if a.has_key(paramname) : 00852 return a[paramname] 00853 specfit_cli = specfit_cli_()