# Path: vasppy/units.py

# 
# Path: vasppy/band.py
# class Band():
# 
#     def __init__( self, index, energy, occupancy, negative_occupancies='warn' ):
#         self.index = index
#         self.energy = energy
#         self.occupancy = handle_occupancy( occupancy, negative_occupancies=negative_occupancies )
# 
#     def __eq__( self, other ):
#         return ( ( self.index == other.index ) &
#                  ( self.energy == other.energy ) &
#                  ( self.occupancy == other.occupancy ) )


import numpy as np  # type: ignore
import re
import math
import warnings
import fortranformat as ff  # type: ignore
from .units import angstrom_to_bohr, ev_to_hartree
from .band import Band
from copy import deepcopy
from functools import reduce
        new_procar.sanity_check()
        return new_procar
 
    def parse_projections( self ):
        self.projection_data = projections_parser( self.read_in )
        try:
            assert( self._number_of_bands * self._number_of_k_points == len( self.projection_data ) )
            self._spin_channels = 1 # non-magnetic, non-spin-polarised
            self._k_point_blocks = 1
            self.calculation[ 'non_spin_polarised' ] = True
        except:
            if self._number_of_bands * self._number_of_k_points * 4 == len( self.projection_data ):
                self._spin_channels = 4 # non-collinear (spin-orbit coupling)
                self._k_point_blocks = 1
                self.calculation[ 'non_collinear' ] = True
                pass
            elif self._number_of_bands * self._number_of_k_points * 2 == len( self.projection_data ):
                self._spin_channels = 2 # spin-polarised
                self._k_point_blocks = 2
                self.calculation[ 'spin_polarised' ] = True
                pass
            else:
                raise
        self._number_of_projections = int( self.projection_data.shape[1] / ( self._number_of_ions + 1 ) ) - 1

    def parse_k_points( self ):
        self._k_points = k_point_parser( self.read_in )[:self._number_of_k_points]

    def parse_bands( self ):
        band_data = re.findall( r"band\s*(\d+)\s*#\s*energy\s*([-.\d]+)\s?\s*#\s"r"*occ.\s*([-.\d]+)", self.read_in )

# Path: vasppy/units.py

# 
# Path: vasppy/band.py
# class Band():
# 
#     def __init__( self, index, energy, occupancy, negative_occupancies='warn' ):
#         self.index = index
#         self.energy = energy
#         self.occupancy = handle_occupancy( occupancy, negative_occupancies=negative_occupancies )
# 
#     def __eq__( self, other ):
#         return ( ( self.index == other.index ) &
#                  ( self.energy == other.energy ) &
#                  ( self.occupancy == other.occupancy ) )


# Path: vasppy/procar.py
import numpy as np  # type: ignore
import re
import math
import warnings
import fortranformat as ff  # type: ignore
from .units import angstrom_to_bohr, ev_to_hartree
from .band import Band
from copy import deepcopy
from functools import reduce

        new_procar.sanity_check()
        return new_procar
 
    def parse_projections( self ):
        self.projection_data = projections_parser( self.read_in )
        try:
            assert( self._number_of_bands * self._number_of_k_points == len( self.projection_data ) )
            self._spin_channels = 1 # non-magnetic, non-spin-polarised
            self._k_point_blocks = 1
            self.calculation[ 'non_spin_polarised' ] = True
        except:
            if self._number_of_bands * self._number_of_k_points * 4 == len( self.projection_data ):
                self._spin_channels = 4 # non-collinear (spin-orbit coupling)
                self._k_point_blocks = 1
                self.calculation[ 'non_collinear' ] = True
                pass
            elif self._number_of_bands * self._number_of_k_points * 2 == len( self.projection_data ):
                self._spin_channels = 2 # spin-polarised
                self._k_point_blocks = 2
                self.calculation[ 'spin_polarised' ] = True
                pass
            else:
                raise
        self._number_of_projections = int( self.projection_data.shape[1] / ( self._number_of_ions + 1 ) ) - 1

    def parse_k_points( self ):
        self._k_points = k_point_parser( self.read_in )[:self._number_of_k_points]

    def parse_bands( self ):
        band_data = re.findall( r"band\s*(\d+)\s*#\s*energy\s*([-.\d]+)\s?\s*#\s"r"*occ.\s*([-.\d]+)", self.read_in )

        self._bands = np.array( [ Band( float(i), float(e), float(o), negative_occupancies=self.negative_occupancies ) for i, e, o in band_data ] )