Parses .transdos (total DOS) and .transdos_x_y (partial DOS) files
        Args:
            path_dir: (str) dir containing DOS files
            efermi: (float) Fermi energy
            dos_spin: (int) -1 for spin down, +1 for spin up
            trim_dos: (bool) whether to post-process / trim DOS

        Returns:
            tuple - (DOS, dict of partial DOS)

def parse_transdos(path_dir, efermi, dos_spin=1, trim_dos=False):

        """
        Parses .transdos (total DOS) and .transdos_x_y (partial DOS) files
        Args:
            path_dir: (str) dir containing DOS files
            efermi: (float) Fermi energy
            dos_spin: (int) -1 for spin down, +1 for spin up
            trim_dos: (bool) whether to post-process / trim DOS

        Returns:
            tuple - (DOS, dict of partial DOS)
        """

        data_dos = {'total': [], 'partial': {}}
        # parse the total DOS data
        ## format is energy, DOS, integrated DOS
        with open(os.path.join(path_dir, "boltztrap.transdos"), 'r') as f:
            count_series = 0  # TODO: why is count_series needed?
            for line in f:
                if line.lstrip().startswith("#"):
                    count_series += 1
                    if count_series > 1:
                        break
                else:
                    data_dos['total'].append(
                        [Energy(float(line.split()[0]), "Ry").to("eV"),
                         float(line.split()[1])])
                    total_elec = float(line.split()[2])

        lw_l = 0
        hg_l = -len(data_dos['total'])
        if trim_dos:
            # Francesco knows what this does
            # It has something to do with a trick of adding fake energies
            # at the endpoints of the DOS, and then re-trimming it. This is
            # to get the same energy scale for up and down spin DOS.
            tmp_data = np.array(data_dos['total'])
            tmp_den = np.trim_zeros(tmp_data[:, 1], 'f')[1:]
            lw_l = len(tmp_data[:, 1]) - len(tmp_den)
            tmp_ene = tmp_data[lw_l:, 0]
            tmp_den = np.trim_zeros(tmp_den, 'b')[:-1]
            hg_l = len(tmp_ene) - len(tmp_den)
            tmp_ene = tmp_ene[:-hg_l]
            tmp_data = np.vstack((tmp_ene, tmp_den)).T
            data_dos['total'] = tmp_data.tolist()

        # parse partial DOS data
        for file_name in os.listdir(path_dir):
            if file_name.endswith(
                    "transdos") and file_name != 'boltztrap.transdos':
                tokens = file_name.split(".")[1].split("_")
                site = tokens[1]
                orb = '_'.join(tokens[2:])
                with open(os.path.join(path_dir, file_name), 'r') as f:
                    for line in f:
                        if not line.lstrip().startswith(" #"):
                            if site not in data_dos['partial']:
                                data_dos['partial'][site] = {}
                            if orb not in data_dos['partial'][site]:
                                data_dos['partial'][site][orb] = []
                            data_dos['partial'][site][orb].append(
                                float(line.split()[1]))
                data_dos['partial'][site][orb] = data_dos['partial'][site][
                                                     orb][lw_l:-hg_l]

        dos_full = {'energy': [], 'density': []}

        for t in data_dos['total']:
            dos_full['energy'].append(t[0])
            dos_full['density'].append(t[1])

        dos = Dos(efermi, dos_full['energy'],
                  {Spin(dos_spin): dos_full['density']})
        dos_partial = data_dos['partial']  # TODO: make this real DOS object?

        return dos, dos_partial