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


Python DataBlock.values_from_property方法代码示例

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


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

示例1: test_5

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
    def test_5(self):
        d = DataBlock()
        d.comments = Comments(["Vgs=13", "Ig=14", "Datetime=2011-10-11 20:11:02",
                               "Vds=-13", "Calibration=SOLT"])
        fi = DimSweep("Freq", 3)
        gi = DimSweep("g", 4)
        d["Vds"] = hfarray([1, 2, 3], dims=(fi,))
        d["Id"] = hfarray([1, 2, 3, 4], dims=(gi,))
        d.comments.property["Ig"].unit = "mA"
        d.guess_units()
        d.values_from_property()

        self.assertEqual(d.Vds.unit, "V")
        self.assertAllclose(d.Vds, [1, 2, 3])
        self.assertEqual(d.Id.unit, "A")
        self.assertAllclose(d.Id, [1, 2, 3, 4])
        self.assertEqual(d.Freq.unit, "Hz")
        self.assertEqual(d.comments.property["Vgs"].unit, "V")
        self.assertEqual(d.comments.property["Ig"].unit, "mA")

        self.assertEqual(d.Ig, 14)
        self.assertEqual(d.Vgs, 13)
        self.assertEqual(d.Ig.unit, "mA")
        self.assertEqual(d.Vgs.unit, "V")
        self.assertTrue("Datetime" in d.allvarnames)
开发者ID:arsenovic,项目名称:hftools,代码行数:27,代码来源:test_data_block.py

示例2: test_1

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
    def test_1(self):
        d = DataBlock()
        fi = DimSweep("Freq", 3)
        gi = DimSweep("g", 4)
        d["Vds"] = hfarray([1, 2, 3], dims=(fi,))
        d["Id"] = hfarray([1, 2, 3, 4], dims=(gi,))
        d.guess_units()
        d.values_from_property()

        self.assertEqual(d.Vds.unit, "V")
        self.assertAllclose(d.Vds, [1, 2, 3])
        self.assertEqual(d.Id.unit, "A")
        self.assertAllclose(d.Id, [1, 2, 3, 4])
        self.assertEqual(d.Freq.unit, "Hz")
开发者ID:arsenovic,项目名称:hftools,代码行数:16,代码来源:test_data_block.py

示例3: read_hdf5

# 需要导入模块: from hftools.dataset import DataBlock [as 别名]
# 或者: from hftools.dataset.DataBlock import values_from_property [as 别名]
def read_hdf5(h5file, name="datablock", **kw):
    if isinstance(h5file, string_types):
        fil = h5py.File(h5file, "r")
    else:
        fil = h5file
    db = DataBlock()
    grp = fil[name]
    blockname = grp.attrs["Blockname"]
    if blockname.lower() == "none":
        blockname = None
    db.blockname = blockname
    comments = grp["Comments"]

    if "fullcomments" in comments and len(comments["fullcomments"]):
        db.comments = Comments([cast_unicode(x).strip() for x in np.array(comments["fullcomments"])])
    else:
        db.comments = Comments()
    ivardata = grp["ivardata"]
    vardata = grp["vardata"]
    for k in ivardata:
        v = ivardata[k]
        datadtype = v.attrs[r"info\dtype"] or None
        dimcls = dims_dict.get(v.attrs[r"info\class"], DimRep)
        unit = str(v.attrs.get(r"info\unit", "none"))
        if unit.lower() == "none":
            unit = None
        vdata = np.array(np.array(v), dtype=datadtype)
        dim = dimcls(k, vdata, unit=unit)
        db[k] = dim
    for k in vardata:
        v = vardata[k]
        datadtype = v.attrs[r"data\dtype"] or None
        dims = tuple(db.ivardata[cast_unicode(dimname)] for dimname in v.attrs[r"info\name"])
        unit = cast_unicode(v.attrs.get(r"data\unit", "none"))
        if unit.lower() == "none":
            unit = None
        db[k] = hfarray(np.array(v), dtype=datadtype, dims=dims, unit=unit)
    if isinstance(h5file, string_types):
        fil.close()

    if kw.get("property_to_vars", False):
        db.values_from_property()
    return db
开发者ID:arsenovic,项目名称:hftools,代码行数:45,代码来源:v_01.py


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