8 h5file=os.path.realpath(sys.argv[-1])
9 h5dir=os.path.dirname(h5file)
13 exportdir=os.path.join(h5dir,'exported')
17 print 'mkdir error, maybe the export directory already exists?'
19 def h5exportfunc(name):
21 if Deflname.endswith('Defl'): #search for _Defl dataset
22 LVDTname=str.replace(Deflname,'Defl','LVDT') #and correspondant LVDT dataset
23 Defldata=f[Deflname][:] #store the data in local var
24 LVDTdata=f[LVDTname][:]
25 #find useful attr (springc)
27 notes=f[Deflname].attrs['IGORWaveNote']
28 springmatch=notes.index("SpringConstant: ")+len("SpringConstant: ")
29 springc=notes[springmatch:].split("\r",1)[0] #probably extracting the leading numbers can be way more elegant than this
32 print 'Something bad happened with '+Deflname+', ignoring it'
34 #returning anything but None halts the visit procedure
36 fp=open(os.path.join(exportdir,name.replace('/',''))+'.txt','w')
37 #uses the full HDF5 path (slashes out) to avoid potential overwriting
39 fp.writelines("IGP-HDF5-Hooke\n")
40 fp.writelines('SpringConstant: '+springc+'\n\n')
41 fp.writelines('App x\tApp y\tRet x\tRet y\n')
42 #write LVDT and Defl data
44 for i in numpy.arange(0,half):
45 fp.writelines(str(LVDTdata[i])+'\t'+str(Defldata[i])+'\t'+str(LVDTdata[i+half])+'\t'+str(Defldata[i+half])+'\n')