Skip to content

Commit 0e2a3a7

Browse files
committed
Plotting S11 Phase
1 parent e435cdc commit 0e2a3a7

2 files changed

Lines changed: 101 additions & 85 deletions

File tree

smith_chart/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ <h4 class="mb-0"><strong>ONLINE SMITH CHART TOOL</strong></h4>
316316

317317
<div class="row mt-4">
318318

319-
<div class="col-lg-4">
319+
<div class="col-12 col-lg-6">
320320
<div class="row text-center"><h4 class="mb-0">S11 Parameter vs Frequency</h4></div>
321321
<div class="row" id="smith_sparameters">
322322
<div>
@@ -325,16 +325,16 @@ <h4 class="mb-0"><strong>ONLINE SMITH CHART TOOL</strong></h4>
325325
</div>
326326
</div>
327327

328-
<div class="col-lg-4">
328+
<!-- <div class="col-lg-4">
329329
<div class="row text-center"><h4 class="mb-0">Reflection Coefficient plotted on a polar axes</h4></div>
330330
<div class="row" id="smith_polar">
331331
<div>
332-
<div id="PolarPlot"><!-- Plotly chart will be drawn inside this DIV --></div>
332+
<div id="PolarPlot"></div>
333333
</div>
334334
</div>
335-
</div>
335+
</div> -->
336336

337-
<div class="col-lg-4">
337+
<div class="col-12 col-lg-6">
338338
<div class="row text-center"><h4 class="mb-0"><small>Distance to Vmax and Vmin</small></h4></div>
339339
<div class="row" id="smith_lambda">
340340
<div>

smith_chart/js/smith_tool.js

Lines changed: 96 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -824,66 +824,66 @@ function update_smith_chart() {
824824

825825

826826

827-
var data_polar = [
828-
{
829-
type: "scatterpolargl",
830-
r: [Number(reflection_mag)],
831-
theta: [reflection_phase],
832-
marker: {
833-
color: "black",
834-
symbol: "square",
835-
size: 8
836-
},
837-
subplot: "polar"
838-
}
839-
]
840-
841-
for(i=0;i<refl_mag.length;i++){
842-
data_polar.push(
843-
{
844-
type: "scatterpolargl",
845-
r: [refl_mag[i]],
846-
theta: [refl_phase[i]],
847-
marker: {
848-
color: 'rgb(200, 0, 0)',
849-
symbol: "circle",
850-
size: 4
851-
},
852-
subplot: "polar"
853-
}
854-
)
855-
}
827+
// var data_polar = [
828+
// {
829+
// type: "scatterpolargl",
830+
// r: [Number(reflection_mag)],
831+
// theta: [reflection_phase],
832+
// marker: {
833+
// color: "black",
834+
// symbol: "square",
835+
// size: 8
836+
// },
837+
// subplot: "polar"
838+
// }
839+
// ]
840+
841+
// for(i=0;i<refl_mag.length;i++){
842+
// data_polar.push(
843+
// {
844+
// type: "scatterpolargl",
845+
// r: [refl_mag[i]],
846+
// theta: [refl_phase[i]],
847+
// marker: {
848+
// color: 'rgb(200, 0, 0)',
849+
// symbol: "circle",
850+
// size: 4
851+
// },
852+
// subplot: "polar"
853+
// }
854+
// )
855+
// }
856856

857857

858-
var layout_polar = {
859-
hovermode: false,
860-
showlegend: false,
861-
paper_bgcolor: 'rgba(0,0,0,0)',
862-
plot_bgcolor: 'rgba(0,0,0,0)',
863-
polar: {
864-
radialaxis: {
865-
tickfont: {
866-
size: 12
867-
},
868-
range: [0, 1],
869-
gridcolor: "rgba(145, 145, 145, 0.75)",
870-
dtick:'0.2'
871-
},
872-
angularaxis: {
873-
tickfont: {
874-
size: 12
875-
},
876-
gridcolor: "rgba(145, 145, 145, 0.75)",
877-
dtick:'15'
878-
},
879-
bgcolor:'rgba(255,255,255,0.2)',
880-
}
881-
};
882-
883-
var polarWidth = document.getElementById("smith_polar").offsetWidth
884-
layout_polar.width = polarWidth;
885-
layout_polar.height = polarWidth;
886-
Plotly.react('PolarPlot', data_polar, layout_polar, config)
858+
// var layout_polar = {
859+
// hovermode: false,
860+
// showlegend: false,
861+
// paper_bgcolor: 'rgba(0,0,0,0)',
862+
// plot_bgcolor: 'rgba(0,0,0,0)',
863+
// polar: {
864+
// radialaxis: {
865+
// tickfont: {
866+
// size: 12
867+
// },
868+
// range: [0, 1],
869+
// gridcolor: "rgba(145, 145, 145, 0.75)",
870+
// dtick:'0.2'
871+
// },
872+
// angularaxis: {
873+
// tickfont: {
874+
// size: 12
875+
// },
876+
// gridcolor: "rgba(145, 145, 145, 0.75)",
877+
// dtick:'15'
878+
// },
879+
// bgcolor:'rgba(255,255,255,0.2)',
880+
// }
881+
// };
882+
883+
// var polarWidth = document.getElementById("smith_polar").offsetWidth
884+
// layout_polar.width = polarWidth;
885+
// layout_polar.height = polarWidth;
886+
// Plotly.react('PolarPlot', data_polar, layout_polar, config)
887887

888888
//
889889
//Create a plots for distance to Vmax and Vmin
@@ -1044,18 +1044,18 @@ var layout_polar = {
10441044
line: {
10451045
color: 'blue',
10461046
},
1047-
name: 'S11 (dB)',
1047+
name: 'Magnitude',
10481048
type: 'scatter'
10491049
};
10501050

1051-
// var traceS22 = {
1052-
// line: {
1053-
// color: 'red',
1054-
// },
1055-
// name: 'S22 (dB)',
1056-
// yaxis: 'y2',
1057-
// type: 'scatter'
1058-
// };
1051+
var traceS11Ph = {
1052+
line: {
1053+
color: 'red',
1054+
},
1055+
name: 'Phase',
1056+
yaxis: 'y2',
1057+
type: 'scatter'
1058+
};
10591059

10601060
var sParamLayout = {
10611061
yaxis: {
@@ -1067,14 +1067,16 @@ var layout_polar = {
10671067
title: 'S11 (dB)',
10681068
automargin: true,
10691069
},
1070-
// yaxis2: {
1071-
// tickfont: {color: 'red'},
1072-
// side: 'right',
1073-
// zeroline: false,
1074-
// showgrid: true,
1075-
// gridcolor: "rgb(37, 50, 64)",
1076-
// fixedrange: true,
1077-
// },
1070+
yaxis2: {
1071+
tickfont: {color: 'red'},
1072+
side: 'right',
1073+
zeroline: false,
1074+
// showgrid: true,
1075+
gridcolor: "rgb(37, 50, 64)",
1076+
fixedrange: true,
1077+
title: 'Phase (deg)',
1078+
automargin: true,
1079+
},
10781080
xaxis: {
10791081
automargin: true,
10801082
title: 'frequency (' + domFreqSel.value + ')',
@@ -1104,31 +1106,45 @@ var layout_polar = {
11041106
var scaledFreq = freq/schematic[0].freq_unit.multiplier;
11051107
//just show 1 point
11061108
traceS11.y = [];
1109+
traceS11Ph.y = [];
11071110
if (span_freq == 0) {
11081111
var newSpanFreq = 1
11091112
traceS11.x = [scaledFreq];
1110-
if (reflection_mag == 0) traceS11.y.push(0)
1111-
else traceS11.y.push(20*Math.log10(reflection_mag))
1113+
traceS11Ph.x = [scaledFreq];
1114+
if (reflection_mag == 0) {
1115+
traceS11.y.push(0);
1116+
traceS11Ph.y.push(0);
1117+
} else {
1118+
traceS11.y.push(20*Math.log10(reflection_mag));
1119+
traceS11Ph.y.push(reflection_phase);
1120+
}
11121121
// traceS22.x = [scaledFreq];
11131122
// traceS22.y = [0.5];
11141123
// sParamLayout.yaxis.range = [0, 2];
11151124
// sParamLayout.yaxis2.range = [0, 2];
11161125
} else {
11171126
// [reflectio_coeff_real, reflectio_coeff_imag, reflection_mag, reflection_phase] = impedanceToReflectionCoefficient (real_old, imag_old, zo)
11181127
traceS11.x = [];
1128+
traceS11Ph.x = [];
11191129
for (i=0; i<span_impedance_re.length;i++) {
11201130
[reflectio_coeff_real, reflectio_coeff_imag, reflection_mag, reflection_phase] = impedanceToReflectionCoefficient (span_impedance_re[i],span_impedance_im[i], zo)
1121-
if (reflection_mag == 0) traceS11.y.push(0)
1122-
else traceS11.y.push(20*Math.log10(reflection_mag))
1131+
if (reflection_mag == 0) {
1132+
traceS11.y.push(0);
1133+
traceS11Ph.y.push(0);
1134+
} else {
1135+
traceS11.y.push(20*Math.log10(reflection_mag));
1136+
traceS11Ph.y.push(reflection_phase);
1137+
}
11231138
traceS11.x.push((freq + span_freq * (i-span_res)/span_res)/schematic[0].freq_unit.multiplier);
1139+
traceS11Ph.x.push((freq + span_freq * (i-span_res)/span_res)/schematic[0].freq_unit.multiplier);
11241140
}
11251141
newSpanFreq = span_freq/schematic[0].freq_unit.multiplier;
11261142
}
11271143

11281144
sParamLayout.xaxis.range = [scaledFreq - newSpanFreq, scaledFreq + newSpanFreq];
11291145

11301146
// var data = [traceS11, traceS22];
1131-
var data = [traceS11];
1147+
var data = [traceS11, traceS11Ph];
11321148
// var smith_lambda = document.getElementById("SParamPlot").offsetWidth;
11331149
// sParamLayout.width = smith_lambda;
11341150
// sParamLayout.height = smith_lambda;

0 commit comments

Comments
 (0)