Converting A s2p to a html sheet

This notebook demonstrates how to convert a s2p touchstone file to an interactive html sheet.

Importing pyMez libraries

In [1]:
from pyMez import *
from pyMez.Code.DataHandlers.Translations import *
Importing pyMez, this should take roughly 30 seconds
Importing Code.DataHandlers.GeneralModels
It took 0.395023 s to import Code.DataHandlers.GeneralModels
Importing Code.DataHandlers.HTMLModels
It took 0.075004 s to import Code.DataHandlers.HTMLModels
Importing Code.DataHandlers.NISTModels
The module smithplot was not found,please put it on the python path
It took 0.560032 s to import Code.DataHandlers.NISTModels
Importing Code.DataHandlers.TouchstoneModels
It took 0.0 s to import Code.DataHandlers.TouchstoneModels
Importing Code.DataHandlers.XMLModels
It took 0.068004 s to import Code.DataHandlers.XMLModels
Importing Code.DataHandlers.ZipModels
It took 0.006 s to import Code.DataHandlers.ZipModels
Importing Code.InstrumentControl.Experiments
It took 3.034174 s to import Code.InstrumentControl.Experiments
Importing Code.InstrumentControl.Instruments
It took 0.001 s to import Code.InstrumentControl.Instruments
Importing Code.Utils.Names
It took 0.001 s to import Code.Utils.Names
It took 4.141237 s to import all of the active modules
C:\Users\sandersa\AppData\Local\Continuum\anaconda3\lib\site-packages\odo\backends\pandas.py:102: FutureWarning: pandas.tslib is deprecated and will be removed in a future version.
You can access NaTType as type(pandas.NaT)
  @convert.register((pd.Timestamp, pd.Timedelta), (pd.tslib.NaTType, type(None)))

Open the s2p file

In [2]:
s2p=S2PV1(os.path.join(os.getcwd(),"S2p_to_Html_Files/20160301_30ft_cable_0.s2p"))

Plot the file

In [3]:
s2p.show();

Transform the s2p to an xml sheet

In [5]:
# We transform to xml specifing format and a xsl style sheet
xml=S2PV1_to_XmlDataTable(s2p,format="MA",style_sheet=os.path.join(TESTS_DIRECTORY,"../XSL/S2P_MA_STYLE.xsl"))

Transform to html using an xsl style sheet

In [7]:
# this converts it to the text, we can use .save_HTML to save a file
html_text=xml.to_HTML()
In [8]:
# now we can load the html_text into a HTMLBase class to show in the browser and save 
html=HTMLBase(html_text=html_text)
In [9]:
# this displays it in the default browser
html.show()
file://C:/Users/sandersa/AppData/Local/Temp/1/tmp7jgg57hm.html
In [10]:
# to save it we just specify the path and save it
html.save(os.path.join(os.getcwd(),"S2p_to_Html_Files/20160301_30ft_cable_0.html"))
Out[10]:
'C:\\Users\\sandersa\\PyCharmProjects\\pyMez3\\Documentation\\Examples\\jupyter\\S2p_to_Html_Files/20160301_30ft_cable_0.html'

Saved html file