Changeset 1359


Ignore:
Timestamp:
May 21, 2014 12:59:59 PM (8 years ago)
Author:
vondreele
Message:

start allowing reading of multiple HKLF files.
put an IndexAllIds? into UpdateConstraints?
edf image fixes
more places in Pawley d-min
format of penalty fxn chi2
allow one Bank selection set to be used for multiple files
new reader for TOF HKLF2 data - nonworking just now

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1355 r1359  
    705705        reqrdr = self.ImportMenuId.get(event.GetId())
    706706        rdlist = self.OnImportGeneric(reqrdr,self.ImportSfactReaderlist,
    707             'Structure Factor')
     707            'Structure Factor',multiple=True)
    708708        if len(rdlist) == 0: return
    709709        self.CheckNotebook()
     
    10221022                            s = Iparm['INS  1IECOF'+str(i+1)].split()
    10231023                            Iesd += [float(S) for S in s]
     1024                        NT = 10
    10241025                        for i in range(8):
    1025                             s = Iparm['INS  1IECOR'+str(i+1)].split()
    1026                             Icovar += [float(S) for S in s]
     1026                            s = Iparm['INS  1IECOR'+str(i+1)]
     1027                            if i == 7:
     1028                                NT = 8
     1029                            Icovar += [float(s[6*j:6*j+6]) for j in range(NT)]
    10271030                        Inst2['Icoeff'] = Icoeff
    10281031                        Inst2['Iesd'] = Iesd
  • trunk/GSASIIIO.py

    r1355 r1359  
    306306    lines = head.split('\n')
    307307    sizexy = [0,0]
    308     pixSize = [0,0]
     308    pixSize = [154,154]     #Pixium4700?
    309309    cent = [0,0]
     310    wave = 1.54187  #default <CuKa>
     311    dist = 1000.
    310312    head = ['European detector data',]
    311313    for line in lines:
     314        line = line.replace(';',' ').strip()
    312315        fields = line.split()
    313316        if 'Dim_1' in line:
     
    317320        elif 'DataType' in line:
    318321            dType = fields[2]
    319         elif 'refined_wavelength' in line:
     322        elif 'wavelength' in line:
    320323            wave = float(fields[2])
    321324        elif 'Size' in line:
     
    335338        if line:
    336339            head.append(line)
     340        else:   #blank line at end of header
     341            break 
    337342    File.seek(fileSize-imSize)
    338343    if dType == 'UnsignedShort':       
    339344        image = np.array(ar.array('H',File.read(imSize)),dtype=np.int32)
    340345    elif dType == 'UnsignedInt':
     346        image = np.array(ar.array('L',File.read(imSize)),dtype=np.int32)
     347    elif dType == 'UnsignedLong':
    341348        image = np.array(ar.array('L',File.read(imSize)),dtype=np.int32)       
    342349    image = np.reshape(image,(sizexy[1],sizexy[0]))
     
    14101417        # more than one data block
    14111418        self.repeat = False
     1419        self.selections = []
    14121420        self.repeatcount = 0
    14131421        self.readfilename = '?'
  • trunk/GSASIIconstrGUI.py

    r1247 r1359  
    205205    ###################################################
    206206    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     207    G2obj.IndexAllIds(Histograms,Phases)
    207208    ##################################################################################
    208209    # patch: convert old-style (str) variables in constraints to G2VarObj objects
  • trunk/GSASIIobj.py

    r1340 r1359  
    946946    element each atom record.
    947947
    948     This is called in two places (only) :func:`GSASIIstrIO.GetUsedHistogramsAndPhases`
    949     (which loads the histograms and phases from a GPX file) and
     948    This is called in three places (only) :func:`GSASIIstrIO.GetUsedHistogramsAndPhases`
     949    (which loads the histograms and phases from a GPX file),
    950950    :meth:`GSASII.GSASII.GetUsedHistogramsAndPhasesfromTree`
    951     (which loads the histograms and phases from the data tree.)
     951    (which loads the histograms and phases from the data tree.) and
     952    :meth:`GSASII.GSASIIconstrGUI.UpdateConstraints
     953    (which displays & edits the constraints in a GUI)
    952954
    953955    TODO: do we need a lookup for rigid body variables?
  • trunk/GSASIIphsGUI.py

    r1283 r1359  
    495495                except ValueError:
    496496                    pass
    497                 pawlVal.SetValue("%.3f"%(generalData['Pawley dmin']))          #reset in case of error               
     497                pawlVal.SetValue("%.5f"%(generalData['Pawley dmin']))          #reset in case of error               
    498498           
    499499            def OnPawleyNegWt(event):
     
    513513            pawleySizer.Add(pawlRef,0,WACV)
    514514            pawleySizer.Add(wx.StaticText(General,label=' Pawley dmin: '),0,WACV)
    515             pawlVal = wx.TextCtrl(General,value='%.3f'%(generalData['Pawley dmin']),style=wx.TE_PROCESS_ENTER)
     515            pawlVal = wx.TextCtrl(General,value='%.5f'%(generalData['Pawley dmin']),style=wx.TE_PROCESS_ENTER)
    516516            pawlVal.Bind(wx.EVT_TEXT_ENTER,OnPawleyVal)       
    517517            pawlVal.Bind(wx.EVT_KILL_FOCUS,OnPawleyVal)
  • trunk/GSASIIstrMath.py

    r1335 r1359  
    21162116        pSum = np.sum(pWt*pVals**2)
    21172117        for name in pWsum:
    2118             print '  Penalty function for %8s = %.3f'%(name,pWsum[name])
    2119         print 'Total penalty function: %.3f on %d terms'%(pSum,len(pVals))
     2118            print '  Penalty function for %8s = %12.5g'%(name,pWsum[name])
     2119        print 'Total penalty function: %12.5g on %d terms'%(pSum,len(pVals))
    21202120        Nobs += len(pVals)
    21212121        M = np.concatenate((M,np.sqrt(pWt)*pVals))
  • trunk/imports/G2pwd_fxye.py

    r1259 r1359  
    210210        title = ''
    211211        comments = None
    212         selections = None
     212#        selections = None
    213213
    214214        # reload previously saved values
     
    216216            Banks = rdbuffer.get('Banks')
    217217            Pos = rdbuffer.get('Pos')
    218             selections = rdbuffer.get('selections')
     218            self.selections = rdbuffer.get('selections')
    219219            comments = rdbuffer.get('comments')
    220220
     
    240240                        # 2nd line is instrument parameter file (optional)
    241241                        self.errors = 'Error reading instrument parameter filename'
    242                         self.instparm = S.split(':')[1].strip()
     242                        self.instparm = S.split(':')[1].strip('[]').strip()
    243243                        continue
    244244                    if S[0] == '#': # allow comments anywhere in the file
     
    273273        elif len(Banks) == 1: # only one Bank, don't ask
    274274            selblk = 0
    275         elif self.repeat and selections is not None:
     275        elif self.repeat and self.selections is not None:
    276276            # we were called to repeat the read
    277             #print 'debug: repeat #',self.repeatcount,'selection',selections[self.repeatcount]
    278             selblk = selections[self.repeatcount]
     277            #print 'debug: repeat #',self.repeatcount,'selection',self.selections[self.repeatcount]
     278            selblk = self.selections[self.repeatcount]
    279279            self.repeatcount += 1
    280             if self.repeatcount >= len(selections): self.repeat = False
     280            if self.repeatcount >= len(self.selections): self.repeat = False
    281281        else:                       # choose from options
    282             selections = self.MultipleBlockSelector(
    283                 Banks,
    284                 ParentFrame=ParentFrame,
    285                 title='Select Bank(s) to read from the list below',
    286                 size=(600,100),
    287                 header='Dataset Selector')
    288             if len(selections) == 0: return False
    289             selblk = selections[0] # select first in list
    290             if len(selections) > 1: # prepare to loop through again
     282            if not len(self.selections):    #use previous selection, otherwise...
     283                self.selections = self.MultipleBlockSelector(
     284                    Banks,
     285                    ParentFrame=ParentFrame,
     286                    title='Select Bank(s) to read from the list below',
     287                    size=(600,100),
     288                    header='Dataset Selector')
     289            if len(self.selections) == 0: return False
     290            selblk = self.selections[0] # select first in list
     291            if len(self.selections) > 1: # prepare to loop through again
    291292                self.repeat = True
    292293                self.repeatcount = 1
     
    294295                    rdbuffer['Banks'] = Banks
    295296                    rdbuffer['Pos'] = Pos
    296                     rdbuffer['selections'] = selections
     297                    rdbuffer['selections'] = self.selections
    297298                    rdbuffer['comments'] = comments
    298299
     
    343344                except:
    344345                    pass
     346            elif 'Omega' in S.split('=')[0] or 'Theta' in S.split('=')[0]:  #HIPD weirdness
     347                try:
     348                    self.Sample['Omega'] = float(S.split('=')[1])
     349                except:
     350                    pass
     351            elif 'Chi' in S.split('=')[0]:
     352                try:
     353                    self.Sample['Chi'] = float(S.split('=')[1])
     354                except:
     355                    pass                   
     356            elif 'Phi' in S.split('=')[0]:
     357                try:
     358                    self.Sample['Phi'] = float(S.split('=')[1])
     359                except:
     360                    pass                   
    345361        self.Sample['Temperature'] = Temperature
    346362        return True       
  • trunk/imports/G2sfact.py

    r1168 r1359  
    4949            extensionlist=('.hkl','.HKL'),
    5050            strictExtension=False,
    51             formatName = 'F containing HKL',
     51            formatName = 'HKL containing F',
    5252            longFormatName = 'Simple [hkl, Fo, sig(Fo)] Structure factor text file'
    5353            )
     
    9090            extensionlist=('.hkl','.HKL'),
    9191            strictExtension=False,
    92             formatName = u'F\u00b2 containing HKL',
     92            formatName = u'HKL containing F\u00b2',
    9393            longFormatName = u'Simple [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'
    9494            )
     
    125125            return False
    126126
     127class NT_HKLF2_ReaderClass(G2IO.ImportStructFactor):
     128    'Routines to import neutron TOF F**2, sig(F**2) reflections from a HKLF file'
     129    def __init__(self):
     130        super(self.__class__,self).__init__( # fancy way to self-reference
     131            extensionlist=('.hkl','.HKL'),
     132            strictExtension=False,
     133            formatName = u'Neutron TOF HKL containing F\u00b2',
     134            longFormatName = u'Neutron TOF [hkl, Fo\u00b2, sig(Fo\u00b2),...] Structure factor text file'
     135            )
     136
     137    def ContentsValidator(self, filepointer):
     138        'Make sure file contains the expected columns on numbers'
     139        return ColumnValidator(self, filepointer)
     140
     141    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
     142        'Read the file'
     143        try:
     144            oldNo = -1
     145            Banks = []
     146            for line,S in enumerate(filepointer):
     147                if S[0] == '#': continue       #ignore comments, if any
     148                bankNo = S.split()[5]
     149                if bankNo != oldNo:
     150                    Banks.append([])
     151                   
     152            for line,S in enumerate(filepointer):
     153                self.errors = '  Error reading line '+str(line+1)
     154                if S[0] == '#': continue       #ignore comments, if any
     155                h,k,l,Fo,sigFo = S.split()
     156                h,k,l = [int(h),int(k),int(l)]
     157                if not any([h,k,l]):
     158                    break
     159                Fo = float(Fo)
     160                sigFo = float(sigFo)
     161                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
     162                self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0])
     163            self.errors = 'Error after reading reflections (unexpected!)'
     164            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
     165            self.UpdateControls(Type='Fosq',FcalcPresent=False) # set Fobs type & if Fcalc values are loaded
     166            self.UpdateParameters(Type='SNT',Wave=None) # histogram type
     167            return True
     168        except Exception as detail:
     169            self.errors += '\n  '+str(detail)
     170            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
     171            import traceback
     172            traceback.print_exc(file=sys.stdout)
     173            return False
     174
Note: See TracChangeset for help on using the changeset viewer.