Skip to content
Snippets Groups Projects
Commit 18bd197a authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Replace SciPy with mplsignal

parent fbc6eed8
No related branches found
No related tags found
1 merge request!238Replace SciPy with mplsignal
Pipeline #90541 passed
...@@ -55,7 +55,7 @@ To generate the documentation, the following additional packages are required: ...@@ -55,7 +55,7 @@ To generate the documentation, the following additional packages are required:
- [Furo](https://pradyunsg.me/furo/) - [Furo](https://pradyunsg.me/furo/)
- [numpydoc](https://numpydoc.readthedocs.io/) - [numpydoc](https://numpydoc.readthedocs.io/)
- [Sphinx-Gallery](https://sphinx-gallery.github.io/) - [Sphinx-Gallery](https://sphinx-gallery.github.io/)
- [SciPy](https://scipy.org/) - [mplsignal](https://mplsignal.readthedocs.io/)
### Using CMake directly ### Using CMake directly
......
...@@ -40,6 +40,7 @@ intersphinx_mapping = { ...@@ -40,6 +40,7 @@ intersphinx_mapping = {
'numpy': ('https://numpy.org/doc/stable/', None), 'numpy': ('https://numpy.org/doc/stable/', None),
'PyQt5': ("https://www.riverbankcomputing.com/static/Docs/PyQt5", None), 'PyQt5': ("https://www.riverbankcomputing.com/static/Docs/PyQt5", None),
'networkx': ('https://networkx.org/documentation/stable', None), 'networkx': ('https://networkx.org/documentation/stable', None),
'mplsignal': ('https://mplsignal.readthedocs.io/en/stable/', None),
} }
numpydoc_show_class_members = False numpydoc_show_class_members = False
......
...@@ -191,15 +191,14 @@ plt.show() ...@@ -191,15 +191,14 @@ plt.show()
# %% # %%
# To compute and plot the frequency response, it is possible to use SciPy and NumPy as # To compute and plot the frequency response, it is possible to use mplsignal
import numpy as np from mplsignal.freq_plots import freqz_fir
import scipy.signal
w, h = scipy.signal.freqz(sim.results['0']) freqz_fir(sim.results["0"])
plt.plot(w, 20 * np.log10(np.abs(h)))
plt.show() plt.show()
# %% # %%
# As seen, the output has not converged to zero, leading to that the frequency-response may not be correct, so we want # As seen, the output has not converged to zero, leading to that the frequency-response may not be correct, so we want
# to simulate for a longer time. # to simulate for a longer time.
...@@ -225,6 +224,5 @@ plt.show() ...@@ -225,6 +224,5 @@ plt.show()
# %% # %%
# And the frequency-response: # And the frequency-response:
w, h = scipy.signal.freqz(sim.results['0']) freqz_fir(sim.results["0"])
plt.plot(w, 20 * np.log10(np.abs(h)))
plt.show() plt.show()
...@@ -31,13 +31,9 @@ sfg.set_execution_time_of_type(Addition.type_name(), 1) ...@@ -31,13 +31,9 @@ sfg.set_execution_time_of_type(Addition.type_name(), 1)
sim = Simulation(sfg, [lambda n: 0 if n else 1]) sim = Simulation(sfg, [lambda n: 0 if n else 1])
sim.run_for(1000) sim.run_for(1000)
import scipy.signal
w, h = scipy.signal.freqz(sim.results['0'])
import matplotlib.pyplot as plt
import numpy as np import numpy as np
from mplsignal.freq_plots import freqz_fir
plt.plot(w, 20 * np.log10(np.abs(h) / 2)) freqz_fir(np.array(sim.results['0']) / 2)
schedule = Schedule(sfg, cyclic=True) schedule = Schedule(sfg, cyclic=True)
...@@ -2,4 +2,4 @@ sphinx ...@@ -2,4 +2,4 @@ sphinx
furo furo
numpydoc numpydoc
sphinx-gallery sphinx-gallery
scipy mplsignal
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment