Example #1
0
    def __init__(self, x_data, y_data, paramters=None):
        self.log = logging.getLogger('RockPy.FITTING.TANH')
        super(Tanh, self).__init__(x_data, y_data, paramters=None, log=self.log)

        self.fit_x = np.arange(min(self.x), max(self.x), 0.01)

        amp = np.max(abs(self.y))
        zero_idx = np.argmin(abs(self.y))

        self.parameters.add('amp', value=amp)
        self.parameters.add('shift', value=self.x[zero_idx])

        ''' Fitting '''
        errfunc = lambda p, x, y: functions.func_tanh(self.parameters, x) - y

        fitout = minimize(errfunc, self.parameters, args=(self.x, self.y))

        self.fit_y = functions.func_tanh(self.parameters, self.fit_x)
Example #2
0
 def calc(self, x_value):
     out = functions.func_tanh(self.parameters, x_value)
     return out