Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot doesn't show when using PyCall to invoke python plots #939

Closed
ruizhi92 opened this issue Oct 27, 2021 · 1 comment
Closed

Plot doesn't show when using PyCall to invoke python plots #939

ruizhi92 opened this issue Oct 27, 2021 · 1 comment

Comments

@ruizhi92
Copy link

Hello,

I encountered a problem when using PyCall to invoke a python package scikit-rf. The problem is that plotting functions defined for a python class doesn't show. The original python code is

import skrf as rf

freq = rf.Frequency(start=0.1, stop=10, unit='GHz', npoints=1001)
tl_media = rf.DefinedGammaZ0(freq, z0=50, gamma=1j*freq.w/rf.c)
C1 = tl_media.capacitor(3.222e-12, name='C1')
C2 = tl_media.capacitor(82.25e-15, name='C2')
C3 = tl_media.capacitor(3.222e-12, name='C3')
L2 = tl_media.inductor(8.893e-9, name='L2')
RL = tl_media.resistor(50, name='RL')
gnd = rf.Circuit.Ground(freq, name='gnd')
port1 = rf.Circuit.Port(freq, name='port1', z0=50)
port2 = rf.Circuit.Port(freq, name='port2', z0=50)    
cnx = [
    [(port1, 0), (C1, 0), (L2, 0), (C2, 0)],
    [(L2, 1), (C2, 1), (C3, 0), (port2, 0)],
    [(gnd, 0), (C1, 1), (C3, 1)],
]
cir = rf.Circuit(cnx)
ntw = cir.network

cir.plot_graph()

This piece of code generates plots correctly in Python.

tmp

However when using PyCall in Julia with slight change in grammer:

using PyCall
rf = pyimport("skrf")

freq = rf.Frequency(start=0.1, stop=10, unit="GHz", npoints=1001)
tl_media = rf.DefinedGammaZ0(freq, z0=50, gamma=1im*freq.w/rf.c)
C1 = tl_media.capacitor(3.222e-12, name="C1")
C2 = tl_media.capacitor(82.25e-15, name="C2")
C3 = tl_media.capacitor(3.222e-12, name="C3")
L2 = tl_media.inductor(8.893e-9, name="L2")
RL = tl_media.resistor(50, name="RL")
gnd = rf.Circuit.Ground(freq, name="gnd")
port1 = rf.Circuit.Port(freq, name="port1", z0=50)
port2 = rf.Circuit.Port(freq, name="port2", z0=50)    
cnx = [
    [(port1, 0), (C1, 0), (L2, 0), (C2, 0)],
    [(L2, 1), (C2, 1), (C3, 0), (port2, 0)],
    [(gnd, 0), (C1, 1), (C3, 1)],
]
cir = rf.Circuit(cnx)
ntw = cir.network

cir.plot_graph()

Nothing shows. I wonder what's the issue here? Are there any workarounds? Thank you.

@ruizhi92
Copy link
Author

ruizhi92 commented Oct 29, 2021

Somehow this piece of code works now... No idea why that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant