{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calrep Example\n",
    "An example of using the pyMez function Calrep to create uncertainties for one-port and two-port raw files generated by the HP Basic program measLP. MeasLP will be replaced with a python routine.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Importing pyMez, this should take roughly 30 seconds\n",
      "Importing Code.DataHandlers.GeneralModels\n",
      "It took 0.609 s to import Code.DataHandlers.GeneralModels\n",
      "Importing Code.DataHandlers.HTMLModels\n",
      "It took 0.188 s to import Code.DataHandlers.HTMLModels\n",
      "Importing Code.DataHandlers.NISTModels\n"
     ]
    }
   ],
   "source": [
    "from pyMez import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# open a raw file in the TESTS_DIRECTORY\n",
    "file_path=os.path.join(TESTS_DIRECTORY,\"CTN208.A1_011613\")\n",
    "raw_measurement=TwoPortRawModel(file_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "# check the data \n",
    "raw_measurement.show();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# now to calrep we just use the calrep function\n",
    "calrep_measurement=calrep(raw_measurement)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# use the plot_calrep \n",
    "plot_calrep(calrep_measurement);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Comparison of the text versions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "print(raw_measurement)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "print(calrep_measurement)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# A plot comparing the two files\n",
    "plot_calrep_results_comparison(calrep_model=calrep_measurement,results_model=raw_measurement);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
