# Path: upho/analysis/smearing.py
# class Smearing:
#     def __init__(self,
#                  function_name="gaussian",
#                  sigma=0.1,
#                  xmin=None,
#                  xmax=None,
#                  xpitch=None):
# 
#         self._function_name = function_name
#         self.set_smearing_function(function_name)
#         self.set_sigma(sigma)
#         if xmin is not None and xmax is not None and xpitch is not None:
#             self.build_xs(xmin, xmax, xpitch)
#         elif not (xmin is None and xmax is None and xpitch is None):
#             raise ValueError('Some of xmin, xmax, and xpitch are None')
# 
#     def set_smearing_function(self, function_name):
#         if function_name == "gaussian":
#             self._smearing_function = gaussian
#         elif function_name == "lorentzian":
#             self._smearing_function = lorentzian
#         elif function_name == "histogram":
#             self._smearing_function = histogram
#         else:
#             raise ValueError("Invalid smaering function name.")
#         return self
# 
#     def build_xs(self, xmin, xmax, xpitch):
#         self.set_xs(create_points(xmin, xmax, xpitch))
#         return self
# 
#     def set_xs(self, xs):
#         self._xs = xs
# 
#     def get_xs(self):
#         return self._xs
# 
#     def set_sigma(self, sigma):
#         self._sigma = sigma
# 
#     def get_sigma(self):
#         return self._sigma
# 
#     def get_function_name(self):
#         return self._function_name
# 
#     def run(self, peaks, weights=None):
#         """Get smeared values.
# 
#         Args:
#             peaks:
#             weights:
#                 Weight factors for "peaks".
#                 Now this can be one-dimeansional and multi-dimensional arrays.
#                 The last dimension must have the same order as the "peaks".
#         """
#         smearing_function = self._smearing_function
#         xs = self._xs
#         sigma = self._sigma
# 
#         tmp = smearing_function(xs[:, None], peaks[None, :], sigma)
#         if weights is not None:
#             values = np.inner(tmp, weights)
#         else:
#             values = np.sum(tmp, axis=1)
# 
#         return values
# 
# def create_points(xmin, xmax, xpitch):
#     n = int(round((xmax - xmin) / xpitch)) + 1
#     points = np.linspace(xmin, xmax, n)
#     return points


import h5py
import numpy as np
from upho.analysis.smearing import Smearing, create_points
            energies = square_frequencies(frequencies)
        else:
            energies = frequencies
        self._smearing.set_xs(energies)

        with h5py.File(filename, 'r') as f:
            self._band_data = f
            self._run()

    def set_evaluated_energies(self, evaluated_energies):
        self._evaluated_energies = evaluated_energies

    def get_evaluated_energies(self):
        return np.copy(self._evaluated_energies)

    def _run(self):
        raise NotImplementedError

    def _load_weights(self, group):
        band_data = self._band_data
        weights = {}
        weights['total'] = band_data[group + 'weights_t'  ]
        weights['E1'   ] = band_data[group + 'weights_e'  ]
        weights['SR'   ] = band_data[group + 'weights_s'  ]
        weights['SR_E1'] = band_data[group + 'weights_s_e']
        if group + 'weights_e2' in band_data:
            weights['E2'   ] = band_data[group + 'weights_e2' ]
        return weights

    def _load_distance(self, group):

# Path: upho/analysis/smearing.py
# class Smearing:
#     def __init__(self,
#                  function_name="gaussian",
#                  sigma=0.1,
#                  xmin=None,
#                  xmax=None,
#                  xpitch=None):
# 
#         self._function_name = function_name
#         self.set_smearing_function(function_name)
#         self.set_sigma(sigma)
#         if xmin is not None and xmax is not None and xpitch is not None:
#             self.build_xs(xmin, xmax, xpitch)
#         elif not (xmin is None and xmax is None and xpitch is None):
#             raise ValueError('Some of xmin, xmax, and xpitch are None')
# 
#     def set_smearing_function(self, function_name):
#         if function_name == "gaussian":
#             self._smearing_function = gaussian
#         elif function_name == "lorentzian":
#             self._smearing_function = lorentzian
#         elif function_name == "histogram":
#             self._smearing_function = histogram
#         else:
#             raise ValueError("Invalid smaering function name.")
#         return self
# 
#     def build_xs(self, xmin, xmax, xpitch):
#         self.set_xs(create_points(xmin, xmax, xpitch))
#         return self
# 
#     def set_xs(self, xs):
#         self._xs = xs
# 
#     def get_xs(self):
#         return self._xs
# 
#     def set_sigma(self, sigma):
#         self._sigma = sigma
# 
#     def get_sigma(self):
#         return self._sigma
# 
#     def get_function_name(self):
#         return self._function_name
# 
#     def run(self, peaks, weights=None):
#         """Get smeared values.
# 
#         Args:
#             peaks:
#             weights:
#                 Weight factors for "peaks".
#                 Now this can be one-dimeansional and multi-dimensional arrays.
#                 The last dimension must have the same order as the "peaks".
#         """
#         smearing_function = self._smearing_function
#         xs = self._xs
#         sigma = self._sigma
# 
#         tmp = smearing_function(xs[:, None], peaks[None, :], sigma)
#         if weights is not None:
#             values = np.inner(tmp, weights)
#         else:
#             values = np.sum(tmp, axis=1)
# 
#         return values
# 
# def create_points(xmin, xmax, xpitch):
#     n = int(round((xmax - xmin) / xpitch)) + 1
#     points = np.linspace(xmin, xmax, n)
#     return points


# Path: upho/phonon/density_extractor.py
import h5py
import numpy as np
from upho.analysis.smearing import Smearing, create_points

            energies = square_frequencies(frequencies)
        else:
            energies = frequencies
        self._smearing.set_xs(energies)

        with h5py.File(filename, 'r') as f:
            self._band_data = f
            self._run()

    def set_evaluated_energies(self, evaluated_energies):
        self._evaluated_energies = evaluated_energies

    def get_evaluated_energies(self):
        return np.copy(self._evaluated_energies)

    def _run(self):
        raise NotImplementedError

    def _load_weights(self, group):
        band_data = self._band_data
        weights = {}
        weights['total'] = band_data[group + 'weights_t'  ]
        weights['E1'   ] = band_data[group + 'weights_e'  ]
        weights['SR'   ] = band_data[group + 'weights_s'  ]
        weights['SR_E1'] = band_data[group + 'weights_s_e']
        if group + 'weights_e2' in band_data:
            weights['E2'   ] = band_data[group + 'weights_e2' ]
        return weights

    def _load_distance(self, group):

        distance = self._band_data[group + 'distance']