I would like to use scipy.signal.lti and scipy.signal.impulse function to calculate the transfer function. I import the scipy module in the following way.
import scipy as sp
import numpy as np
import matplotlib.pyplot as plt
from math import *
However, when I type the following scripts,
tf = sp.signal.lti(numH, denH)
The Kernel gives an error:
---> 10 tf = sp.signal.lti(numH, denH)
AttributeError: 'module' object has no attribute 'signal'
I tried another way to import the signal module,
from scipy.signal import lti, step, impulse
Then, the script works,
tf = lti(numH, denH)
So, my questions is, must we import every subpackage in the script? Then what's the point of importing the scipy package?
Thanks.
From the scipy doc:
Using any of these subpackages requires an explicit import. For example,
import scipy.cluster.
or from scipy import cluster.
There isn't much point to doing a simple
import scipy
Look at the site-packages/scipy/__init__.py file for more details. Compare it with the numpy init.
numpy is an integrated package, scipy is a collection of loosely integrated packages. numpy is the basic numeric package that everyone uses. The scipy subpackages are relatively independent of each other. I can load and use sparse without knowning anything about the signal or integrate packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With