docs: def compare(what, imt, calc_ids, files, samplesites=100, rtol=.1, atol=1E-4):
      """
      Compare the hazard curves or maps of two or more calculations
      """
      sids, imtls, poes, arrays = getdata(what, calc_ids, samplesites)
      try:
          levels = imtls[imt]
      except KeyError:
          sys.exit(
              '%s not found. The available IMTs are %s' % (imt, list(imtls)))
      imt2idx = {imt: i for i, imt in enumerate(imtls)}
      head = ['site_id'] if files else ['site_id', 'calc_id']
      if what == 'hcurves':
          array_imt = arrays[:, :, imtls(imt)]
          header = head + ['%.5f' % lvl for lvl in levels]
      else:  # hmaps
          array_imt = arrays[:, :, imt2idx[imt]]
          header = head + [str(poe) for poe in poes]
      rows = collections.defaultdict(list)
      diff_idxs = get_diff_idxs(array_imt, rtol, atol)
      if len(diff_idxs) == 0:
          print('There are no differences within the tolerance of %d%%' %
                (rtol * 100))
          return
      arr = array_imt.transpose(1, 0, 2)  # shape (N, C, L)
      for sid, array in sorted(zip(sids[diff_idxs], arr[diff_idxs])):
          for calc_id, cols in zip(calc_ids, array):
              if files:
                  rows[calc_id].append([sid] + list(cols))
              else:
                  rows['all'].append([sid, calc_id] + list(cols))
      if files:
          fdict = {calc_id: open('%s.txt' % calc_id, 'w')
                   for calc_id in calc_ids}
          for calc_id, f in fdict.items():
              f.write(views.rst_table(rows[calc_id], header))
              print('Generated %s' % f.name)
      else:
          print(views.rst_table(rows['all'], header))