Changeset 225
- Timestamp:
- Jan 6, 2011 1:23:52 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r193 r225 203 203 wx.Frame.__init__(self, name='GSASII', parent=parent, 204 204 size=wx.Size(300, 250),style=wx.DEFAULT_FRAME_STYLE, title='GSAS-II data tree') 205 screenSize = wx.DisplaySize()205 clientSize = wx.ClientDisplayRect() 206 206 Size = self.GetSize() 207 xPos = screenSize[0]-Size[0]208 self.SetPosition(wx.Point(xPos, 0))207 xPos = clientSize[2]-Size[0] 208 self.SetPosition(wx.Point(xPos,clientSize[1])) 209 209 self._init_utils() 210 210 self.SetMenuBar(self.GSASIIMenu) … … 410 410 imagefiles.sort() 411 411 for imagefile in imagefiles: 412 Comments,Data,Size,Image = G2IO.GetImageData( imagefile)412 Comments,Data,Size,Image = G2IO.GetImageData(self,imagefile) 413 413 if Comments: 414 414 Id = self.PatternTree.AppendItem(parent=self.root,text='IMG '+ospath.basename(imagefile)) … … 450 450 self.PickId = Id 451 451 self.Image = Id 452 self.PatternTree.SelectItem(Id) #show last one 453 self.PatternTree.Expand(Id) 452 self.PatternTree.SelectItem(G2gd.GetPatternTreeItemId(self,Id,'Image Controls')) #show last one 454 453 finally: 455 454 dlg.Destroy() -
trunk/GSASIIIO.py
r223 r225 406 406 return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)] 407 407 408 def GetImageData(imagefile,imageOnly=False): 408 def CheckImageFile(self,imagefile): 409 if not ospath.exists(imagefile): 410 dlg = wx.FileDialog(self, 'Bad image file name; choose name', '.', '',\ 411 'MAR345 (*.mar3450;*.mar2300)|*.mar3450;*.mar2300|ADSC Image (*.img)\ 412 |*.img|Detector tif (*.tif;*.tiff)|*.tif;*.tiff|GE Image sum (*.sum)\ 413 |*.sum|GE Image avg (*.avg)|*.avg|GE Image raw (*)|*|All files (*.*)|*.*',wx.OPEN) 414 if self.dirname: 415 dlg.SetDirectory(self.dirname) 416 try: 417 dlg.SetFilename(ospath.split(imagefile)[1]) 418 if dlg.ShowModal() == wx.ID_OK: 419 self.dirname = dlg.GetDirectory() 420 imagefile = dlg.GetPath() 421 else: 422 imagefile = False 423 finally: 424 dlg.Destroy() 425 return imagefile 426 427 def GetImageData(self,imagefile,imageOnly=False): 409 428 ext = ospath.splitext(imagefile)[1] 410 429 Comments = [] … … 575 594 576 595 def GetTifData(filename,imageOnly=False): 577 # only works for APS Perkin-Elmer detector data files in "TIFF" format that are readable by Fit2D596 # only works for APS Perkin-Elmer or MAR detector data files in "TIFF" format that are readable by Fit2D 578 597 import struct as st 579 598 import array as ar … … 595 614 lines = ['not a detector tiff file',] 596 615 return lines,0,0 597 size,Ityp = st.unpack('<ii',File.read(8))616 origSize,Ityp = st.unpack('<ii',File.read(8)) 598 617 File.seek(30) 599 size = st.unpack('<i',File.read(4))[0] 618 finalSize = st.unpack('<i',File.read(4))[0] 619 if finalSize: 620 sizeScale = origSize/finalSize 621 else: 622 sizeScale = 1 623 finalSize = origSize 600 624 if Ityp == 0: 601 625 tifType = 'Pilatus' 602 pixy = (172 ,172)626 pixy = (172*sizeScale,172*sizeScale) 603 627 pos = 4096 604 628 if not imageOnly: … … 606 630 elif Ityp == 1: 607 631 tifType = 'PE' 608 pixy = (200 ,200)632 pixy = (200*sizeScale,200*sizeScale) 609 633 pos = 8 610 634 if not imageOnly: … … 612 636 elif Ityp == 3328: 613 637 tifType = 'MAR' 614 pixy = (79 ,79)638 pixy = (79*sizeScale,79*sizeScale) 615 639 pos = 4096 616 640 if not imageOnly: … … 619 643 lines = 'unknown tif type' 620 644 return lines,0,0 621 image = np.zeros(shape=( size,size),dtype=np.int32)645 image = np.zeros(shape=(finalSize,finalSize),dtype=np.int32) 622 646 row = 0 623 while row < size:647 while row < finalSize: 624 648 File.seek(pos) 625 649 if 'PE' in tifType: 626 650 if dataType == 5: 627 line = ar.array('f',File.read(4* size))651 line = ar.array('f',File.read(4*finalSize)) 628 652 else: 629 line = ar.array('l',File.read(4* size))630 pos += 4* size653 line = ar.array('l',File.read(4*finalSize)) 654 pos += 4*finalSize 631 655 elif 'MAR' in tifType: 632 line = ar.array('H',File.read(2* size))633 pos += 2* size656 line = ar.array('H',File.read(2*finalSize)) 657 pos += 2*finalSize 634 658 image[row] = np.asarray(line) 635 659 row += 1 … … 639 663 return image 640 664 else: 641 return head,data, size,image665 return head,data,finalSize,image 642 666 643 667 def ProjFileOpen(self): -
trunk/GSASIIgrid.py
r195 r225 245 245 self._init_ctrls(parent,name,size,pos) 246 246 self.data = data 247 self.screenSize = wx.DisplaySize()247 clientSize = wx.ClientDisplayRect() 248 248 Size = self.GetSize() 249 xPos = self.screenSize[0]-Size[0]250 self.SetPosition(wx.Point(xPos, 250))249 xPos = clientSize[2]-Size[0] 250 self.SetPosition(wx.Point(xPos,clientSize[1]+250)) 251 251 self.dirname = '' 252 252 self.AtomGrid = [] … … 254 254 255 255 def setSizePosLeft(self,Width): 256 screenSize = wx.DisplaySize()257 Width[1] = min(Width[1], screenSize[1]-300)256 clientSize = wx.ClientDisplayRect() 257 Width[1] = min(Width[1],clientSize[2]-300) 258 258 self.SetSize(Width) 259 self.SetPosition(wx.Point( screenSize[0]-Width[0],250))259 self.SetPosition(wx.Point(clientSize[2]-Width[0],clientSize[1]+250)) 260 260 261 261 def Clear(self): -
trunk/GSASIIplot.py
r197 r225 1019 1019 Page.canvas.mpl_connect('pick_event', OnImPick) 1020 1020 Page.canvas.mpl_connect('button_release_event', OnImRelease) 1021 xylim = [] 1021 1022 if not event: #event from GUI TextCtrl - don't want focus to change to plot!!! 1022 1023 Page.SetFocus() … … 1024 1025 size,imagefile = self.PatternTree.GetItemPyData(self.Image) 1025 1026 if imagefile != self.oldImagefile: 1026 self.ImageZ = G2IO.GetImageData(imagefile,imageOnly=True) 1027 imagefile = G2IO.CheckImageFile(self,imagefile) 1028 if not imagefile: 1029 self.G2plotNB.Delete('2D Powder Image') 1030 return 1031 self.PatternTree.SetItemPyData(self.Image,[size,imagefile]) 1032 self.ImageZ = G2IO.GetImageData(self,imagefile,imageOnly=True) 1027 1033 self.oldImagefile = imagefile 1028 1034 Data = self.PatternTree.GetItemPyData( … … 1133 1139 Plot.set_xlim(xlim) 1134 1140 Plot.set_ylim(ylim) 1135 if not newPlot :1141 if not newPlot and xylim: 1136 1142 Page.toolbar.push_current() 1137 1143 Plot.set_xlim(xylim[0])
Note: See TracChangeset
for help on using the changeset viewer.