/
_dsclansNTF.py
50 lines (41 loc) · 1.43 KB
/
_dsclansNTF.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
# _dsclansNTF.py
# Module providing the dsclansNTF function
# Copyright 2013 Giuseppe Venturini
# This file is part of python-deltasigma.
#
# python-deltasigma is a 1:1 Python replacement of Richard Schreier's
# MATLAB delta sigma toolbox (aka "delsigma"), upon which it is heavily based.
# The delta sigma toolbox is (c) 2009, Richard Schreier.
#
# python-deltasigma is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# LICENSE file for the licensing terms.
"""Module providing the dsclansNTF() function
"""
import numpy as np
from ._utils import carray
def dsclansNTF(x, order, rmax, Hz):
""" Conversion of clans parameters into a NTF.
Translate x into H.
I've changed the relationships between (zeta, wn) and x
in order to guarantee LHP roots of the s-polynomial.
Returns the NTF, a zpk tuple.
"""
x = x.squeeze()
Hz = carray(Hz)
Hz = Hz.reshape((-1,))
Hp = np.zeros((1,), dtype=np.complex128)
odd = (order % 2 == 1)
if odd:
s = -x[0]**2.
Hp[0] = rmax*(1. + s)/(1. - s)
for i in range(0+1*odd, order, 2):
Hp = np.hstack((Hp, np.zeros((2,))))
zeta = x[i]**2
wn = x[i + 1]**2
s = np.roots(np.array((1, 2*zeta*wn, wn**2)))
Hp[i:i+2] = rmax*(1. + s)/(1. - s)
H = (Hz, Hp, 1.)
return H