Exemple #1
0
def test__init__():
    # Test __init__
    fm = np.logspace(3, 9, 100)
    lorentzian = Pnoise(fm, 10 * np.log10(1 / (fm * fm)), label='Lorentzian')
    white = Pnoise(fm, -120 * np.ones(fm.shape), label='white')
    added = white + lorentzian
    added.label = "addition"
    assert_almost_equal(added.ldbc[0], -60, 4)
    assert_almost_equal(added.ldbc[-1], -120, 4)
    ix, = np.where(fm > 1e6)
    assert_almost_equal(added.ldbc[ix[0]], -117.2822, 4)
Exemple #2
0
def test_integration():
    fm = np.logspace(4, 8, 1000)
    lorentzian = Pnoise(fm, 10 * np.log10(1 / (fm * fm)), label='Lorentzian')
    white = Pnoise(fm, -120 * np.ones(fm.shape), label='white')
    added = lorentzian + white
    iadded_gardner = added.integrate()
    iadded_trapz = added.integrate(method='trapz')
    f_int = lambda fm: 2.0e-12 * fm - 2.0 / fm
    i_f_int = np.sqrt(f_int(fm[-1]) - f_int(fm[0]))
    assert_almost_equal(iadded_trapz, i_f_int, 5)
    assert_almost_equal(iadded_trapz, i_f_int, 5)
Exemple #3
0
def test_add_points():
    obj = Pnoise([1e3, 1e6, 1e9], [-100, -120, -140])
    obj.add_points([1e2, 1e3, 1e10], [-80, -70, -160])
    assert np.all(obj.fm == [1e2, 1e3, 1e6, 1e9, 1e10])
    assert np.all(obj.ldbc == [-80, -70, -120, -140, -160])
    # Check deep the interpolation
    obj.fm = [1e2, 1e6, 1.1e5, 7e7]
    obj.fm = [1e3, 1e6, 1.1e5, 7e7, 1e10]
Exemple #4
0
def test_add_noise_sources():
    from numpy.testing import assert_almost_equal
    import matplotlib.pyplot as plt
    myAnalogPLL = AnalogPLL(4, 521.8e+06, Navg=10, prescaler=2, plltype=2)
    myAnalogPLL.loopcalc(1e6, 60.0, -130.0, 1e6, 0.1, 300)
    myAnalogPLL.lti()
    pinput = [
        Pnoise([1e3, 1e6, 1e9], [-140, -140, -140], label='input', fc=48e6)
    ]
    poutput = [
        Pnoise([1e3, 1e6, 1e9], [-70, -120, -180], label='VCO', fc=480e6)
    ]

    fm = np.logspace(4, 8, 100)
    pn_total, pn_in_colored, pn_out_colored = \
        myAnalogPLL.add_noise_sources(fm, pn_inputs=pinput, pn_outputs=poutput)
    assert_almost_equal(pn_total.interp1d(1e8), -160, 2)
    assert_almost_equal(pn_total.interp1d(1e4), -120, 2)
Exemple #5
0
def test_interp1d_class():
    fm = np.array([1e3, 1e5, 1e7])
    lorentzian = Pnoise(fm, 10 * np.log10(1 / (fm * fm)), label='Lorentzian')
    val = lorentzian.interp1d(1e6)
    assert_almost_equal(val, -120, 4)
Exemple #6
0
def test_fc_settler():
    fm = np.array([1e3, 1e5, 1e7])
    ldbc = 10 * np.log10(1 / (fm * fm))
    lorentzian = Pnoise(fm, ldbc, fc=1e9, label='Lorentzian')
    lorentzian.fc = 10e9
    assert_almost_equal(lorentzian.ldbc, ldbc + 20 * log10(10e9 / 1e9))
Exemple #7
0
def test_fm_fc_scaling():
    pnobj = Pnoise([1e4, 1e6, 1e8], [-80, -100, -120], fc=2e9)
    pnobj.fc = 20e9
    assert np.all(pnobj.ldbc == [-60, -80, -100])
    pnobj.fm = [1e5, 1e6, 1e7]
    assert np.all(pnobj.ldbc == [-70, -80, -90])
Exemple #8
0
def test_at_fc():
    pnobj = Pnoise([1e4, 1e6, 1e8], [-80, -100, -120], fc=2e9)
    pnob2 = pnobj.at_fc(20e9)
    assert np.all(pnob2.ldbc == [-60, -80, -100])