# Path: phononweb/phononweb.py
# def open_file_phononwebsite(filename,port=8000,
#                             website="http://henriquemiranda.github.io/phononwebsite",
#                             host="localhost"):
#         def end_headers (self):
#         def log_message(self, format, *args):
#     def signal_handler(signal, frame):
# def estimate_band_connection(prev_eigvecs, eigvecs, prev_band_order):
#     def reorder_eigenvalues(self):
#     def get_chemical_formula(self):
#     def save_netcdf(self):
#     def get_distances_qpts(self):
#     def get_highsym_qpts(self):
#         def collinear(a,b,c):
#     def set_repetitions(self,reps):
#     def set_labels(self,labels):
#     def write_json(self,prefix=None,folder='.'):
#     def open_json(self,prefix=None,folder='.',host='localhost',port=8000):
#     def __str__(self):
#     class CORSRequestHandler (SimpleHTTPRequestHandler):
# class Phonon():


from math import pi
from .pw import *
from .phononweb import Phonon, bohr_angstroem, atomic_numbers
import numpy as np
                    vec[k][n][i] = np.array(cvec, dtype=complex)

        #the quantum espresso eigenvectors are already scaled with the atomic masses
        #if the file comes from dynmat.eig they are not scaled with the atomic masses
        #here we scale then with sqrt(m) so that we recover the correct scalling on the website
        #we check if the eigenvectors are orthogonal or not
        #for na in xrange(self.natoms):
        #    atomic_specie = self.atypes[na]-1
        #    atomic_number = self.atomic_numbers[atomic_specie]
        #    vectors[:,:,na,:,:] *= sqrt(atomic_mass[atomic_number])

        self.nqpoints     = len(qpt)
        self.nphons       = nphons
        self.eigenvalues  = eig#*eV/hartree_cm1
        self.eigenvectors = vec.view(dtype=float).reshape([self.nqpoints,nphons,nphons,2])

        #convert to reduced coordinates
        self.qpoints = car_red(qpt,self.rec)
        return self.eigenvalues, self.eigenvectors, self.qpoints

    def read_atoms(self,filename):
        """ 
        read the data from a quantum espresso input file
        """
        pwin = PwIn(filename=filename)
        cell, pos, self.atom_types = pwin.get_atoms()
        self.cell = np.array(cell)*bohr_angstroem
        self.rec = rec_lat(cell)*pwin.alat
        self.pos = np.array(pos)
        self.atom_numbers = [atomic_numbers[x] for x in self.atom_types]

# Path: phononweb/phononweb.py
# def open_file_phononwebsite(filename,port=8000,
#                             website="http://henriquemiranda.github.io/phononwebsite",
#                             host="localhost"):
#         def end_headers (self):
#         def log_message(self, format, *args):
#     def signal_handler(signal, frame):
# def estimate_band_connection(prev_eigvecs, eigvecs, prev_band_order):
#     def reorder_eigenvalues(self):
#     def get_chemical_formula(self):
#     def save_netcdf(self):
#     def get_distances_qpts(self):
#     def get_highsym_qpts(self):
#         def collinear(a,b,c):
#     def set_repetitions(self,reps):
#     def set_labels(self,labels):
#     def write_json(self,prefix=None,folder='.'):
#     def open_json(self,prefix=None,folder='.',host='localhost',port=8000):
#     def __str__(self):
#     class CORSRequestHandler (SimpleHTTPRequestHandler):
# class Phonon():


# Path: phononweb/qephonon.py
from math import pi
from .pw import *
from .phononweb import Phonon, bohr_angstroem, atomic_numbers
import numpy as np

                    vec[k][n][i] = np.array(cvec, dtype=complex)

        #the quantum espresso eigenvectors are already scaled with the atomic masses
        #if the file comes from dynmat.eig they are not scaled with the atomic masses
        #here we scale then with sqrt(m) so that we recover the correct scalling on the website
        #we check if the eigenvectors are orthogonal or not
        #for na in xrange(self.natoms):
        #    atomic_specie = self.atypes[na]-1
        #    atomic_number = self.atomic_numbers[atomic_specie]
        #    vectors[:,:,na,:,:] *= sqrt(atomic_mass[atomic_number])

        self.nqpoints     = len(qpt)
        self.nphons       = nphons
        self.eigenvalues  = eig#*eV/hartree_cm1
        self.eigenvectors = vec.view(dtype=float).reshape([self.nqpoints,nphons,nphons,2])

        #convert to reduced coordinates
        self.qpoints = car_red(qpt,self.rec)
        return self.eigenvalues, self.eigenvectors, self.qpoints

    def read_atoms(self,filename):
        """ 
        read the data from a quantum espresso input file
        """
        pwin = PwIn(filename=filename)
        cell, pos, self.atom_types = pwin.get_atoms()
        self.cell = np.array(cell)*bohr_angstroem
        self.rec = rec_lat(cell)*pwin.alat
        self.pos = np.array(pos)
        self.atom_numbers = [atomic_numbers[x] for x in self.atom_types]

        self.atomic_numbers = np.unique(self.atom_numbers)