Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. !05/04/2014
  2. @1332
  3. Contact Angle (deg) 106.87
  4. Contact Angle Left (deg) 106.90
  5. Contact Angle Right (deg) 106.85
  6. Wetting Tension (mN/m) -21.13
  7. Wetting Tension Left (mN/m) -21.16
  8. Wetting Tension Right (mN/m) -21.11
  9. Base Tilt Angle (deg) 0.64
  10. Base (mm) 1.7001
  11. Base Area (mm2) 2.2702
  12. Height (mm) 1.1174
  13. Sessile Volume (ul) 2.1499
  14. Sessile Surface Area (mm2) 6.3842
  15. Contrast (cts) 255
  16. Sharpness (cts) 186
  17. Black Peak (cts) 0
  18. White Peak (cts) 255
  19. Edge Threshold (cts) 105
  20. Base Left X (mm) 2.435
  21. Base Right X (mm) 4.135
  22. Base Y (mm) 3.801
  23. RMS Fit Error (mm) 2.201E-3
  24.  
  25. @1333
  26. Contact Angle (deg) 105.42
  27. Contact Angle Left (deg) 106.04
  28. Contact Angle Right (deg) 104.80
  29. Wetting Tension (mN/m) -19.36
  30. Wetting Tension Left (mN/m) -20.12
  31. Wetting Tension Right (mN/m) -18.59
  32. Base Tilt Angle (deg) 0.33
  33. Base (mm) 1.6619
  34. Base Area (mm2) 2.1691
  35. Height (mm) 0.9837
  36. Sessile Volume (ul) 1.6893
  37. Sessile Surface Area (mm2) 5.3962
  38. Contrast (cts) 255
  39. Sharpness (cts) 190
  40. Black Peak (cts) 0
  41. White Peak (cts) 255
  42. Edge Threshold (cts) 105
  43. Base Left X (mm) 2.397
  44. Base Right X (mm) 4.040
  45. Base Y (mm) 3.753
  46. RMS Fit Error (mm) 3.546E-3
  47.  
  48. with open(infile) as f, open(outfile, 'w') as f2:
  49. for line in f:
  50. if line.split():
  51. if line.split()[0][0] == '!':
  52. for i in range(1,11):
  53. current_date += (line.split()[0][i])
  54. f2.write(current_date[:2] + ' ' + current_date[3:5] + ' ' + current_date[6:] + 'n')
  55. current_date = ""
  56. if line.split()[0][0] == '@':
  57. for i in range(0,5):
  58. measure_time += (line.split()[0][i])
  59. f2.write(measure_time[1:3] + ":" + measure_time[3:] + 'n')
  60. if line.split()[0] == "Contact" and line.split()[2] == "(deg)":
  61. contact_angle = line.split()[-1].strip()
  62. f2.write("Contact Angle (deg): " + contact_angle + 'nn')
  63. measure_time = ""
  64. else:
  65. continue
  66.  
  67. from datetime import datetime
  68. import numpy as np
  69.  
  70. dt = input("Enter treatment date and time in format: dd mm yyyy hh:mmn")
  71. #dt = '27 03 2014 12:06'
  72.  
  73. dob = datetime.strptime(dt,'%d %m %Y %H:%M')
  74.  
  75.  
  76.  
  77. b = datetime(2014,3,27,16,22,0)
  78. c = b-dob
  79. print(c.seconds)
  80. print(c.seconds/60)
  81. print(c.seconds//3600)
  82.  
  83. data = {}
  84.  
  85. date = ID = values = None
  86.  
  87. for line in datafile:
  88. if line.lstrip().startswith('!'):
  89. date = line[1:].strip()
  90. print date, line
  91. elif line.lstrip().startswith('@'):
  92. ID = line[1:].strip()
  93. data[ID] = {}
  94. data[ID]['date'] = date
  95. elif line.strip(): # line not all whitespace
  96. if not ID:
  97. continue # we skip until we get next ID
  98. try:
  99. words = line.split()
  100. value = float(words[-1]) # last word
  101. unit = words[-2].lstrip('(').rstrip(')')
  102. item = {'value': value, 'unit': unit}
  103. key = ' '.join(words[:-2])
  104. data[ID][key] = item
  105. except (ValueError) as err:
  106. print "Could not parse this line:"
  107. print line
  108. continue
  109. else: # if 'empty' line
  110. ID = None
  111.  
  112. records = []
  113. record = {}
  114. for line in f:
  115. kv = line.strip().split('t')
  116. if kv[0].startswith('@'):
  117. record['measurement_date'] = msr_date
  118. records.append(record) # store the last record
  119. record = {} # make a new empty record
  120. for n in range(21):
  121. kv = f.next().strip().split('t')
  122. quantity = kv[0].split('(')[0].strip()
  123. value = float(kv[1])
  124. record[quantity] = value
  125. elif kv[0].startswith('!'):
  126. msr_date = datetime.strptime(kv[0][1:], "%d/%m/%Y") # append it to the record later
  127. else:
  128. pass # empty line
  129. records.pop() # The first record is a dummy record
  130. # the last record has nog been appended yet
  131. record['measurement_date'] = msr_date
  132. records.append(record)
  133.  
  134. arr = np.array([ (d['Contact Angle'], d['msr_date'], d['msr_date'] - treatment_date)
  135. for d in records ], dtype=[
  136. ('contact_angle', 'f4'),
  137. ('msr_date', 'datetime64'),
  138. ('lapse_time', 'timedelta64')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement