Changeset 1894


Ignore:
Timestamp:
Jun 17, 2015 1:12:45 PM (7 years ago)
Author:
vondreele
Message:

Twins & Flack parameter can't exist together - make each exclusive
rename TwinFr?;n as TwinFr:n so constraint will work
Add a "Clear" option for fixed background points
Prevent Add, Move, Del ops. for fixed points when toolbar active

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r1891 r1894  
    10461046            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
    10471047            bottomSizer.Add(BabSizer(),0,WACV|wx.BOTTOM,5)
    1048             if not SGData['SGInv']:        #not operational yet - no test data
     1048            if not SGData['SGInv'] and len(UseList[G2frame.hist]['Twins']) < 2:
    10491049                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
    10501050            bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5)
  • trunk/GSASIIgrid.py

    r1889 r1894  
    102102[ wxID_BACKCOPY,wxID_LIMITCOPY, wxID_SAMPLECOPY, wxID_SAMPLECOPYSOME, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY,
    103103    wxID_SAMPLESAVE, wxID_SAMPLELOAD,wxID_ADDEXCLREGION,wxID_SETSCALE,wxID_SAMPLE1VAL,wxID_ALLSAMPLELOAD,
    104     wxID_PEAKSMOVE,
    105 ] = [wx.NewId() for item in range(13)]
     104] = [wx.NewId() for item in range(12)]
    106105
    107106[ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD,
     
    793792        self.BackFixed.Append(id=self.wxID_BackPts['Del'], kind=wx.ITEM_RADIO,text='Delete',
    794793            help='Delete fixed background points with mouse clicks')
     794        self.wxID_BackPts['Clear'] = wx.NewId()
     795        self.BackFixed.Append(id=self.wxID_BackPts['Clear'], kind=wx.ITEM_NORMAL,text='Clear',
     796            help='Clear fixed background points')
    795797        self.wxID_BackPts['Fit'] = wx.NewId()
    796798        self.BackFixed.Append(id=self.wxID_BackPts['Fit'], kind=wx.ITEM_NORMAL,text='Fit background',
  • trunk/GSASIIplot.py

    r1889 r1894  
    224224        self.plotCanvas = plotCanvas
    225225        POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 6 # remove one button, nos. start at 1!
    226         self.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN)
     226        self.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN)    #doesn't work in miniconda
    227227        self.parent = self.GetParent()
    228228        key = os.path.join(os.path.split(__file__)[0],'key.ico')
     
    12681268            pick = str(pick)
    12691269        elif G2frame.PatternTree.GetItemText(PickId) == 'Background':
    1270             # selected a fixed background point. Can move it or delete it. 
     1270            # selected a fixed background point. Can move it or delete it.
    12711271            for mode,id in G2frame.dataFrame.wxID_BackPts.iteritems(): # what menu is selected?
    12721272                if G2frame.dataFrame.BackMenu.FindItemById(id).IsChecked():
     
    13001300        PickId = G2frame.PickId                             # points to item in tree
    13011301        if G2frame.PatternTree.GetItemText(PickId) == 'Background' and event.xdata:
     1302            if Page.toolbar._active:    # prevent ops. if a toolbar zoom button pressed
     1303                return
    13021304            # Background page, deal with fixed background points
    13031305            if G2frame.SubBack or G2frame.Weight or G2frame.Contour or not G2frame.SinglePlot:
  • trunk/GSASIIpwdGUI.py

    r1893 r1894  
    792792
    793793    def OnBkgFit(event):
    794         def SetInstParms(Inst):
    795             dataType = Inst['Type'][0]
    796             insVary = []
    797             insNames = []
    798             insVals = []
    799             for parm in Inst:
    800                 insNames.append(parm)
    801                 insVals.append(Inst[parm][1])
    802                 if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
    803                     'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
    804                         insVary.append(parm)
    805             instDict = dict(zip(insNames,insVals))
    806             instDict['X'] = max(instDict['X'],0.01)
    807             instDict['Y'] = max(instDict['Y'],0.01)
    808             if 'SH/L' in instDict:
    809                 instDict['SH/L'] = max(instDict['SH/L'],0.002)
    810             return dataType,instDict,insVary
     794#        def SetInstParms(Inst):
     795#            dataType = Inst['Type'][0]
     796#            insVary = []
     797#            insNames = []
     798#            insVals = []
     799#            for parm in Inst:
     800#                insNames.append(parm)
     801#                insVals.append(Inst[parm][1])
     802#                if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     803#                    'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
     804#                        insVary.append(parm)
     805#            instDict = dict(zip(insNames,insVals))
     806#            instDict['X'] = max(instDict['X'],0.01)
     807#            instDict['Y'] = max(instDict['Y'],0.01)
     808#            if 'SH/L' in instDict:
     809#                instDict['SH/L'] = max(instDict['SH/L'],0.002)
     810#            return dataType,instDict,insVary
    811811   
    812812        PatternId = G2frame.PatternId       
     
    836836
    837837        # load instrument and background params
    838         dataType,insDict,insVary = SetInstParms(inst)
     838#        dataType,insDict,insVary = SetInstParms(inst)
    839839        bakType,bakDict,bakVary = G2pwd.SetBackgroundParms(background)
    840840        # how many background parameters are refined?
     
    865865        # show the updated background values
    866866        wx.CallLater(100,UpdateBackground,G2frame,data)
     867       
     868    def OnBkgClear(event):
     869        if 'FixedPoints' not in data[1]:
     870            return
     871        else:
     872            del data[1]['FixedPoints']
     873            G2plt.PlotPatterns(G2frame,plotType='PWDR')
    867874   
    868875    def OnPeaksMove(event):
     
    10691076    G2frame.Bind(wx.EVT_MENU,OnPeaksMove,id=G2gd.wxID_PEAKSMOVE)
    10701077    G2frame.Bind(wx.EVT_MENU,OnBkgFit,id=G2frame.dataFrame.wxID_BackPts['Fit'])
     1078    G2frame.Bind(wx.EVT_MENU,OnBkgClear,id=G2frame.dataFrame.wxID_BackPts['Clear'])   
    10711079    BackId = G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Background')
    10721080    Choices = ['chebyschev','cosine','Q^2 power series','Q^-2 powder series','lin interpolate','inv interpolate','log interpolate']
  • trunk/GSASIIstrIO.py

    r1891 r1894  
    22402240                    if hapData['Babinet'][bab][1]:
    22412241                        hapVary.append(pfx+bab)
    2242                 hapDict[pfx+'Flack'] = hapData.get('Flack',[0.,False])[0]
    2243                 if hapData.get('Flack',[0,False])[1]:
    2244                     hapVary.append(pfx+'Flack')
    22452242                Twins = hapData.get('Twins',[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],])
     2243                if len(Twins) == 1:
     2244                    hapDict[pfx+'Flack'] = hapData.get('Flack',[0.,False])[0]
     2245                    if hapData.get('Flack',[0,False])[1]:
     2246                        hapVary.append(pfx+'Flack')
    22462247                sumTwFr = 0.
    22472248                controlDict[pfx+'TwinLaw'] = []               
     
    22492250                    controlDict[pfx+'TwinLaw'].append(twin[0])
    22502251                    if it:
    2251                         hapDict[pfx+'TwinFr;'+str(it)] = twin[1]
     2252                        hapDict[pfx+'TwinFr:'+str(it)] = twin[1]
    22522253                        sumTwFr += twin[1]
    22532254                    else:
    2254                         hapDict[pfx+'TwinFr;'+str(it)] = twin[1][0]
    2255                     if Twins[0][1][1] and it:
    2256                         hapVary.append(pfx+'TwinFr;'+str(it))
     2255                        hapDict[pfx+'TwinFr:'+str(it)] = twin[1][0]
     2256                    if Twins[0][1][1]:
     2257                        hapVary.append(pfx+'TwinFr:'+str(it))
    22572258                #need to make constraint on TwinFr
    22582259                controlDict[pfx+'TwinLaw'] = np.array(controlDict[pfx+'TwinLaw'])
    22592260                if len(Twins) > 1:    #force sum to unity
    2260                     hapDict[pfx+'TwinFr;0'] = 1.-sumTwFr
     2261                    hapDict[pfx+'TwinFr:0'] = 1.-sumTwFr
    22612262                if Print:
    22622263                    print >>pFile,'\n Phase: ',phase,' in histogram: ',histogram
     
    22712272                    if hapData['Babinet']['BabA'][0]:
    22722273                        PrintBabinet(hapData['Babinet'])
    2273                     if not SGData['SGInv']:
     2274                    if not SGData['SGInv'] and len(Twins) == 1:
    22742275                        print >>pFile,' Flack parameter: %10.3f'%(hapData['Flack'][0]),' Refine?',hapData['Flack'][1]
    22752276                    if len(Twins) > 1:
    22762277                        for it,twin in enumerate(Twins):
    2277                             print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr;'+str(it)]),Twins[0][1][1]
     2278                            print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
    22782279                       
    22792280                Histogram['Reflection Lists'] = phase       
     
    24412442            else:
    24422443                ptstr += '%12.3f'%(item[1][0])
    2443             if pfx+'TwinFr;'+str(it) in TwinSig:
    2444                 sigstr += '%12.3f'%(TwinSig[pfx+'TwinFr;'+str(it)])
     2444            if pfx+'TwinFr:'+str(it) in TwinSig:
     2445                sigstr += '%12.3f'%(TwinSig[pfx+'TwinFr:'+str(it)])
    24452446            else:
    24462447                sigstr += 12*' '
     
    25462547                    while True:
    25472548                        try:
    2548                             hapData['Twins'][it][1] = parmDict[pfx+'TwinFr;'+str(it)]
    2549                             if pfx+'TwinFr;'+str(it) in sigDict:
    2550                                 TwinFrSig[pfx+'TwinFr;'+str(it)] = sigDict[pfx+'TwinFr;'+str(it)]
     2549                            hapData['Twins'][it][1] = parmDict[pfx+'TwinFr:'+str(it)]
     2550                            if pfx+'TwinFr:'+str(it) in sigDict:
     2551                                TwinFrSig[pfx+'TwinFr:'+str(it)] = sigDict[pfx+'TwinFr:'+str(it)]
    25512552                            if it:
    25522553                                sumTwFr += hapData['Twins'][it][1]
  • trunk/GSASIIstrMath.py

    r1891 r1894  
    816816    BLtables = calcControls['BLtables']
    817817    Flack = 1.0
    818     if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType']:
     818    if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict:
    819819        Flack = 1.-2.*parmDict[phfx+'Flack']
    820820    TwinLaw = np.array([[[1,0,0],[0,1,0],[0,0,1]],])
    821821    if 'S' in calcControls[hfx+'histType']:
    822822        TwinLaw = calcControls[phfx+'TwinLaw']
    823         TwinFr = np.array([parmDict[phfx+'TwinFr;'+str(i)] for i in range(len(TwinLaw))])
     823        TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))])
    824824        if len(TwinLaw) > 1:
    825825            TwinFr[0] = 1.-np.sum(TwinFr[1:])       
     
    916916    if 'S' in calcControls[hfx+'histType']:
    917917        TwinLaw = calcControls[phfx+'TwinLaw']
    918         TwinFr = np.array([parmDict[phfx+'TwinFr;'+str(i)] for i in range(len(TwinLaw))])
     918        TwinFr = np.array([parmDict[phfx+'TwinFr:'+str(i)] for i in range(len(TwinLaw))])
    919919        if len(TwinLaw) > 1:
    920920            TwinFr[0] = 1.-np.sum(TwinFr[1:])
     
    940940    dFdtw = np.zeros((nRef,nTwin))
    941941    Flack = 1.0
    942     if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType']:
     942    if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict:
    943943        Flack = 1.-2.*parmDict[phfx+'Flack']
    944944    for iref,refl in enumerate(refDict['RefList']):
     
    987987            dfbdfr = np.sum(fb/occ,axis=-2)        #Fdata != 0 avoids /0. problem
    988988            dfbdba = np.sum(-sinp*Tcorr[:,np.newaxis],axis=1)
    989             dfadfl = np.sum(-FPP*Tcorr*sinp)
    990             dfbdfl = np.sum(FPP*Tcorr*cosp)
    991989            dfbdui = np.sum(-SQfactor*fb,axis=-2)
    992990            if len(TwinLaw) > 1:
     
    994992                dfbdua = np.array([np.sum(-Hij[it]*np.swapaxes(fb,-2,-1)[:,it,:,:,np.newaxis],axis=2) for it in range(nTwin)])
    995993            else:
     994                dfadfl = np.sum(-FPP*Tcorr*sinp)
     995                dfbdfl = np.sum(FPP*Tcorr*cosp)
    996996                dfbdx = np.sum(twopi*Uniq*np.swapaxes(fbx,-2,-1)[:,:,:,np.newaxis],axis=2)           
    997997                dfbdua = np.sum(-Hij*np.swapaxes(fb,-2,-1)[:,:,:,np.newaxis],axis=2)
     
    10231023                dFdui[iref] = [SA[it]*(dfadui[0][it]+dfbdui[1][it])+SB[it]*(dfbdui[0][it]+dfadui[1][it]) for it in range(nTwin)]
    10241024                dFdua[iref] = [SA[it]*(dfadua[it][0]+dfbdua[it][1])+SB[it]*(dfbdua[it][0]+dfadua[it][1]) for it in range(nTwin)]
    1025                 dFdfl[iref] = -SA*dfadfl-SB*dfbdfl
    10261025                dFdtw[iref] = 2.*SA+2.*SB
    10271026            else:
     
    10491048            dFdvDict[pfx+'AU13:'+str(i)] = np.sum(0.5*dFdua.T[4][i]*TwinFr[:,np.newaxis],axis=0)/2.
    10501049            dFdvDict[pfx+'AU23:'+str(i)] = np.sum(0.5*dFdua.T[5][i]*TwinFr[:,np.newaxis],axis=0)/2.
    1051         dFdvDict[phfx+'Flack'] = np.sum(dFdfl*TwinFr,axis=1)    #?
    10521050    else:
    10531051        for i in range(len(Mdata)):
     
    10671065    dFdvDict[phfx+'BabU'] = dFdbab.T[1]
    10681066    if nTwin > 1:
    1069         for i in range(nTwin-1):    #skip the base twin element
    1070             dFdvDict[phfx+'TwinFr;'+str(i+1)] = dFdtw.T[i+1]
     1067        for i in range(nTwin):
     1068            dFdvDict[phfx+'TwinFr:'+str(i)] = dFdtw.T[i]
    10711069    return dFdvDict
    10721070   
Note: See TracChangeset for help on using the changeset viewer.