Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !05/04/2014
- @1332
- Contact Angle (deg) 106.87
- Contact Angle Left (deg) 106.90
- Contact Angle Right (deg) 106.85
- Wetting Tension (mN/m) -21.13
- Wetting Tension Left (mN/m) -21.16
- Wetting Tension Right (mN/m) -21.11
- Base Tilt Angle (deg) 0.64
- Base (mm) 1.7001
- Base Area (mm2) 2.2702
- Height (mm) 1.1174
- Sessile Volume (ul) 2.1499
- Sessile Surface Area (mm2) 6.3842
- Contrast (cts) 255
- Sharpness (cts) 186
- Black Peak (cts) 0
- White Peak (cts) 255
- Edge Threshold (cts) 105
- Base Left X (mm) 2.435
- Base Right X (mm) 4.135
- Base Y (mm) 3.801
- RMS Fit Error (mm) 2.201E-3
- @1333
- Contact Angle (deg) 105.42
- Contact Angle Left (deg) 106.04
- Contact Angle Right (deg) 104.80
- Wetting Tension (mN/m) -19.36
- Wetting Tension Left (mN/m) -20.12
- Wetting Tension Right (mN/m) -18.59
- Base Tilt Angle (deg) 0.33
- Base (mm) 1.6619
- Base Area (mm2) 2.1691
- Height (mm) 0.9837
- Sessile Volume (ul) 1.6893
- Sessile Surface Area (mm2) 5.3962
- Contrast (cts) 255
- Sharpness (cts) 190
- Black Peak (cts) 0
- White Peak (cts) 255
- Edge Threshold (cts) 105
- Base Left X (mm) 2.397
- Base Right X (mm) 4.040
- Base Y (mm) 3.753
- RMS Fit Error (mm) 3.546E-3
- with open(infile) as f, open(outfile, 'w') as f2:
- for line in f:
- if line.split():
- if line.split()[0][0] == '!':
- for i in range(1,11):
- current_date += (line.split()[0][i])
- f2.write(current_date[:2] + ' ' + current_date[3:5] + ' ' + current_date[6:] + 'n')
- current_date = ""
- if line.split()[0][0] == '@':
- for i in range(0,5):
- measure_time += (line.split()[0][i])
- f2.write(measure_time[1:3] + ":" + measure_time[3:] + 'n')
- if line.split()[0] == "Contact" and line.split()[2] == "(deg)":
- contact_angle = line.split()[-1].strip()
- f2.write("Contact Angle (deg): " + contact_angle + 'nn')
- measure_time = ""
- else:
- continue
- from datetime import datetime
- import numpy as np
- dt = input("Enter treatment date and time in format: dd mm yyyy hh:mmn")
- #dt = '27 03 2014 12:06'
- dob = datetime.strptime(dt,'%d %m %Y %H:%M')
- b = datetime(2014,3,27,16,22,0)
- c = b-dob
- print(c.seconds)
- print(c.seconds/60)
- print(c.seconds//3600)
- data = {}
- date = ID = values = None
- for line in datafile:
- if line.lstrip().startswith('!'):
- date = line[1:].strip()
- print date, line
- elif line.lstrip().startswith('@'):
- ID = line[1:].strip()
- data[ID] = {}
- data[ID]['date'] = date
- elif line.strip(): # line not all whitespace
- if not ID:
- continue # we skip until we get next ID
- try:
- words = line.split()
- value = float(words[-1]) # last word
- unit = words[-2].lstrip('(').rstrip(')')
- item = {'value': value, 'unit': unit}
- key = ' '.join(words[:-2])
- data[ID][key] = item
- except (ValueError) as err:
- print "Could not parse this line:"
- print line
- continue
- else: # if 'empty' line
- ID = None
- records = []
- record = {}
- for line in f:
- kv = line.strip().split('t')
- if kv[0].startswith('@'):
- record['measurement_date'] = msr_date
- records.append(record) # store the last record
- record = {} # make a new empty record
- for n in range(21):
- kv = f.next().strip().split('t')
- quantity = kv[0].split('(')[0].strip()
- value = float(kv[1])
- record[quantity] = value
- elif kv[0].startswith('!'):
- msr_date = datetime.strptime(kv[0][1:], "%d/%m/%Y") # append it to the record later
- else:
- pass # empty line
- records.pop() # The first record is a dummy record
- # the last record has nog been appended yet
- record['measurement_date'] = msr_date
- records.append(record)
- arr = np.array([ (d['Contact Angle'], d['msr_date'], d['msr_date'] - treatment_date)
- for d in records ], dtype=[
- ('contact_angle', 'f4'),
- ('msr_date', 'datetime64'),
- ('lapse_time', 'timedelta64')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement