/
_rmsGain.py
54 lines (39 loc) · 1.54 KB
/
_rmsGain.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
51
52
53
54
# -*- coding: utf-8 -*-
# _rmsGain.py
# Module providing the rmsGain 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 rmsGain() function
"""
import numpy as np
from scipy.linalg import norm
from ._evalTF import evalTF
def rmsGain(H, f1, f2, N=100):
"""Compute the root mean-square gain of a discrete-time TF.
The computation is carried out over the frequency band ``(f1, f2)``,
employing ``N`` discretization steps.
**Parameters:**
H : object
The discrete-time transfer function. See :func:`evalTF` for the supported types.
f1 : scalar
The start value in Hertz of the frequency band over which the gain is evaluated.
f2 : scalar
The end value (inclusive) in Hertz of the aforementioned frequency band.
N : integer, optional
The number of discretization points to be taken over specified interval.
**Returns:**
Grms : scalar
The root mean-square gain
"""
w = np.linspace(2*np.pi*f1, 2*np.pi*f2, N)
g = norm(evalTF(H, np.exp(1j*w))) / np.sqrt(N)
return g