docs: def hdf5(self, path, features, filtered=True, override=False,
               compression="gzip"):
          """Export the data of the current instance to an HDF5 file
  
          Parameters
          ----------
          path: str
              Path to an .rtdc file. The ending .rtdc is added
              automatically.
          features: list of str
              The features in the resulting .tsv file. These are strings
              that are defined in `dclab.definitions.feature_names`, e.g.
              "area_cvx", "deform", "frame", "fl1_max", "image".
          filtered: bool
              If set to `True`, only the filtered data (index in ds._filter)
              are used.
          override: bool
              If set to `True`, an existing file ``path`` will be overridden.
              If set to `False`, raises `OSError` if ``path`` exists.
          compression: str or None
              Compression method for "contour", "image", and "trace" data
              as well as logs; one of [None, "lzf", "gzip", "szip"].
          """
          path = pathlib.Path(path)
          # Make sure that path ends with .rtdc
          if not path.suffix == ".rtdc":
              path = path.parent / (path.name + ".rtdc")
          # Check if file already exist
          if not override and path.exists():
              raise OSError("File already exists: {}\n".format(path)
                            + "Please use the `override=True` option.")
          elif path.exists():
              path.unlink()
  
          meta = {}
  
          # only export configuration meta data (no user-defined config)
          for sec in dfn.CFG_METADATA:
              if sec in ["fmt_tdms"]:
                  # ignored sections
                  continue
              if sec in self.rtdc_ds.config:
                  meta[sec] = self.rtdc_ds.config[sec].copy()
  
          if filtered:
              filtarr = self.rtdc_ds.filter.all
              nev = np.sum(filtarr)
          else:
              nev = len(self.rtdc_ds)
              filtarr = np.ones(nev, dtype=bool)
  
          # update number of events
          meta["experiment"]["event count"] = nev
  
          # write meta data
          with write(path_or_h5file=path, meta=meta, mode="append") as h5obj:
              # write each feature individually
              for feat in features:
                  # event-wise, because
                  # - tdms-based datasets don't allow indexing with numpy
                  # - there might be memory issues
                  if feat == "contour":
                      cont_list = []
                      cmax = 0
                      for ii in range(len(self.rtdc_ds)):
                          if filtarr[ii]:
                              dat = self.rtdc_ds["contour"][ii]
                              cont_list.append(dat)
                              cmax = max(cmax, dat.max())
                      write(h5obj,
                            data={"contour": cont_list},
                            mode="append",
                            compression=compression)
                  elif feat in ["mask", "image"]:
                      # store image stacks (reduced file size and save time)
                      m = 64
                      im0 = self.rtdc_ds[feat][0]
                      imstack = np.zeros((m, im0.shape[0], im0.shape[1]),
                                         dtype=im0.dtype)
                      jj = 0
                      for ii in range(len(self.rtdc_ds)):
                          if filtarr[ii]:
                              dat = self.rtdc_ds[feat][ii]
                              imstack[jj] = dat
                              if (jj + 1) % m == 0:
                                  jj = 0
                                  write(h5obj,
                                        data={feat: imstack},
                                        mode="append",
                                        compression=compression)
                              else:
                                  jj += 1
                      # write rest
                      if jj:
                          write(h5obj,
                                data={feat: imstack[:jj, :, :]},
                                mode="append",
                                compression=compression)
                  elif feat == "trace":
                      for tr in self.rtdc_ds["trace"].keys():
                          tr0 = self.rtdc_ds["trace"][tr][0]
                          trdat = np.zeros((nev, tr0.size), dtype=tr0.dtype)
                          jj = 0
                          for ii in range(len(self.rtdc_ds)):
                              if filtarr[ii]:
                                  trdat[jj] = self.rtdc_ds["trace"][tr][ii]
                                  jj += 1
                          write(h5obj,
                                data={"trace": {tr: trdat}},
                                mode="append",
                                compression=compression)
                  elif feat == "index" and filtered:
                      # re-enumerate data index feature (filtered data)
                      write(h5obj,
                            data={"index": np.arange(1, nev+1)},
                            mode="append")
                  else:
                      write(h5obj,
                            data={feat: self.rtdc_ds[feat][filtarr]},
                            mode="append")