mwavepy.calibration.calibration | index /home/alex/docs/python/path/mwavepy/calibration/calibration.py

`Contains the Calibration class, and supporting functions`

Modules
`` |  |
itertools mwavepy.mathFunctions | numpy os | pylab scipy.stats | mwavepy.touchstone warnings

Classes
`` |  | __builtin__.object Calibration
class Calibration(__builtin__.object)
`` | `Represents a Calibration object, which can run a calibration algorithm, store results, and apply calibration to measurements. see init for more information on usage.`
| Methods defined here: __init__(self, measured, ideals, type=None, frequency=None, is_reciprocal=False, name=None, sloppy_input=False, **kwargs) `Calibration initializer. takes: measured: a list of measured Network's (order must align with 'ideals' ideals: a list of ideal Network's (order must align with 'measured' [ optional]: frequency: a Frequency object over which the calibration is defined [None]. if None then will take frequency information from the first measurement. type: string representing what type of calibration is to be performed [None]. supported types at the moment are: 'one port': standard one-port cal. if more than 2 measurement/ideal pairs are given it will calculate the least squares solution. 'two port': standard two-port calibibration based on 8-term error model. can take switch-terms into by using the switch_term option. if None, will inspect number of ports on first measured network and choose either 'one port' or 'two port' is_reciprocal: enables the reciprocity assumption on the property error_network [False]. switch_terms: tuple holding the two measured switch terms in the order (forward, reverse) [None]. the tuple elements should be Network types. (note: is only used in two-port calibrations,see roger mark's paper on switch terms) name: string holding the name of calibration, just for your convenience [None]. sloppy_input: a Boolean. Allows ideals and measured lists to be 'aligned' based on the network names [False]. Can be **kwargs: key-word arguments passed to the calibration algorithm. note: all calibration algorithms are in calibrationAlgorithms.py, and are referenced by the dictionary in this object called 'calibration_algorihtm_dict'` apply_cal(self, input_ntwk) `apply the current calibration to a measurement. takes: input_ntwk: the measurement to apply the calibration to, a Network type. returns: caled: the calibrated measurement, a Network type.` apply_cal_to_all_in_dir(self, dir, contains=None, f_unit='ghz') `convience function to apply calibration to an entire directory of measurements, and return a dictionary of the calibrated results, optionally the user can 'grep' the direction by using the contains switch. takes: dir: directory of measurements (string) contains: will only load measurements who's filename contains this string. f_unit: frequency unit, to use for all networks. see frequency.Frequency.unit for info. returns: ntwkDict: a dictionary of calibrated measurements, the keys are the filenames.` biased_error(self, std_names=None) `estimate of biased error for overdetermined calibration with multiple connections of each standard takes: std_names: list of strings to uniquely identify each standard.* returns: systematic error: mwavepy.Network type who's .s_mag is proportional to the systematic error metric note: mathematically, this is mean_s(|mean_c(r)|) where: r: complex residual errors mean_c: complex mean taken accross connection mean_s: complex mean taken accross standard` mean_residuals(self) plot_coefs_db(self, ax=None, show_legend=True, **kwargs) `plot magnitude of the error coeficient dictionary` plot_errors(self, std_names=None, *args, **kwargs) `plot calibration error metrics for an over-determined calibration. see biased_error, unbiased_error, and total_error for more info` plot_residuals(self, attribute, *args, **kwargs) `plots a component of the residual errors on the Calibration-plane. takes: attribute: name of ploting method of Network class to call possible options are: 'mag', 'db', 'smith', 'deg', etc *args,**kwargs: passed to plot_s_'atttribute'() note: the residuals are calculated by: (apply_cal(self.measured[k])-self.ideals[k])` plot_residuals_db(self, *args, **kwargs) `see plot_residuals` plot_residuals_mag(self, *args, **kwargs) `see plot_residuals` plot_residuals_smith(self, *args, **kwargs) `see plot_residuals` plot_uncertainty_per_standard(self, *args, **kwargs) `see uncertainty_per_standard` run(self) `runs the calibration algorihtm. this is automatically called the first time any dependent property is referenced (like error_ntwk), but only the first time. if you change something and want to re-run the calibration use this.` total_error(self, std_names=None) `estimate of total error for overdetermined calibration with multiple connections of each standard. This is the combined effects of both biased and un-biased errors takes: std_names: list of strings to uniquely identify each standard.* returns: composit error: mwavepy.Network type who's .s_mag is proportional to the composit error metric note: mathematically, this is std_cs(r) where: r: complex residual errors std_cs: standard deviation taken accross connections and standards` unbiased_error(self, std_names=None) `estimate of unbiased error for overdetermined calibration with multiple connections of each standard takes: std_names: list of strings to uniquely identify each standard.* returns: stochastic error: mwavepy.Network type who's .s_mag is proportional to the stochastic error metric see also: uncertainty_per_standard, for this a measure of unbiased errors for each standard note: mathematically, this is mean_s(std_c(r)) where: r: complex residual errors std_c: standard deviation taken accross connections mean_s: complex mean taken accross standards` uncertainty_per_standard(self, std_names=None, attribute='s') `given that you have repeat-connections of single standard, this calculates the complex standard deviation (distance) for each standard in the calibration across connection #. takes: std_names: list of strings to uniquely identify each standard.* attribute: string passed to func_on_networks to calculate std deviation on a component if desired. ['s'] returns: list of mwavepy.Networks, whose magnitude of s-parameters is proportional to the standard deviation for that standard *example: if your calibration had ideals named like: 'short 1', 'short 2', 'open 1', 'open 2', etc. you would pass this mycal.uncertainty_per_standard(['short','open','match'])` Data descriptors defined here: Ts `T-matricies used for de-embeding, a two-port calibration.` __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` coefs `coefs: a dictionary holding the calibration coefficients for one port cal's 'directivity':e00 'reflection tracking':e01e10 'source match':e11 for 7-error term two port cal's TODO:` error_ntwk `a Network type which represents the error network being calibrated out.` frequency `frequency object for the calibration` nports `the number of ports in the calibration` nstandards `number of ideal/measurement pairs in calibration` output_from_cal `a dictionary holding all of the output from the calibration algorithm` residual_ntwks `returns a the residuals for each calibration standard in the form of a list of Network types. these residuals are calculated in the 'calibrated domain', meaning they are r = (E.inv ** m - i) where, r: residual network, E: embedding network, m: measured network i: ideal network This way the units of the residual networks are meaningful note: the residuals are only calculated if they are not existent. so, if you want to re-calculate the residual networks then you delete the property '_residual_ntwks'.` residuals `if calibration is overdeteremined, this holds the residuals in the form of a vector. also available are the complex residuals in the form of mwavepy.Network's, see the property 'residual_ntwks' from numpy.lstsq: residues: the sum of the residues; squared euclidean norm for each column vector in b (given ax=b)` type `string representing what type of calibration is to be performed. supported types at the moment are: 'one port': standard one-port cal. if more than 2 measurement/ideal pairs are given it will calculate the least squares solution. 'two port': two port calibration based on the error-box model note: algorithms referenced by calibration_algorithm_dict, are stored in calibrationAlgorithms.py` Data and other attributes defined here: calibration_algorithm_dict = {'one port': <function one_port>, 'one port nls': <function one_port_nls>, 'one port parametric': <function parameterized_self_calibration>, 'one port parametric bounded': <function parameterized_self_calibration_bounded>, 'two port': <function two_port>, 'two port parametric': <function parameterized_self_calibration>}

Functions
`` |  | error_dict_2_network(coefs, frequency=None, is_reciprocal=False, **kwargs) `convert a dictionary holding standard error terms to a Network object. takes: returns:` rand(...) `rand(d0, d1, ..., dn) Random values in a given shape. Create an array of the given shape and propagate it with random samples from a uniform distribution over ``[0, 1)``. Parameters ---------- d0, d1, ..., dn : int Shape of the output. Returns ------- out : ndarray, shape ``(d0, d1, ..., dn)`` Random values. See Also -------- random Notes ----- This is a convenience function. If you want an interface that takes a shape-tuple as the first argument, refer to `random`. Examples -------- >>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random` two_port_error_vector_2_Ts(error_coefficients) `## Functions`

Data
`` |  | ALMOST_ZER0 = 1e-06 f_wr1 = <mwavepy.frequency.Frequency object> f_wr10 = <mwavepy.frequency.Frequency object> f_wr1p5 = <mwavepy.frequency.Frequency object> f_wr2p2 = <mwavepy.frequency.Frequency object> f_wr3 = <mwavepy.frequency.Frequency object> mil = 2.5399999999999997e-05 pi = 3.141592653589793 wr1 = Rectangular Waveguide Media. 750-1100 GHz. 201 points a= 2.54e-04m, b= 1.27e-04m wr10 = Rectangular Waveguide Media. 75-110 GHz. 201 points a= 2.54e-03m, b= 1.27e-03m wr1p5 = Rectangular Waveguide Media. 500-750 GHz. 201 points a= 3.81e-04m, b= 1.90e-04m wr2p2 = Rectangular Waveguide Media. 330-500 GHz. 201 points a= 5.59e-04m, b= 2.79e-04m wr3 = Rectangular Waveguide Media. 220-325 GHz. 201 points a= 7.62e-04m, b= 3.81e-04m