当前位置: 首页>>代码示例>>Python>>正文


Python DataBlock.Z0方法代码示例

本文整理汇总了Python中hftools.dataset.DataBlock.Z0方法的典型用法代码示例。如果您正苦于以下问题:Python DataBlock.Z0方法的具体用法?Python DataBlock.Z0怎么用?Python DataBlock.Z0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hftools.dataset.DataBlock的用法示例。


在下文中一共展示了DataBlock.Z0方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: proc_info

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import Z0 [as 别名]
def proc_info(info, f, data, fn, noisedata):
    info_list = info.upper().split()
    if len(info_list) == 5:
        info = freq_mult, twoporttype, datatype, rtype, z0 = info_list
    elif len(info_list) == 3:
        info = freq_mult, twoporttype, datatype = info_list
        z0 = 1.
    else:
        msg = ("# format should only have 5 values this one has %d" %
               len(info_list))
        raise TouchstoneError(msg)
    z0 = float(z0)
    f = f * freqmultdict[freq_mult]
    if fn is not None:
        fn = fn * freqmultdict[freq_mult]

    convfunc = dict(RI=re_im_to_complex,
                    DB=dB_angle_to_complex,
                    MA=mag_angle_to_complex)

    if datatype not in convfunc:
        pars = datatype
        msg = "Unknown dataformat: %s, valid formats: RI, DB, MAG" % pars
        raise TouchstoneError(msg)

    out = np.empty((data.shape[0], data.shape[1] // 2), dtype=np.complex128)

    out[...] = convfunc[datatype](data[:, ::2],  data[:, 1::2])
    if out.shape[1] == 1:
        out.shape = (out.shape[0], 1, 1)
    elif out.shape[1] == 4:
        out.shape = (out.shape[0], 2, 2)
        out = out.transpose(0, 2, 1)
    else:
        N = int(sqrt(out.shape[1]))
        out.shape = (out.shape[0], N, N)

    dims = (DimSweep("freq", f, unit="Hz"), )
    if fn is not None and len(f) == len(fn) and np.allclose(f, fn):
        noisedims = dims
    elif fn is None:
        noisedims = None
    else:
        noisedims = (DimSweep("freqn", fn, unit="Hz"), )
    out = make_matrix(out, dims)
    f = hfarray(f, dims)
    db = DataBlock()
    db[info[1]] = out
    if noisedata is not None:
        db.Rn = hfarray(noisedata[..., -1], dims=noisedims) * z0
        db.Fmin = 10 ** (hfarray(noisedata[..., 0], dims=noisedims) / 10)
        db.Gopt = hfarray(convfunc[datatype](noisedata[:, 1], noisedata[:, 2]),
                          dims=noisedims)
    db.Z0 = hfarray(z0, unit="Ohm")
    return db
开发者ID:hftools,项目名称:hftools,代码行数:57,代码来源:touchstone.py


注:本文中的hftools.dataset.DataBlock.Z0方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。