# Path: pyqstem/wave.py
# class Potential(BaseArray):
# 
#     def __init__(self, array, sampling, periodic_xy=True, periodic_z=False):
#         BaseArray.__init__(self, array, sampling)
# 
#         self.periodic_xy=periodic_xy
#         self.periodic_z=periodic_z
# 
#     def view(self,method='intensity',nav_axis=2,ind=-1,slider=False,ax=None,**kwargs):
#         projected = np.sum(self.array,axis=2)
#         self.refs += view(self,method=method,nav_axis=nav_axis,ind=ind,slider=slider,ax=ax,**kwargs)


import numpy as np
import numpy.linalg
from .wave import Potential
        from skimage.filters import gaussian

    if units=='QSTEM':
        V=2/0.52917721067*V # 2/a0
    elif units=='ASE':
        V=1/0.07957747154594767*V # 1/epsilon0
    elif units=='SI':
        e=1.60217662*10**(-19)
        epsilon0=8.854187817*10**(-12)
        V=e/epsilon0*V
    else:
        raise RuntimeError('Unit convention {0} not recognized.'.format(units))

    return V

def create_potential_slices(V,n,box,nonneg=True):
    Nz=V.shape[2]

    if n<1:
        raise RuntimeError('n should be a positive integer')

    if Nz%n!=0:
        raise RuntimeError('V.shape[2] is not divisible by n ({0} % {1} != 0)'.format(Nz,n))

    V_slices=np.zeros(V.shape[:2]+(n,))

    dz=box[2]/float(Nz)
    nz=int(Nz/n)
    for i in range(n):
        V_slices[:,:,i]=np.trapz(V[:,:,i*nz:(i+1)*nz+1],dx=dz,axis=2)


# Path: pyqstem/wave.py
# class Potential(BaseArray):
# 
#     def __init__(self, array, sampling, periodic_xy=True, periodic_z=False):
#         BaseArray.__init__(self, array, sampling)
# 
#         self.periodic_xy=periodic_xy
#         self.periodic_z=periodic_z
# 
#     def view(self,method='intensity',nav_axis=2,ind=-1,slider=False,ax=None,**kwargs):
#         projected = np.sum(self.array,axis=2)
#         self.refs += view(self,method=method,nav_axis=nav_axis,ind=ind,slider=slider,ax=ax,**kwargs)


# Path: pyqstem/potentials.py
import numpy as np
import numpy.linalg
from .wave import Potential
        from skimage.filters import gaussian


    if units=='QSTEM':
        V=2/0.52917721067*V # 2/a0
    elif units=='ASE':
        V=1/0.07957747154594767*V # 1/epsilon0
    elif units=='SI':
        e=1.60217662*10**(-19)
        epsilon0=8.854187817*10**(-12)
        V=e/epsilon0*V
    else:
        raise RuntimeError('Unit convention {0} not recognized.'.format(units))

    return V

def create_potential_slices(V,n,box,nonneg=True):
    Nz=V.shape[2]

    if n<1:
        raise RuntimeError('n should be a positive integer')

    if Nz%n!=0:
        raise RuntimeError('V.shape[2] is not divisible by n ({0} % {1} != 0)'.format(Nz,n))

    V_slices=np.zeros(V.shape[:2]+(n,))

    dz=box[2]/float(Nz)
    nz=int(Nz/n)
    for i in range(n):
        V_slices[:,:,i]=np.trapz(V[:,:,i*nz:(i+1)*nz+1],dx=dz,axis=2)


    if nonneg: