Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions h5pyViewer/FrmProcRoiStat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#*-----------------------------------------------------------------------*
#| |
#| Copyright (c) 2013 by Paul Scherrer Institute (http://www.psi.ch) |
Expand Down Expand Up @@ -44,9 +45,9 @@ def __init__(self, parent, title, hid,fnValMsk,fnIntegMsk):
self.prs=prs=ProcRoiStat()
prs.SetRoiMat((fnValMsk,fnIntegMsk),raw.shape)
prs.SetProcess('avg')
print 'numnber of ROI,',prs.roiLenArr.size,'Total number of pixels',prs.roiIdxArr.size
print('numnber of ROI,',prs.roiLenArr.size,'Total number of pixels',prs.roiIdxArr.size)
prs.Process(raw)
print prs.resArr[0,:].max(),prs.resArr[0,:].min()
print(prs.resArr[0,:].max(),prs.resArr[0,:].min())
canvas.data=prs.resArr
#.reshape(prs.mskNumSeg,-1)
#canvas.data=np.rot90(prs.resArr[0,:].reshape(-1,prs.mskNumSeg))
Expand Down
10 changes: 5 additions & 5 deletions h5pyViewer/FrmPyFAI.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def FindCenter(arr):
yy=np.arange(shape[1])
x=(xx*sx).sum()/sx.sum()
y=(yy*sy).sum()/sy.sum()
#print x,y
#print(x,y)
#import pylab as plt #used for the colormaps
#plt.figure()
#plt.subplot(211)
Expand Down Expand Up @@ -76,7 +76,7 @@ def InitChild(self,data):
self.hl=ax.plot(*out)
ax.set_yscale('log')
#canvas.data=imgPolar
#print imgPolar.shape
#print(imgPolar.shape)
#out=ai.xrpd(imgData,1000)
#out=ai.xrpd_OpenCL(imgData,1000)
#import pylab
Expand Down Expand Up @@ -195,7 +195,7 @@ def __init__(self, parent, title, hid):

imgPolar,theta,chi=self.ai.xrpd2(raw,self.numPtTh,self.numPtCh)
canvas.data=imgPolar
print imgPolar.shape
print(imgPolar.shape)

def BuildMenu(self):
HdfImageGLFrame.BuildMenu(self)
Expand Down Expand Up @@ -281,7 +281,7 @@ def __init__(self,parent):
sizer.Fit(self)

def OnModify(self, event):
print 'OnModify'
print('OnModify')
frm=self.GetParent()
ds=frm.dataSet
canvas=frm.canvas
Expand All @@ -301,7 +301,7 @@ def OnModify(self, event):
glImg._data=canvas.GetTxrData()
glImg._texture=Texture(glImg._data)
#self.glImg=glImg=glumpy.image.Image(txrData, colormap=colMap,vmin=txrRng[0], vmax=txrRng[1])
print canvas.data.shape,glImg.data.shape
print(canvas.data.shape,glImg.data.shape)
glImg.update()
canvas.OnPaint(None)#force to repaint, Refresh and Update do not force !
frm.Refresh(False)
Expand Down
38 changes: 20 additions & 18 deletions h5pyViewer/GLCanvasImg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
from six import iteritems
#*-----------------------------------------------------------------------*
#| |
#| Copyright (c) 2013 by Paul Scherrer Institute (http://www.psi.ch) |
Expand Down Expand Up @@ -29,8 +31,8 @@ def MplAddColormap(m,lut):
kG,vG,dummy=zip(*lstG)
kB,vB,dummy=zip(*lstB)
except TypeError as e:
print 'failed to add '+m+' (probably some lambda function)'
#print lut
print('failed to add '+m+' (probably some lambda function)')
#print(lut)
return
kLst=set()
kLst.update(kR)
Expand All @@ -54,7 +56,7 @@ def MplAddAllColormaps(colMapNameLst=None):
try:
import matplotlib.cm as cm
except ImportError as e:
print 'ImportError: '+e.message
print(e)
if not colMapNameLst:
colMapNameLst=[m for m in cm.datad if not m.endswith("_r")]
for m in colMapNameLst:
Expand Down Expand Up @@ -92,9 +94,9 @@ def OnMouseEvent(self, event):
return
if event.ButtonDown():
self.mouseStart=(np.array(event.GetPosition()),self.imgCoord.copy())
print 'drag Start'
print('drag Start')
elif event.ButtonUp():
print 'drag End'
print('drag End')
del self.mouseStart
else:
try:
Expand All @@ -105,7 +107,7 @@ def OnMouseEvent(self, event):
ic=self.imgCoord
pOfs=(ic[0::4]+[.5,.5])*pSz
tPos=(pMouse-pOfs)/(pSz-2*pOfs)#position on the image 0..1
#print tPos
#print(tPos)
if (tPos<0).any() or (tPos>1).any(): return
tPos=tPos*(ic[3::4]-ic[1::4])+ic[1::4]
tPos[0]*=data.shape[1]
Expand Down Expand Up @@ -137,7 +139,7 @@ def OnMouseEvent(self, event):
if icStart[7]-tOfs[1]>1:
tOfs[1]=icStart[7]-1

#print icStart[1::4],icStart[3::4],tOfs
#print(icStart[1::4],icStart[3::4],tOfs)

ic[1::4]=icStart[1::4]-tOfs
ic[3::4]=icStart[3::4]-tOfs
Expand Down Expand Up @@ -168,30 +170,30 @@ def OnMouseWeel(self, event):
tMax[tMax>1]=1
ic[1::4]=tMin
ic[3::4]=tMax
#print tPos,pSz,pMouse,n,ic
#print(tPos,pSz,pMouse,n,ic)
self.SetZoom()
self.Refresh(False)

pass

def OnEraseBackground(self, event):
"""Process the erase background event."""
#print 'OnEraseBackground'
#print('OnEraseBackground')
pass # Do nothing, to avoid flashing on MSWin

def OnSize(self, event):
print 'OnSize'
print('OnSize')
wx.CallAfter(self.DoSetViewport)
event.Skip()
def DoSetViewport(self):
print 'DoSetViewport'
print('DoSetViewport')
size = self.GetClientSize()
self.SetCurrent(self.context)
glViewport(0, 0, size.width, size.height)

def OnPaint(self, event):
"""Process the drawing event."""
#print 'OnPaint'
#print('OnPaint')
self.SetCurrent(self.context)

# This is a 'perfect' time to initialize OpenGL ... only if we need to
Expand Down Expand Up @@ -307,7 +309,7 @@ def GetTxrData(self):

def InitGL(self):
"""Initialize OpenGL for use in the window."""
#print 'InitGL'
#print('InitGL')
glClearColor(.2, .2, .2, 1)
colMap=glumpy.colormap.Hot
txrColBar=np.linspace(0.,1., 256).astype(np.float32)
Expand All @@ -319,7 +321,7 @@ def InitGL(self):

def Reshape(self, width, height):
"""Reshape the OpenGL viewport based on the dimensions of the window."""
#print 'Reshape'
#print('Reshape')
glViewport(0, 0, width, height)

glMatrixMode(GL_PROJECTION)
Expand Down Expand Up @@ -348,7 +350,7 @@ def __init__(self,parent):
colMapLst=[]
#adding all existing colormaps
#MplAddAllColormaps()
#for (k,v) in glumpy.colormap.__dict__.iteritems():
#for (k,v) in iteritems(glumpy.colormap.__dict__):
# if isinstance(v,glumpy.colormap.Colormap):
# colMapLst.append(k)

Expand All @@ -363,8 +365,8 @@ def __init__(self,parent):
MplAddColormap(k,lut)
v=glumpy.colormap.__dict__[k]
except ImportError as e:
print e.message
print "don't have colormap "+k
print(e.message)
print("don't have colormap "+k)
continue
if isinstance(v,glumpy.colormap.Colormap):
colMapLst.append(k)
Expand Down Expand Up @@ -403,7 +405,7 @@ def __init__(self,parent):
sizer.Fit(self)

def OnModify(self, event):
#print 'OnModify'
#print('OnModify')
parent=self.GetParent()
glImg=parent.glImg
glColBar=parent.glColBar
Expand Down
36 changes: 19 additions & 17 deletions h5pyViewer/h5pyViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#| |
#| Author Thierry Zamofing ([email protected]) |
#*-----------------------------------------------------------------------*
from __future__ import print_function
from six import iteritems
'''
hdf5 viewer to dispay images, tables, attributes and trees of a hdf5 file.
'''
Expand All @@ -18,15 +20,15 @@
try:
from hdfImageGL import *
except ImportError as e:
print 'ImportError: '+e.message
print(e)
try:
from FrmPyFAI import *
except ImportError as e:
print 'ImportError: '+e.message
print(e)
try:
from FrmProcRoiStat import ProcRoiStatFrame
except ImportError as e:
print 'ImportError: '+e.message
print(e)

import utilities as ut

Expand All @@ -47,8 +49,8 @@ def __init__(self,parent):
st0=wx.StaticText(panel,-1,s,(30,10))
bmp = wx.StaticBitmap(panel,-1,wx.Bitmap(os.path.join(imgDir,'splash1.png'), wx.BITMAP_TYPE_ANY ), (30,st0.Position[1]+st0.Size[1]+10))

for k,v in os.environ.iteritems():
print k,'=',v
for k,v in iteritems(os.environ):
print(k,'=',v)

class HdfTreePopupMenu(wx.Menu):
def __init__(self, wxObjSrc):
Expand Down Expand Up @@ -130,13 +132,13 @@ def OnShowRoiStat(self, event):
dlg = wx.FileDialog(wxTree, "Choose valid mask file (e.g. pilatus_valid_mask.mat)", os.getcwd(), '','MATLAB files (*.mat)|*.mat|all (*.*)|*.*', wx.FD_OPEN|wx.FD_CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
fnValMsk= dlg.GetPath()
print 'OnOpen',fnValMsk
print('OnOpen',fnValMsk)
dlg.Destroy()
if not fnValMsk: return
dlg = wx.FileDialog(wxTree, "Choose ROI mask file (e.g. pilatus_integration_mask.mat)", os.getcwd(), '','MATLAB files (*.mat)|*.mat|all (*.*)|*.*', wx.FD_OPEN|wx.FD_CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
fnIntegMsk = dlg.GetPath()
print 'OnOpen',fnIntegMsk
print('OnOpen',fnIntegMsk)
dlg.Destroy()
if not fnIntegMsk: return
#fnMatRoi='/scratch/detectorData/cSAXS_2013_10_e14608_georgiadis_3D_for_Marianne/analysis/data/pilatus_integration_mask.mat'
Expand Down Expand Up @@ -179,7 +181,7 @@ def OnShell(self, event):
#for cmd in [
# 'wnd=app.GetTopWindow();wxTree=wnd.wxTree',
# 'wxNode=wnd.wxTree.GetSelection()',
# 'print wnd.fid',
# 'print(wnd.fid)',
# 'lbl=wxTree.GetItemText(wxNode)',
# 'hid=wxTree.GetPyData(wxNode)']:
# shell.run(cmd, prompt=False)
Expand All @@ -188,29 +190,29 @@ def OnPrintProperties(self, event):
wxTree,wxNode=self.wxObjSrc
lbl=wxTree.GetItemText(wxNode)
hid=wxTree.GetPyData(wxNode)
print HdfViewerFrame.GetPropertyStr(wxTree,wxNode)
print(HdfViewerFrame.GetPropertyStr(wxTree,wxNode))

def OnItem2(self, event):
print 'OnItem2'
print('OnItem2')
pass

def OnItem3(self, event):
print 'OnItem3'
print('OnItem3')
pass

class HdfViewerFrame(wx.Frame):

def OpenFile(self,fnHDF):
try:
self.fid=h5py.h5f.open(fnHDF,flags=h5py.h5f.ACC_RDONLY)
self.fid=h5py.h5f.open(fnHDF.encode('utf-8'),flags=h5py.h5f.ACC_RDONLY)
except IOError as e:
sys.stderr.write('Unable to open File: '+fnHDF+'\n')
else:
self.wxTree.ShowHirarchy(self.fid)

def CloseFile(self):
#http://docs.wxwidgets.org/2.8/wx_windowdeletionoverview.html#windowdeletionoverview
#print 'CloseFile'
#print('CloseFile')
try:
self.fid.close()
del self.fid
Expand Down Expand Up @@ -250,11 +252,11 @@ def OnOpen(self, event):
#self.SetStatusText("You selected: %s" % mypath)
self.CloseFile()
self.OpenFile(path)
#print 'OnOpen',path
#print('OnOpen',path)
dlg.Destroy()

def OnCloseWindow(self, event):
#print 'OnCloseWindow'
#print('OnCloseWindow')
self.Destroy()

def OnAbout(self,event):
Expand Down Expand Up @@ -313,7 +315,7 @@ def GetPropertyStr(wxTree,wxNode):
hidStr=wxTree.GetItemText(wxNode)
hid=wxTree.GetPyData(wxNode)
#o=wxTree.GetItemData(wxNode)
#print o.Data,wxTree.GetPyData(wxNode)
#print(o.Data,wxTree.GetPyData(wxNode))
#if type(gid)==h5py.h5g.GroupID:
txt=path+'\n'
t=type(hid)
Expand All @@ -330,7 +332,7 @@ def GetPropertyStr(wxTree,wxNode):
hid=h5py.h5o.open(hid,'/')
t=type(hid)
objInf=h5py.h5o.get_info(hid)
#print t,hid.id,objInf.fileno, objInf.rc, objInf.type, objInf.addr, objInf.hdr
#print(t,hid.id,objInf.fileno, objInf.rc, objInf.type, objInf.addr, objInf.hdr)
txt+=type(hid).__name__+':%d\n'%hid.id
txt+='addr:%d fileno:%d refCnt:%d\n'%(objInf.addr,objInf.fileno, objInf.rc)
try:
Expand Down
5 changes: 3 additions & 2 deletions h5pyViewer/hdfAttrib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
#*-----------------------------------------------------------------------*
#| |
#| Copyright (c) 2013 by Paul Scherrer Institute (http://www.psi.ch) |
Expand Down Expand Up @@ -47,7 +48,7 @@ def ShowAttr(self,hid):
idxItem=self.InsertStringItem(idxAttr, aid.name)
val=GetAttrVal(aid)
self.SetStringItem(idxItem, 1, str(val))
#print idxAttr,idxItem,aid,aid.name,val
#print(idxAttr,idxItem,aid,aid.name,val)
try:
aidUnit=h5py.h5a.open(hid,'_u_'+aid.name)
except KeyError as e:
Expand All @@ -74,7 +75,7 @@ def OnActivateItem(self,event):
aid=h5py.h5a.open(hid,index=event.Data)
val=GetAttrVal(aid)
if type(val)!=np.ndarray:
print val
print(val)
return
frame=HdfGridFrame(self,aid.name,val)
frame.Show(True)
Expand Down
8 changes: 4 additions & 4 deletions h5pyViewer/hdfGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self,parent,fmt):
sizer.Fit(self)

def OnModify(self, event):
#print 'OnModify'
#print('OnModify')
parent=self.GetParent()
#event.EventObject.Value
#self.cbPredef.Value
Expand Down Expand Up @@ -228,7 +228,7 @@ def __init__(self, parent,lbl,hid):
else:
tbl.view = tbl.data[sl].T
self.wxAxCtrlLst=wxAxCtrlLst
#print type(tbl)
#print(type(tbl))

grid.SetTable (tbl, True)
#AutoSize must be called after SetTable, but takes lot of time on big tables!
Expand All @@ -248,12 +248,12 @@ def OnColSize(self,event):
if event.ShiftDown():
col=event.RowOrCol
sz=self.grid.GetColSize(col)
print 'OnColSize',col,sz
print('OnColSize',col,sz)
self.grid.SetDefaultColSize(sz, True)
self.grid.ForceRefresh()

def OnSetFormat(self,event):
print 'OnSetFormat'
print('OnSetFormat')

fmt=getattr(self.grid.Table,'cellFormat','')
dlg=DlgFormatSetup(self,fmt)
Expand Down
Loading