Can't change frequency list in Microring example
danielj-n opened this issue · 0 comments
danielj-n commented
- OPICS version: 0.3.3
- Python version: Python 3.10.5
- Operating System: Arch Linux
Description
I was trying to change the frequency range used in the microring example by changing the line in the Network initialization:
opics/examples/microring/microring.py
Line 11 in 414e517
I changed "2000" to "20000" hoping to get 20000 points in the output plot instead of 2000 for more resolution.
When I did this I got an error:
daniel@acer-swift maybe_trash]$ python microring.py
____ ____ _______________
/ __ \/ __ \/ _/ ____/ ___/
/ / / / /_/ // // / \__ \
/ /_/ / ____// // /___ ___/ /
\____/_/ /___/\____//____/
OPICS version 0.3.3
20000
Traceback (most recent call last):
File "/home/daniel/documents/school/masc/research/maybe_trash/microring.py", line 35, in <module>
circuit.sim_result.plot_sparameters(
File "/home/daniel/.local/lib/python3.10/site-packages/opics/components.py", line 262, in plot_sparameters
plt.plot(x_data, np.square(np.abs(self.s[:, int(i), int(j)])))
File "/usr/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2769, in plot
return gca().plot(
File "/usr/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 1632, in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 312, in __call__
yield from self._plot_args(this, kwargs)
File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 498, in _plot_args
raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (2000,) and (20000,)
What I Did
I was thinking this probably came from using the global frequency list instead of the supplied frequency list somewhere in the code. I traced my issue back in the Opics code to this line:
Line 54 in 414e517
This line seems to set the frequency list of the combined component to the global frequency list rather than using the frequency list of the supplied components. I believe this line should reuse the frequency list from the components that are being combined.
One quick fix for this is to change the line to:
combination_f = components[0].f
This fixes the problem for me. However, I'm not sure if this is an actual issue or if there's a proper way to do this I missed.