Changeset 974
- Timestamp:
- 04/03/06 16:38:28 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapfit.py
r722 r974 1 from _asap import sdfit1 from _asap import fitentry 2 2 from asap import rcParams 3 3 4 class asapfit( sdfit):4 class asapfit(fitentry): 5 5 6 def __init__(self, other): 7 sdfit.__init__(self,other) 6 def __init__(self, other=None): 7 if isinstance(other, fitentry): 8 fitentry.__init__(self,other) 9 else: 10 fitentry.__init__(self) 8 11 9 12 def __str__(self): 10 if self.__len__() == 0:11 return "No fits"12 13 out = "" 13 for i in range(self.__len__()): 14 out += "Fit No %d:" % (i) 15 pars = self.getparameters(i) 16 mask = self.getfixedparameters(i) 17 funcs = self.getfunctions(i) 18 comps = self.getcomponents(i) 19 finfo = self.getframeinfo(i) 20 pos=0 21 k = 0 22 for f in funcs: 23 out += "\n Type: " 24 out += f 25 s = pos 26 pos += comps[k] 27 ps = pars[s:pos] 28 out += "\n Parameters: " 29 out += self._format_pars(pars[s:pos],f, finfo[0]) 30 out += "\n Fixed Parms: " 31 out += str(mask[s:pos]) 32 out += "\n Frame: " 33 out += str(finfo) 34 out += "\n" 14 out += "Fit:" 15 pars = self.getparameters() 16 mask = self.getfixedparameters() 17 funcs = self.getfunctions() 18 comps = self.getcomponents() 19 finfo = self.getframeinfo() 20 pos=0 21 k = 0 22 for f in funcs: 23 out += "\n Type: " 24 out += f 25 s = pos 26 pos += comps[k] 27 ps = pars[s:pos] 28 out += "\n Parameters: " 29 out += self._format_pars(pars[s:pos],f, finfo[0]) 30 out += "\n Fixed Parms: " 31 out += str(mask[s:pos]) 32 out += "\n Frame: " 33 out += str(finfo) 35 34 out += "\n" 35 out += "\n" 36 36 return out 37 37 38 38 def as_dict(self): 39 39 out = [] 40 for i in range(self.__len__()): 41 pars = self.getparameters(i) 42 mask = self.getfixedparameters(i) 43 funcs = self.getfunctions(i) 44 comps = self.getcomponents(i) 45 pos=0 46 k=0 47 comp = [] 48 for f in funcs: 49 s = pos 50 pos += comps[k] 51 ps = pars[s:pos] 52 d = {'function' : f, 53 'parameters' : pars[s:pos], 54 'fixed' : mask[s:pos], 55 'frame' : self.getframeinfo(i) 56 } 57 comp.append(d) 58 out.append(comp) 40 pars = self.getparameters() 41 mask = self.getfixedparameters() 42 funcs = self.getfunctions() 43 comps = self.getcomponents() 44 pos=0 45 k=0 46 comp = [] 47 for f in funcs: 48 s = pos 49 pos += comps[k] 50 ps = pars[s:pos] 51 d = {'function' : f, 52 'parameters' : pars[s:pos], 53 'fixed' : mask[s:pos], 54 'frame' : self.getframeinfo() 55 } 56 comp.append(d) 57 out.append(comp) 59 58 return out 60 61 59 62 60 def _format_pars(self, pars, ftype, unit): … … 70 68 elif ftype == 'gauss': 71 69 out += 'peak = %3.3f , centre = %3.3f %s, FWHM = %3.3f %s' % (pars[0],pars[1],unit,pars[2],unit) 72 73 70 return out
Note:
See TracChangeset
for help on using the changeset viewer.