AdvancedPhotonSource / GSAS-II

Home for GSAS-II: crystallographic and diffraction-based structural characterization of materials
Other
33 stars 14 forks source link

Integration fails with 1-ID image with size 3095 x 3073 #59

Closed briantoby closed 3 months ago

briantoby commented 3 months ago

Integration of Spectrum Logic 3131 (https://static1.squarespace.com/static/5ae6dd648f51303ed37b4cdd/t/65e1bb687bac7950d6bc4676/1709292392891/SL+3131HS.pdf) image from 1-ID fails with this error:

IndexError                                Traceback (most recent call last)
File ~/G2/git/g2full/GSAS-II/GSASII/GSASIIimgGUI.py:547, in UpdateImageControls.<locals>.OnIntegrate(event, useTA, useMask)
    545 if masks.get('SpotMask',{'spotMask':None})['spotMask'] is not None:
    546     sumImg = ma.array(sumImg,mask=masks['SpotMask']['spotMask'])
--> 547 G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,useTA=useTA,useMask=useMask)            
    548 G2frame.PauseIntegration = G2frame.Integrate[-1]
    549 del sumImg  #force cleanup

File ~/G2/git/g2full/GSAS-II/GSASII/GSASIIimage.py:1581, in ImageIntegrate(image, data, masks, blkSize, returnN, useTA, useMask)
   1579     tam = MakeMaskMap(data,Masks,(iBeg,iFin),(jBeg,jFin),tamp)
   1580 Block = image[iBeg:iFin,jBeg:jFin]          # image Pixel mask has been applied here
-> 1581 tax,tay,taz,tad = Fill2ThetaAzimuthMap(Masks,TAr,tam,Block)    #applies remaining masks
   1582 times[0] += time.time()-t0      # time mask application
   1583 t0 = time.time()

File ~/G2/git/g2full/GSAS-II/GSASII/GSASIIimage.py:1368, in Fill2ThetaAzimuthMap(masks, TAr, tam, image, ringMask)
   1366 else:
   1367     mask = ~mask
-> 1368     return tax[mask],tay[mask],image[mask]/pol[mask],tad[mask]

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

The problem seems related to the size of the image and the block size used to process the image. The block size is 128x128 and 3073 is 128*24 + 1 so we must process a block that is one pixel wide. This is where the integration fails.

briantoby commented 3 months ago

Cute bug: np.squeeze was being used to reduce dimensionality of an array. Works a bit too well in that it eliminates the row for the 1 column block. Better to use array indexing. See change in f8f7271