Bjoern Olausson

anamo.py PDF Print E-mail
  
Tuesday, 08 December 2009 00:00

  1. # -*- coding: utf-8 -*-
  2. #
  3. #--------------------------------------------------------------------------------
  4. #anamo.py v1.6, Copyright Bjoern Olausson
  5. #--------------------------------------------------------------------------------
  6. #This program is free software; you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation; either version 2 of the License, or
  9. #(at your option) any later version.
  10. #
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. #GNU General Public License for more details.
  15. #
  16. #To view the license visit
  17. #http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. #or write to
  19. #Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. #--------------------------------------------------------------------------------
  21. #--------------------------------------------------------------------------------
  22. #
  23. #This script is intended to pars NAMD output files and plot energy, temperature, and
  24. #whatever information NAMD writes down.
  25.  
  26. #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  27. #If you have different Values for "outputEnergies" and "outputPressure" use Time/TS if you want to plot
  28. #information affected by this value. Use PTime/PTS if you want to plot Information which is affcted by
  29. #this keyword. I didn't test this so far. If you use it double check the resulting plot.
  30. #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  31.  
  32. #
  33. #PRESSURE: PTS PXX PXY PXZ PYX PYY PYZ PZX PZY PZZ
  34. #GPRESSURE: PTS PXX PXY PXZ PYX PYY PYZ PZX PZY PZZ
  35. #PRESSAVG: PTS PXX PXY PXZ PYX PYY PYZ PZX PZY PZZ
  36. #GPRESSAVG: PTS PXX PXY PXZ PYX PYY PYZ PZX PZY PZZ
  37. #ENERGY: TS BOND ANGLE DIHED IMPRP ELECT VDW BOUNDARY MISC KINETIC TOTAL TEMP TOTAL2 TOTAL3 TEMPAVG PRESSURE GPRESSURE VOLUME PRESSAVG GPRESSAVG
  38. ##---------- --------- --------- --------- --------- ---------
  39. #
  40. # PTS PXX *PXY PXZ *PYX PYY +PYZ PZX +PZY PZZ
  41. # PRESSURE: 29101000 113.817 270.048 -425.735 270.048 -577.887 116.238 -425.735 116.238 -25.2852
  42. #GPRESSURE: 29101000 -131.017 120.797 -384.488 167.638 -452.296 173.325 -159.551 -48.9657 64.5387
  43. # PRESSAVG: 29101000 -16.186 5.86015 4.60358 5.86015 -12.8187 -85.7577 4.60358 -85.7577 47.1837
  44. #GPRESSAVG: 29101000 -15.7132 9.52987 5.07437 -4.25737 -14.0235 -91.353 3.07567 -79.6831 48.6288
  45. # ENERGY: 29101000 2805.2103 8458.6888 4626.4405 53.0736 -39150.1769 -1947.9501 0.0000 0.0000 13354.4343 -11800.2794 301.4109 -11674.5603 -11671.2349 300.4348 -163.1183 -172.9249 182937.7460 6.0596 6.2974
  46.  
  47.  
  48. #---------- --------- --------- --------- --------- ---------
  49. import sys, os, shutil, string, glob, subprocess, itertools, pylab, scipy, re
  50.  
  51. from optparse import OptionParser, OptionGroup
  52. opa = OptionParser()
  53.  
  54. opa.add_option("-f", action="append", dest="chmout", metavar="FILE",
  55. help="NAMD out file")
  56. opa.add_option("-o", action="store", dest="saveplot", metavar="FILE",
  57. help="Filename to which we save the plot (.png) and RAW data (.dat)")
  58.  
  59. opa.add_option("-s", action="store_true", dest="singleplot",
  60. help="Plot to single image")
  61.  
  62. group = OptionGroup(opa, "You can choose freely from the following Values which will occure on either X or Y Axis",
  63. "TS Time PTS PTime BOND ANGLE DIHED IMPRP ELECT VDW BOUNDARY MISC KINETIC TOTAL TEMP TOTAL2 TOTAL3 TEMPAVG PRESSURE GPRESSURE VOLUME PRES SAVG GPRESSAVG PTS PXX PXY PXZ PYX PYY PYZ PZX PZY PZZ GPXX GPXY GPXZ GPYX GPYY GPYZ GPZX GPZY GPZZ PXXAV PXYAV PXZAV PYXAV PYYAV PYZAV PZXAV PZYAV PZZAV GPXXAV GPXYAV GPXZAV GPYXAV GPYYAV GPYZAV GPZXAV GPZYAV GPZZAV (If you use one of Pressure Tensors, use for TS PTS or for Time PTime)")
  64.  
  65. group.add_option("-m", action="store_true", dest="Mini",
  66. help="Use this option to only analys the minimization part of the output file. Default is, to skip the minimization steps and only plot the MD part")
  67.  
  68. group.add_option("-n", action="store_true", dest="MDMIN",
  69. help="Use this option to analys the MD and minimization part of the output file.")
  70.  
  71. group.add_option("-x", action="append", dest="xax",
  72. help="Choose Value from above you want to appear on the X-axis.")
  73.  
  74. group.add_option("-y", action="append", dest="yax",
  75. help="Choose Value from above you want to appear on the Y-axis. If you want to plot multible Y values, you have to asign every Y value a X value and vice versa. For example: anaout.py -x TS -x TS -y PRESSURE -y TEMPAVG")
  76. opa.add_option_group(group)
  77.  
  78.  
  79. # instruct optparse to parse the program's command line
  80. (options, args) = opa.parse_args()
  81.  
  82. # Checking for required otions
  83. if not options.chmout:
  84. parser.error("-f must be set")
  85.  
  86. #chmout = options.chmout.split(" ")
  87. chmout = options.chmout
  88. Mini = options.Mini
  89. MDMIN = options.MDMIN
  90. xax = options.xax
  91. yax = options.yax
  92. saveplot = options.saveplot
  93. singleplot = options.singleplot
  94.  
  95. #If "*" is found in a parameter, glob it.
  96. for element in chmout :
  97. if '*' in element :
  98. chmout.extend(glob.glob(element))
  99. chmout.remove(element)
  100. chmout.sort()
  101.  
  102. #Defining the lists
  103. TIMES = []
  104. PTS = []
  105. TS = []; BOND = []; ANGLE = []; DIHED = []; IMPRP = []; ELECT = []; VDW = []; BOUNDARY = []; MISC = []; KINETIC = []; TOTAL = []; TEMP = []; TOTAL2 = []; TOTAL3 = []; TEMPAVG = []; PRESSURE = []; GPRESSURE = []; VOLUME = []; PRESSAVG = []; GPRESSAVG = []
  106. PXX = []; PXY = []; PXZ = []; PYX = []; PYY = []; PYZ = []; PZX = []; PZY = []; PZZ = []
  107. GPXX = []; GPXY = []; GPXZ = []; GPYX = []; GPYY = []; GPYZ = []; GPZX = []; GPZY = []; GPZZ = []
  108. PXXAV = []; PXYAV = []; PXZAV = []; PYXAV = []; PYYAV = []; PYZAV = []; PZXAV = []; PZYAV = []; PZZAV = []
  109. GPXXAV = []; GPXYAV = []; GPXZAV = []; GPYXAV = []; GPYYAV = []; GPYZAV = []; GPZXAV = []; GPZYAV = []; GPZZAV = []
  110.  
  111. #Regular expression to find the start of the MD simulation
  112. #MDp = re.compile('Info: Finished startup')
  113. MDstart = re.compile('TCL: Running for [0-9]+ steps')
  114. #Regular expression to find the Timestep used
  115. TSre = re.compile('Info: +TIMESTEP +[1-9]+')
  116. #Regular expression to see if "minimization on" was used in the config file
  117. MINonly = re.compile('CONJUGATE GRADIENT MINIMIZATION ACTIVE')
  118. #Regular expression to see if "mini" was run
  119. MINstart = re.compile('TCL: Minimizing for [0-9]+ steps')
  120.  
  121.  
  122.  
  123. #Info: TIMESTEP 2
  124. def Info(line) :
  125. if TSre.match(line):
  126. MyTS = re.sub("\D", "", line)
  127. if MyTS.isdigit():
  128. TIMES.append(int(MyTS))
  129. else:
  130. raise Exception('Timestep is not a digit')
  131.  
  132. #PRESSURE: 28601100 -13.0939 160.713 -191.914 160.713 -540.017 -233.812 -191.914 -233.812 1224.65
  133. def Pressure(line) :
  134. PTS.append(int(line.split()[1]))
  135. PXX.append(float(line.split()[2]))
  136. PXY.append(float(line.split()[3]))
  137. PXZ.append(float(line.split()[4]))
  138. PYX.append(float(line.split()[5]))
  139. PYY.append(float(line.split()[6]))
  140. PYZ.append(float(line.split()[7]))
  141. PZX.append(float(line.split()[8]))
  142. PZY.append(float(line.split()[9]))
  143. PZZ.append(float(line.split()[10]))
  144. #GPRESSURE: 28601100 35.4952 117.701 -181.483 248.367 -208.371 -129.89 -404.508 -349.542 913.535
  145. def GPressure(line) :
  146. GPXX.append(float(line.split()[2]))
  147. GPXY.append(float(line.split()[3]))
  148. GPXZ.append(float(line.split()[4]))
  149. GPYX.append(float(line.split()[5]))
  150. GPYY.append(float(line.split()[6]))
  151. GPYZ.append(float(line.split()[7]))
  152. GPZX.append(float(line.split()[8]))
  153. GPZY.append(float(line.split()[9]))
  154. GPZZ.append(float(line.split()[10]))
  155. #PRESSAVG: 28601100 11.1302 78.4552 38.3246 78.4552 2.34895 -59.1307 38.3246 -59.1307 2.71294
  156. def PresAv(line) :
  157. PXXAV.append(float(line.split()[2]))
  158. PXYAV.append(float(line.split()[3]))
  159. PXZAV.append(float(line.split()[4]))
  160. PYXAV.append(float(line.split()[5]))
  161. PYYAV.append(float(line.split()[6]))
  162. PYZAV.append(float(line.split()[7]))
  163. PZXAV.append(float(line.split()[8]))
  164. PZYAV.append(float(line.split()[9]))
  165. PZZAV.append(float(line.split()[10]))
  166. #GPRESSAVG: 28601100 6.71473 68.2579 37.7828 76.8936 1.54956 -64.4147 42.1503 -46.2259 3.81618
  167. def GPresAv(line) :
  168. GPXXAV.append(float(line.split()[2]))
  169. GPXYAV.append(float(line.split()[3]))
  170. GPXZAV.append(float(line.split()[4]))
  171. GPYXAV.append(float(line.split()[5]))
  172. GPYYAV.append(float(line.split()[6]))
  173. GPYZAV.append(float(line.split()[7]))
  174. GPZXAV.append(float(line.split()[8]))
  175. GPZYAV.append(float(line.split()[9]))
  176. GPZZAV.append(float(line.split()[10]))
  177.  
  178. #ENERGY: 29101000 2805.2103 8458.6888 4626.4405 53.0736 -39150.1769 -1947.9501 0.0000 0.0000 13354.4343 -11800.2794 301.4109 -11674.5603 -11671.2349 300.4348 -163.1183 -172.9249 182937.7460 6.0596 6.2974
  179. #ENERGY: TS BOND ANGLE DIHED IMPRP ELECT VDW BOUNDARY MISC KINETIC TOTAL TEMP TOTAL2 TOTAL3 TEMPAVG PRESSURE GPRESSURE VOLUME PRESSAVG GPRESSAVG
  180. def Energy(line) :
  181. TS.append(int(line.split()[1]))
  182. BOND.append(float(line.split()[2]))
  183. ANGLE.append(float(line.split()[3]))
  184. DIHED.append(float(line.split()[4]))
  185. IMPRP.append(float(line.split()[5]))
  186. ELECT.append(float(line.split()[6]))
  187. VDW.append(float(line.split()[7]))
  188. BOUNDARY.append(float(line.split()[8]))
  189. MISC.append(float(line.split()[9]))
  190. KINETIC.append(float(line.split()[10]))
  191. TOTAL.append(float(line.split()[11]))
  192. TEMP.append(float(line.split()[12]))
  193. TOTAL2.append(float(line.split()[13]))
  194. TOTAL3.append(float(line.split()[14]))
  195. TEMPAVG.append(float(line.split()[15]))
  196. #TS.append(int(line[7:16].strip()))
  197. #BOND.append(float(line[16:31].strip()))
  198. #ANGLE.append(float(line[31:46].strip()))
  199. #DIHED.append(float(line[46:61].strip()))
  200. #IMPRP.append(float(line[61:76].strip()))
  201. #ELECT.append(float(line[76:96].strip()))
  202. #VDW.append(float(line[96:112].strip()))
  203. #BOUNDARY.append(float(line[112:126].strip()))
  204. #MISC.append(float(line[126:141].strip()))
  205. #KINETIC.append(float(line[141:156].strip()))
  206. #TOTAL.append(float(line[156:176].strip()))
  207. #TEMP.append(float(line[176:191].strip()))
  208. #TOTAL2.append(float(line[191:206].strip()))
  209. #TOTAL3.append(float(line[206:221].strip()))
  210. #TEMPAVG.append(float(line[221:236].strip()))
  211. # If "minimization on" was used in the config file, these values are not populated
  212. if MINs or MINo :
  213. PRESSURE.append(float(0))
  214. GPRESSURE.append(float(0))
  215. VOLUME.append(float(0))
  216. PRESSAVG.append(float(0))
  217. GPRESSAVG.append(float(0))
  218. else:
  219. PRESSURE.append(float(line.split()[16]))
  220. GPRESSURE.append(float(line.split()[17]))
  221. VOLUME.append(float(line.split()[18]))
  222. PRESSAVG.append(float(line.split()[19]))
  223. GPRESSAVG.append(float(line.split()[20]))
  224.  
  225. LineFunc = {
  226. 'Info': Info,
  227. 'PRESSURE': Pressure,
  228. 'GPRESSURE': GPressure,
  229. 'PRESSAVG': PresAv,
  230. 'GPRESSAVG': GPresAv,
  231. 'ENERGY': Energy
  232. }
  233.  
  234. fnum = 0
  235. nMDs = 0
  236. nMINs = 0
  237. nMINo = 0
  238. for outfile in chmout :
  239. MINo = ""
  240. MINs = ""
  241. MDs = ""
  242. #Add Zeros for the first (Group-)Pressure averages cause there are no
  243. #averages for the first timestep in the outfile when you use the keyword
  244. #printGroupPressure
  245. PresAv('0 0 0 0 0 0 0 0 0 0 0')
  246. GPresAv('0 0 0 0 0 0 0 0 0 0 0')
  247. mm = False
  248. for lines in open(outfile, "r") :
  249. #Find TIMESTEP and extract it
  250. if TSre.search(lines):
  251. LineFunc[LineStart[0]](lines)
  252. #Check if this is a "minimization only" run
  253. if MINonly.search(lines):
  254. MINo = True
  255. MINs = False
  256. MDs = False
  257. nMINo += 1
  258. print "%s mini only part(s) found" %(nMINo)
  259. #Check if a minimization was run prior to MD
  260. if MINstart.search(lines):
  261. MINs = True
  262. MDs = False
  263. nMINs += 1
  264. print "%s mini part(s) found" %(nMINs)
  265. #Check for "MD" start
  266. if MDstart.search(lines):
  267. MDs = True
  268. MINs = False
  269. nMDs += 1
  270. print "%s md part(s) found" %(nMDs)
  271. #Get the Line description to invoke the corresponding function
  272. LineStart = lines.split(":")
  273. #Per default we analyse only the MD run part of the logfile
  274. #Check if the MD startpoint is reached and start grabbing the lines
  275. if MDs and not MINs and not Mini:
  276. if LineStart[0] in LineFunc :
  277. LineFunc[LineStart[0]](lines)
  278. #Only analyse the minimizations bevor/between/after a MD run
  279. if Mini:
  280. #Check if the MINIMIZATION startpoint is reached
  281. if MINs and not MDs:
  282. if LineStart[0] in LineFunc :
  283. LineFunc[LineStart[0]](lines)
  284. #Analyse both MINIMIZATION and MD part
  285. if MDMIN:
  286. if MINs or MDs:
  287. if LineStart[0] in LineFunc :
  288. LineFunc[LineStart[0]](lines)
  289. #If this is a MINIMIZATION only run... we default to this instead to the MD part
  290. if MINo:
  291. if LineStart[0] in LineFunc :
  292. LineFunc[LineStart[0]](lines)
  293. fnum = fnum + 1
  294. print
  295. print "---------------------DONE---------------------"
  296. if nMDs == 0 and nMINo == 0 and not Mini:
  297. print "Only mini part(s) (%s) found, but there was no option passed to analyse minimization" %(nMINs)
  298. raise Exception("Add \"-m\" to your options and run again")
  299. else:
  300. print "%s mini part(s) found overall" %(nMINs)
  301. print "%s mini only part(s)) found overall" %(nMINo)
  302. print "%s md part(s) found overall" %(nMDs)
  303. print "---------------------DONE---------------------"
  304.  
  305.  
  306. #Convert Lists to scipy arrays
  307. TS = scipy.array(TS)
  308. PTS = scipy.array(PTS)
  309. #Calculate time from Timesteps in ns
  310. Time = TS
  311. Time = Time * TIMES[0] * 1e-6
  312. PTime = PTS
  313. PTime = PTime * TIMES[0] * 1e-6
  314. BOND = scipy.array(BOND)
  315. ANGLE = scipy.array(ANGLE)
  316. DIHED = scipy.array(DIHED)
  317. IMPRP = scipy.array(IMPRP)
  318. ELECT = scipy.array(ELECT)
  319. VDW = scipy.array(VDW)
  320. BOUNDARY = scipy.array(BOUNDARY)
  321. MISC = scipy.array(MISC)
  322. KINETIC = scipy.array(KINETIC)
  323. TOTAL = scipy.array(TOTAL)
  324. TEMP = scipy.array(TEMP)
  325. TOTAL2 = scipy.array(TOTAL2)
  326. TOTAL3 = scipy.array(TOTAL3)
  327. TEMPAVG = scipy.array(TEMPAVG)
  328. PRESSURE = scipy.array(PRESSURE)
  329. GPRESSURE = scipy.array(GPRESSURE)
  330. VOLUME = scipy.array(VOLUME)
  331. PRESSAVG = scipy.array(PRESSAVG)
  332. PXX = scipy.array(PXX)
  333. PXY = scipy.array(PYY)
  334. PXZ = scipy.array(PZZ)
  335. PYX = scipy.array(PYX)
  336. PYY = scipy.array(PYY)
  337. PYZ = scipy.array(PYZ)
  338. PZX = scipy.array(PZX)
  339. PZY = scipy.array(PZY)
  340. PZZ = scipy.array(PZZ)
  341. GPXX = scipy.array(GPXX)
  342. GPXY = scipy.array(GPXY)
  343. GPXZ = scipy.array(GPXZ)
  344. GPYX = scipy.array(GPYX)
  345. GPYY = scipy.array(GPYY)
  346. GPYZ = scipy.array(GPYZ)
  347. GPZX = scipy.array(GPZX)
  348. GPZY = scipy.array(GPZY)
  349. GPZZ = scipy.array(GPZZ)
  350. PXXAV = scipy.array(PXXAV)
  351. PXYAV = scipy.array(PXYAV)
  352. PXZAV = scipy.array(PXZAV)
  353. PYXAV = scipy.array(PYXAV)
  354. PYYAV = scipy.array(PYYAV)
  355. PYZAV = scipy.array(PYZAV)
  356. PZXAV = scipy.array(PZXAV)
  357. PZYAV = scipy.array(PZYAV)
  358. PZZAV = scipy.array(PZZAV)
  359. GPXXAV = scipy.array(GPXXAV)
  360. GPXYAV = scipy.array(GPXYAV)
  361. GPXZAV = scipy.array(GPXZAV)
  362. GPYXAV = scipy.array(GPYXAV)
  363. GPYYAV = scipy.array(GPYYAV)
  364. GPYZAV = scipy.array(GPYZAV)
  365. GPZXAV = scipy.array(GPZXAV)
  366. GPZYAV = scipy.array(GPZYAV)
  367. GPZZAV = scipy.array(GPZZAV)
  368.  
  369. #COMBINED = scipy.array([[TS], [Time], [TOTEner], [TOTKe], [ENERgy], [TEMPerature], [GRMS], [HFCTote], [HFCKe], [EHFCor], [VIRKe], [BONDs], [ANGLes], [UREYb], [DIHEdrals], [IMPRopers], [CMAPs], [VDWaals], [ELEC], [HBONds], [ASP], [USER], [IMNBvdw], [IMELec], [IMHBnd], [RXNField], [EXTElec], [EWKSum], [EWSElf], [EWEXcl], [EWQCor], [EWUTil], [HARMonic], [CDIHedral], [CIC], [RESDistance], [NOE], [GEO], [MDIP], [SSBP], [SHEL], [DROFfa], [VIRE], [VIRI], [PRESSE], [PRESSI], [VOLUme]])
  370. PlotDict = {
  371. 'TS': TS,
  372. 'PTS': PTS,
  373. 'Time': Time,
  374. 'PTime': PTime,
  375. 'BOND': BOND,
  376. 'ANGLE': ANGLE,
  377. 'DIHED': DIHED,
  378. 'IMPRP': IMPRP,
  379. 'ELECT': ELECT,
  380. 'VDW': VDW,
  381. 'BOUNDARY': BOUNDARY,
  382. 'MISC': MISC,
  383. 'KINETIC': KINETIC,
  384. 'TOTAL': TOTAL,
  385. 'TEMP': TEMP,
  386. 'TOTAL2': TOTAL2,
  387. 'TOTAL3': TOTAL3,
  388. 'TEMPAVG': TEMPAVG,
  389. 'PRESSURE': PRESSURE,
  390. 'GPRESSURE': GPRESSURE,
  391. 'VOLUME': VOLUME,
  392. 'PRESSAVG': PRESSAVG,
  393. 'GPRESSAVG': GPRESSAVG,
  394. 'PXX': PXX,
  395. 'PXY': PXY,
  396. 'PXZ': PXZ,
  397. 'PYX': PYX,
  398. 'PYY': PYY,
  399. 'PYZ': PYZ,
  400. 'PZX': PZX,
  401. 'PZY': PZY,
  402. 'PZZ': PZZ,
  403. 'GPXX': GPXX,
  404. 'GPXY': GPXY,
  405. 'GPXZ': GPXZ,
  406. 'GPYX': GPYX,
  407. 'GPYY': GPYY,
  408. 'GPYZ': GPYZ,
  409. 'GPZX': GPZX,
  410. 'GPZY': GPZY,
  411. 'GPZZ': GPZZ,
  412. 'PXXAV': PXXAV,
  413. 'PXYAV': PXYAV,
  414. 'PXZAV': PXZAV,
  415. 'PYXAV': PYXAV,
  416. 'PYYAV': PYYAV,
  417. 'PYZAV': PYZAV,
  418. 'PZXAV': PZXAV,
  419. 'PZYAV': PZYAV,
  420. 'PZZAV': PZZAV,
  421. 'GPXXAV': GPXXAV,
  422. 'GPXYAV': GPXYAV,
  423. 'GPXZAV': GPXZAV,
  424. 'GPYXAV': GPYXAV,
  425. 'GPYYAV': GPYYAV,
  426. 'GPYZAV': GPYZAV,
  427. 'GPZXAV': GPZXAV,
  428. 'GPZYAV': GPZYAV,
  429. 'GPZZAV': GPZZAV,
  430.  
  431. }
  432.  
  433. def SaveData(Xvalues,Yvalues, Xname, Yname, saveplot) :
  434. if saveplot :
  435. savedata = Xname+"-"+Yname+"_"+saveplot+".dat"
  436. fout = open(savedata, "w")
  437. for i,j in itertools.izip(Xvalues,Yvalues) :
  438. fout.writelines("%s %s
    "
    % (i,j))
  439. fout.close()
  440.  
  441. def SaveImage(Xname, Yname, saveplot) :
  442. if saveplot :
  443. saveimg = Xname+"-"+Yname+"_"+saveplot+".png"
  444. pylab.savefig(saveimg)
  445.  
  446. def DynaPltSingle(Xvalues,Yvalues,Xname,Yname) :
  447. #Do some nice plots later
  448. SaveData(Xvalues, Yvalues, Xname, Yname, saveplot)
  449. pylab.plot(Xvalues, Yvalues)
  450. Xlegend.append(Xname)
  451. Ylegend.append(Yname)
  452.  
  453. def DynaPltMulti(Xvalues,Yvalues,Xname,Yname, figure) :
  454. pylab.figure(figure)
  455. pylab.plot(Xvalues, Yvalues)
  456. pylab.xlabel(Xname)
  457. pylab.ylabel(Yname)
  458. SaveImage(Xname, Yname, saveplot)
  459. SaveData(Xvalues,Yvalues, Xname, Yname, saveplot)
  460.  
  461. fign = 0
  462. Xlegend = []
  463. Xlabel = []
  464. Ylegend = []
  465. Ylabel = []
  466. if singleplot :
  467. for xAxis,yAxis in itertools.izip(xax,yax) :
  468. DynaPltSingle(PlotDict[xAxis], PlotDict[yAxis], xAxis, yAxis)
  469. pylab.legend((Ylegend), shadow = True)
  470. pylab.ylabel(Ylegend)
  471. pylab.xlabel(Xlegend)
  472. SaveImage(xAxis, 'MULTI', saveplot)
  473. else :
  474. figure = 0
  475. for xAxis,yAxis in itertools.izip(xax,yax) :
  476. DynaPltMulti(PlotDict[xAxis], PlotDict[yAxis], xAxis, yAxis, figure)
  477. figure = figure + 1
  478. pylab.show()
  479.  
  480.  

Attachments:
FileFile sizeLast Modified
Download this file (anamo.py)anamo.py17 Kb12/08/09 13:57
Last Updated ( Tuesday, 08 December 2009 13:56 )
 

Add comment


Security code
Refresh