import numpy as np
from scipy import special as special

from ..utils import kB


class Weight2Phase:
    type = 'Line shape'
    name = 'Weighting factor'
    equation = r'A*[0.5 + 0.5 erf[(x-T_{0})/\DeltaT]] + A_{0}'
    params = ['T_{0}', r'\DeltaT', 'A', 'A_{0}']
    bounds = [(0, None), (0, None), (None, None), (None, None)]

    @staticmethod
    def func(x, t0, dt, amp, off):
        return amp*(0.5 + 0.5*special.erf((x-t0)/dt)) + off


class HendricksonBray:
    type = 'Line shape'
    name = 'Hendrickson-Bray'
    equation = 'AB/(B+(A-B)exp[-E/(kT)]) + w_0'
    params = ['A', 'B', 'E', 'w_{0}']
    bounds = [(0, None)] * 4

    @staticmethod
    def func(x, a, b, e, w0):
        return a*b / (b + (a-b)*np.exp(-e/kB/x)) + w0
