def get_scan_timestamps(self): scan_down_time = 0 scan_up_time = 0 for i in range(len(self.smps_data)): if ''.join(self.smps_data[i][0].split()).lower() == "scanuptime(s)": scan_up_time = int(self.smps_data[i][1]) scan_down_time = int(self.smps_data[i + 1][1]) break scan_duration = scan_up_time + scan_down_time print ("Scan duration:", scan_duration) scan_start_times = self.smps_data[0] # generate scan end times from scan start times. Also, create a scan object for each scan for i in range(len(scan_start_times)): a_scan = Scan() self.scans.append(a_scan) start_time = datetime.strptime(scan_start_times[i], "%H:%M:%S") end_time = start_time + timedelta(seconds=scan_duration) a_scan.set_start_time(start_time) a_scan.set_end_time(end_time) a_scan.set_up_time(scan_up_time) a_scan.set_down_time(scan_down_time) a_scan.set_duration(scan_duration) a_scan.set_counts_2_conc(self.counts_to_conc_conv)