Last active
July 15, 2024 00:05
-
-
Save shabaz123/f170ad68a8247b65f04d4a58ae92787f to your computer and use it in GitHub Desktop.
Plot S11 data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a Smith Chart and plot the contents of a .s1p file | |
import numpy as np | |
import skrf as rf | |
from matplotlib import rcParams, pyplot as plt | |
import sys | |
from mpl_smithchart import SmithAxes | |
# output settings | |
out_title = "Smith Chart Output" | |
# set the default filename | |
fname1 = 'test.s1p' | |
# check if there is any command line filename | |
if len(sys.argv) == 2: | |
fname1 = sys.argv[1] | |
print(f'Opening file: {fname1}') | |
ntwk1 = rf.Network(fname1) | |
sdata = ntwk1.s | |
sdata = sdata.reshape(sdata.shape[0]) | |
# customize the Smith Chart functionality here: | |
SmithAxes.update_scParams(plot_marker_start='x', plot_marker_end='x', plot_marker_hack=True) | |
# create a figure and Smith Chart | |
plt.figure(figsize=(10,10)).set_layout_engine('tight') | |
ax = plt.subplot(111, projection='smith') | |
# plot the data | |
plt.plot(sdata, markevery=5, label="trace1", datatype=SmithAxes.S_PARAMETER) | |
# final decorations | |
legend = plt.legend(loc="lower right", fontsize=12) | |
plt.title(out_title, fontsize=18) | |
# save the plot to a file | |
plt.savefig("export.png", format="png") | |
# display the plot | |
plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment