Changeset 5265


Ignore:
Timestamp:
Apr 16, 2022 9:13:35 PM (11 months ago)
Author:
toby
Message:

back out LaueFringe? dev work

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5264 r5265  
    79417941            G2frame.GPXtree.SetItemPyData(item,data)
    79427942#end patch
    7943         if GSASIIpath.GetConfigValue('debug'):
    7944             import importlib as imp
    7945             imp.reload(G2pdG)
    7946             print('reloading G2pdG')
     7943        # if GSASIIpath.GetConfigValue('debug'):
     7944        #     import importlib as imp
     7945        #     imp.reload(G2pdG)
     7946        #     print('reloading G2pdG')
    79477947        G2pdG.UpdatePeakGrid(G2frame,data)
    79487948        G2plt.PlotPatterns(G2frame)
  • trunk/GSASIIpwd.py

    r5264 r5265  
    5252    print ('pydiffax is not available for this platform')
    5353import GSASIIfiles as G2fil
    54 import LaueFringe as LF
     54#import LaueFringe as LF
    5555   
    5656# trig functions in degrees
     
    14091409    yb = getBackground('',parmDict,bakType,dataType,xdata,fixback)[0]
    14101410    yc = np.zeros_like(yb)
    1411     if parmDict.get('LaueFringe',False):
    1412         if 'Lam1' in parmDict.keys():
    1413             lam = parmDict['Lam1']
    1414             lam2 = parmDict['Lam2']
    1415             Ka2 = True
    1416             lamRatio = 360*(lam2-lam)/(np.pi*lam)
    1417             kRatio = parmDict['I(L2)/I(L1)']
    1418         else:
    1419             lam = parmDict['Lam']
    1420             Ka2 = False
    1421         shol = 0
    1422         # loop over peaks
    1423         iPeak = -1
    1424         cells =  parmDict['ncell']
    1425         while True:
    1426             iPeak += 1
    1427             try:
    1428                 pos = parmDict['pos'+str(iPeak)]
    1429                 #tth = (pos-parmDict['Zero'])
    1430                 intens = parmDict['int'+str(iPeak)]
    1431                 damp =  parmDict['damp'+str(iPeak)]
    1432                 asym =  parmDict['asym'+str(iPeak)]
    1433                 sig =  parmDict['sig'+str(iPeak)]
    1434                 gam =  parmDict['gam'+str(iPeak)]
    1435                 fmin = 4 # for now make peaks 4 degrees wide
    1436                 fmin = min(0.9*abs(xdata[-1] - xdata[0]),fmin) # unless the data range is smaller
    1437                 iBeg = np.searchsorted(xdata,pos-fmin/2)
    1438                 iFin = np.searchsorted(xdata,pos+fmin/2)
    1439                 if not iBeg+iFin:       # skip peak below low limit
    1440                     continue
    1441                 elif not iBeg-iFin:     # got peak above high limit (peaks sorted, so we can stop)
    1442                     break
    1443                 LF.LaueFringePeakCalc(xdata,yc,lam,pos,intens,damp,asym,sig,gam,shol,cells,fmin)
    1444                 if Ka2:
    1445                     pos2 = pos+lamRatio*tand(pos/2.0)       # + 360/pi * Dlam/lam * tan(th)
    1446                     iBeg = np.searchsorted(xdata,pos2-fmin)
    1447                     iFin = np.searchsorted(xdata,pos2+fmin)
    1448                     if iBeg-iFin:
    1449                         LF.LaueFringePeakCalc(xdata,yc,lam2,pos2,intens*kRatio,damp,asym,sig,gam,shol,cells,fmin)
    1450             except KeyError:        #no more peaks to process
    1451                 return yb+yc
    1452     elif 'C' in dataType:
     1411    # if parmDict.get('LaueFringe',False):
     1412    #     if 'Lam1' in parmDict.keys():
     1413    #         lam = parmDict['Lam1']
     1414    #         lam2 = parmDict['Lam2']
     1415    #         Ka2 = True
     1416    #         lamRatio = 360*(lam2-lam)/(np.pi*lam)
     1417    #         kRatio = parmDict['I(L2)/I(L1)']
     1418    #     else:
     1419    #         lam = parmDict['Lam']
     1420    #         Ka2 = False
     1421    #     shol = 0
     1422    #     # loop over peaks
     1423    #     iPeak = -1
     1424    #     cells =  parmDict['ncell']
     1425    #     while True:
     1426    #         iPeak += 1
     1427    #         try:
     1428    #             pos = parmDict['pos'+str(iPeak)]
     1429    #             #tth = (pos-parmDict['Zero'])
     1430    #             intens = parmDict['int'+str(iPeak)]
     1431    #             damp =  parmDict['damp'+str(iPeak)]
     1432    #             asym =  parmDict['asym'+str(iPeak)]
     1433    #             sig =  parmDict['sig'+str(iPeak)]
     1434    #             gam =  parmDict['gam'+str(iPeak)]
     1435    #             fmin = 4 # for now make peaks 4 degrees wide
     1436    #             fmin = min(0.9*abs(xdata[-1] - xdata[0]),fmin) # unless the data range is smaller
     1437    #             iBeg = np.searchsorted(xdata,pos-fmin/2)
     1438    #             iFin = np.searchsorted(xdata,pos+fmin/2)
     1439    #             if not iBeg+iFin:       # skip peak below low limit
     1440    #                 continue
     1441    #             elif not iBeg-iFin:     # got peak above high limit (peaks sorted, so we can stop)
     1442    #                 break
     1443    #             LF.LaueFringePeakCalc(xdata,yc,lam,pos,intens,damp,asym,sig,gam,shol,cells,fmin)
     1444    #             if Ka2:
     1445    #                 pos2 = pos+lamRatio*tand(pos/2.0)       # + 360/pi * Dlam/lam * tan(th)
     1446    #                 iBeg = np.searchsorted(xdata,pos2-fmin)
     1447    #                 iFin = np.searchsorted(xdata,pos2+fmin)
     1448    #                 if iBeg-iFin:
     1449    #                     LF.LaueFringePeakCalc(xdata,yc,lam2,pos2,intens*kRatio,damp,asym,sig,gam,shol,cells,fmin)
     1450    #         except KeyError:        #no more peaks to process
     1451    #             return yb+yc
     1452    # elif 'C' in dataType:
     1453    if 'C' in dataType:
    14531454        shl = max(parmDict['SH/L'],0.002)
    14541455        Ka2 = False
     
    16461647            ip = names.index(parm)
    16471648            dMdv[varyList.index(name)] = dMdpk[4*int(Id)+ip]
    1648     if parmDict.get('LaueFringe',False):
    1649         for i,name in enumerate(varyList):
    1650             if not np.all(dMdv[i] == 0): continue
    1651             deltaParmDict = parmDict.copy()
    1652             delta = max(parmDict[name]/1e5,0.001)
    1653             deltaParmDict[name] += delta
    1654             intArrP = getPeakProfile(dataType,deltaParmDict,xdata,fixback,varyList,bakType)
    1655             deltaParmDict[name] -= 2*delta
    1656             intArrM = getPeakProfile(dataType,deltaParmDict,xdata,fixback,varyList,bakType)
    1657             dMdv[i] = 0.5 * (intArrP - intArrM) / delta
    1658         return dMdv
     1649    # if parmDict.get('LaueFringe',False):
     1650    #     for i,name in enumerate(varyList):
     1651    #         if not np.all(dMdv[i] == 0): continue
     1652    #         deltaParmDict = parmDict.copy()
     1653    #         delta = max(parmDict[name]/1e5,0.001)
     1654    #         deltaParmDict[name] += delta
     1655    #         intArrP = getPeakProfile(dataType,deltaParmDict,xdata,fixback,varyList,bakType)
     1656    #         deltaParmDict[name] -= 2*delta
     1657    #         intArrM = getPeakProfile(dataType,deltaParmDict,xdata,fixback,varyList,bakType)
     1658    #         dMdv[i] = 0.5 * (intArrP - intArrM) / delta
     1659    #     return dMdv
    16591660    if 'C' in dataType:
    16601661        shl = max(parmDict['SH/L'],0.002)
     
    24662467                raise Exception('Instrumental profile terms cannot be varied '+
    24672468                                    'after setPeakInstPrmMode(False) is used')
    2468     fitFunc = errPeakProfile
    2469     dervFunc = devPeakProfile
    24702469    parmDict['LaueFringe'] = False
    2471     if FitPgm == 'LaueFringe':
    2472         #======================================================================
    2473         print('Debug: reload LaueFringe')  # TODO: remove me
    2474         import imp
    2475         imp.reload(LF)
    2476         # TODO: remove ^^^^
    2477         #======================================================================
    2478         for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1',
    2479             'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',):
    2480             if v in varyList:
    2481                 raise Exception('Instrumental profile terms cannot be varied '+
    2482                                     'in Laue Fringe fits')
    2483         parmDict['LaueFringe'] = True
    2484         #fitFunc = LF.errLaueFit
    2485         #dervFunc = None
    2486     elif 'analytic' not in controls.get('deriv type',''):
    2487         dervFunc = None
     2470    # if FitPgm == 'LaueFringe':
     2471    #     #======================================================================
     2472    #     print('Debug: reload LaueFringe')  # TODO: remove me
     2473    #     import imp
     2474    #     imp.reload(LF)
     2475    #     # TODO: remove ^^^^
     2476    #     #======================================================================
     2477    #     for v in ('U','V','W','X','Y','Z','alpha','alpha-0','alpha-1',
     2478    #         'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',):
     2479    #         if v in varyList:
     2480    #             raise Exception('Instrumental profile terms cannot be varied '+
     2481    #                                 'in Laue Fringe fits')
     2482    #     parmDict['LaueFringe'] = True
    24882483
    24892484    while not noFit:
     
    24922487        Rvals = {}
    24932488        badVary = []
    2494         result = so.leastsq(fitFunc,values,Dfun=dervFunc,full_output=True,ftol=Ftol,col_deriv=True,
     2489        result = so.leastsq(errPeakProfile,values,Dfun=devPeakProfile,full_output=True,ftol=Ftol,col_deriv=True,
    24952490               args=(x[xBeg:xFin],y[xBeg:xFin],fixback[xBeg:xFin],wtFactor*w[xBeg:xFin],dataType,parmDict,varyList,bakType,dlg))
    24962491        ncyc = int(result[2]['nfev']/2)
     
    25242519    if dlg: dlg.Destroy()
    25252520    yb[xBeg:xFin] = getBackground('',parmDict,bakType,dataType,x[xBeg:xFin],fixback[xBeg:xFin])[0]
    2526     # if FitPgm == 'LaueFringe':
    2527     #     yc[xBeg:xFin] = LF.getLauePeakProfile(dataType,parmDict,x[xBeg:xFin],fixback[xBeg:xFin],varyList,bakType)
    2528     # else:
    2529     #     yc[xBeg:xFin] = getPeakProfile(dataType,parmDict,x[xBeg:xFin],fixback[xBeg:xFin],varyList,bakType)
    25302521    yc[xBeg:xFin] = getPeakProfile(dataType,parmDict,x[xBeg:xFin],fixback[xBeg:xFin],varyList,bakType)
    25312522    yd[xBeg:xFin] = y[xBeg:xFin]-yc[xBeg:xFin]
  • trunk/GSASIIpwdGUI.py

    r5264 r5265  
    835835            G2frame.OnFileSaveas(event)
    836836        FitPgm = 'LSQ'
    837         if data.get('FitPgm',0) == 1:
    838             FitPgm = 'LaueFringe'
     837#        if data.get('FitPgm',0) == 1:
     838#            FitPgm = 'LaueFringe'
    839839        wx.CallAfter(OnPeakFit,FitPgm)
    840840       
     
    845845            reflGrid.DisableCellEditControl()
    846846        FitPgm = 'LSQ'
    847         if data.get('FitPgm',0) == 1:
    848             FitPgm = 'LaueFringe'
     847#        if data.get('FitPgm',0) == 1:
     848#            FitPgm = 'LaueFringe'
    849849        wx.CallAfter(OnPeakFit,FitPgm,oneCycle=True)
    850850       
     
    952952        wtFactor = Pattern[0]['wtFactor']
    953953        bxye = GetFileBackground(G2frame,data,background,scale=False)
    954         peaks['LaueFringe'] = peaks.get('LaueFringe',{})
    955         peaks['LaueFringe']['satellites'] = []
    956954        overallInfo = []
    957         import LaueFringe as LF
    958         lines = peaks['LaueFringe'].get('Show')
    959         if 'Laue' in FitPgm:
    960             overallInfo = [{'ncell':peaks['LaueFringe']['ncell']}] # add overall info
    961             if lines:
    962                 for i in peaks['peaks']:
    963                     pks = list(range(-lines,0)) + list(range(1,lines+1))
    964                     peaks['LaueFringe']['satellites'].extend(
    965                         LF.LaueSatellite(i[0],peaks['LaueFringe']['ncell'],pks))
    966 #======================================================================
    967         print('Debug: reload G2pwd')  # TODO: remove me
    968         import imp
    969         imp.reload(G2pwd)
    970         imp.reload(G2plt)
    971         # TODO: remove ^^^^
     955#         peaks['LaueFringe'] = peaks.get('LaueFringe',{})
     956#         peaks['LaueFringe']['satellites'] = []
     957#         import LaueFringe as LF
     958#         lines = peaks['LaueFringe'].get('Show')
     959#         if 'Laue' in FitPgm:
     960#             overallInfo = [{'ncell':peaks['LaueFringe']['ncell']}] # add overall info
     961#             if lines:
     962#                 for i in peaks['peaks']:
     963#                     pks = list(range(-lines,0)) + list(range(1,lines+1))
     964#                     peaks['LaueFringe']['satellites'].extend(
     965#                         LF.LaueSatellite(i[0],peaks['LaueFringe']['ncell'],pks))
     966# #======================================================================
     967#         print('Debug: reload G2pwd')  # TODO: remove me
     968#         import imp
     969#         imp.reload(G2pwd)
     970#         imp.reload(G2plt)
     971#         # TODO: remove ^^^^
    972972#======================================================================
    973973        if noFit:
     
    11421142        'recompute & plot the peaks any time a value in the table is edited'
    11431143        FitPgm = 'LSQ'
    1144         if data.get('FitPgm',0) == 1:
    1145             FitPgm = 'LaueFringe'
     1144#        if data.get('FitPgm',0) == 1:
     1145#            FitPgm = 'LaueFringe'
    11461146        OnPeakFit(FitPgm,noFit=True)
    11471147       
     
    12341234    mainSizer.Add(topSizer,0,wx.EXPAND)
    12351235    G2G.HorizontalLine(mainSizer,G2frame.dataWindow)
    1236     if 'C' in Inst['Type'][0]:
    1237         topSizer = wx.BoxSizer(wx.HORIZONTAL)
    1238         topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Fitting mode: '),0,WACV)
    1239         pkType = G2G.G2ChoiceButton(G2frame.dataWindow,('Powder diffraction','Laue fringes'),
    1240                     indLoc=data,indKey='FitPgm',
    1241                     onChoice=updateMe)
    1242         topSizer.Add(pkType,0,WACV)
    1243         if data['FitPgm']:
    1244             topSizer.Add((15,-1))
    1245             if 'LaueFringe' not in data:
    1246                 data['LaueFringe'] = {'ncell':20}
    1247             elif 'ncell' not in data['LaueFringe']:
    1248                 data['LaueFringe']['ncell'] = 20
    1249             siz = G2G.G2SpinWidget(G2frame.dataWindow,data['LaueFringe'] ,'ncell',
    1250                                        'Laue ncell',
    1251                                        onChange=RefreshPeakGrid,onChangeArgs=[None])
    1252             topSizer.Add(siz,0,WACV)
    1253             data['LaueFringe']['Show'] =  data['LaueFringe'].get('Show',0)
    1254             #ch = G2G.G2CheckBox(G2frame.dataWindow,' Show',data['LaueFringe'],'Show',
    1255             #                        OnChange=RefreshPeakGrid)
    1256             topSizer.Add(wx.StaticText(G2frame.dataWindow,label='  Show '),0,WACV)
    1257             ch = G2G.EnumSelector(G2frame.dataWindow,data['LaueFringe'],'Show',
    1258                                     ['None','1','2','3','4','5','6'],list(range(7)),
    1259                                     OnChange=RefreshPeakGrid)
    1260             topSizer.Add(ch,0,WACV)
    1261             topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' satellites'),0,WACV)
    1262         mainSizer.Add(topSizer)
     1236    # if 'C' in Inst['Type'][0]:
     1237        # topSizer = wx.BoxSizer(wx.HORIZONTAL)
     1238        # topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Fitting mode: '),0,WACV)
     1239        # pkType = G2G.G2ChoiceButton(G2frame.dataWindow,('Powder diffraction','Laue fringes'),
     1240        #             indLoc=data,indKey='FitPgm',
     1241        #             onChoice=updateMe)
     1242        # topSizer.Add(pkType,0,WACV)
     1243        # if data['FitPgm']:
     1244        #     topSizer.Add((15,-1))
     1245        #     if 'LaueFringe' not in data:
     1246        #         data['LaueFringe'] = {'ncell':20}
     1247        #     elif 'ncell' not in data['LaueFringe']:
     1248        #         data['LaueFringe']['ncell'] = 20
     1249        #     siz = G2G.G2SpinWidget(G2frame.dataWindow,data['LaueFringe'] ,'ncell',
     1250        #                                'Laue ncell',
     1251        #                                onChange=RefreshPeakGrid,onChangeArgs=[None])
     1252        #     topSizer.Add(siz,0,WACV)
     1253        #     data['LaueFringe']['Show'] =  data['LaueFringe'].get('Show',0)
     1254        #     #ch = G2G.G2CheckBox(G2frame.dataWindow,' Show',data['LaueFringe'],'Show',
     1255        #     #                        OnChange=RefreshPeakGrid)
     1256        #     topSizer.Add(wx.StaticText(G2frame.dataWindow,label='  Show '),0,WACV)
     1257        #     ch = G2G.EnumSelector(G2frame.dataWindow,data['LaueFringe'],'Show',
     1258        #                             ['None','1','2','3','4','5','6'],list(range(7)),
     1259        #                             OnChange=RefreshPeakGrid)
     1260        #     topSizer.Add(ch,0,WACV)
     1261        #     topSizer.Add(wx.StaticText(G2frame.dataWindow,label=' satellites'),0,WACV)
     1262        # mainSizer.Add(topSizer)
    12631263    mainSizer.Add(reflGrid,0,wx.ALL,10)
    12641264    G2frame.dataWindow.SetSizer(mainSizer)
Note: See TracChangeset for help on using the changeset viewer.