Skip to content

Commit

Permalink
better file names for harminv
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDominec committed Mar 9, 2015
1 parent 2faa8ca commit 2c2594f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions harminv_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ def harminv(x, y, d=100, f=30, amplitude_prescaling=None):
if amplitude_prescaling == None:
amplitude_prescaling = 1000./np.max(np.abs(y))

with open('/tmp/hitest.dat', 'w') as outfile:
with open('/tmp/harminv_input.dat', 'w') as outfile:
outfile.write("#t[s]\t E(t)\n")
np.savetxt(outfile, zip(x/2, np.real(y) * amplitude_prescaling), fmt="%.8e")
import subprocess
dt = x[1]-x[0]
#subprocess.Popen('harminv 0-1000 -t %g -d %g -f %g < hitest.dat > hiout.dat' % (dt, d, f), shell=True, stdout=subprocess.PIPE).stdout.read().strip()
#subprocess.Popen('harminv 0-%f -t %g -d %g -f %g < /tmp/hitest.dat > /tmp/hiout.dat' % (1/dt/10, dt, d, f), shell=True, stdout=subprocess.PIPE).stdout.read().strip()
subprocess.Popen('harminv %f-%f -t %g < /tmp/hitest.dat > /tmp/hiout.dat' % (0, 1./dt/10., dt*1.), shell=True, stdout=subprocess.PIPE).stdout.read().strip()
subprocess.Popen('harminv %f-%f -t %g < /tmp/harminv_input.dat > /tmp/harminv_output.dat' % (0, 1./dt/10., dt*1.), shell=True, stdout=subprocess.PIPE).stdout.read().strip()
try:
(mf, md, mQ, mA, mp, merr) = np.loadtxt('/tmp/hiout.dat', usecols=list(range(6)), unpack=True, delimiter=', ', skiprows=1)
(mf, md, mQ, mA, mp, merr) = np.loadtxt('/tmp/harminv_output.dat', usecols=list(range(6)), unpack=True, delimiter=', ', skiprows=1)
except:
print "\nWARNING: Harminv detected no resonances.\n\n"
(mf, md, mQ, mA, mp, merr) = [np.array([]) for _ in range(6)]
Expand Down

0 comments on commit 2c2594f

Please sign in to comment.