Commit 6d50c15c authored by jclamber's avatar jclamber
Browse files

add polynomial curve fitting to g3cpu_parse

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@113 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent ac54faf9
......@@ -19,12 +19,12 @@ def main(argv):
tl=-1. # time last
out='' # if blank plot on screen, else on png file
tmax=10. # gadget.param file
smooth=0 # smooth or not curve
try:
opts,args=getopt.getopt(argv,"h",["in=","tm=","out=","dt=","tf=","tl="])
opts,args=getopt.getopt(argv,"h",["in=","tm=","out=","dt=","tf=","tl=","smooth="])
except getopt.GetoptError:
printHelp(prog,file,dt,tf,tl,out)
printHelp(prog,file,dt,tf,tl,out,smooth)
sys.exit(2)
for opt, arg in opts:
......@@ -43,6 +43,8 @@ def main(argv):
out = arg
elif opt in ("--tm"):
tmax = float(arg)
elif opt in ("--smooth"):
smooth = int(arg)
fig = plt.figure(figsize=(8,8),dpi=100)
......@@ -91,7 +93,13 @@ def main(argv):
print "Elapsed : ",elapsed, " cpu0=",cpu[0],cpu[-1]
ddd=getHMS(int(elapsed),"ELD")
f_label=f_label+"\n%s"%(ddd)
plt.plot(time,cpu,label=f_label) #,'r.-')
if (smooth):
z=np.polyfit(time,cpu,4)
f4=np.poly1d(z)
plt.plot(time,f4(time),label=f_label) #,'r.-')
else:
plt.plot(time,cpu,label=f_label) #,'r.-')
plt.xlabel('Simulation time')
plt.ylabel('Cpu time (seconds)')
......@@ -190,14 +198,14 @@ def parseCPU(file,dt,tf,tl):
print "cpu.size = ", cpu.size
return time,cpu,ncores
def printHelp(prog,file,dt,tf,tl,out):
def printHelp(prog,file,dt,tf,tl,out,smooth):
help= """\
----------------------------------------------
Plot gadget3 cpu time between 2 delta time
----------------------------------------------
Syntaxe : %s --in <inputfile[:legend]> --dt <delta time> --tf <time first> --tl <time last> --out <image name>
Syntaxe : %s --in <inputfile[:legend]> --dt <delta time> --tf <time first> --tl <time last> --out <image name> --smooth <1|0>
Notes :
inputfile : cpu.txt file from gadget3 simulation [%s]
......@@ -209,9 +217,10 @@ def printHelp(prog,file,dt,tf,tl,out):
tf : simulation time first [%f]
tl : simulation time last [%f]
out : output image filename, or plot on screen if blank [%s]
smooth : curve fit smoothing.... [%d]
"""
print help % (prog,file,dt,tf,tl,out)
print help % (prog,file,dt,tf,tl,out,smooth)
if __name__=='__main__':
main(sys.argv[0:])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment