2.py


SUBMITTED BY: bitcoinsachen

DATE: Oct. 23, 2016, 7:06 p.m.

FORMAT: Python 3

SIZE: 1.5 kB

HITS: 731

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Mon Oct 17 16:24:09 2016
  5. @author: *******
  6. @Matrikelnummer: 152****
  7. @Seminar: Wissenschaftliches Programmieren in Python
  8. """
  9. import numpy as np
  10. mypath= 'imsil_out'
  11. from os import listdir
  12. onlyfiles= [f for f in listdir(mypath) if f.endswith('.out')] #suche daten mit der Endung .out im ordner mypath
  13. from copy import copy
  14. yieldliste = copy(onlyfiles)
  15. tiltliste = copy(onlyfiles)
  16. laenge = len(onlyfiles)-1
  17. i=0
  18. while i <=laenge:
  19. file = mypath+'/'+onlyfiles[i]
  20. searchfile = open(file, "r")
  21. for line in searchfile:
  22. if "tilt=" in line:
  23. tiltvalue = line
  24. if " | Backscattered |" in line:
  25. yvalue = line
  26. searchfile.close()
  27. tiltliste[i]=tiltvalue[18:23]
  28. yieldliste[i]=yvalue[35:40]
  29. i=i+1
  30. print('tilt list:',tiltliste)
  31. print('yield field', yieldliste)
  32. #print(auslesen[18:23])
  33. f = open("output", "w+")
  34. f.write("Das ist mein Output File \nTiltliste :")
  35. f.write("\n")
  36. i=0
  37. while i<= laenge:
  38. f.write(tiltliste[i])
  39. f.write("\n")
  40. i=i+1
  41. if i > laenge:
  42. break
  43. f.write("Yieldliste :\n")
  44. i=0
  45. while i<= laenge:
  46. f.write(yieldliste[i])
  47. f.write("\n")
  48. i=i+1
  49. if i > laenge:
  50. break
  51. import matplotlib.pyplot as plt
  52. plt.title('2. Hausübung - Mat.Nr. 1525911')
  53. plt.xlabel('tilt=XXX')
  54. plt.ylabel('Yield (per Ion) ?')
  55. plt.grid(True)
  56. plt.plot(tiltliste,yieldliste)
  57. plt.show()
  58. #print(f)

comments powered by Disqus