1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14  """ 
 15  This package contains the Pattern class in SrRietveld, which is an script interface 
 16  to access the structure information 
 17  """ 
 18   
 19  __id__ = "$Id: pattern.py 6727 2011-08-26 21:53:10Z yshang $" 
 20   
 21  from diffpy.refinementdata.pattern import Pattern as BasePattern 
 22  from diffpy.refinementdata.refinable import Refinable 
 23  from diffpy.srrietveld.paramnames import PARAMNAMES 
 24   
 26      """ 
 27      Pattern inherits the Pattern class in diffpy.refinementdata. Its basic  
 28      data is the array of 2theta, time of flight, intensity, error. It may not  
 29      have a list of parameters. It may have a file object which stores the original  
 30      data.  
 31       
 32      data member: 
 33           
 34          xobs: the observed data 
 35          yobs: the observed y data 
 36          ycal: the refined y data 
 37          refl: the reflection list 
 38          srcfiles: the source files, including data files and source files  
 39      """ 
 40   
 41   
 42 -    def __init__(self, owner, name=None,  handle=None, shape=None): 
  43              """Initialization 
 44               
 45              @type owner:    a data project 
 46              @param owner:    the owner, which is usually a refinement. 
 47              @type name:    string 
 48              @param name     the name of the pattern 
 49              @type handle:    a HDF5Handle object 
 50              @param handle: a HDF5Handle pointing to the underlying HDF5 node.           
 51       
 52              A name is passed to the initialization method when creating a node. 
 53               
 54              A handle is passed to the inialization method in two cases: 
 55                  1.  when loading from a HDF5 file; 
 56                  2.  when creating a HDF5 file but the object is a hard link to  
 57                      a preexisiting one. 
 58                       
 59              In the case when both name and handle are given, name will be simply ignored. 
 60              In the case when neither name nor handle is given, an exception will be raised. 
 61               
 62              Usually in the scripting interface, users do not have to worry about the  
 63              initialization 
 64              """         
 65              BasePattern.__init__(self, owner, name, handle, shape) 
 66               
 67              return 
  68       
 70          ''' 
 71          Get the absolute data file path 
 72           
 73          @return:  the absolute data path strings 
 74          ''' 
 75          return self.getByPath(PARAMNAMES[self.getEngineType()]['data_file_absolute']) 
  76       
 78          ''' 
 79          Get the background coefficients in a two dimensional array 
 80           
 81          @return: the background coefficient values in a two dimensional array 
 82          ''' 
 83          return self.getByPath(PARAMNAMES[self.getEngineType()]['background_coefficients']) 
  84   
 86          ''' 
 87          Get the background coefficients standard deviations in a two dimensional array 
 88           
 89          @return: the background coefficient standard deviations in a two dimensional array 
 90          ''' 
 91          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['background_coefficients']) 
  92       
 94          ''' 
 95          Get the background type identification number. This number has different 
 96          meanings in engines.  
 97           
 98          @return: an integer represent the type of the background function 
 99          ''' 
100          return self.getByPath(PARAMNAMES[self.getEngineType()]['background_type']).first() 
 101       
103          ''' 
104          Get the path of the data file.  
105           
106          @return: the data path strings 
107          '''  
108          return self.getByPath(PARAMNAMES[self.getEngineType()]['data_file']) 
 109       
111          '''Get the engine type for this refinement 
112       
113          @return:    the string of the engine type, for example I{"gsas"} or I{"fullprof"}''' 
114           
115          return self.owner.owner.getEngineType() 
 116       
118          ''' 
119          Get the polarization type id numbers. These numbers have different meanings 
120          in different engine files, please refer to the manual of the refinement engine.  
121           
122          @return: the Tmin of the pattern as float 
123          ''' 
124          return self.getByPath(PARAMNAMES[self.getEngineType()]['polar_type']) 
 125   
127          ''' 
128          Get the refined wavelength value. In FullProf, there can be only one  
129          lambda value can be refined 
130           
131          @return: the values of wavelength in angstroms 
132          ''' 
133          return self.getByPath(PARAMNAMES[self.getEngineType()]['lambda'])     
 134       
136          ''' 
137          Get the refined wavelength standard deviation. In FullProf, there can be only one  
138          lambda value can be refined 
139           
140          @return: the wavelength standard deviation 
141          ''' 
142          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['lambda']) 
 143       
145          ''' 
146          Get the first wavelength value 
147           
148          @return: the values of the wavelength in angstroms 
149          ''' 
150          return self.getByPath(PARAMNAMES[self.getEngineType()]['lambda1']) 
 151       
153          ''' 
154          Get the first wavelength standard deviation 
155           
156          @return: the wavelength standard deviation 
157          ''' 
158          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['lambda1']) 
 159       
161          ''' 
162          Get the second wavelength value 
163           
164          @return: the values of the wavelength in angstroms  
165          ''' 
166          return self.getByPath(PARAMNAMES[self.getEngineType()]['lambda2']) 
 167   
169          ''' 
170          Get the second wavelength standard deviation 
171           
172          @return: the wavelength standard deviation  
173          ''' 
174          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['lambda2']) 
 175       
177          ''' 
178          Get the number of background coefficients. This is number is from the  
179          dimensions of the background coefficients array  
180           
181          @return: the number of background coefficients 
182          ''' 
183          return len(self.getBackgroundCoefficients()[0]) 
 184       
186          ''' 
187          Get the polarization factors 
188           
189          @return: the polarization factors 
190          ''' 
191          return self.getByPath(PARAMNAMES[self.getEngineType()]['polar']) 
 192       
194          ''' 
195          Get the Rp value of the refinement list 
196           
197          @return:    the values of Rp 
198          ''' 
199          return self.getByPath(PARAMNAMES[self.getEngineType()]['Rp']) 
 200       
202          ''' 
203          Get the Rwp value of the refinement list 
204           
205          @return:    the values of Rwp 
206          ''' 
207          return self.getByPath(PARAMNAMES[self.getEngineType()]['Rwp']) 
 208       
210          ''' 
211          Get the ratio value of the refinement list. These values are read from  
212          the engine files, and not calculated in SrRietveld. 
213           
214          @return:    the values of ratios of intensities of lambda2 / lambda1 
215          ''' 
216          return self.getByPath(PARAMNAMES[self.getEngineType()]['ratio']) 
 217       
219          ''' 
220          Get the scale factor of the pattern 
221           
222          @return: the scale factor of the pattern as float 
223          ''' 
224          return self.getByPath(PARAMNAMES[self.getEngineType()]['scale']) 
 225       
227          ''' 
228          Get the scale factor standard deviation 
229           
230          @return: the scale factor standard deviation 
231          ''' 
232          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['scale']) 
 233           
235          ''' 
236          Get the step values 
237           
238          @return: the step sizes 
239          ''' 
240          return self.getByPath(PARAMNAMES[self.getEngineType()]['step']) 
 241       
243          ''' 
244          Get the Tmin of the pattern 
245           
246          @return: the Tmin of the pattern as float 
247          ''' 
248          return self.getByPath(PARAMNAMES[self.getEngineType()]['Tmin']) 
 249       
251          ''' 
252          Get the use flag of this pattern. In GSAS a histogram can be flagged as  
253          used (True) or unused (False). The pattern will be included in the  
254          refinement only if its used. The pattern will always be used in a  
255          FullProf refinement.  
256           
257          @return: the use flags (boolean) of this pattern in refinements  
258          ''' 
259          return self.getByPath(PARAMNAMES[self.getEngineType()]['used']) 
 260       
262          ''' 
263          Get the Tmax of the pattern 
264           
265          @return: the Tmax of the pattern as float 
266          ''' 
267          return self.getByPath(PARAMNAMES[self.getEngineType()]['Tmax']) 
 268       
270          ''' 
271          Get the observed x axis points. This parameters is only available after 
272          the refinement is complete.   
273           
274          @return: a multi-dimensional array with the x axis points.     
275          ''' 
276          return self.getByPath(PARAMNAMES[self.getEngineType()]['xobs']) 
 277       
279          ''' 
280          Get the observed y values. This parameters is only available after 
281          the refinement is complete.   
282           
283          @return: a multi-dimensional array with the observed y values.     
284          ''' 
285          return self.getByPath(PARAMNAMES[self.getEngineType()]['yobs']) 
 286       
288          ''' 
289          Get the calculated y values. This parameters is only available after 
290          the refinement is complete.   
291           
292          @return: a multi-dimensional array with the calculated y values.     
293          ''' 
294          return self.getByPath(PARAMNAMES[self.getEngineType()]['ycal']) 
 295           
297          ''' 
298          Get the zero shift value for this pattern 
299           
300          @return: the zero shift value as float 
301          ''' 
302          return self.getByPath(PARAMNAMES[self.getEngineType()]['zero']) 
 303       
305          ''' 
306          Get the zero shift standard deviation 
307           
308          @return: the zero shift standard deviation 
309          ''' 
310          return self.getSigmaByPath(PARAMNAMES[self.getEngineType()]['zero']) 
 311       
313          ''' 
314          Get the excluded regions as list  
315          ''' 
316          return [obj for obj in self.listObjects(recursively = True) if obj.name.startswith('ExcludedRegion[')] 
  317       
319      ''' 
320      This is a script interface of the excluded region, with access functions to 
321      the begin and end parameters in the object 
322      ''' 
323 -    def __init__(self, owner, name=None, handle=None, formula=None, variables=None, shape=None): 
 324          """Initialization. 
325           
326          @type owner:    a data project 
327          @param owner:    the owner, which is usually a refinement. 
328          @type name:    string 
329          @param name     the name of the pattern 
330          @type handle:    a HDF5Handle object 
331          @param handle: a HDF5Handle pointing to the underlying HDF5 node.   
332          @type formula:    string 
333          @param formula:    a string of the function definition in C style 
334          @type variables:    a space separated string 
335          @param variables:    a space separated string of all variables  
336   
337          A name is passed to the initialization method when creating a node. 
338           
339          A handle is passed to the inialization method in two cases: 
340              1.  when loading from a HDF5 file; 
341              2.  when creating a HDF5 file but the object is a hard link to  
342                  a preexisiting one. 
343                   
344          In the case when both name and handle are given, name will be simply ignored. 
345          In the case when neither name nor handle is given, an exception will be raised. 
346           
347          Generally, in the scripting interface, users do not have to call this  
348          constructor directly 
349          """ 
350          Refinable.__init__(self, owner, name, handle, shape) 
351          return 
 352       
354          ''' 
355          Get the begin values of the excluded region 
356           
357          @return: begin values 
358          ''' 
359          return self.getByPath(PARAMNAMES[self.getEngineType()]["begin"]) 
 360           
362          ''' 
363          Get the end values of the excluded region 
364           
365          @return: end values 
366          ''' 
367          return self.getByPath(PARAMNAMES[self.getEngineType()]["end"]) 
 368   
369           
371          '''Get the engine type for this refinement 
372           
373          @return:    the string of the engine type, for example I{"gsas"} or I{"fullprof"}''' 
374           
375          return self.owner.owner.getEngineType() 
  376