Changeset 4570


Ignore:
Timestamp:
Sep 16, 2020 9:04:32 PM (15 months ago)
Author:
vondreele
Message:

Implement arc mask method for determining polarization with scipy minimize_scalar method to find minimum difference between arc mask on/mask off integrations

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r4569 r4570  
    15071507                break
    15081508    return mask
     1509
     1510def DoPolaCalib(ImageZ,imageData,arcTth):
     1511    ''' Determine image polarization by successive integrations with & without preset arc mask.
     1512    '''
     1513    from scipy.optimize import minimize_scalar
     1514    Arc = [arcTth,[45.,135.],2.0]
     1515    Masks = {'Points':[],'Rings':[],'Arcs':[],'Polygons':[],'Frames':[],
     1516        'Thresholds':imageData['range'],'SpotMask':{'esdMul':3.,'spotMask':None}}
     1517    AMasks = {'Points':[],'Rings':[],'Arcs':[Arc,],'Polygons':[],'Frames':[],
     1518        'Thresholds':imageData['range'],'SpotMask':{'esdMul':3.,'spotMask':None}}
     1519    data = copy.deepcopy(imageData)
     1520   
     1521    def func(p):
     1522        p = min(1.0,max(p,0.0))
     1523        data['PolaVal'][0] = p
     1524        H0 = ImageIntegrate(ImageZ,data,Masks)[0]
     1525        H0A = ImageIntegrate(ImageZ,data,AMasks)[0]
     1526        M = np.sum(H0-H0A)
     1527        print('polarization %.4f, fxn: %.1f'%(p,M))
     1528        return M**2
     1529   
     1530    res = minimize_scalar(func,bracket=[1.,.999],tol=.0001)
     1531    print(res)
     1532    pola = min(1.0,max(res.x,.0))
     1533    imageData['PolaVal'][0] = pola
  • trunk/GSASIIimgGUI.py

    r4546 r4570  
    136136        G2plt.PlotExposedImage(G2frame,newPlot=True,event=tc.event)
    137137       
    138     #G2frame.dataWindow.ClearData()
     138    def OnPolaCalib(event):
     139        IOtth = [data['IOtth'][0]+2.,data['IOtth'][1]-2.]
     140        dlg = G2G.SingleFloatDialog(G2frame,'Polarization test arc mask',
     141''' Do not use if pattern has uneven absorption
     142 Set 2-theta max in image controls to be fully inside image 
     143 Enter 2-theta position for arc mask (%.1f-%.1f) '''%(IOtth[0],IOtth[1]),IOtth[1],IOtth,format='%.2f')
     144        if dlg.ShowModal() == wx.ID_OK:
     145            arcTth = dlg.GetValue()
     146            G2fil.G2SetPrintLevel('none')
     147            G2img.DoPolaCalib(G2frame.ImageZ,data,arcTth)
     148            G2fil.G2SetPrintLevel('all')
     149            UpdateImageData(G2frame,data)
     150        dlg.Destroy()
     151       
     152    G2frame.dataWindow.ClearData()
    139153    G2frame.ImageZ = GetImageZ(G2frame,data)
    140154    mainSizer = G2frame.dataWindow.GetSizer()
     
    161175    distSizer.Add(G2G.ValidatedTxtCtrl(G2frame.dataWindow,data['PolaVal'],0,nDig=(10,4),
    162176        xmin=0.,xmax=1.,typeHint=float),0,WACV)
     177    polaCalib = wx.Button(G2frame.dataWindow,label='Calibrate?')
     178    polaCalib.Bind(wx.EVT_BUTTON,OnPolaCalib)
     179    distSizer.Add(polaCalib,0,WACV)
    163180    mainSizer.Add(distSizer,0)
    164181    if 'samplechangerpos' not in data or data['samplechangerpos'] is None:
    165182        data['samplechangerpos'] = 0.0
    166183    mainSizer.Add(wx.StaticText(G2frame.dataWindow,label='Sample changer position %.2f mm'%data['samplechangerpos']),0,WACV)
     184    G2frame.dataWindow.SetDataSize()
    167185
    168186################################################################################
  • trunk/GSASIIphsGUI.py

    r4568 r4570  
    1172811728        const = 9.e-2/(np.pi*Sample['Gonio. radius'])                  #shifts in microns
    1172911729        gconst = 2.35482 # sqrt(8 ln 2)
     11730        dx = (xdata[0][1]-xdata[0][0])*20.              #this ian approximation - not correct, but CW seems to be needed
     11731        gconst *= dx
    1173011732       
    1173111733        wx.BeginBusyCursor()
Note: See TracChangeset for help on using the changeset viewer.