當前位置: 首頁>>代碼示例>>Python>>正文


Python PropertyTree.parse_info方法代碼示例

本文整理匯總了Python中pycap.PropertyTree.parse_info方法的典型用法代碼示例。如果您正苦於以下問題:Python PropertyTree.parse_info方法的具體用法?Python PropertyTree.parse_info怎麽用?Python PropertyTree.parse_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pycap.PropertyTree的用法示例。


在下文中一共展示了PropertyTree.parse_info方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_export_eclab_ascii_format

# 需要導入模塊: from pycap import PropertyTree [as 別名]
# 或者: from pycap.PropertyTree import parse_info [as 別名]
    def test_export_eclab_ascii_format(self):
        # define dummy experiment
        # it is quicker than building an actual EIS experiment
        class DummyExperiment(Experiment):

            def __new__(cls, *args, **kwargs):
                return object.__new__(DummyExperiment)

            def __init__(self, ptree):
                Experiment.__init__(self)
        dummy = DummyExperiment(PropertyTree())
        # produce dummy data for the experiment
        # here just a circle on the complex plane
        n = 10
        f = ones(n, dtype=float)
        Z = ones(n, dtype=complex)
        for i in range(n):
            f[i] = 10**(i / (n - 1))
            Z[i] = cos(2 * pi * i / (n - 1)) + 1j * sin(2 * pi * i / (n - 1))
        dummy._data['frequency'] = f
        dummy._data['impedance'] = Z
        # need a supercapacitor here to make sure method inspect() is kept in
        # sync with the EC-Lab headers
        ptree = PropertyTree()
        ptree.parse_info('super_capacitor.info')
        super_capacitor = EnergyStorageDevice(ptree)
        dummy._extra_data = super_capacitor.inspect()

        # export the data to ECLab format
        eclab = ECLabAsciiFile('untitled.mpt')
        eclab.update(dummy)

        # check that all lines end up with Windows-style line break '/r/n'
        # file need to be open in byte mode or the line ending will be
        # converted to '\n'...
        # also check that the number of lines in the headers has been computed
        # correctly and that the last one contains the column headers
        with open('untitled.mpt', mode='rb') as fin:
            lines = fin.readlines()
            for line in lines:
                self.assertNotEqual(line.find(b'\r\n'), -1)
                self.assertNotEqual(line.find(b'\r\n'), len(line) - 4)
            header_lines = int(lines[1].split(
                b':')[1].lstrip(b'').rstrip(b'\r\n'))
            self.assertEqual(
                header_lines,
                len(eclab._unformated_headers)
            )
            self.assertEqual(lines[header_lines - 1].find(b'freq/Hz'), 0)

        # check Nyquist plot does not throw
        nyquist = NyquistPlot('nyquist.png')
        nyquist.update(dummy)
開發者ID:ORNL-CEES,項目名稱:Cap,代碼行數:55,代碼來源:test_impedance_spectroscopy.py

示例2: Copyright

# 需要導入模塊: from pycap import PropertyTree [as 別名]
# 或者: from pycap.PropertyTree import parse_info [as 別名]
# Copyright (c) 2016, the Cap authors.
#
# This file is subject to the Modified BSD License and may not be distributed
# without copyright and license information. Please refer to the file LICENSE
# for the text and further information on this license.

from pycap import PropertyTree, EnergyStorageDevice
from pycap import Charge
from pycap import initialize_data
from mpi4py import MPI
import unittest

comm = MPI.COMM_WORLD
filename = 'series_rc.info'
ptree = PropertyTree()
ptree.parse_info(filename)
device = EnergyStorageDevice(ptree, comm)


class capChargeTestCase(unittest.TestCase):

    def test_charge_constant_current(self):
        ptree = PropertyTree()
        ptree.put_string('charge_mode', 'constant_current')
        ptree.put_double('charge_current', 10e-3)
        ptree.put_string('charge_stop_at_1', 'voltage_greater_than')
        ptree.put_double('charge_voltage_limit', 1.4)
        ptree.put_double('time_step', 0.2)
        charge = Charge(ptree)
        data = initialize_data()
        charge.run(device, data)
開發者ID:ORNL-CEES,項目名稱:Cap,代碼行數:33,代碼來源:test_charge_discharge.py


注:本文中的pycap.PropertyTree.parse_info方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。