Skip to content

Commit

Permalink
move read_cube_density
Browse files Browse the repository at this point in the history
  • Loading branch information
ireaml committed Aug 17, 2023
1 parent da492b1 commit 3355beb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
28 changes: 0 additions & 28 deletions macrodensity/alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,34 +657,6 @@ def create_plotting_mesh(NGX: int,NGY: int,NGZ: int,pc: np.ndarray,grad: np.ndar
return plane


def read_cube_density(FILE: str) -> np.ndarray:
"""
Reads a cube density file and extracts relevant information.
Parameters:
FILE (str): The path to the cube density file.
Returns:
numpy.ndarray: A 3x3 numpy array representing the lattice.
Example:
>>> file_path = 'path/to/your/cube_density_file.cube'
>>> # Read the cube density file and get the lattice
>>> lattice = read_cube_density(file_path)
>>> print(lattice)
"""
f = open(FILE,"r")
lines = f.readlines()
f.close()
lattice = np.zeros(shape=(3,3))
for line in lines:
inp = line.split()
if inp == []:
continue
if len(inp) == 4:
natms = inp[0]


def points_2_plane(a: np.ndarray, b: np.ndarray, c: np.ndarray) -> np.ndarray:
"""
Calculates the plane coefficients from three points in space.
Expand Down
30 changes: 29 additions & 1 deletion macrodensity/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,32 @@ def read_vasp_density(FILE: str, use_pandas: bool=None, quiet: bool=False) -> tu
if not quiet:
print("Average of the potential = ", np.average(Potential))

return Potential, NGX, NGY, NGZ, lattice
return Potential, NGX, NGY, NGZ, lattice


def read_cube_density(FILE: str) -> np.ndarray:
"""
Reads a cube density file and extracts relevant information.
Parameters:
FILE (str): The path to the cube density file.
Returns:
numpy.ndarray: A 3x3 numpy array representing the lattice.
Example:
>>> file_path = 'path/to/your/cube_density_file.cube'
>>> # Read the cube density file and get the lattice
>>> lattice = read_cube_density(file_path)
>>> print(lattice)
"""
f = open(FILE,"r")
lines = f.readlines()
f.close()
lattice = np.zeros(shape=(3,3))
for line in lines:
inp = line.split()
if inp == []:
continue
if len(inp) == 4:
natms = inp[0]

0 comments on commit 3355beb

Please sign in to comment.