docs: def _time_interval_operation(self, interval, operation, percentile=0):
          """Get a collection of a certain time interval with a given math operation."""
          # retrive the function that correctly describes the operation
          if operation == 'average':
              funct = self._average
          elif operation == 'total':
              funct = self._total
          else:
              assert 0 <= percentile <= 100, \
                  'percentile must be between 0 and 100. Got {}'.format(percentile)
              funct = self._get_percentile_function(percentile)
  
          # retrive the data that correctly describes the time interval
          if interval == 'monthly':
              data_dict = self.group_by_month()
              dates = self.header.analysis_period.months_int
          elif interval == 'daily':
              data_dict = self.group_by_day()
              dates = self.header.analysis_period.doys_int
          elif interval == 'monthlyperhour':
              data_dict = self.group_by_month_per_hour()
              dates = self.header.analysis_period.months_per_hour
          else:
              raise ValueError('Invalid input value for interval: {}'.format(interval))
          # get the data and header for the new collection
          new_data, d_times = [], []
          for i in dates:
              vals = data_dict[i]
              if vals != []:
                  new_data.append(funct(vals))
                  d_times.append(i)
          new_header = self.header.duplicate()
          if operation == 'percentile':
              new_header.metadata['operation'] = '{} percentile'.format(percentile)
          else:
              new_header.metadata['operation'] = operation
  
          # build the final data collection
          if interval == 'monthly':
              collection = MonthlyCollection(new_header, new_data, d_times)
          elif interval == 'daily':
              collection = DailyCollection(new_header, new_data, d_times)
          elif interval == 'monthlyperhour':
              collection = MonthlyPerHourCollection(new_header, new_data, d_times)
  
          collection._validated_a_period = True
          return collection