Skip to content

Commit

Permalink
Merge pull request #583 from RandomDefaultUser/dos_from_numpy_file
Browse files Browse the repository at this point in the history
Make from_numpy_file usable for DOS
  • Loading branch information
RandomDefaultUser authored Oct 9, 2024
2 parents 0bd1ab5 + 4323274 commit ff0ea2f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions mala/targets/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,36 @@ def read_from_array(self, array, units="1/eV"):
self.density_of_states = array
return array

def read_from_numpy_file(
self, path, units=None, array=None, reshape=False
):
"""
Read the data from a numpy file.
Parameters
----------
path : string
Path to the numpy file.
units : string
Units the data is saved in.
array : np.ndarray
If not None, the array to save the data into.
The array has to be 4-dimensional.
Returns
-------
data : numpy.ndarray or None
If array is None, a numpy array containing the data.
Elsewise, None, as the data will be saved into the provided
array.
"""
loaded_array = np.load(path)
self._process_loaded_array(loaded_array, units=units)
return loaded_array

# Calculations
##############

Expand Down

0 comments on commit ff0ea2f

Please sign in to comment.