Changeset 615 for trunk/GSASII.py
- Timestamp:
- May 15, 2012 10:54:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r614 r615 217 217 "G2"+prefix+"*.py")): 218 218 filelist.append(filename) 219 print 'debug: found',filename219 #print 'debug: found',filename 220 220 filelist = sorted(list(set(filelist))) # remove duplicates 221 221 for filename in filelist: … … 278 278 if not reader.strictExtension: 279 279 choices += "|any file (*.*)|*.*" 280 # get the file 280 # get the file(s) 281 281 if multiple: 282 282 mode = style=wx.OPEN | wx.CHANGE_DIR | wx.MULTIPLE … … 320 320 try: 321 321 fp = open(filename,'Ur') 322 if len(filelist) == 1: 323 # confirm we have the right file 324 rdmsg = 'File '+str(filename)+' begins:\n\n' 325 for i in range(3): 326 rdmsg += fp.readline() 327 rdmsg += '...' 328 result = wx.ID_NO 329 # it would be better to use something that 330 # would resize better, but this will do for now 331 dlg = wx.MessageDialog( 332 self, rdmsg, 333 'Is this the file you want?', 334 wx.YES_NO | wx.ICON_QUESTION, 335 ) 336 dlg.SetSize((700,300)) # does not resize on Mac 337 try: 338 result = dlg.ShowModal() 339 finally: 340 dlg.Destroy() 341 if result == wx.ID_NO: return [] 342 322 343 self.lastimport = filename 323 344 # try the file first with Readers that specify the … … 546 567 numbanks = rd.numbanks 547 568 # is there an instrument parameter file defined for the current data set? 548 if rd.instparm or lastdatafile == filename:569 if rd.instparm or (lastdatafile == filename and lastIparmfile): 549 570 if rd.instparm: 550 571 instfile = os.path.join(os.path.split(filename)[0], … … 554 575 instfile = lastIparmfile 555 576 if os.path.exists(instfile): 556 print 'debug: try read',instfile577 #print 'debug: try read',instfile 557 578 Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd) 558 579 if Iparm: 559 print 'debug: success'580 #print 'debug: success' 560 581 rd.instfile = instfile 561 582 rd.instmsg = instfile + ' bank ' + str(rd.instbank) … … 563 584 else: 564 585 self.ErrorDialog('Open Error', 565 'Error opening file '+str(instfile) 586 'Error opening instrument parameter file ' 587 +str(instfile) 566 588 +' requested by file '+ filename) 567 589 # is there an instrument parameter file matching the current file … … 572 594 Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd) 573 595 if Iparm: 574 print 'debug: success'596 #print 'debug: success' 575 597 rd.instfile = instfile 576 598 rd.instmsg = instfile + ' bank ' + str(rd.instbank) 577 599 return Iparm 578 600 else: 579 print 'debug open/read failed',instfile601 print 'debug: open/read failed',instfile 580 602 pass # fail silently 581 603 … … 583 605 instfile = '' 584 606 dlg = wx.FileDialog(self, 585 'Choose an instrument file or press Cancel to select a default setting', 607 'Choose an instrument file for ' 608 +rd.idstring 609 +' or press Cancel to select a default setting', 586 610 '.', '', 587 611 'GSAS iparm file (*.prm)|*.prm|All files(*.*)|*.*', … … 595 619 Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd) 596 620 if Iparm: 597 print 'debug: success with',instfile621 #print 'debug: success with',instfile 598 622 rd.instfile = instfile 599 623 rd.instmsg = instfile + ' bank ' + str(rd.instbank) … … 604 628 605 629 # still no success: offer the user a last choice 606 dlg = wx.MessageDialog(self,607 '''Is thislaboratory Cu Ka1/Ka2 data?630 msg = 'Are the data from ' + rd.idstring 631 msg += ''' laboratory Cu Ka1/Ka2 data? 608 632 (No = 0.6A wavelength synchrotron data) 609 Change wavelength in Instrument Parameters if needed''' ,610 633 Change wavelength in Instrument Parameters if needed''' 634 dlg = wx.MessageDialog(self, msg, 'Data type?', 611 635 wx.YES_NO | wx.ICON_QUESTION) 612 636 try: … … 623 647 return rd.Iparm_Sync06 624 648 625 def SetPowderInstParms(self, Iparm ):649 def SetPowderInstParms(self, Iparm, rd): 626 650 '''extracts values from instrument parameter file and creates 627 651 the contents of the instrument parameter tree entry 628 652 ''' 629 653 DataType = Iparm['INS HTYPE '].strip()[0:3] # take 1st 3 chars 654 # override inst values with values read from data file 655 if rd.instdict.get('type'): 656 DataType = rd.instdict.get('type') 657 wave1 = None 658 wave2 = 0.0 659 if rd.instdict.get('wave'): 660 wl = rd.instdict.get('wave') 661 wave1 = wl[0] 662 if len(wl) > 1: wave2 = wl[1] 630 663 data = [DataType,] 631 664 if 'C' in DataType: 632 665 s = Iparm['INS 1 ICONS'] 633 v = (G2IO.sfloat(s[:10]),G2IO.sfloat(s[10:20]),G2IO.sfloat(s[20:30]),G2IO.sfloat(s[55:65]),G2IO.sfloat(s[40:50])) #get lam1, lam2, zero, pola & ratio 666 if not wave1: 667 wave1 = G2IO.sfloat(s[:10]) 668 wave2 = G2IO.sfloat(s[10:20]) 669 v = (wave1,wave2, 670 G2IO.sfloat(s[20:30]),G2IO.sfloat(s[55:65]),G2IO.sfloat(s[40:50])) #get lam1, lam2, zero, pola & ratio 634 671 if not v[1]: 635 672 names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth'] … … 698 735 self.PatternTree.SetItemPyData( 699 736 self.PatternTree.AppendItem(Id,text='Instrument Parameters'), 700 self.SetPowderInstParms(Iparm ))737 self.SetPowderInstParms(Iparm,rd)) 701 738 self.PatternTree.SetItemPyData( 702 739 self.PatternTree.AppendItem(Id,text='Sample Parameters'),
Note: See TracChangeset
for help on using the changeset viewer.