Changeset 4685 for trunk/GSASIIimage.py


Ignore:
Timestamp:
Dec 29, 2020 12:37:31 PM (10 months ago)
Author:
vondreele
Message:

Add gain map calculator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r4671 r4685  
    12621262    return useMask
    12631263
     1264def MakeGainMap(image,Ix,Iy,data,masks,blkSize=128):
     1265    import scipy.ndimage.filters as sdif
     1266    Iy *= npcosd(Ix[:-1])**3       #undo parallax 3 or 4?
     1267    Iy *= (1000./data['distance'])**2    #undo r^2 effect
     1268    Iy /= np.array(G2pwd.Polarization(data['PolaVal'][0],Ix[:-1],0.)[0])    #undo polarization
     1269    if data['Oblique'][1]:
     1270        Iy *= G2pwd.Oblique(data['Oblique'][0],Ix[:-1])     #undo penetration
     1271    IyInt = scint.interp1d(Ix[:-1],Iy[0],bounds_error=False)
     1272    GainMap = np.zeros_like(image,dtype=float)
     1273    #do interpolation on all points - fills in the empty bins; leaves others the same
     1274    Nx,Ny = data['size']
     1275    nXBlks = (Nx-1)//blkSize+1
     1276    nYBlks = (Ny-1)//blkSize+1
     1277    for iBlk in range(nYBlks):
     1278        iBeg = iBlk*blkSize
     1279        iFin = min(iBeg+blkSize,Ny)
     1280        for jBlk in range(nXBlks):
     1281            jBeg = jBlk*blkSize
     1282            jFin = min(jBeg+blkSize,Nx)
     1283            TA = Make2ThetaAzimuthMap(data,(iBeg,iFin),(jBeg,jFin))           #2-theta & azimuth arrays & create position mask
     1284            Ipix = IyInt(TA[0])
     1285            GainMap[iBeg:iFin,jBeg:jFin] = image[iBeg:iFin,jBeg:jFin]/(Ipix*TA[3])
     1286    GainMap = np.nan_to_num(GainMap)
     1287    GainMap = sdif.gaussian_filter(GainMap,3.,order=0)
     1288    return 1./GainMap
     1289
    12641290def ImageIntegrate(image,data,masks,blkSize=128,returnN=False,useTA=None,useMask=None):
    12651291    'Integrate an image; called from OnIntegrateAll and OnIntegrate in G2imgGUI'    #for q, log(q) bins need data['binType']
     
    13731399        H0 *= np.array(G2pwd.Polarization(data['PolaVal'][0],H2[:-1],0.)[0])
    13741400    H0 /= np.abs(npcosd(H2[:-1]-np.abs(data['det2theta'])))           #parallax correction
     1401    H0 *= (data['distance']/1000.)**2    #remove r^2 effect
    13751402    if 'SASD' in data['type']:
    13761403        H0 /= npcosd(H2[:-1])           #one more for small angle scattering data?
Note: See TracChangeset for help on using the changeset viewer.