Changeset 3831
- Timestamp:
- Mar 1, 2019 10:32:38 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIscriptable.py
r3828 r3831 2322 2322 ''' 2323 2323 return self.data['Sample Parameters'] 2324 2324 2325 @property 2326 def Background(self): 2327 '''Provides a list with with the Background parameters 2328 for this histogram. 2329 2330 :returns: list containing a list and dict with background values 2331 ''' 2332 return self.data['Background'] 2333 2334 def add_back_peak(self,pos,int,sig,gam,refflags=[]): 2335 '''Adds a background peak to the Background parameters 2336 2337 :param float pos: position of peak, a 2theta or TOF value 2338 :param float int: integrated intensity of background peak, usually large 2339 :param float sig: Gaussian width of background peak, usually large 2340 :param float gam: Lorentzian width of background peak, usually unused (small) 2341 :param list refflags: a list of 1 to 4 boolean refinement flags for 2342 pos,int,sig & gam, respectively (use [0,1] to refine int only). 2343 Defaults to [] which means nothing is refined. 2344 ''' 2345 if 'peaksList' not in self.Background[1]: 2346 self.Background[1]['peaksList'] = [] 2347 flags = 4*[False] 2348 for i,f in enumerate(refflags): 2349 if i>3: break 2350 flags[i] = bool(f) 2351 bpk = [] 2352 for i,j in zip((pos,int,sig,gam),flags): 2353 bpk += [float(i),j] 2354 self.Background[1]['peaksList'].append(bpk) 2355 self.Background[1]['nPeaks'] = len(self.Background[1]['peaksList']) 2356 2357 def del_back_peak(self,peaknum): 2358 '''Removes a background peak from the Background parameters 2359 2360 :param int peaknum: the number of the peak (starting from 0) 2361 ''' 2362 npks = self.Background[1].get('nPeaks',0) 2363 if peaknum >= npks: 2364 raise Exception('peak {} not found in histogram {}'.format(peaknum,self.name)) 2365 del self.Background[1]['peaksList'][peaknum] 2366 self.Background[1]['nPeaks'] = len(self.Background[1]['peaksList']) 2367 2368 def ref_back_peak(self,peaknum,refflags=[]): 2369 '''Sets refinement flag for a background peak 2370 2371 :param int peaknum: the number of the peak (starting from 0) 2372 :param list refflags: a list of 1 to 4 boolean refinement flags for 2373 pos,int,sig & gam, respectively. If a flag is not specified 2374 it defaults to False (use [0,1] to refine int only). 2375 Defaults to [] which means nothing is refined. 2376 ''' 2377 npks = self.Background[1].get('nPeaks',0) 2378 if peaknum >= npks: 2379 raise Exception('peak {} not found in histogram {}'.format(peaknum,self.name)) 2380 flags = 4*[False] 2381 for i,f in enumerate(refflags): 2382 if i>3: break 2383 flags[i] = bool(f) 2384 for i,f in enumerate(flags): 2385 self.Background[1]['peaksList'][peaknum][2*i+1] = f 2386 2325 2387 @property 2326 2388 def id(self): … … 3239 3301 if arg in self.ControlList[typ]: break 3240 3302 else: 3303 print('Allowed args:\n',[nam for nam,typ in self.findControl('')]) 3241 3304 raise Exception('arg {} not defined in G2Image.setControl' 3242 3305 .format(arg)) … … 3274 3337 raise Exception('arg {} not defined in G2Image.getControl'.format(arg)) 3275 3338 3276 def findControl(self,arg ):3339 def findControl(self,arg=''): 3277 3340 '''Finds the Image Controls parameter(s) in the current image 3278 that match the string in arg. 3341 that match the string in arg. Default is '' which returns all 3342 parameters. 3279 3343 3280 3344 Example:
Note: See TracChangeset
for help on using the changeset viewer.