code: def fit_heptad_register(crangles):
      crangles = [x if x > 0 else 360 + x for x in crangles]
      hept_p = [x * (360.0 / 7.0) + ((360.0 / 7.0) / 2.0) for x in range(7)]
      ideal_crangs = [
          hept_p[0],
          hept_p[2],
          hept_p[4],
          hept_p[6],
          hept_p[1],
          hept_p[3],
          hept_p[5]
      ]
      full_hept = len(crangles) // 7
      ideal_crang_list = ideal_crangs * (full_hept + 2)
      fitting = []
      for i in range(7):
          ang_pairs = zip(crangles, ideal_crang_list[i:])
          ang_diffs = [abs(y - x) for x, y in ang_pairs]
          fitting.append((i, numpy.mean(ang_diffs), numpy.std(ang_diffs)))
      return sorted(fitting, key=lambda x: x[1])