Changeset 1279
- Timestamp:
- Apr 17, 2014 10:51:20 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpwdGUI.py
r1278 r1279 2678 2678 'Schulz-Zimm':{'Volume':[0.05,False],'Mean':[1000.,False],'StdDev':[300.,False],}, 2679 2679 'Unified':{'G':[100,False],'Rg':[100,False],'B':[1.e-4,False],'P':[4,False],'Cutoff':[1e-5,False],}, 2680 'Porod':{'B':[1.e-4,False],'P':[4,False] },2680 'Porod':{'B':[1.e-4,False],'P':[4,False],'Cutoff':[1e-5,False],}, 2681 2681 'Monodisperse':{'Volume':[0.05,False],'Radius':[100,False],}, #OK for spheres 2682 2682 'Bragg':{'PkInt':[100,False],'PkPos':[0.2,False], … … 2689 2689 2690 2690 def OnCopyModel(event): 2691 print 'copy model' 2692 print data 2691 hst = G2frame.PatternTree.GetItemText(G2frame.PatternId) 2692 histList = GetHistsLikeSelected(G2frame) 2693 if not histList: 2694 G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame) 2695 return 2696 copyList = [] 2697 dlg = G2gd.G2MultiChoiceDialog( 2698 G2frame.dataFrame, 2699 'Copy models from\n'+hst[5:]+' to...', 2700 'Copy models', histList) 2701 try: 2702 if dlg.ShowModal() == wx.ID_OK: 2703 for i in dlg.GetSelections(): 2704 copyList.append(histList[i]) 2705 finally: 2706 dlg.Destroy() 2707 for item in copyList: 2708 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,item) 2709 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Models'), 2710 copy.deepcopy(data)) 2693 2711 2694 2712 def OnFitModel(event): … … 2902 2920 PlotText = G2frame.G2plotNB.nb.GetPageText(G2frame.G2plotNB.nb.GetSelection()) 2903 2921 if 'Powder' in PlotText: 2904 G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot= False)2922 G2plt.PlotPatterns(G2frame,plotType='SASD',newPlot=True) 2905 2923 elif 'Size' in PlotText: 2906 2924 G2plt.PlotSASDSizeDist(G2frame) -
trunk/imports/G2sad_xye.py
r1263 r1279 29 29 extensionlist=('.xsad','.xdat'), 30 30 strictExtension=False, 31 formatName = 'q step X-ray QIE data',32 longFormatName = 'q stepped X-ray text data file in Q,I,E order; E optional'31 formatName = 'q (A-1) step X-ray QIE data', 32 longFormatName = 'q (A-1) stepped X-ray text data file in Q,I,E order; E optional' 33 33 ) 34 34 … … 77 77 f = float(data[1]) 78 78 if f <= 0.0: 79 y.append(0.0)80 w.append(1.0)79 del x[-1] 80 continue 81 81 elif len(vals) > 2: 82 82 y.append(float(data[1])) … … 99 99 self.instdict['type'] = 'LXC' 100 100 x = np.array(x) 101 if np.any(x > 2.): #q must be nm-1102 x /= 10.103 101 self.smallangledata = [ 104 102 x, # x-axis values q … … 122 120 return False 123 121 122 class txt_nmXRayReaderClass(G2IO.ImportSmallAngleData): 123 'Routines to import X-ray q SAXD data from a .xsad or .xdat file, q in nm-1' 124 def __init__(self): 125 super(self.__class__,self).__init__( # fancy way to self-reference 126 extensionlist=('.xsad','.xdat'), 127 strictExtension=False, 128 formatName = 'q (nm-1) step X-ray QIE data', 129 longFormatName = 'q (nm-1) stepped X-ray text data file in Q,I,E order; E optional' 130 ) 131 132 # Validate the contents -- make sure we only have valid lines 133 def ContentsValidator(self, filepointer): 134 'Look through the file for expected types of lines in a valid q-step file' 135 Ndata = 0 136 for i,S in enumerate(filepointer): 137 vals = S.split() 138 if len(vals) >= 2: 139 try: 140 data = [float(val) for val in vals] 141 Ndata += 1 142 except ValueError: 143 pass 144 if not Ndata: 145 self.errors = 'No 2 or more column numeric data found' 146 return False 147 return True # no errors encountered 148 149 def Reader(self,filename,filepointer, ParentFrame=None, **unused): 150 print 'Read a q-step text file' 151 x = [] 152 y = [] 153 w = [] 154 try: 155 wave = 1.5428 #Cuka default 156 Temperature = 300 157 Ndata = 0 158 for i,S in enumerate(filepointer): 159 if len(S) == 1: #skip blank line 160 continue 161 if '=' in S: 162 self.comments.append(S[:-1]) 163 if 'wave' in S.split('=')[0].lower(): 164 try: 165 wave = float(S.split('=')[1]) 166 except: 167 pass 168 continue 169 vals = S.split() 170 if len(vals) >= 2: 171 try: 172 data = [float(val) for val in vals] 173 x.append(float(data[0])/10.) #convert nm-1 to A-1 174 f = float(data[1]) 175 if f <= 0.0: 176 x.pop() 177 continue 178 elif len(vals) > 2: 179 y.append(float(data[1])) 180 w.append(1.0/float(data[2])**2) 181 else: 182 y.append(float(data[1])) 183 w.append(1.0/float(data[1])) 184 except ValueError: 185 msg = 'Error in line '+str(i+1) 186 print msg 187 continue 188 N = len(x) 189 for S in self.comments: 190 if 'Temp' in S.split('=')[0]: 191 try: 192 Temperature = float(S.split('=')[1]) 193 except: 194 pass 195 self.instdict['wave'] = wave 196 self.instdict['type'] = 'LXC' 197 x = np.array(x) 198 self.smallangledata = [ 199 x, # x-axis values q 200 np.array(y), # small angle pattern intensities 201 np.array(w), # 1/sig(intensity)^2 values (weights) 202 np.zeros(N), # calc. intensities (zero) 203 np.zeros(N), # obs-calc profiles 204 ] 205 self.smallangleentry[0] = filename 206 self.smallangleentry[2] = 1 # xye file only has one bank 207 self.idstring = ospath.basename(filename) 208 # scan comments for temperature 209 self.Sample['Temperature'] = Temperature 210 211 return True 212 except Exception as detail: 213 self.errors += '\n '+str(detail) 214 print self.formatName+' read error:'+str(detail) # for testing 215 import traceback 216 traceback.print_exc(file=sys.stdout) 217 return False 218 124 219 class txt_CWNeutronReaderClass(G2IO.ImportSmallAngleData): 125 220 'Routines to import neutron CW q SAXD data from a .nsad or .ndat file' … … 128 223 extensionlist=('.nsad','.ndat'), 129 224 strictExtension=False, 130 formatName = 'q step neutron CW QIE data',131 longFormatName = 'q stepped neutron CW text data file in Q,I,E order; E optional'225 formatName = 'q (A-1) step neutron CW QIE data', 226 longFormatName = 'q (A-1) stepped neutron CW text data file in Q,I,E order; E optional' 132 227 ) 133 228 … … 220 315 traceback.print_exc(file=sys.stdout) 221 316 return False 317 318 class txt_nmCWNeutronReaderClass(G2IO.ImportSmallAngleData): 319 'Routines to import neutron CW q in nm-1 SAXD data from a .nsad or .ndat file' 320 def __init__(self): 321 super(self.__class__,self).__init__( # fancy way to self-reference 322 extensionlist=('.nsad','.ndat'), 323 strictExtension=False, 324 formatName = 'q (nm-1) step neutron CW QIE data', 325 longFormatName = 'q (nm-1) stepped neutron CW text data file in Q,I,E order; E optional' 326 ) 327 328 # Validate the contents -- make sure we only have valid lines 329 def ContentsValidator(self, filepointer): 330 'Look through the file for expected types of lines in a valid q-step file' 331 Ndata = 0 332 for i,S in enumerate(filepointer): 333 vals = S.split() 334 if len(vals) >= 2: 335 try: 336 data = [float(val) for val in vals] 337 Ndata += 1 338 except ValueError: 339 pass 340 if not Ndata: 341 self.errors = 'No 2 or more column numeric data found' 342 return False 343 return True # no errors encountered 344 345 def Reader(self,filename,filepointer, ParentFrame=None, **unused): 346 print 'Read a q-step text file' 347 x = [] 348 y = [] 349 w = [] 350 try: 351 wave = 1.5428 #Cuka default 352 Temperature = 300 353 Ndata = 0 354 for i,S in enumerate(filepointer): 355 if len(S) == 1: #skip blank line 356 continue 357 if '=' in S: 358 self.comments.append(S[:-1]) 359 if 'wave' in S.split('=')[0].lower(): 360 try: 361 wave = float(S.split('=')[1]) 362 except: 363 pass 364 continue 365 vals = S.split() 366 if len(vals) >= 2: 367 try: 368 data = [float(val) for val in vals] 369 x.append(float(data[0])/10.) #convert to A-1 370 f = float(data[1]) 371 if f <= 0.0: 372 y.append(0.0) 373 w.append(1.0) 374 elif len(vals) > 2: 375 y.append(float(data[1])) 376 w.append(1.0/float(data[2])**2) 377 else: 378 y.append(float(data[1])) 379 w.append(1.0/float(data[1])) 380 except ValueError: 381 msg = 'Error in line '+str(i+1) 382 print msg 383 continue 384 N = len(x) 385 for S in self.comments: 386 if 'Temp' in S.split('=')[0]: 387 try: 388 Temperature = float(S.split('=')[1]) 389 except: 390 pass 391 self.instdict['wave'] = wave 392 self.instdict['type'] = 'LNC' 393 x = np.array(x) 394 self.smallangledata = [ 395 x, # x-axis values q 396 np.array(y), # small angle pattern intensities 397 np.array(w), # 1/sig(intensity)^2 values (weights) 398 np.zeros(N), # calc. intensities (zero) 399 np.zeros(N), # obs-calc profiles 400 ] 401 self.smallangleentry[0] = filename 402 self.smallangleentry[2] = 1 # xye file only has one bank 403 self.idstring = ospath.basename(filename) 404 # scan comments for temperature 405 self.Sample['Temperature'] = Temperature 406 407 return True 408 except Exception as detail: 409 self.errors += '\n '+str(detail) 410 print self.formatName+' read error:'+str(detail) # for testing 411 import traceback 412 traceback.print_exc(file=sys.stdout) 413 return False
Note: See TracChangeset
for help on using the changeset viewer.