Changeset 239
- Timestamp:
- Jan 13, 2011 1:34:07 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r237 r239 409 409 'MAR345 (*.mar3450;*.mar2300)|*.mar3450;*.mar2300|ADSC Image (*.img)\ 410 410 |*.img|Detector tif (*.tif;*.tiff)|*.tif;*.tiff|GE Image sum (*.sum)\ 411 |*.sum|GE Image avg (*.avg)|*.avg|GE Image raw (*)|*|All files (*.*)|*.*',wx.OPEN | wx.MULTIPLE) 411 |*.sum|GE Image avg (*.avg)\ 412 |*.avg|Any image file (*.mar3450;*.mar2300;*.img;*.tif;*.tiff;*.sum)\ 413 |*.mar3450;*.mar2300;*.img;*.tif;*.tiff;*.sum|All files (*.*)|*.*', 414 wx.OPEN | wx.MULTIPLE) 412 415 if self.dirname: 413 416 dlg.SetDirectory(self.dirname) … … 431 434 Data['cutoff'] = 10 432 435 Data['pixLimit'] = 20 436 Data['calibdmin'] = 0.5 437 Data['calibskip'] = 0 433 438 Data['ellipses'] = [] 434 439 Data['calibrant'] = '' … … 443 448 Data['cutoff'] = 10 444 449 Data['pixLimit'] = 20 450 Data['calibdmin'] = 0.5 451 Data['calibskip'] = 0 445 452 Data['ellipses'] = [] 446 453 Data['calibrant'] = '' -
trunk/GSASIIIO.py
r230 r239 491 491 image[row] = np.asarray(line) 492 492 row += 1 493 data = {'pixelSize':(200,200),'wavelength':0.15,'distance':250.0,'center':[204.8,204.8] }493 data = {'pixelSize':(200,200),'wavelength':0.15,'distance':250.0,'center':[204.8,204.8],'size':[size,size]} 494 494 File.close() 495 495 if imageOnly: … … 527 527 center[1] = float(line.split('=')[1]) 528 528 head.append(line) 529 data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center }529 data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center,'size':[size,size]} 530 530 image = [] 531 531 row = 0 … … 583 583 size = int(items[1]) 584 584 pos = 4096 585 data['size'] = [size,size] 585 586 File.seek(pos) 586 587 line = File.read(8) … … 629 630 finalSize = origSize 630 631 if Ityp == 0: 631 print finalSize 632 if finalSize == 1207975936: 633 finalSize = origSize = 1536 632 File.seek(62) 633 S = File.read(32) 634 if 'PILATUS' in S: 635 dataType = 0 636 tifType = 'Pilatus' 637 if '2M' in S: 638 sizexy = [1475,1679] 639 elif '100K' in S: 640 sizexy = [487,195] 641 pixy = (172,172) 642 pos = 4096 643 if not imageOnly: 644 print 'Read Pilatus tiff file: ',filename 645 else: 646 sizexy = [1536,1536] 634 647 sizeScale = 1 635 648 tifType = 'Gold' … … 638 651 if not imageOnly: 639 652 print 'Read Gold tiff file:',filename 640 else:641 tifType = 'Pilatus'642 pixy = (172*sizeScale,172*sizeScale)643 pos = 4096644 if not imageOnly:645 print 'Read Pilatus tiff file: ',filename646 653 elif Ityp == 1: 647 654 tifType = 'PE' 655 sizexy = [finalSize,finalSize] 648 656 pixy = (200*sizeScale,200*sizeScale) 649 657 pos = 8 … … 652 660 elif Ityp == 3328: 653 661 tifType = 'MAR' 662 sizexy = [finalSize,finalSize] 654 663 pixy = (79*sizeScale,79*sizeScale) 655 664 pos = 4096 … … 659 668 lines = 'unknown tif type' 660 669 return lines,0,0 661 image = np.zeros(shape=( finalSize,finalSize),dtype=np.int32)670 image = np.zeros(shape=(sizexy[1],sizexy[0]),dtype=np.int32) 662 671 row = 0 663 while row < finalSize:672 while row < sizexy[1]: 664 673 File.seek(pos) 665 if 'PE' in tifType :674 if 'PE' in tifType or 'Pilatus' in tifType: 666 675 if dataType == 5: 667 line = ar.array('f',File.read(4* finalSize))676 line = ar.array('f',File.read(4*sizexy[0])) 668 677 else: 669 line = ar.array(' l',File.read(4*finalSize))670 pos += 4* finalSize678 line = ar.array('L',File.read(4*sizexy[0])) 679 pos += 4*sizexy[0] 671 680 elif 'MAR' in tifType or 'Gold' in tifType: 672 line = ar.array('H',File.read(2* finalSize))673 pos += 2* finalSize681 line = ar.array('H',File.read(2*sizexy[0])) 682 pos += 2*sizexy[0] 674 683 image[row] = np.asarray(line) 675 684 row += 1 676 center = [pixy[0]* finalSize/2000,pixy[1]*finalSize/2000]677 data = {'pixelSize':pixy,'wavelength':0.10,'distance':100.0,'center':center }685 center = [pixy[0]*sizexy[0]/2000,pixy[1]*sizexy[1]/2000] 686 data = {'pixelSize':pixy,'wavelength':0.10,'distance':100.0,'center':center,'size':sizexy} 678 687 File.close() 679 688 if imageOnly: 680 689 return image 681 690 else: 682 return head,data, finalSize,image691 return head,data,sizexy[0],image 683 692 684 693 def ProjFileOpen(self): -
trunk/GSASIIimage.py
r230 r239 341 341 print 'no calibration material selected' 342 342 return True 343 344 Bravais,cell,skip,limits = calFile.Calibrants[data['calibrant']] 343 344 skip = data['calibskip'] 345 dmin = data['calibdmin'] 346 Bravais,cell = calFile.Calibrants[data['calibrant']][:2] 345 347 A = G2lat.cell2A(cell) 346 348 wave = data['wavelength'] 347 349 cent = data['center'] 348 350 elcent,phi,radii = ellipse 349 HKL = G2lat.GenHBravais( limits[0],Bravais,A)[skip:]351 HKL = G2lat.GenHBravais(dmin,Bravais,A)[skip:] 350 352 dsp = HKL[0][3] 351 353 tth = 2.0*asind(wave/(2.*dsp)) … … 384 386 numZ = len(Ring) 385 387 data['rings'].append(np.array(Ring)) 386 ellipse = FitRing(Ring)387 elcent,phi,radii = ellipse388 newellipse = FitRing(Ring) 389 elcent,phi,radii = newellipse 388 390 if abs(phi) > 45. and phi < 0.: 389 391 phi += 180. 390 392 dist = calcDist(radii,tth) 391 393 distR = 1.-dist/data['distance'] 394 if abs(distR) > 0.1: 395 print distR,dist,data['distance'] 396 del data['rings'][-1] 397 continue 392 398 if distR > 0.001: 393 399 print 'Wavelength too large?' … … 395 401 print 'Wavelength too small?' 396 402 else: 403 ellipse = newellipse 397 404 if abs((radii[1]/radii[0]-ratio)/ratio) > 0.01: 398 405 print 'Bad fit for ring # %i. Try reducing Pixel search range'%(i) -
trunk/GSASIIimgGUI.py
r238 r239 39 39 def OnNewCalibrant(event): 40 40 data['calibrant'] = calSel.GetValue() 41 data['calibskip'] = calFile.Calibrants[data['calibrant']][2] 41 42 limits = calFile.Calibrants[data['calibrant']][3] 42 data[' pixLimit'] = limits[1]43 data['calibdmin'],data['pixLimit'],data['cutoff'] = limits 43 44 pixLimit.SetValue(str(limits[1])) 44 data['cutoff'] = limits[2]45 45 cutOff.SetValue('%.1f'%(limits[2])) 46 calibSkip.SetValue(str(data['calibskip'])) 47 calibDmin.SetValue('%.1f'%(limits[0])) 46 48 47 49 def OnPixLimit(event): 48 50 data['pixLimit'] = int(pixLimit.GetValue()) 49 51 52 def OnCalibSkip(event): 53 data['calibskip'] = int(calibSkip.GetValue()) 54 55 def OnCalibDmin(event): 56 try: 57 dmin = float(calibDmin.GetValue()) 58 if dmin < 0.5: 59 raise ValueError 60 data['calibdmin'] = dmin 61 except ValueError: 62 pass 63 calibDmin.SetValue("%.1f"%(data['calibdmin'])) #reset in case of error 64 65 50 66 def OnCutOff(event): 51 67 try: 52 68 cutoff = float(cutOff.GetValue()) 69 if cutoff < 0.1: 70 raise ValueError 53 71 data['cutoff'] = cutoff 54 72 except ValueError: … … 217 235 id = G2gd.GetPatternTreeItemId(self, self.root, name) 218 236 size,imagefile = self.PatternTree.GetItemPyData(id) 219 image = G2IO.GetImageData(imagefile,imageOnly=True) 237 print imagefile 238 image = G2IO.GetImageData(self,imagefile,True) 220 239 Id = G2gd.GetPatternTreeItemId(self,id, 'Image Controls') 221 240 Data = self.PatternTree.GetItemPyData(Id) … … 274 293 oldData = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Image Controls')) 275 294 Data['range'] = oldData['range'] 295 Data['ring'] = [] 296 Data['rings'] = [] 297 Data['ellipses'] = [] 276 298 self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,id, 'Image Controls'),Data) 277 299 finally: … … 401 423 calSel.Bind(wx.EVT_COMBOBOX, OnNewCalibrant) 402 424 comboSizer.Add(calSel,0,wx.ALIGN_CENTER_VERTICAL) 425 mainSizer.Add(comboSizer,0,wx.ALIGN_CENTER_HORIZONTAL) 426 mainSizer.Add((10,10),0) 427 428 comboSizer = wx.BoxSizer(wx.HORIZONTAL) 403 429 comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Pixel search range '),0, 404 430 wx.ALIGN_CENTER_VERTICAL) … … 414 440 cutOff.Bind(wx.EVT_KILL_FOCUS,OnCutOff) 415 441 comboSizer.Add(cutOff,0,wx.ALIGN_CENTER_VERTICAL) 442 comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Calib lines to skip '),0, 443 wx.ALIGN_CENTER_VERTICAL) 444 calibSkip = wx.ComboBox(parent=self.dataDisplay,value=str(data['calibskip']),choices=['0','1','2','3','4','5','6','7','8','9','10'], 445 style=wx.CB_READONLY|wx.CB_DROPDOWN) 446 calibSkip.Bind(wx.EVT_COMBOBOX, OnCalibSkip) 447 comboSizer.Add(calibSkip,0,wx.ALIGN_CENTER_VERTICAL) 448 comboSizer.Add(wx.StaticText(parent=self.dataDisplay,label=' Min calib d-spacing '),0, 449 wx.ALIGN_CENTER_VERTICAL) 450 calibDmin = wx.TextCtrl(parent=self.dataDisplay,value=("%.1f" % (data['calibdmin'])), 451 style=wx.TE_PROCESS_ENTER) 452 calibDmin.Bind(wx.EVT_TEXT_ENTER,OnCalibDmin) 453 calibDmin.Bind(wx.EVT_KILL_FOCUS,OnCalibDmin) 454 comboSizer.Add(calibDmin,0,wx.ALIGN_CENTER_VERTICAL) 416 455 417 456 mainSizer.Add(comboSizer,0,wx.ALIGN_CENTER_HORIZONTAL) -
trunk/GSASIIplot.py
r231 r239 837 837 G2gd.GetPatternTreeItemId(self,self.Image, 'Image Controls')) 838 838 Page.canvas.SetToolTipString('') 839 size = len(self.ImageZ)839 sizexy = Data['size'] 840 840 if event.xdata and event.ydata: #avoid out of frame errors 841 841 Page.canvas.SetCursor(wx.CROSS_CURSOR) … … 863 863 ypix = ypos*scaley 864 864 Int = 0 865 if (0 <= xpix <= size ) and (0 <= ypix <= size):865 if (0 <= xpix <= sizexy[0]) and (0 <= ypix <= sizexy[1]): 866 866 Int = self.ImageZ[ypix][xpix] 867 867 tth,azm,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data) … … 947 947 pixLimit = Data['pixLimit'] 948 948 if self.itemPicked is None and PickName == 'Image Controls': 949 size = len(self.ImageZ) 949 # sizexy = Data['size'] 950 950 Xpos = event.xdata 951 951 if not (Xpos and self.ifGetRing): #got point out of frame … … 1081 1081 if len(self.ImageZ) > 1024: 1082 1082 imScale = len(self.ImageZ)/1024 1083 sizexy = Data['size'] 1083 1084 pixelSize = Data['pixelSize'] 1085 # print sizexy,pixelSize,len(self.ImageZ),len(self.ImageZ[0]) 1084 1086 scalex = 1000./pixelSize[0] 1085 1087 scaley = 1000./pixelSize[1] 1086 xmax = len(self.ImageZ)1087 Xmax = len(self.ImageZ)*pixelSize[0]/1000.1088 Xmax = sizexy[0]*pixelSize[0]/1000. 1089 Ymax = sizexy[1]*pixelSize[1]/1000. 1088 1090 xlim = (-0.5,Xmax-.5) 1089 ylim = ( Xmax-.5,-0.5,)1091 ylim = (Ymax-.5,-0.5,) 1090 1092 Imin,Imax = Data['range'][1] 1091 1093 acolor = mpl.cm.get_cmap(Data['color']) -
trunk/ImageCalibrants.py
r167 r239 7 7 'LaB6 SRM660a':(2,(4.1569162,4.1569162,4.1569162,90,90,90),0,(0.5,20,10)), 8 8 'LaB6 SRM660a skip 1':(2,(4.1569162,4.1569162,4.1569162,90,90,90),1,(0.5,20,10)), 9 'LaB6 SRM660a ID-1 hydra skip 6':(2,(4.1569162,4.1569162,4.1569162,90,90,90),6,(0.7,5,0.5)), 9 10 'LaB6 SRM660': (2,(4.15695,4.15695,4.15695,90,90,90),0,(0.5,20,10)), 10 11 'Si SRM640c':(0,(5.4311946,5.4311946,5.4311946,90,90,90),0,(0.5,20,10)),
Note: See TracChangeset
for help on using the changeset viewer.