This is an example of how to apply a two-port calibration created by the Microwave Uncertainty Framework.
# we first import the SParameter module in the Analysis subpackage, this form also imports the base API
from pyMez.Code.Analysis.SParameter import *
# we just need to supply the file path for the s2p
s2p_file_path=r"./Applying_Calibration_Example_Files/Kit_Open_P1_C15102_P2_WR15_20180313_001.s2p"
# opening the file is just calling the S2PV1 class or the SNP class
s2p=S2PV1(s2p_file_path)
# to see a plot of the file use the show method
s2p.show();
# now open the correction s4p. This can be found in the VNAUncert_results/Solutions folder after running the MUF
s4p=SNP(r"./Applying_Calibration_Example_Files/Solution_0.s4p")
# to plot use the show method
s4p.show();
# now apply the correction. Here we are correcting the complex data so we acess the complex numbers directly
# This style is better than applying the correction using the s4p and s2p objects directly because it allows
# for corrections with out presuming a starting style except 2d-lists of complex numbers
corrected_sparameters=correct_sparameters_sixteen_term(sixteen_term_correction=s4p.sparameter_complex,
sparameters_complex=s2p.sparameter_complex)
# now we put these into a new s2p object
# The None parameter specifies a new file
corrected_s2p=S2PV1(None,sparameter_complex=corrected_sparameters)
# now we have a file with corrected sparameters, that we can show or save
corrected_s2p.show();
# Now we can save the file. To find the default file name inspect the path attribute.
corrected_s2p.path
# to save as another name just enter the new path
corrected_s2p.save(r'./Applying_Calibration_Example_Files/corrected_s2p.s2p')