import numpy as np
import pandas as pd

class GranuloLoader:

    """ This class allows to load granulo data file """

    def __init__(self, path: str):

        self._path = path
        self._data = pd.read_excel(self._path, engine="odf", header=0)

        self._time = self._data.iloc[:, 0].tolist()
        self._y = self._data.iloc[:, 1].tolist()                        # distance from left bank (m)
        self._z = self._data.iloc[:, 2].tolist()                        # depth (m)

        self._r_grain = 1e-6 * np.array(self._data.columns.values)[5:].astype(float) / 2        # grain radius (m)

        self._Ctot = self._data.iloc[:, 3].tolist()                # Total concentration (g/L)
        self._D50 = self._data.iloc[:, 4].tolist()               # median diameter (um)
        self._frac_vol = np.array(self._data.iloc[:, 5:]) / 100           # Volume fraction (%)

        self._frac_vol_cumul = np.cumsum(self._frac_vol, axis=1)    # Cumulated volume fraction (%)

