<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Leighanne,<o:p></o:p></p>
<p class="MsoNormal">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.
</p>
<p class="MsoNormal">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.</p>
<p class="MsoNormal">Best,</p>
<p class="MsoNormal">Bob<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">
Mail</a> for Windows</p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:gsas-ii@aps.anl.gov">Gallington, Leighanne C. via GSAS-II</a><br>
<b>Sent: </b>Wednesday, March 16, 2022 5:18 PM<br>
<b>To: </b><a href="mailto:gsas-ii@aps.anl.gov">gsas-ii@aps.anl.gov</a><br>
<b>Cc: </b><a href="mailto:jiahuichen@anl.gov">Chen, Jiahui</a>; <a href="mailto:jweng@anl.gov">
Weng, James</a><br>
<b>Subject: </b>[GSAS-II] GSAS-II image import int vs float</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Hi Bob and Brian,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">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.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"> elif sizexy == [2048,2048] or sizexy == [1024,1024] or sizexy == [3072,3072]:
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">        if IFD[273][2][0] == 8:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">            if IFD[258][2][0] == 32:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                tifType = 'PE'<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                pixy = [200.,200.]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                File.seek(8)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                G2fil.G2Print ('Read APS PE-detector tiff file: '+filename)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                if dataType == 5:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                    image = np.array(np.frombuffer(File.read(4*Npix),dtype=np.float32),dtype=np.int32)  #fastest<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                else:<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">                    image = np.array(np.frombuffer(File.read(4*Npix),dtype=np.int32),dtype=np.int32)<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">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?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Leighanne<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Tahoma",sans-serif;color:black">--
<br>
Leighanne C. Gallington, Ph.D.<br>
Assistant Chemist<br>
Advanced Photon Source (X-ray Science Division)<br>
Argonne National Laboratory<br>
Argonne, IL  60439<br>
gallington@anl.gov<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>