@@ -0,0 +1,1638 @@
+class DataRegion:%0A    def __init__(self):%0A        self.data = %5B%5D%0A%0A    def addTimeData(self, data_time, data_value):%0A        self.data.append((data_time, data_value))%0A%0A    def isTimeInRegion(self, secs_since_epoch):%0A        return self.data%5B0%5D%5B0%5D %3C= secs_since_epoch %3C= self.data%5B-1%5D%5B0%5D%0A%0A    def dataInTimeRegion(self, start_time, end_time):%0A        in_region = False%0A        result = %5B%5D%0A%0A        for item in self.data:%0A            # print(item%5B0%5D)%0A            if not in_region:%0A                if start_time %3C= item%5B0%5D %3C= end_time:%0A                    in_region = True%0A                    result.append(item)%0A            else:%0A                if end_time %3C item%5B0%5D:%0A                    in_region = False%0A                else:%0A                    result.append(item)%0A%0A        return result%0A%0A    def interpolatedValueAtTime(self, secs_since_epoch):%0A        if secs_since_epoch %3C self.data%5B0%5D%5B0%5D:%0A            return None%0A        elif self.data%5B-1%5D%5B0%5D %3C secs_since_epoch:%0A            return None%0A        else:%0A            start = None%0A            end = None%0A%0A            for (time, value) in self.data:%0A                if time == secs_since_epoch:%0A                    return value%0A                else:%0A                    if time %3C= secs_since_epoch:%0A                        start = (time, value)%0A                    elif secs_since_epoch %3C time:%0A                        if end is None:%0A                            end = (time, value)%0A%0A            time_delta = end%5B0%5D - start%5B0%5D%0A            percent = time_delta / (secs_since_epoch - start%5B0%5D)%0A            value_delta = end%5B1%5D - start%5B1%5D%0A%0A            return start%5B1%5D + value_delta * percent%0A

Create class to hold regions of data