1 # Copyright (C) 2010-2012 Alberto Gomez-Casado <a.gomezcasado@tnw.utwente.nl>
2 # W. Trevor King <wking@drexel.edu>
4 # This file is part of Hooke.
6 # Hooke is free software: you can redistribute it and/or modify it under the
7 # terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option) any
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with Hooke. If not, see <http://www.gnu.org/licenses/>.
24 h5file=os.path.realpath(sys.argv[-1])
25 h5dir=os.path.dirname(h5file)
29 exportdir=os.path.join(h5dir,'exported')
33 print 'mkdir error, maybe the export directory already exists?'
35 def h5exportfunc(name):
37 if Deflname.endswith('Defl'): #search for _Defl dataset
38 LVDTname=str.replace(Deflname,'Defl','LVDT') #and correspondant LVDT dataset
39 Defldata=f[Deflname][:] #store the data in local var
40 LVDTdata=f[LVDTname][:]
41 #find useful attr (springc)
43 notes=f[Deflname].attrs['IGORWaveNote']
44 springmatch=notes.index("SpringConstant: ")+len("SpringConstant: ")
45 springc=notes[springmatch:].split("\r",1)[0] #probably extracting the leading numbers can be way more elegant than this
48 print 'Something bad happened with '+Deflname+', ignoring it'
50 #returning anything but None halts the visit procedure
52 fp=open(os.path.join(exportdir,name.replace('/',''))+'.txt','w')
53 #uses the full HDF5 path (slashes out) to avoid potential overwriting
55 fp.writelines("IGP-HDF5-Hooke\n")
56 fp.writelines('SpringConstant: '+springc+'\n\n')
57 fp.writelines('App x\tApp y\tRet x\tRet y\n')
58 #write LVDT and Defl data
60 for i in numpy.arange(0,half):
61 fp.writelines(str(LVDTdata[i])+'\t'+str(Defldata[i])+'\t'+str(LVDTdata[i+half])+'\t'+str(Defldata[i+half])+'\n')