width_delay_beam_experiment/DataAnalysis.py
def envelope_fit(t, V, verbose = True):
    '''
    Uses the package lmfit to fit the given data: t and V. The model for this
    fit is an overdamped step response of a second order RLC circuit.

    assumes:
    - the data is suitable for the fitting model of overdamped step response
      of a second order RLC circuit.

    arguments:
    - t: the time-axis (or x-axis) of data
    - V: the voltage values

    returns:
    - fit_mod: the model object (see lmfit) corresponding to the model provided.
    - result.params: the Parameter (see lmfit) object corresponding to the
                     solution to the fitting algorithm.
    '''
    # Given initial parameters (set by eye after staring at the data for a while)
    init = [0.5, -2, 200, 1000, 50]

    # Set the model as a overdamped step response of RLC circuit
    fit_mod = lmfit.model.Model(step_responseRLC_overdamped)

    # Create the Parameter() object, pars is essentially a dictionary
    pars = fit_mod.make_params()

    # Set the parameters in the pars object to initial conditions.
    pars['a_0'].set(init[0])
    pars['a_1'].set(init[1])
    pars['a_2'].set(init[2])
    pars['alpha'].set(init[3])
    pars['w_d'].set(init[4])

    # Fit V and store resultant ModelResult object
    result = fit_mod.fit(V, pars, t=t)

    # verbose is True, print out the fit report (has stats info)
    if verbose:
        print(result.fit_report())

    return fit_mod, result.params

    Uses the package lmfit to fit the given data: t and V. The model for this
    fit is an overdamped step response of a second order RLC circuit.

    assumes:
    - the data is suitable for the fitting model of overdamped step response
      of a second order RLC circuit.

    arguments:
    - t: the time-axis (or x-axis) of data
    - V: the voltage values

    returns:
    - fit_mod: the model object (see lmfit) corresponding to the model provided.
    - result.params: the Parameter (see lmfit) object corresponding to the
                     solution to the fitting algorithm.
    
Uses the package lmfit to fit the given data: t and V. The model for this
fit is an overdamped step response of a second order RLC circuit.

the data is suitable for the fitting model of overdamped step response
of a second order RLC circuit.

the time-axis (or x-axis) of data
V: the voltage values

the model object  corresponding to the model provided.
result.params: the Parameter  object corresponding to the
solution to the fitting algorithm.
Uses the package lmfit to fit the given data : t and V . The model for this fit is an overdamped step response of a second order RLC circuit . the data is suitable for the fitting model of overdamped step response of a second order RLC circuit . the time - axis ( or x - axis ) of data V : the voltage values the model object corresponding to the model provided . result . params : the Parameter object corresponding to the solution to the fitting algorithm .
def envelope_fit(t, V, verbose = True):
    init = [0.5, -2, 200, 1000, 50]
    fit_mod = lmfit.model.Model(step_responseRLC_overdamped)
    pars = fit_mod.make_params()
    pars['a_0'].set(init[0])
    pars['a_1'].set(init[1])
    pars['a_2'].set(init[2])
    pars['alpha'].set(init[3])
    pars['w_d'].set(init[4])
    result = fit_mod.fit(V, pars, t=t)
    if verbose:
        print(result.fit_report())
    return fit_mod, result.params
def envelope_fit ( t , V , verbose = True ) : init = [ 0.5 , - 2 , 200 , 1000 , 50 ] fit_mod = lmfit . model . Model ( step_responseRLC_overdamped ) pars = fit_mod . make_params ( ) pars [ 'a_0' ] . set ( init [ 0 ] ) pars [ 'a_1' ] . set ( init [ 1 ] ) pars [ 'a_2' ] . set ( init [ 2 ] ) pars [ 'alpha' ] . set ( init [ 3 ] ) pars [ 'w_d' ] . set ( init [ 4 ] ) result = fit_mod . fit ( V , pars , t = t ) if verbose : print ( result . fit_report ( ) ) return fit_mod , result . params
Uses the package lmfit to fit the given data: t and V. The model for this
fit is an overdamped step response of a second order RLC circuit.
Uses the package lmfit to fit the given data : t and V . The model for this fit is an overdamped step response of a second order RLC circuit .
'''
    Uses the package lmfit to fit the given data: t and V. The model for this
    fit is an overdamped step response of a second order RLC circuit.

    assumes:
    - the data is suitable for the fitting model of overdamped step response
      of a second order RLC circuit.

    arguments:
    - t: the time-axis (or x-axis) of data
    - V: the voltage values

    returns:
    - fit_mod: the model object (see lmfit) corresponding to the model provided.
    - result.params: the Parameter (see lmfit) object corresponding to the
                     solution to the fitting algorithm.
    ''' # Given initial parameters (set by eye after staring at the data for a while) # Set the model as a overdamped step response of RLC circuit # Create the Parameter() object, pars is essentially a dictionary # Set the parameters in the pars object to initial conditions. # Fit V and store resultant ModelResult object # verbose is True, print out the fit report (has stats info)
t
V
verbose