import numpy as np
import pandas as pd


class Spark:
    """The TECAN Spark Multimode Microplate Reader."""

    manufacturer = "Tecan"
    """Name of Manufacturer."""

    name = "spark"
    """Name of Instrument Model."""

    supported_models = ["Spark"]
    """List of supported models."""

    def __init__(self, model, sn=None):
        """
        Args:
            model (str): The model name of the instrument.
            sn (str or int, optional): The serial number of the instrument. Defaults to None.
        """
        self.model = model
        self.sn = sn

    @staticmethod
    def load_eem(filepath):
        """Loads an Excitation Emission Matrix which is generated by the instrument.

        Args:
            filepath (str): The filepath of the data file.

        Returns:
            pandas.DataFrame: An Excitation Emission Matrix.
        """
        eem_df = pd.read_excel(filepath, index_col=0)
        eem_df = eem_df.T
        eem_df = eem_df.replace("OVER", np.nan)
        eem_df.columns = eem_df.columns.astype(float)
        eem_df = eem_df.sort_index(axis=0)
        eem_df = eem_df.sort_index(axis=1)
        eem_df.columns.name = "excitation_wavelength"
        eem_df.index.name = "emission_wavelength"
        return eem_df

    @staticmethod
    def load_absorbance(filepath):
        """Loads an absorbance spectrum which is generated by the instrument.

        Args:
            filepath (str): The filepath of the data file.

        Raises:
            NotImplementedError: On the TODO list...
        """
        raise NotImplementedError()

    @staticmethod
    def load_water_raman(filepath):
        """Loads a water Raman spectrum which is generated by the instrument.

        Args:
            filepath (str): The filepath of the data file.

        Raises:
            NotImplementedError: On the TODO list...
        """
        raise NotImplementedError()

    @staticmethod
    def load_spectral_corrections():
        """TODO - Should load instrument specific spectral corrections which will be used in data preprocessing.

        Raises:
            NotImplementedError: On the TODO list...
        """
        raise NotImplementedError()
