Changeset 2820
- Timestamp:
- May 4, 2017 4:06:25 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2818 r2820 520 520 if Start: #clear old bank selections to allow new ones to be selected by user 521 521 rd.selections = [] 522 Start = False522 rd.dnames = [] 523 523 rd.ReInitialize() # purge anything from a previous read 524 524 fp.seek(0) # rewind … … 528 528 if rd.errors: 529 529 errorReport += ': '+rd.errors 530 continue 530 continue 531 if len(rd.selections)>1 and Start: 532 dlg = G2G.G2MultiChoiceDialog(self,'Dataset Selector','Select data to read from the list below',rd.dnames) 533 if dlg.ShowModal() == wx.ID_OK: 534 rd.selections = dlg.GetSelections() 535 Start = False 536 dlg.Destroy() 531 537 repeat = True 532 538 rdbuffer = {} # create temporary storage for file reader … … 562 568 rd.Data['ImageTag'] = rd.repeatcount 563 569 rd.Data['formatName'] = rd.formatName 564 # print rd.readfilename565 # print rd.sumfile566 # print rd.Image.shape,rd.Image.dtype567 570 if rd.sumfile: 568 571 rd.readfilename = rd.sumfile … … 703 706 header = 'Select histogram(s) to add to new phase(s):' 704 707 for phaseName in newPhaseList: 705 header += '\n '+ str(phaseName)708 header += '\n '+phaseName 706 709 707 710 notOK = True … … 1092 1095 If the number of banks in the data and instrument parameter files 1093 1096 agree, then the sets of banks are assumed to match up and bank 1094 is used to select the instrument parameter file. If not , the user1095 is asked to make a selection.1097 is used to select the instrument parameter file. If not and not TOF, 1098 the user is asked to make a selection. 1096 1099 :param obj rd: the raw data (histogram) data object. This 1097 1100 sets rd.instbank. … … 1118 1121 rd.powderentry[2] = 1 1119 1122 return Iparm 1120 # if 'PNT' in hType: # not sure what this is about 1121 # rd.instbank = bank 1122 # elif ibanks != databanks or bank is None: 1123 if (ibanks != databanks and databanks != 1) or bank is None: 1124 # number of banks in data and prm file not not agree, need a 1125 # choice from a human here 1123 if 'PNT' in Iparm['INS HTYPE ']: #allow mismatch between banks in data iparm file for TOF 1124 rd.instbank = bank 1125 elif ibanks != databanks or bank is None: 1126 1126 choices = [] 1127 1127 for i in range(1,1+ibanks): … … 1190 1190 wave2 = G2IO.sfloat(s[10:20]) 1191 1191 v = (wave1,wave2, 1192 G2IO.sfloat(s[20:30]) ,G2IO.sfloat(s[55:65]),G2IO.sfloat(s[40:50])) #get lam1, lam2, zero, pola & ratio1192 G2IO.sfloat(s[20:30])/100.,G2IO.sfloat(s[55:65]),G2IO.sfloat(s[40:50])) #get lam1, lam2, zero, pola & ratio 1193 1193 if not v[1]: 1194 1194 names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth'] … … 1435 1435 return GetDefaultParms(self,rd) 1436 1436 else: 1437 self.ErrorDialog('Open Error', 1438 u'Error opening instrument parameter file ' 1439 +'{} requested by file '.format(instfile,filename)) 1437 self.ErrorDialog('Open Error',u'Error opening instrument parameter file ' \ 1438 +'{} requested by file '.format(instfile,filename)) 1440 1439 #Finally - ask user for Instrument parametrs file - seems it can't be in a zip file 1441 1440 while True: # loop until we get a file that works or we get a cancel … … 1525 1524 lastdatafile = '' 1526 1525 newHistList = [] 1527 lastVals = []1526 # lastVals = [] 1528 1527 self.EnablePlot = False 1529 1528 for rd in rdlist: … … 1532 1531 else: 1533 1532 # get instrument parameters for each dataset, unless already set 1534 if lastIparmfile: # is this histogram like previous?1535 if lastVals != (rd.powderdata[0].min(),rd.powderdata[0].max(),len(rd.powderdata[0])):1536 lastIparmfile = ''1533 # if lastIparmfile: # is this histogram like previous? 1534 # if lastVals != (rd.powderdata[0].min(),rd.powderdata[0].max(),len(rd.powderdata[0])): 1535 # lastIparmfile = '' 1537 1536 Iparms = self.GetPowderIparm(rd, Iparm, lastIparmfile, lastdatafile) 1538 1537 if not Iparms: #may have bailed out … … 1542 1541 if rd.repeat_instparm: 1543 1542 lastIparmfile = rd.instfile 1544 lastVals = (rd.powderdata[0].min(),rd.powderdata[0].max(),len(rd.powderdata[0]))1543 # lastVals = (rd.powderdata[0].min(),rd.powderdata[0].max(),len(rd.powderdata[0])) 1545 1544 # override any keys in read instrument parameters with ones set in import 1546 1545 for key in Iparm1: … … 3253 3252 sub = self.PatternTree.AppendItem(parent=sub,text=PhaseName) 3254 3253 E,SGData = G2spc.SpcGroup('P 1') 3255 self.PatternTree.SetItemPyData(sub,G2 IO.SetNewPhase(Name=PhaseName,SGData=SGData))3254 self.PatternTree.SetItemPyData(sub,G2obj.SetNewPhase(Name=PhaseName,SGData=SGData)) 3256 3255 G2gd.SelectDataTreeItem(self,sub) #bring up new phase General tab 3257 3256 -
trunk/GSASIIimgGUI.py
r2798 r2820 93 93 if backImage is not None: 94 94 sumImg += np.array(backImage*backScale,dtype='int32') 95 if darkImg: del darkImg #force cleanup96 if backImg: del backImg95 # if darkImg: del darkImg #force cleanup 96 # if backImg: del backImg 97 97 sumImg -= int(data.get('Flat Bkg',0)) 98 98 Imax = np.max(sumImg) -
trunk/GSASIIobj.py
r2818 r2820 1812 1812 self.SciPy = False #image reader needed scipy 1813 1813 self.repeat = False 1814 self.repeat = False1815 1814 self.repeatcount = 0 1816 1815 self.readfilename = '?' -
trunk/GSASIIpwdGUI.py
r2817 r2820 33 33 import GSASIIpwd as G2pwd 34 34 import GSASIIIO as G2IO 35 import GSASIIobj as G2obj 35 36 import GSASIIlattice as G2lat 36 37 import GSASIIspc as G2spc … … 3158 3159 E,SGData = G2spc.SpcGroup(controls[13]) 3159 3160 G2frame.PatternTree.SetItemPyData(sub, \ 3160 G2 IO.SetNewPhase(Name=PhaseName,SGData=SGData,cell=cell[1:],Super=ssopt))3161 G2obj.SetNewPhase(Name=PhaseName,SGData=SGData,cell=cell[1:],Super=ssopt)) 3161 3162 Status.SetStatusText('Change space group from '+str(controls[13])+' if needed') 3162 3163 finally: -
trunk/GSASIIscriptable.py
r2817 r2820 13 13 import sys 14 14 import cPickle 15 import imp 15 16 import GSASIIpath 16 17 import GSASIIobj as G2obj … … 96 97 print('project save successful') 97 98 98 def ImportPowder(filename,reader): 99 print 'importer' 99 def ImportPowder(reader,filename,bankNo=0): 100 rdfile,rdpath,descr = imp.find_module(reader) 101 rdclass = imp.load_module(reader,rdfile,rdpath,descr) 102 rd = rdclass.GSAS_ReaderClass() 103 fl = open(filename) 104 if rd.ContentsValidator(fl): 105 fl.seek(0) 106 rd.selections = [bankNo,] 107 if rd.Reader(filename,fl): 108 return rd 109 print rd.errors 110 return None 100 111 101 112 -
trunk/imports/G2pwd_GPX.py
r2817 r2820 16 16 import numpy as np 17 17 import GSASIIobj as G2obj 18 import GSASIIIO as G2IO19 18 import GSASIIpath 20 19 GSASIIpath.SetVersionNumber("$Revision$") … … 40 39 self.errors = 'This is not a valid .GPX file. Not recognized by cPickle' 41 40 return False 42 return True 41 filepointer.seek(0) 42 nhist = 0 43 while True: 44 try: 45 data = cPickle.load(filepointer) 46 except EOFError: 47 break 48 if data[0][0][:4] == 'PWDR': 49 nhist += 1 50 self.dnames.append(data[0][0]) 51 if nhist: 52 if not len(self.selections): #no PWDR entries 53 self.selections = range(nhist) 54 return True 55 self.errors = 'No powder entries found' 56 return False 43 57 44 58 def Reader(self,filename,filepointer, ParentFrame=None, **kwarg): … … 51 65 # reload previously saved values 52 66 if self.repeat and rdbuffer is not None: 53 sel ections = rdbuffer.get('selections')67 self.selections = rdbuffer.get('selections') 54 68 poslist = rdbuffer.get('poslist') 55 69 histnames = rdbuffer.get('histnames') … … 75 89 elif len(histnames) == 1: # one block, no choices 76 90 selblk = 0 77 elif self.repeat and sel ections is not None:91 elif self.repeat and self.selections is not None: 78 92 # we were called to repeat the read 79 93 #print 'debug: repeat #',self.repeatcount,'selection',selections[self.repeatcount] 80 selblk = sel ections[self.repeatcount]94 selblk = self.selections[self.repeatcount] 81 95 self.repeatcount += 1 82 if self.repeatcount >= len(sel ections): self.repeat = False96 if self.repeatcount >= len(self.selections): self.repeat = False 83 97 else: # choose from options 84 selections = G2IO.MultipleBlockSelector( 85 histnames, 86 ParentFrame=ParentFrame, 87 title='Select histogram(s) to read from the list below', 88 size=(600,250), 89 header='Dataset Selector') 90 if len(selections) == 0: 91 self.errors = 'No histogram selected' 92 return False 93 selblk = selections[0] # select first in list 94 if len(selections) > 1: # prepare to loop through again 98 selblk = self.selections[0] # select first in list 99 if len(self.selections) > 1: # prepare to loop through again 95 100 self.repeat = True 96 101 self.repeatcount = 1 … … 98 103 rdbuffer['poslist'] = poslist 99 104 rdbuffer['histnames'] = histnames 100 rdbuffer['selections'] = sel ections105 rdbuffer['selections'] = self.selections 101 106 102 107 fl = open(filename,'rb') -
trunk/imports/G2pwd_fxye.py
r2817 r2820 17 17 import numpy as np 18 18 import GSASIIobj as G2obj 19 import GSASIIIO as G2IO20 19 import GSASIIpath 21 20 GSASIIpath.SetVersionNumber("$Revision$") … … 32 31 self.clockWd = {} 33 32 self.TimeMap = {} 33 self.dnames = [] 34 34 35 35 # Validate the contents -- look for a bank line 36 36 def ContentsValidator(self, filepointer): 37 'Valid ate by checking to see if the file has BANK lines'37 'Validrate by checking to see if the file has BANK lines & count them' 38 38 #print 'ContentsValidator: '+self.formatName 39 nBanks= 0 40 fname = ospath.basename(filepointer.name) 39 41 for i,line in enumerate(filepointer): 40 42 self.GSAS = True … … 46 48 if line[0] == '#': continue 47 49 if line[:4] == 'BANK': 48 return True 50 self.dnames.append(fname+' '+''.join(line.split()[:2])) 51 nBanks += 1 52 continue 49 53 elif line[:7] == 'Monitor': continue 50 54 elif line [:8] == 'TIME_MAP': #LANSCE TOF data 51 return True 52 else: 53 self.errors = 'Unexpected information in line: '+str(i+1) 54 if all([ord(c) < 128 and ord(c) != 0 for c in str(line)]): # show only if ASCII 55 self.errors += ' '+str(line) 56 else: 57 self.errors += ' (binary)' 58 return False 55 continue 56 # else: 57 # if not all(c in ' 0123456789.eE+-' for c in line[:-1]): 58 # self.errors = 'Unexpected information in line: '+str(i+1) 59 # self.errors += ' '+str(line) 60 # return False 61 if nBanks: 62 if not len(self.selections): 63 self.selections = range(nBanks) 64 return True 65 self.errors = 'No BANK records found' 59 66 return False # no bank records 60 67 … … 322 329 if self.repeatcount >= len(self.selections): self.repeat = False 323 330 else: # choose from options 324 if not len(self.selections): #use previous selection, otherwise...325 self.selections = G2IO.MultipleBlockSelector(326 Banks,327 ParentFrame=ParentFrame,328 title='Select Bank(s) to read from the list below',329 size=(600,300),330 header='Dataset Selector')331 if len(self.selections) == 0:332 self.errors = 'No banks selected'333 return False334 331 selblk = self.selections[0] # select first in list 335 332 if len(self.selections) > 1: # prepare to loop through again
Note: See TracChangeset
for help on using the changeset viewer.