Coder's Corner

From MesoscopicWiki

Jump to: navigation, search

Contents

Matlab

vnaGUI mfiles (courtesy of Dr. Zadler)

Download all of these and put in a directory, possible /home/(your name)/mfiles. Do not forget to add this directory to your Matlab path and save it.

Latest update: (04.24.2008) (makeNicePlot.m, vna_GUI.m, and getDataColumn.m updated)


vnaGUI walkthrough

This short guide will walk you through the basics of the vnaGUI for plotting and data manipulation. Suggestions are welcome. Let me know about bugs so I can squash em. Don't forget to download all the necessary mfiles before proceeding.

Truncating the data set is not covered here, but is pretty obvious.

Opening Screen
  • This is the opening screen.
  • File selection is via the matlab uigetfile command, so you can choose a file in any location... it is then listed for reference at the top of the GUI.
  • Plotting options include an interpolated surface plot, a mesh plot, or a contour plot. A 'Nice Plot' can be made a la Scott's fitting code, cleverly stolen and integreted.
  • Checkbox option for data to plot, trans amplitude, reflected phase, etc.
  • The grid lines can be turned on/off at will.
  • If you want a 2D top-down view, you can click the 'Flat View' button at the bottom. This is useful and necessary for the later functions.


Data file is chosen
  • I chose to open the violet_fullScanRange.txt data.
  • The transmitted phase is plotted, showing an anomolous hump in the data that we'll try to get rid of. No phase wrapping is apparent here.


Flat view, tight axis
  • Click 'Flat View'. This will give you a top-down perspective.
  • Click 'Tighten Axes'. This will fit the data to the axes nicely.


Select local feature
  • Click the 'Local Feature' button to open another figure with 3 options.
  • We want to remove that hump in the data. Let's define a line that crosses the hump. Since the hump is nearly constant horizontally in the picture, we want to think of the data as a set of vertical lines. Each line has this background feature in it that we want to remove. So by defining a vertical line, we say 'take the curvature of this line and subtract it from every vertical line in our data set.'
  • Click the button that says 'Define Feature Line'. Now make a vertical line on the left side of the data as shown. If your line is more horizontal that vertical, the program will try to remove a horizontal feature from every vertical line (vise versa of the explanation above). You can see in the picture the line is green. The program now sees that you want to remove the feature in the direction shown. It takes the first 5 lines of the data (for now, this will be improved later) and averages them creating a single vertical line of data in which the feature is apparent. This feature line is then subtracted from the data at every horizontal position.


After feature removal
  • Click the 'Remove Feature' button and you should see something similar to the picture here. The hump is gone from the data. If you don't like the line you've make, before you remove the feature you can use the clear button to remove your selection and redefine the line.
  • Now we still have a slight planar skew to the data, so let's remove that next.


Before planar removal
  • Open the planar dialog options. You need to select 3 points to define a plane in 3 dimensions. My suggestion is to rotate the figure a few times using the rotation tool and get a good idea of what 3 points would best define the plane.
  • Flatten the view and tighten the axes.
  • Click 'Define Plane'. The dialog tells you to select 3 points. I select them in a clockwise fashion, but it shouldn't make a difference. You will be shown the plane generated by your point selection. Rotate it and see if you like it. If not, clear it, flatten the view, and try again. When you are satisfied, click 'Remove Offset'.


After planar removal
  • You can see that the background of the image is a more consistent gray/white color now.



Mesh and surface plotting for VNA data

(*.m files are not uploadable, so these have the .txt extension)

(03.19.08) Publishplot.m written by MDW, based on SS's code. The plot is saved in two formats when the code is run: .fig and .jpg. If you want to save it as an eps, then just change the .jpg extension to an .eps extension.

Plot_trans.m written by Scott S.


(03.20.08) MplSurfPlot.m written by Brian Z.; REQUIRES: RemoveLinearOffset.m, nonLinearoffset.m, and mplNicePlot.m

(03.20.08) RemoveLinearOffset.m written by Brian Z.; needed by MplSurfPlot.m if you want to remove a linear offset in the X and Z(or Y) data.

(03.20.08) nonLinearOffset.m written by Brian Z.; needed by MplSurfPlot.m if you want to remove phase or amplitude drift.

(03.20.08) mplNicePlot.m written by Brian Z.; needed by MplSurfPlot.m: uses Scott's PublishPlot.m to create nice looking figures with an option to save both .jpg and .fig formats.



Mathematica

Introduction to Mathematica

  • Mathematica101.nb written by late Prof. James J. Kelly and modified by Alex Yuffa. This tutorial is for Mathematica Version 6 but it should work with later versions.
  • More tutorials from late Prof. James J. Kelly Essential Mathematica Tutorials. Note: These tutorials are for Mathematica Version 5.2.

Data Processing with Mathematica Tutorials

Python

Python for Scientific Computing

  • SciPy (pronounced "Sigh Pie") is open-source software for mathematics, science, and engineering.
  • FiPy is a Finite Volume PDE Solver using Python.

Bug Fixes

  • If import matplotlib.pyplot as plt gives errors in afm.py then you should remove all Hershey fonts. Ayuffa

LaTeX