Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ggventurini committed Jan 21, 2014
2 parents 68ab10c + 4c80b13 commit a2df3a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deltasigma/_peakSNR.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def test_peakSNR():
"""Test function for peakSNR().
"""
import scipy.io, pkg_resources
fname = pkg_resources.resource_filename(__name__, "test_data/test_snr_amp.mat")
snr = scipy.io.loadmat(fname)['snr'].reshape(-1)
amp = scipy.io.loadmat(fname)['amp'].reshape(-1)
fname = pkg_resources.resource_filename(__name__, "test_data/test_peak_snr.mat")
snr = scipy.io.loadmat(fname)['snr'].reshape((-1,))
amp = scipy.io.loadmat(fname)['amp'].reshape((-1,))
peak_snr, peak_amp = 76.612340603949761, -3.220409771005124
ps, pa = peakSNR(snr, amp)
assert np.allclose(ps, peak_snr, atol=1e-8, rtol=1e-5)
Expand Down
Binary file added deltasigma/test_data/test_peak_snr.mat
Binary file not shown.
21 changes: 21 additions & 0 deletions deltasigma/test_data/test_snr_amp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
% code to generate snr, amp, snr_user, amp_user
clc
clear *
stf = []
% Design parameters
order = 4;
osr = 256;
nlev = 2;
f0 = 0.22;
Hinf = 1.25;
form = 'CRFB';

ntf = synthesizeNTF(order,osr,2,Hinf,f0);
[a1,g1,b1,c1] = realizeNTF(ntf,form);
ABCD = stuffABCD(a1, g1, b1, c1, form);
[a2,g2,b2,c2] = mapABCD(ABCD, form);

[snr, amp] = simulateSNR(ABCD, osr, [], f0, nlev);
amp_user = linspace(-100, 0, 200);
[snr_user, amp_user] = simulateSNR(ABCD, osr, amp_user, f0, nlev)
%[snr2, amp2] = simulateSNR(ntf, osr, [], f0, nlev)

0 comments on commit a2df3a3

Please sign in to comment.