def hfss_touchstone_2_media(filename, f_unit='ghz'): ''' Creates a :class:`~skrf.media.media.Media` object from a a HFSS-style touchstone file with Gamma and Z0 comments Parameters ------------ filename : string the HFSS-style touchstone file f_unit : ['hz','khz','mhz','ghz'] passed to f_unit parameters of Frequency constructor Returns -------- my_media : skrf.media.Media object the transmission line model defined by the gamma, and z0 comments in the HFSS file. Examples ---------- >>> port1_media, port2_media = rf.hfss_touchstone_2_media('line.s2p') See Also --------- hfss_touchstone_2_gamma_z0 : returns gamma, and z0 ''' f, gamma, z0 = hfss_touchstone_2_gamma_z0(filename) freq = Frequency.from_f(f) freq.unit = f_unit media_list = [] for port_n in range(gamma.shape[1]): media_list.append(\ Media( frequency = freq, propagation_constant = gamma[:, port_n], characteristic_impedance = z0[:, port_n] ) ) return media_list