Beispiel #1
0
def test_cropFreq_both():
    filtered_freq, filtered_Z = cropFrequencies(frequencies,
                                                Z_correct,
                                                freqmin=1,
                                                freqmax=1e3)

    assert (filtered_freq >= 1).all() and (filtered_freq <= 1e3).all()
Beispiel #2
0
 def calculate(row):
     f, z = pp.cropFrequencies(FREQ, row.complex_z, 200)
     f, z = pp.ignoreBelowX(f, z)
     circuit = 'p(R1,C1)-p(R2,C2)'
     guess = [5e+4, 1e-10, 5e+6, 1e-10]
     model = modelling.model_impedance(circuit, guess, f, z)
     return modelling.get_resistance(model)
Beispiel #3
0
def test_cropFreq_minonly():

    filtered_freq, filtered_Z = cropFrequencies(frequencies,
                                                Z_correct,
                                                freqmin=1)

    assert (filtered_freq >= 1).all()
Beispiel #4
0
def test_cropFreq_maxonly():

    filtered_freq, filtered_Z = cropFrequencies(frequencies,
                                                Z_correct,
                                                freqmax=1e3)

    assert (filtered_freq <= 1e3).all()
Beispiel #5
0
def model_conductivity(freq, complex_z, cutoff, circuit, guess):
    """Takes a row of the dataframe and return the model object, the resistance and the rmse.

    Args:
        row ([type]): [description]

    Returns:
        model: the model object
        resistance: calculated resistance
        rmse: the root mean square error on the resistance
    """
    f, z = pp.cropFrequencies(np.array(freq), complex_z, cutoff)
    f, z = pp.ignoreBelowX(f, z)
    model = model_impedance(circuit, guess, f, z)
    rmse = fitting.rmse(z, model.predict(f))
    resistance = get_resistance(model)
    return model, resistance, rmse
Beispiel #6
0
def cole(data,
         freq,
         temp,
         freq_min=200,
         freq_max=None,
         fit=False,
         ax=None,
         **kwargs):
    """Creates a Cole-Cole plot (imaginary versus real impedance) at a given temperature. Finds the available data closest to the temperature specified by 'temp'. A linear least squares circle fit can be added by setting fit=True.

    :param temp: temperature in degrees C
    :type temp: float/int
    """
    data = conductivity_only(data)
    # for temp in temp_list:
    [index, Tval] = index_temp(data.temp, temp)
    f, z = pp.cropFrequencies(frequencies=np.array(freq),
                              Z=data.complex_z.iloc[index],
                              freqmin=freq_min,
                              freqmax=freq_max)
    f, z = pp.ignoreBelowX(f, z)
    p = ax.scatter(np.real(z) / 1000, np.abs(np.imag(z)) / 1000, **kwargs)

    if fit:
        model = data.model.iloc[index]
        predicted = model.predict(np.geomspace(0.001, 2000000, 100))
        ax.plot(np.real(predicted) / 1000, np.abs(np.imag(predicted)) / 1000)
        ax.add_artist(AnchoredText(model.circuit, loc=2))

    if not ax.xaxis.get_label().get_text():
        ax.axis('equal')
        # ax.axis('square')
        ax.set_xlim(left=0)
        ax.set_ylim(bottom=0)
        ax.set_ylabel(r'$-Im(Z) [{}]$'.format(K_OHM))
        ax.set_xlabel(r'$Re(Z) [{}]$'.format(K_OHM))
        ax.ticklabel_format(style='sci', scilimits=(-3, 4), axis='both')
        ax.set_title('Cole-Cole')

    return ax