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