Get the projected density of states for an element.

    Args:
        dos (:obj:`~pymatgen.electronic_structure.dos.CompleteDos`): The
            density of states.
        element (str): Element symbol. E.g. 'Zn'.
        sites (tuple): The atomic indices over which to sum the density of
            states, as a :obj:`tuple`. Indices are zero based for each
            element. For example, ``(0, 1, 2)`` will sum the density of states
            for the 1st, 2nd and 3rd sites of the element specified.
        lm_orbitals (:obj:`tuple`, optional): The orbitals to decompose into
            their lm contributions (e.g. p -> px, py, pz). Should be provided
            as a :obj:`tuple` of :obj:`str`. For example, ``('p')``, will
            extract the projected density of states for the px, py, and pz
            orbitals. Defaults to ``None``.
        orbitals (:obj:`tuple`, optional): The orbitals to extract from the
            projected density of states. Should be provided as a :obj:`tuple`
            of :obj:`str`. For example, ``('s', 'px', 'dx2')`` will extract the
            s, px, and dx2 orbitals, only. If ``None``, all orbitals will be
            extracted. Defaults to ``None``.

    Returns:
        dict: The projected density of states. Formatted as a :obj:`dict`
        mapping the orbitals to :obj:`~pymatgen.electronic_structure.dos.Dos`
        objects. For example::

            {
                's': Dos,
                'p': Dos
            }

def get_element_pdos(dos, element, sites, lm_orbitals=None, orbitals=None):
    """Get the projected density of states for an element.

    Args:
        dos (:obj:`~pymatgen.electronic_structure.dos.CompleteDos`): The
            density of states.
        element (str): Element symbol. E.g. 'Zn'.
        sites (tuple): The atomic indices over which to sum the density of
            states, as a :obj:`tuple`. Indices are zero based for each
            element. For example, ``(0, 1, 2)`` will sum the density of states
            for the 1st, 2nd and 3rd sites of the element specified.
        lm_orbitals (:obj:`tuple`, optional): The orbitals to decompose into
            their lm contributions (e.g. p -> px, py, pz). Should be provided
            as a :obj:`tuple` of :obj:`str`. For example, ``('p')``, will
            extract the projected density of states for the px, py, and pz
            orbitals. Defaults to ``None``.
        orbitals (:obj:`tuple`, optional): The orbitals to extract from the
            projected density of states. Should be provided as a :obj:`tuple`
            of :obj:`str`. For example, ``('s', 'px', 'dx2')`` will extract the
            s, px, and dx2 orbitals, only. If ``None``, all orbitals will be
            extracted. Defaults to ``None``.

    Returns:
        dict: The projected density of states. Formatted as a :obj:`dict`
        mapping the orbitals to :obj:`~pymatgen.electronic_structure.dos.Dos`
        objects. For example::

            {
                's': Dos,
                'p': Dos
            }
    """
    el_dos = {}
    for site in sites:
        # build a list of which orbitals we are after
        # start with s, p, and d orbitals only
        spd = [orb for orb in dos.get_element_spd_dos(element).keys() if
               ((orbitals and orb.name in orbitals) or not orbitals) and
               ((lm_orbitals and orb.name not in lm_orbitals) or
                not lm_orbitals)]

        # now add any lm decomposed orbitals
        lm = [orb for orb in Orbital
              if lm_orbitals and orb.name[0] in lm_orbitals]

        # extract the data
        for orb in spd:
            pdos = dos.get_site_spd_dos(site)[orb]
            el_dos[orb.name] = (el_dos[orb.name] + pdos if orb.name in el_dos
                                else pdos)

        for orb in lm:
            pdos = dos.get_site_orbital_dos(site, orb)
            el_dos[orb.name] = (el_dos[orb.name] + pdos if orb.name in el_dos
                                else pdos)
    return el_dos