Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make from_numpy_file usable for DOS #583

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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