[GSAS-II] GSAS-II image import int vs float
Von Dreele, Robert B.
vondreele at anl.gov
Thu Mar 17 08:26:25 CDT 2022
Hi Leighanne,
Your fix isn’t appropriate, because it will break the reading of many other kinds of images. Images are generally considered by GSAS-II to be fairly large integers not small floats, because that’s the way they are from the detectors. To make gain maps work in GSAS-II one has to put it into this integer realm by multiplying each gain point by 1000 and then saving the gain map as integers (not floats). That way GSAS-II image processing & viewing can work with it. When the gain map is used inside GSAS-II, the scale of 1000 is removed to make the gain map correction (see lines 120-128 in GSASIIimgGUI.py for this code). As for reading in the gain maps as is, there must be an internal signature in the tif file that indicates that it is floats & not integers and then the scaling by 1000 must be applied otherwise it won’t work. This would require another special adaption in the tif importer – I’d rather not do that; it’s messy enough because of all the weird tif formats out there.
My recommendation is to go back to the source of your gain maps and have them written as integers scaled by 1000. That way GSAS-II can read, display & apply them easily.
Best,
Bob
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows
From: Gallington, Leighanne C. via GSAS-II<mailto:gsas-ii at aps.anl.gov>
Sent: Wednesday, March 16, 2022 5:18 PM
To: gsas-ii at aps.anl.gov<mailto:gsas-ii at aps.anl.gov>
Cc: Chen, Jiahui<mailto:jiahuichen at anl.gov>; Weng, James<mailto:jweng at anl.gov>
Subject: [GSAS-II] GSAS-II image import int vs float
Hi Bob and Brian,
We've run into some problems when trying to import and apply gain maps, with values ranging from about 0.97 to 1.03, to Jiahui's data. After doing some digging, I've found that when the PE images are imported, the values are converted from floats to integers. As far as I can tell, the conversion is happening in the code snippet below, from file G2img_1TIF.py, in function GetTifData.
elif sizexy == [2048,2048] or sizexy == [1024,1024] or sizexy == [3072,3072]:
if IFD[273][2][0] == 8:
if IFD[258][2][0] == 32:
tifType = 'PE'
pixy = [200.,200.]
File.seek(8)
G2fil.G2Print ('Read APS PE-detector tiff file: '+filename)
if dataType == 5:
image = np.array(np.frombuffer(File.read(4*Npix),dtype=np.float32),dtype=np.int32) #fastest
else:
image = np.array(np.frombuffer(File.read(4*Npix),dtype=np.int32),dtype=np.int32)
If I change the np.int32 to np.float32, the gain map can be read in, applied to data, and integrated successfully. I'm not sure what else I might have broken downstream when I do that, and there's still some funkiness with the slider bars for the intensities. Can you implement a cleaner fix into the G2img code?
Thanks,
Leighanne
--
Leighanne C. Gallington, Ph.D.
Assistant Chemist
Advanced Photon Source (X-ray Science Division)
Argonne National Laboratory
Argonne, IL 60439
gallington at anl.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.aps.anl.gov/pipermail/gsas-ii/attachments/20220317/263fba06/attachment.html>
More information about the GSAS-II
mailing list