# Path: pyDFTutils/ase_utils/symbol.py
# def symnum_to_sym(symbol_number):
#     """
#     symnum-> sym. eg: Fe1-> Fe
#     """
#     try:
#         a=re.search('[A-Za-z]+',symbol_number).group()
#         return a
#     except AttributeError:
#         raise AttributeError('%s is not a good symbol_number'%symbol_number)
# 
# Path: pyDFTutils/vasp/vasp_utils.py
# def get_symdict(filename='POSCAR', atoms=None):
#     """
#     get a symbol_number: index dict.
#     """
#     if filename is None and atoms is not None:
#         syms = atoms.get_chemical_symbols()
#     elif filename is not None and atoms is None:
#         syms = read(filename).get_chemical_symbols()
# 
#     symdict = symbol_number(syms)
#     return symdict


from ase.io import read
from ase.calculators.vasp import VaspDos
from os.path import join
from shutil import copyfile
from scipy import trapz,integrate
from pyDFTutils.ase_utils.symbol import symnum_to_sym
from .vasp_utils import get_symdict
from matplotlib.ticker import FormatStrFormatter
from collections import OrderedDict,Iterable
        from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt
import os
import copy
        if ispin==2:
            lsites=['dxy+','dyz+','dxz+','dxy-','dyz-','dxz-']
        else:
            lsites=['dxy','dyz','dxz']
    elif sites=='p':
        if ispin==2:
            lsites=['px+','py+','pz+','px-','py-','pz-']
        else:
            lsites=['px','py','pz']
    elif sites=='s':
        if ispin==2:
            lsites=['s+','s-']
        else:
            lsites=['s']
    else:
        lsites=lsites

    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    for atom_num in atom_nums:
        copyfile(filename,join(output_dir,'DOSCAR'))
        plotldos_group([atom_num],lsites,ymin=ymin,ymax=ymax,xmin=xmin,xmax=xmax,special_location=None,output=join(output_dir, '%s_%s_dos.png'%(atom_num,sites)))




def plot_all_pdos_eg(element_types=None,filename='DOSCAR',ispin=2,ymin=-2.0,ymax=2.0,xmin=-15.0,xmax=5.0):
    """
    plot the local dos of all atoms.
    """

# Path: pyDFTutils/ase_utils/symbol.py
# def symnum_to_sym(symbol_number):
#     """
#     symnum-> sym. eg: Fe1-> Fe
#     """
#     try:
#         a=re.search('[A-Za-z]+',symbol_number).group()
#         return a
#     except AttributeError:
#         raise AttributeError('%s is not a good symbol_number'%symbol_number)
# 
# Path: pyDFTutils/vasp/vasp_utils.py
# def get_symdict(filename='POSCAR', atoms=None):
#     """
#     get a symbol_number: index dict.
#     """
#     if filename is None and atoms is not None:
#         syms = atoms.get_chemical_symbols()
#     elif filename is not None and atoms is None:
#         syms = read(filename).get_chemical_symbols()
# 
#     symdict = symbol_number(syms)
#     return symdict


# Path: pyDFTutils/vasp/vasp_dos.py
from ase.io import read
from ase.calculators.vasp import VaspDos
from os.path import join
from shutil import copyfile
from scipy import trapz,integrate
from pyDFTutils.ase_utils.symbol import symnum_to_sym
from .vasp_utils import get_symdict
from matplotlib.ticker import FormatStrFormatter
from collections import OrderedDict,Iterable
        from scipy.interpolate import interp1d
import numpy as np
import matplotlib.pyplot as plt
import os
import copy

        if ispin==2:
            lsites=['dxy+','dyz+','dxz+','dxy-','dyz-','dxz-']
        else:
            lsites=['dxy','dyz','dxz']
    elif sites=='p':
        if ispin==2:
            lsites=['px+','py+','pz+','px-','py-','pz-']
        else:
            lsites=['px','py','pz']
    elif sites=='s':
        if ispin==2:
            lsites=['s+','s-']
        else:
            lsites=['s']
    else:
        lsites=lsites

    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    for atom_num in atom_nums:
        copyfile(filename,join(output_dir,'DOSCAR'))
        plotldos_group([atom_num],lsites,ymin=ymin,ymax=ymax,xmin=xmin,xmax=xmax,special_location=None,output=join(output_dir, '%s_%s_dos.png'%(atom_num,sites)))




def plot_all_pdos_eg(element_types=None,filename='DOSCAR',ispin=2,ymin=-2.0,ymax=2.0,xmin=-15.0,xmax=5.0):
    """
    plot the local dos of all atoms.
    """

    symdict=get_symdict()