code: def _read_erd(erd_file, begsam, endsam):
      hdr = _read_hdr_file(erd_file)
      n_allchan = hdr['num_channels']
      shorted = hdr['shorted']
      n_shorted = sum(shorted)
      if n_shorted > 0:
          raise NotImplementedError('shorted channels not tested yet')
      if hdr['file_schema'] in (7,):
          abs_delta = b'\x80'
          raise NotImplementedError('schema 7 not tested yet')
      if hdr['file_schema'] in (8, 9):
          abs_delta = b'\xff\xff'
      n_smp = endsam - begsam
      data = empty((n_allchan, n_smp))
      data.fill(NaN)
      etc = _read_etc(erd_file.with_suffix('.etc'))
      all_beg = etc['samplestamp']
      all_end = etc['samplestamp'] + etc['sample_span'] - 1
      try:
          begrec = where((all_end >= begsam))[0][0]
          endrec = where((all_beg < endsam))[0][-1]
      except IndexError:
          return data
      with erd_file.open('rb') as f:
          for rec in range(begrec, endrec + 1):
              begpos_rec = begsam - all_beg[rec]
              endpos_rec = endsam - all_beg[rec]
              begpos_rec = max(begpos_rec, 0)
              endpos_rec = min(endpos_rec, all_end[rec] - all_beg[rec] + 1)
              d1 = begpos_rec + all_beg[rec] - begsam
              d2 = endpos_rec + all_beg[rec] - begsam
              dat = _read_packet(f, etc['offset'][rec], endpos_rec, n_allchan,
                                 abs_delta)
              data[:, d1:d2] = dat[:, begpos_rec:endpos_rec]
      if n_shorted > 0:
          full_channels = where(asarray([x == 0 for x in shorted]))[0]
          output = empty((n_allchan, n_smp))
          output.fill(NaN)
          output[full_channels, :] = data
      else:
          output = data
      factor = _calculate_conversion(hdr)
      return expand_dims(factor, 1) * output