예제 #1
0
    def _times(self):
        """Fill in start and end times and dates."""

        # just in case a calibration timestamp happens to occur before or after the first or last CGM reading of the day
        if len(self.calibrations) != 0 and len(self.readings) != 0:
            self.start_time, self.date = util_time.get_start_time(
                self.calibrations[0]['timestamp'],
                self.readings[0]['timestamp'])
            self.end_time = util_time.get_end_time(
                self.calibrations[-1]['timestamp'],
                self.readings[-1]['timestamp'])[0]
        elif len(self.readings) != 0:
            self.start_time = util_time.parse_timestamp(
                self.readings[0]['timestamp'])
            self.date = self.start_time.date()
            self.end_time = util_time.parse_timestamp(
                self.readings[-1]['timestamp'])
        else:
            self.start_time = util_time.parse_timestamp(
                self.calibrations[0]['timestamp'])
            self.date = self.start_time.date()
            print
            print str(
                self.date) + " has (a) calibration(s) but no CGM readings."
            print
            self.end_time = util_time.parse_timestamp(
                self.calibrations[0]['timestamp'])
예제 #2
0
	def _times(self):
		"""Fill in start and end times and dates."""

		# just in case a calibration timestamp happens to occur before or after the first or last CGM reading of the day
		if len(self.calibrations) != 0 and len(self.readings) != 0:
			self.start_time, self.date = util_time.get_start_time(self.calibrations[0]['timestamp'], 
				self.readings[0]['timestamp'])
			self.end_time = util_time.get_end_time(self.calibrations[-1]['timestamp'], 
				self.readings[-1]['timestamp'])[0]
		elif len(self.readings) != 0:
			self.start_time = util_time.parse_timestamp(self.readings[0]['timestamp'])
			self.date = self.start_time.date()
			self.end_time = util_time.parse_timestamp(self.readings[-1]['timestamp'])
		else:
			self.start_time = util_time.parse_timestamp(self.calibrations[0]['timestamp'])
			self.date = self.start_time.date()
			print
			print str(self.date) + " has (a) calibration(s) but no CGM readings."
			print
			self.end_time = util_time.parse_timestamp(self.calibrations[0]['timestamp'])
예제 #3
0
    def __init__(self, dex, out_path, options):

        with open(dex, 'rb') as f:
            self.dexcom = json.load(f)

        self.path = out_path

        self.calibrations = self.dexcom['Calibrations']

        self.readings = self.dexcom['Readings']

        # of these, only using self.start_date so far, but the rest could be potentially useful?
        self.start_time, self.start_date = util_time.get_start_time(
            self.calibrations[0]['timestamp'], self.readings[0]['timestamp'])

        self.end_time, self.end_date = util_time.get_end_time(
            self.calibrations[-1]['timestamp'], self.readings[-1]['timestamp'])

        # dict of DexcomDay objects, keyed by Python datetime.date()
        self.days = {}

        # dict of DexcomWeek objects, keyed by Python datetime.date().isocalendar()[1] (= ISO week number)
        self.weeks = {}

        # dict of DexcomMonth objects, keyed by Python datetime.month
        self.months = {}

        # dict of DexcomYear objects, keyed by Python datetime.year
        self.years = {}

        # dict of all batched objects
        self.units = {'days': self.days}

        # method to split data into DexcomDay objects
        self._split_by_day()

        # following lines allow for looping through self.days dict in sequential date order
        self.dates = []
        for day in self.days.values():
            if type(day.date) != type('abc'):
                self.dates.append(day.date)
            else:
                print "Empty Date!"
                day.print_summary()
            # populate each day's just_readings array
            day.just_readings = [
                reading['blood_glucose'] for reading in day.readings
            ]
            self._crunch_all(day)

        self.dates.sort()

        if options[0]:
            # method to split data into DexcomWeek objects
            self._split_by_week()
            self.units['weeks'] = self.weeks

        if options[1]:
            # method to split data into DexcomMonth objects
            self._split_by_month()
            self.units['months'] = self.months

        if options[2]:
            # method to split data into DexcomYear objects
            self._split_by_year()
            self.units['years'] = self.years
예제 #4
0
	def __init__(self, dex, options):

		with open(dex, 'rb') as f:
			self.dexcom = json.load(f)

		self.path = dex.rstrip('dexcom.json')

		self.calibrations = self.dexcom['Calibrations']

		self.readings = self.dexcom['Readings']

		# of these, only using self.start_date so far, but the rest could be potentially useful?
		self.start_time, self.start_date = util_time.get_start_time(self.calibrations[0]['timestamp'], 
			self.readings[0]['timestamp'])

		self.end_time, self.end_date = util_time.get_end_time(self.calibrations[-1]['timestamp'], 
			self.readings[-1]['timestamp'])

		# dict of DexcomDay objects, keyed by Python datetime.date()
		self.days = {}

		# dict of DexcomWeek objects, keyed by Python datetime.date().isocalendar()[1] (= ISO week number)
		self.weeks = {}

		# dict of DexcomMonth objects, keyed by Python datetime.month
		self.months = {}

		# dict of DexcomYear objects, keyed by Python datetime.year
		self.years = {}

		# dict of all batched objects
		self.units = {'days': self.days}

		# method to split data into DexcomDay objects
		self._split_by_day()

		# following lines allow for looping through self.days dict in sequential date order
		self.dates = []
		for day in self.days.values():
			if type(day.date) != type('abc'):
				self.dates.append(day.date)
			else:
				print "Empty Date!"
				day.print_summary()
			# populate each day's just_readings array
			day.just_readings = [reading['blood_glucose'] for reading in day.readings]
			self._crunch_all(day)

		self.dates.sort()

		if options[0]:
			# method to split data into DexcomWeek objects
			self._split_by_week()
			self.units['weeks'] = self.weeks

		if options[1]:
			# method to split data into DexcomMonth objects
			self._split_by_month()
			self.units['months'] = self.months

		if options[2]:
			# method to split data into DexcomYear objects
			self._split_by_year()
			self.units['years'] = self.years