Exemplo n.º 1
0
def hanger_func_complex_SI_Guess(data, f, fit_window=None):
    ## This is complete garbage, just to get some return value
    xvals = f
    abs_data = np.abs(data)
    peaks = a_tools.peak_finder(xvals, abs_data)
      # Search for peak
    if peaks['dip'] is not None:    # look for dips first
        f0 = peaks['dip']
        amplitude_factor = -1.
    elif peaks['peak'] is not None:  # then look for peaks
        f0 = peaks['peak']
        amplitude_factor = 1.
    else:                                 # Otherwise take center of range
        f0 = np.median(xvals)
        amplitude_factor = -1.

    min_index = np.argmin(abs_data)
    max_index = np.argmax(abs_data)
    min_frequency = xvals[min_index]
    max_frequency = xvals[max_index]

    amplitude_guess = max(dm_tools.reject_outliers(abs_data))

    # Creating parameters and estimations
    S21min = (min(dm_tools.reject_outliers(abs_data)) /
              max(dm_tools.reject_outliers(abs_data)))

    Q = f0 / abs(min_frequency - max_frequency)

    Qe = abs(Q / abs(1 - S21min))
    guess_dict = {'f0': {'value': f0*1e-9,
                         'min': min(xvals)*1e-9,
                         'max': max(xvals)*1e-9},
                  'A': {'value': amplitude_guess},
                  'Qe': {'value': Qe,
                         'min': 1,
                         'max': 50e6},
                  'Ql': {'value': Q,
                         'min': 1,
                         'max': 50e6},
                  'theta': {'value': 0,
                            'min': -np.pi/2,
                            'max': np.pi/2},
                  'alpha': {'value':0,
                            'vary':True},
                  'phi_0': {'value':0,
                            'vary':True},
                  'phi_v': {'value':0,
                            'vary':True}}

    return guess_dict
Exemplo n.º 2
0
def SlopedHangerFuncAmplitudeGuess(data, f, fit_window=None):
    xvals = f
    peaks = a_tools.peak_finder(xvals, data)
      # Search for peak
    if peaks['dip'] is not None:    # look for dips first
        f0 = peaks['dip']
        amplitude_factor = -1.
    elif peaks['peak'] is not None:  # then look for peaks
        f0 = peaks['peak']
        amplitude_factor = 1.
    else:                                 # Otherwise take center of range
        f0 = np.median(xvals)
        amplitude_factor = -1.

    min_index = np.argmin(data)
    max_index = np.argmax(data)
    min_frequency = xvals[min_index]
    max_frequency = xvals[max_index]

    amplitude_guess = max(dm_tools.reject_outliers(data))

    # Creating parameters and estimations
    S21min = (min(dm_tools.reject_outliers(data)) /
              max(dm_tools.reject_outliers(data)))

    Q = f0 / abs(min_frequency - max_frequency)

    Qe = abs(Q / abs(1 - S21min))
    guess_dict = {'f0': {'value': f0*1e-9,
                         'min': min(xvals)*1e-9,
                         'max': max(xvals)*1e-9},
                  'A': {'value': amplitude_guess},
                  'Q': {'value': Q,
                        'min': 1,
                        'max': 50e6},
                  'Qe': {'value': Qe,
                         'min': 1,
                         'max': 50e6},
                  'Qi': {'expr': 'abs(1./(1./Q-1./Qe*cos(theta)))',
                         'vary': False},
                  'Qc': {'expr': 'Qe/cos(theta)',
                         'vary': False},
                  'theta': {'value': 0,
                            'min': -np.pi/2,
                            'max': np.pi/2},
                  'slope': {'value':0,
                            'vary':True}}
    return guess_dict