2021-09-17 08:47:57 -04:00
|
|
|
import sys
|
|
|
|
import io
|
|
|
|
import pptx
|
|
|
|
from pptx.util import Inches, Pt
|
|
|
|
sys.path.append("..")
|
2021-09-17 08:06:57 -04:00
|
|
|
from gwygsf import GSF
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
plt.ioff()
|
|
|
|
|
|
|
|
def makeplot(name):
|
|
|
|
c = GSF()
|
|
|
|
c.fromfile(name)
|
|
|
|
x0 = float(c.attr["XOffset"]) * 1e6
|
|
|
|
xl = x0 + float(c.attr["XReal"]) * 1e6
|
|
|
|
y0 = float(c.attr["YOffset"]) * 1e6
|
|
|
|
yl = y0 + float(c.attr["YReal"]) * 1e6
|
|
|
|
|
|
|
|
fig, ax = plt.subplots()
|
|
|
|
gr = ax.imshow(c.d, extent=(x0,xl,y0,yl))
|
|
|
|
ax.set_xlabel("um")
|
|
|
|
ax.set_ylabel("um")
|
|
|
|
fig.colorbar(gr)
|
|
|
|
|
2021-09-17 08:47:57 -04:00
|
|
|
img = io.BytesIO()
|
|
|
|
fig.savefig(img)
|
|
|
|
return img
|
|
|
|
|
|
|
|
def build_pptx(l, out):
|
|
|
|
prs = pptx.Presentation()
|
|
|
|
imgoff_x = Inches(2)
|
|
|
|
imgoff_y = Inches(2)
|
|
|
|
textoff = Inches(0.5)
|
|
|
|
textoff_x = Inches(4.6)
|
|
|
|
def addslide():
|
|
|
|
return prs.slides.add_slide(prs.slide_layouts[6])
|
|
|
|
|
|
|
|
for (n,im) in l:
|
|
|
|
s = addslide()
|
|
|
|
s.shapes.add_picture(im, imgoff_x, imgoff_y)
|
|
|
|
txt = s.shapes.add_textbox(textoff_x,textoff,textoff,textoff).text_frame.add_paragraph()
|
|
|
|
txt.text = n
|
|
|
|
txt.font.size = Pt(15)
|
|
|
|
|
|
|
|
prs.save(f"{out}.pptx")
|
|
|
|
|
|
|
|
build_pptx([(x,makeplot(x)) for x in sys.argv[2:len(sys.argv)-1]], sys.argv[len(sys.argv)-1])
|