docs: def calculate_speed(self, section, alignment_results=None):
          """ Calculate speed using alignment information.
  
          :param section: The section (template or complement) we're calculating
              speed for.
          :param alignment_results: Optional dictionary of the alignment summary,
              so that speed can be calculated without having to write the summary
              out to the fast5 file first.
          :return: Speed in bases per second or zero if the speed could not be
              calculated.
  
          The only reliable way we have of finding out how many bases have gone through the pore is by
          looking at how much of the reference the sequence aligned to. This takes that information and
          uses it to calculate speed in reference-bases-per-second.
          """
          speed = 0.0
          if alignment_results:
              results = self._get_results(alignment_results)
          else:
              results = self.get_results()[section]
          if results['status'] != 'match found':
              return 0.0
          ref_span = results['ref_span']
          ref_len = ref_span[1] - ref_span[0]
          seq_span = results['seq_span']
          seq_len = seq_span[1] - seq_span[0]
          total_len = results['seq_len']
  
          sample_rate = self.handle.get_channel_info()['sampling_rate']
  
          # We need the duration from the segmentation results
          chain = self.handle.get_chain(self.group_name)
          if chain is not None:
              segmentation_group = dict(chain).get('segmentation')
          else:
              segmentation_group = None
          duration = 0
          if segmentation_group is not None:
              with SegmentationTools(self.handle, group_name=segmentation_group) as seg:
                  summary = seg.get_results()
                  if summary is not None:
                      duration = summary['duration_{}'.format(section)]
          if duration == 0:
              return 0.0
  
          normalized_duration = duration * seq_len / float(total_len)
          speed = sample_rate * ref_len / normalized_duration
          return speed