def export_csv(self, path, idx=None, header=None, formatted=False,
                   sort_idx=True, fmt='%.18e'):
        if not idx:
            idx = self._idx
        if not header:
            header = self.get_header(idx, formatted=formatted)
        assert len(idx) == len(header), \
            "Idx length does not match header length"
        body = self.get_values(idx)
        with open(path, 'w') as fd:
            fd.write(','.join(header) + '\n')
            np.savetxt(fd, body, fmt=fmt, delimiter=',')