Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: scikit-rf/web-apps
base: e00ce044f9
...
head fork: scikit-rf/web-apps
compare: 69e3f46a70
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
6 .gitignore
@@ -0,0 +1,6 @@
+calibration/ideals/*
+calibration/measured/*
+calibration/caled/*
+calibration/duts/*
+calibration/plots/*
+!.gitignore
View
0  calibration/caled/.gitignore
No changes.
View
0  calibration/duts/.gitignore
No changes.
View
0  calibration/ideals/.gitignore
No changes.
View
187 calibration/index.html 100644 → 100755
@@ -2,13 +2,55 @@
<html>
<head>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
+<style>
+ h2{
+ padding: 10px;
+
+ }
+ td,tr {
+ text-align: center;
+ padding: 10px;
+ }
+ .left-cell {
+ text-align: left;
+ }
+
+ .outline{
+ border: 2px solid grey;
+ width: 80%;
+ border-radius:25px;
+ -moz-border-radius:25px; /* Firefox 3.6 and earlier */
+ }
+ .suboutline{
+ border: 1px solid grey;
+ border-radius:15px;
+ -moz-border-radius:15px; /* Firefox 3.6 and earlier */
+ padding: 10px;
+ }
+ .suboutline2{
+ border: 1px solid grey;
+ border-radius:15px;
+ -moz-border-radius:15px; /* Firefox 3.6 and earlier */
+ width:70%;
+ text-align:center;
+ }
+ table{
+ width: 100%;
+ }
+ div.stds{
+ }
+</style>
<script type="text/javascript">
var n_stds = 0
+ var n_duts= 0
var min_n_stds = 3
+ var min_n_duts = 0
var stds = new Array();
+ var duts = new Array();
var measuredDivParent = 'measured'
var idealsDivParent = 'ideals'
+ var dutDivParent = 'duts'
function Std(num, measuredDiv, idealDiv)
{
@@ -21,25 +63,46 @@
this.measuredDiv = document.createElement('div')
this.idealsDiv= document.createElement('div')
- this.idealsDiv.innerHTML = "<p>#"+ this.num +
+ this.idealsDiv.innerHTML = "<p>"+ this.num +
" : <input type='file' id='ideal'" + this.num +
- " name='ideal" + this.num + "'/></p>"
- this.measuredDiv.innerHTML = "<p>#"+ this.num +
+ " name='ideal" + this.num + "' /></p>"
+ this.measuredDiv.innerHTML = "<p>"+ this.num +
" : <input type='file' id='measure'" + this.num +
" name='measure" + this.num + "'/></p>"
this.measuredDivParent.appendChild(this.measuredDiv)
this.idealsDivParent.appendChild(this.idealsDiv)
}
-
+
+ function Dut(num, parentDiv)
+ {
+ this.num = num
+ this.name = "dut"+this.num
+
+ this.dutDivParent = document.getElementById(parentDiv)
+
+ this.dutDiv = document.createElement('div')
+
+ this.dutDiv.innerHTML = "<p>"+ this.num +
+ " : <input type='file' id='dut'" + this.num +
+ " name='dut" + this.num + "'/></p>"
+ this.dutDivParent.appendChild(this.dutDiv)
+ }
+
function addStd()
{
var std = new Std(n_stds,measuredDivParent,idealsDivParent);
stds.push(std);
n_stds++;
- document.getElementById('output').innerHTML=n_stds
+ document.getElementById('stdCounter').innerHTML=n_stds
+ }
+ function addDut()
+ {
+ var dut = new Dut(n_duts,dutDivParent);
+ duts.push(dut);
+ n_duts++;
+ document.getElementById('dutCounter').innerHTML=n_duts
}
-
function rmStd()
{
if (n_stds > min_n_stds)
@@ -50,65 +113,109 @@
stds.pop();
n_stds--;
- document.getElementById('output').innerHTML=n_stds
+ document.getElementById('stdCounter').innerHTML=n_stds
}
else
{
alert('no')
}
}
-
+ function rmDut()
+ {
+ if (n_duts > min_n_duts)
+ {
+ var dut = duts[duts.length-1];
+ dut.dutDivParent.removeChild(dut.dutDiv);
+ duts.pop();
+ n_duts--;
+
+ document.getElementById('dutCounter').innerHTML=n_duts
+ }
+ else
+ {
+ alert('no')
+ }
+ }
+ function load(){
+ addStd();
+ addStd();
+ addStd();
+ }
</script>
</head>
-<center><h1>Online Calibrator</h1></center>
-<body>
-<form enctype="multipart/form-data"
- method="post"
- action="../cgi-bin/calibrate.py">
+
+<center><h1>Calibration Station</h1></center>
+
+<body onload="load()">
+<form enctype="multipart/form-data" method="post" action="../cgi-bin/calibrate.py">
<center>
-<table border=1 width=80%>
+<div class = "outline">
+<table border = 0 >
<tr>
<td>
-<center>
- <h2>Ideals</h2>
-</center>
-</td>
-<td>
-<center>
- <h2>Measurements</h2>
-</center>
+ <div class = "suboutline">
+ <table border=0>
+ <tr>
+ <td>
+ <h2>Ideals</h2>
+ <div id="ideals" class = "stds"></div>
+ </td><td>
+ <h2>Measurements</h2>
+ <div id="measured" class = "stds"></div>
+ </td>
+ </tr>
+ <tr>
+ <td colspan = 2>
+ <input type="button" value="Add Standard" onClick="addStd();">
+ <input type="button" value="Remove Standard" onClick="rmStd();">
+ </td></tr>
+ </tr>
+ </table>
+ </div>
</td>
</tr>
<tr>
<td>
- <div id="ideals" style="border: 1px solid red; padding: 10px;">
-</td>
-<td>
- <div id="measured" style="border: 1px solid green; padding: 10px;">
-</div>
+ <center>
+ <div class="suboutline2">
+ <table width = "80%">
+ <tr>
+ <td>
+ <h2>DUT's</h2>
+ <div id="duts" class = "duts" width = 80></div>
+ </td></tr><tr><td>
+ <input type="button" value="Add DUT" onClick="addDut();">
+ <input type="button" value="Remove DUT" onClick="rmDut();">
+ </td>
+ </tr>
+ </table>
+ </div>
+ </center>
</td>
</tr>
-<tr><td colspan = 2>
-<center>
- <input type="button" value="Add Standard" onClick="addStd();">
- <input type="button" value="Remove Standard" onClick="rmStd();">
- <br><br>
- <input type="Submit" value="Calibrate!">
- <textarea id ="output" name="output"></textarea>
-</center>
+
+<tr>
+<td colspan =2>
+ <input type="checkbox" name="make report" /> option1
+ <input type="checkbox" name="make report" /> option2
+</td></tr>
+<tr>
+<td colspan =2>
+ <input type="Submit" value="Calibrate!">
+</td></tr>
+
+
</td></tr>
</table>
+<textarea id ="stdCounter" name="stdCounter"></textarea>
+<textarea id ="dutCounter" name="dutCounter"></textarea>
</form>
+</div>
-<script type="text/javascript">
- addStd();
- addStd();
- addStd();
-</script>
<p><font size="1"><a href='mailto:arsenovic@virginia.edu'>Questions/Comments</a></font></p>
<br><br><br><br>
View
0  calibration/measured/.gitignore
No changes.
View
0  calibration/plots/.gitignore
No changes.
View
122 cgi-bin/calibrate.py
@@ -17,14 +17,27 @@
measured_dir = '../calibration/measured/'
ideals_dir = '../calibration/ideals/'
-output_dir = '../calibration/output/'
-plot_fmts = ['pdf','png','eps']
+duts_dir = '../calibration/duts/'
+caled_dir = '../calibration/caled/'
+plot_dir = '../calibration/plots/'
+plot_fmts = ['png','pdf']
+
+component_to_name ={
+ 's_db':'Magnitude',
+ 's_deg':'Phase',
+ 's_smith':'Smith Chart',
+ }
+
+
+n_stds = int(form.getvalue('stdCounter'))
+n_duts = int(form.getvalue('dutCounter'))
-n_stds = int(form.getvalue('output'))
measured =[]
ideals = []
+duts = []
message = ''
+
for k in range(n_stds):
if not(form['measure%i'%(k)].filename and form['ideal%i'%(k)].filename):
message ='<script type="text/javascript">alert(\'enter more data\')</script>'
@@ -33,11 +46,16 @@
fileitem = form['measure%i'%(k)]
fn = os.path.basename(fileitem.filename).replace('_','-')
open(measured_dir + fn, 'wb').write(fileitem.file.read())
- measured.append(rf.Network(measured_dir + fn, 'wb'))
+ measured.append(rf.Network(measured_dir + fn))
fileitem = form['ideal%i'%(k)]
fn = os.path.basename(fileitem.filename).replace('_','-')
open(ideals_dir + fn, 'wb').write(fileitem.file.read())
- ideals.append(rf.Network(ideals_dir + fn, 'wb'))
+ ideals.append(rf.Network(ideals_dir + fn))
+for k in range(n_duts):
+ fileitem = form['dut%i'%(k)]
+ fn = os.path.basename(fileitem.filename).replace('_','-')
+ open(duts_dir + fn, 'wb').write(fileitem.file.read())
+ duts.append(rf.Network(duts_dir + fn))
@@ -45,32 +63,80 @@
measured = measured,
ideals = ideals,
)
-cal.error_ntwk.write_touchstone( 'ErrorNetwork',dir = output_dir)
-cal.plot_coefs_db()
-pylab.title('Error Coefficients')
-[pylab.savefig(output_dir+'Error Coefficients'+'.'+fmt, format=fmt) for fmt in plot_fmts]
-
-message = """
-<center>
-<a href = '%s'>Error Network</a>
-<img width=\'825\' src=\'%s\'></img>
-<br>
-<a href='%s'>png</a>
-<a href='%s'>pdf</a>
-<a href='%s'>eps</a>
-</center>"""\
-%(output_dir+'ErrorNetwork.s2p',
-output_dir+'Error Coefficients'+'.png',
-output_dir+'Error Coefficients'+'.'+ 'pdf',
-output_dir+'Error Coefficients'+'.'+ 'png',
-output_dir+'Error Coefficients'+'.'+ 'eps',)
-
-print """\
+
+caled = [cal.apply_cal(k) for k in duts]
+
+message='''
+<div>
+<h2>
+Touchstone Files
+</h2>
+</div>'''
+
+for ntwk in caled:
+ fn = ntwk.name+'.s'+str(ntwk.number_of_ports)+'p'
+ message+='''
+ <a href=\'%s\'>%s</a> <br>
+ '''%(caled_dir+fn,fn)
+ ntwk.write_touchstone(dir = caled_dir)
+
+message +='''
+<div>
+<h2>
+Plots
+</h2>
+</div>'''
+
+
+for component in ['s_db', 's_deg','s_smith']:
+ plot_name = component_to_name[component]
+ message+='''
+ <div>
+ <h3>
+ %s
+ </h3>
+ </div>'''%(plot_name)
+
+ pylab.figure()
+ pylab.title(plot_name)
+ for ntwk in caled:
+ ntwk.__getattribute__('plot_%s'%component)()
+
+
+ message += '''
+ <div class = "unit">
+ <img width=\'825\' src=\'%s\'></img><br>
+ '''%(plot_dir+plot_name+'.png')
+
+ for fmt in plot_fmts:
+ fn = plot_dir+plot_name+'.'+fmt
+ pylab.savefig(fn, format=fmt)
+ message += '''<a href = \'%s\'>%s</a>
+ '''%(fn,fmt)
+ message+='''
+ </div>
+ <div text-align="center">
+ '''
+message += '''
+</div>
+'''
+
+print '''\
Content-Type: text/html\n
<html>
+
+<head>
+<style>
+ div.unit{
+ text-align:center;
+ padding: 10px;
+ border: 0px solid black;
+ }
+</style>
+</head>
<body>
- <p>%s</p>
+%s
</body>
</html>
-""" % message
+''' % message
View
35 cgi-bin/touchstone_plotter.py
@@ -2,16 +2,25 @@
import cgi, os
import cgitb; cgitb.enable()
+import ast
+import matplotlib
+matplotlib.use('Agg')
+import numpy
+import pylab
+import sys
+sys.path.append('/home/alex/code/scikit-rf/')
+import skrf as rf
-form = cgi.FieldStorage()
-
-# Get filename here.
-fileitem = form['filename']
-
+# intputs
plot_dir = '../touchstone_plotter/plots/'
plot_fmts = ['pdf','png','eps']
touchstone_dir = '../touchstone_plotter/touchstones/'
+
+
+form = cgi.FieldStorage()
+fileitem = form['filename']
+
# Test if the file was uploaded
if fileitem.filename:
# strip leading path from file name to avoid
@@ -38,21 +47,9 @@
show_grid = False
title = form.getvalue('title')
-
- import ast
plot_args = ast.literal_eval(form.getvalue('args'))
plot_kwargs = ast.literal_eval(form.getvalue('kwargs'))
-
-
-
- import matplotlib
- import numpy
- matplotlib.use('Agg')
- import pylab
- import sys
- sys.path.append('/home/alex/code/scikit-rf/')
- import skrf as rf
if latex_on:
pylab.rcParams['text.usetex'] = True
else:
@@ -91,11 +88,11 @@
else:
message = 'No file was uploaded'
-print """\
+print '''\
Content-Type: text/html\n
<html>
<body>
<p>%s</p>
</body>
</html>
-""" % (message,)
+''' % (message,)

No commit comments for this range

Something went wrong with that request. Please try again.