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


Python TimeSeries.as_dict方法代码示例

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


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

示例1: test010

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test010(self):
     '''result of TimeSeries.as_dict is indexed on locationId
     parameterId 2-tuples'''
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     self.assertEquals(set([("600", "P1201"), ("600", "P2504")]),
                       set(obj.keys()))
     self.assertTrue(isinstance(obj[("600", "P1201")], TimeSeries))
     self.assertTrue(isinstance(obj[("600", "P2504")], TimeSeries))
开发者ID:nens,项目名称:timeseries,代码行数:10,代码来源:timeseries_tests.py

示例2: test024

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test024(self):
     'TimeSeries.write_to_pi_file writes dict to stream with 12 offset'
     stream = mock.Stream()
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     TimeSeries.write_to_pi_file(stream, obj, offset=12)
     target = file(self.testdata + "targetOutput12.xml").read()
     current = ''.join(stream.content)
     self.assertEquals(target.strip(), current.strip())
开发者ID:nens,项目名称:timeseries,代码行数:10,代码来源:timeseries_tests.py

示例3: test030

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test030(self):
     'TimeSeries.write_to_pi_file appends children to stream'
     stream = mock.Stream()
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     TimeSeries.write_to_pi_file(stream, obj, offset=0, append=True)
     target_lines = file(self.testdata + "targetOutput00.xml").readlines()[3:-1]
     target = ''.join(i.strip() for i in target_lines)
     current = ''.join(i.strip() for i in ''.join(stream.content).split('\n'))
     self.assertEquals(target, current)
开发者ID:nens,项目名称:timeseries,代码行数:11,代码来源:timeseries_tests.py

示例4: test111

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test111(self):
     'TimeSeries.as_dict reads events of series (b)'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P2504")]
     self.assertEquals([
             (str_to_datetime("2010-04-05", "00:00:00", 2), 17),
             (str_to_datetime("2010-04-08", "00:00:00", 2), 22),
             (str_to_datetime("2010-04-10", "00:00:00", 2), 24), ],
                       ts.get_values())
开发者ID:nens,项目名称:timeseries,代码行数:11,代码来源:timeseries_tests.py

示例5: test113

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test113(self):
     'TimeSeries.get_values with only requested timeseries'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P2504")]
     dates = [str_to_datetime("2010-04-05", "00:00:00", 2),
              str_to_datetime("2010-04-10", "00:00:00", 2)]
     self.assertEquals([
             (str_to_datetime("2010-04-05", "00:00:00", 2), (17, 0, '')),
             (str_to_datetime("2010-04-10", "00:00:00", 2), (24, 0, '')), ],
                       ts.get_events(dates=dates))
开发者ID:nens,项目名称:timeseries,代码行数:12,代码来源:timeseries_tests.py

示例6: test352

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
    def test352(self):
        'TimeSeries.as_dict filters based on timestamps from django QuerySet'

        DT = datetime
        testdata = django.QuerySet([
                {'location': '124',
                 'parameter': 'Q',
                 'events': [(DT(2011, 11, 11, 12, 20), 0.1, 8, ''),
                            (DT(2011, 11, 11, 12, 25), 0.2, 1, ''),
                            (DT(2011, 11, 11, 12, 30), 0.3, 2, '')]},
                ])
        end = DT(2011, 11, 11, 12, 25)
        obj = TimeSeries.as_dict(testdata, end=end)
        self.assertEquals(set([('124', 'Q')]), set(obj.keys()))
        self.assertEquals([((), {'timestamp__lte': end})], testdata.filtered)
开发者ID:nens,项目名称:timeseries,代码行数:17,代码来源:timeseries_tests.py

示例7: test110

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test110(self):
     'TimeSeries.as_dict reads events of series (a)'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P1201")]
     self.assertEquals([
             (str_to_datetime("2010-04-03", "00:00:00", 2), 20),
             (str_to_datetime("2010-04-04", "00:00:00", 2), 22),
             (str_to_datetime("2010-04-05", "00:00:00", 2), 17),
             (str_to_datetime("2010-04-06", "00:00:00", 2), 20),
             (str_to_datetime("2010-04-07", "00:00:00", 2), 21),
             (str_to_datetime("2010-04-08", "00:00:00", 2), 22),
             (str_to_datetime("2010-04-09", "00:00:00", 2), 24),
             (str_to_datetime("2010-04-10", "00:00:00", 2), 24),
             (str_to_datetime("2010-04-11", "00:00:00", 2), 24),
             (str_to_datetime("2010-04-12", "00:00:00", 2), 22), ],
                       ts.get_values())
开发者ID:nens,项目名称:timeseries,代码行数:18,代码来源:timeseries_tests.py

示例8: test100

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test100(self):
     'TimeSeries.as_dict reads events of series (a)'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     ts = obj[("600", "P1201")]
     self.assertEquals([
             (str_to_datetime("2010-04-03", "00:00:00", 2), (20, 0, '')),
             (str_to_datetime("2010-04-04", "00:00:00", 2), (22, 0, '')),
             (str_to_datetime("2010-04-05", "00:00:00", 2), (17, 0, '')),
             (str_to_datetime("2010-04-06", "00:00:00", 2), (20, 0, '')),
             (str_to_datetime("2010-04-07", "00:00:00", 2), (21, 0, '')),
             (str_to_datetime("2010-04-08", "00:00:00", 2), (22, 0, '')),
             (str_to_datetime("2010-04-09", "00:00:00", 2), (24, 0, '')),
             (str_to_datetime("2010-04-10", "00:00:00", 2), (24, 0, '')),
             (str_to_datetime("2010-04-11", "00:00:00", 2), (24, 0, '')),
             (str_to_datetime("2010-04-12", "00:00:00", 2), (22, 0, '')), ],
                       ts.get_events())
开发者ID:nens,项目名称:timeseries,代码行数:18,代码来源:timeseries_tests.py

示例9: test112

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
    def test112(self):
        """TimeSeries.as_dict reads events of series (c)

        This time series contains two values that should be ignored.

        """
        obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.missVal.xml")
        ts = obj[("600", "P1212")]
        self.assertEquals([
                (str_to_datetime("2010-04-03", "00:00:00", 2), 20),
                (str_to_datetime("2010-04-04", "00:00:00", 2), 22),
                (str_to_datetime("2010-04-05", "00:00:00", 2), 17),
                (str_to_datetime("2010-04-06", "00:00:00", 2), 20),
                (str_to_datetime("2010-04-07", "00:00:00", 2), 21),
                (str_to_datetime("2010-04-09", "00:00:00", 2), 24),
                (str_to_datetime("2010-04-11", "00:00:00", 2), 24),
                (str_to_datetime("2010-04-12", "00:00:00", 2), 22), ],
                          ts.get_values())
开发者ID:nens,项目名称:timeseries,代码行数:20,代码来源:timeseries_tests.py

示例10: test103

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
    def test103(self):
        """TimeSeries.as_dict reads events of series (d)

        This time series contains two values that should be ignored.

        """
        obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.no.missVal.xml")
        ts = obj[("600", "P1212")]
        self.assertEquals([
                (str_to_datetime("2010-04-03", "00:00:00", 2), (20, 0, '')),
                (str_to_datetime("2010-04-04", "00:00:00", 2), (22, 0, '')),
                (str_to_datetime("2010-04-05", "00:00:00", 2), (17, 0, '')),
                (str_to_datetime("2010-04-06", "00:00:00", 2), (20, 0, '')),
                (str_to_datetime("2010-04-07", "00:00:00", 2), (21, 0, '')),
                (str_to_datetime("2010-04-08", "00:00:00", 2), (-999.0, 0, '')),
                (str_to_datetime("2010-04-09", "00:00:00", 2), (24, 0, '')),
                (str_to_datetime("2010-04-10", "00:00:00", 2), (-999.0, 0, '')),
                (str_to_datetime("2010-04-11", "00:00:00", 2), (24, 0, '')),
                (str_to_datetime("2010-04-12", "00:00:00", 2), (22, 0, '')), ],
                          ts.get_events())
开发者ID:nens,项目名称:timeseries,代码行数:22,代码来源:timeseries_tests.py

示例11: test305

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
    def test305(self):
        'TimeSeries.as_dict reads from django QuerySet'

        DT = datetime
        testdata = django.QuerySet([
                {'location': '123',
                 'parameter': 'Q',
                 'events': [(DT(2011, 11, 11, 12, 20), 1.1, 8, ''),
                            (DT(2011, 11, 11, 12, 25), 1.2, 1, ''),
                            (DT(2011, 11, 11, 12, 30), 1.3, 2, '')]},
                {'location': '124',
                 'parameter': 'Q',
                 'events': [(DT(2011, 11, 11, 12, 20), 0.1, 8, ''),
                            (DT(2011, 11, 11, 12, 25), 0.2, 1, ''),
                            (DT(2011, 11, 11, 12, 30), 0.3, 2, '')]},
                ])
        obj = TimeSeries.as_dict(testdata)
        self.assertEquals(set([('123', 'Q'), ('124', 'Q')]), set(obj.keys()))
        self.assertEquals(set([1.1, 1.2, 1.3]), set(i[0] for i in obj[('123', 'Q')]._events.values()))
        self.assertEquals(set([0.1, 0.2, 0.3]), set(i[0] for i in obj[('124', 'Q')]._events.values()))
        self.assertEquals([], testdata.filtered)
开发者ID:nens,项目名称:timeseries,代码行数:23,代码来源:timeseries_tests.py

示例12: test_write_to_pi_file

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
def test_write_to_pi_file():
    """Test the way to write a TimeseriesStub-like object to a PI XML file."""
    series = \
        SparseTimeseriesStub(datetime(2011, 10, 25), [10.0, 20.0, 30.0])

    testdata = pkg_resources.resource_filename("timeseries", "testdata/")
    filename = "sluice-error.xml"
    filepath = os.path.join(testdata, filename)
    if filename in os.listdir(testdata):
        os.remove(filepath)

    write_to_pi_file(location_id="SAP", parameter_id="sluice-error",
        filename=filepath, timeseries=series)

    obj = TimeSeries.as_dict(filepath)

    if filename in os.listdir(testdata):
        os.remove(filepath)

    stored_events = [(e[0], e[1][0]) for e in obj[("SAP", "sluice-error")].get_events()]
    assert stored_events == list(series.events())
开发者ID:nens,项目名称:timeseries,代码行数:23,代码来源:timeseriesstub_tests.py

示例13: test_write_dict_to_pi_file

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
def test_write_dict_to_pi_file():
    """Test to write a dict of TimeseriesStub-like objects to a PI XML file."""
    dict_series =\
        {"precipitation": SparseTimeseriesStub(datetime(2011, 10, 25), [10.0, 20.0, 30.0]),
         "seepage": SparseTimeseriesStub(datetime(2011, 10, 25), [40.0, 50.0, 60.0]),
         }

    testdata = pkg_resources.resource_filename("timeseries", "testdata/")
    filename = "open-water-incoming-flows.xml"
    filepath = os.path.join(testdata, filename)
    if filename in os.listdir(testdata):
        os.remove(filepath)

    write_to_pi_file(location_id="SAP", filename=filepath, timeseries=dict_series)

    obj = TimeSeries.as_dict(filepath)

    if filename in os.listdir(testdata):
        os.remove(filepath)

    for parameter_id, series in dict_series.iteritems():
        stored_events = [(e[0], e[1][0]) for e in obj[("SAP", parameter_id)].get_events()]
        assert stored_events == list(series.events())
开发者ID:nens,项目名称:timeseries,代码行数:25,代码来源:timeseriesstub_tests.py

示例14: test000

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test000(self):
     'TimeSeries.as_dict accepts file name, returns dictionary'
     obj = TimeSeries.as_dict(self.testdata + "read.PI.timezone.2.xml")
     self.assertTrue(isinstance(obj, dict))
开发者ID:nens,项目名称:timeseries,代码行数:6,代码来源:timeseries_tests.py

示例15: test005

# 需要导入模块: from timeseries import TimeSeries [as 别名]
# 或者: from timeseries.TimeSeries import as_dict [as 别名]
 def test005(self):
     'TimeSeries.as_dict accepts open stream, returns dictionary'
     stream = file(self.testdata + "read.PI.timezone.2.xml")
     obj = TimeSeries.as_dict(stream)
     self.assertTrue(isinstance(obj, dict))
开发者ID:nens,项目名称:timeseries,代码行数:7,代码来源:timeseries_tests.py


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