本文整理匯總了Python中phildb.database.PhilDB.read方法的典型用法代碼示例。如果您正苦於以下問題:Python PhilDB.read方法的具體用法?Python PhilDB.read怎麽用?Python PhilDB.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phildb.database.PhilDB
的用法示例。
在下文中一共展示了PhilDB.read方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_read_unique
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_read_unique(self):
db = PhilDB(self.test_tsdb)
results = db.read('410730', 'D')
self.assertEqual(results.values[0], 1)
self.assertEqual(results.values[1], 2)
self.assertEqual(results.values[2], 3)
示例2: test_read_non_unique
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_read_non_unique(self):
db = PhilDB(self.test_tsdb)
db.add_measurand('P', 'PRECIPITATION', 'Precipitation')
db.add_timeseries_instance('410730', 'D', 'Foo', measurand = 'P', source = 'DATA_SOURCE')
with self.assertRaises(MultipleResultsFound) as context:
results = db.read('410730', 'D')
示例3: test_read
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_read(self):
db_name = os.path.join(self.test_data_dir, 'test_tsdb')
db = PhilDB(db_name)
results = db.read('410730', 'D', measurand = 'Q', source = 'DATA_SOURCE')
self.assertEqual(results.index[0].year, 2014)
self.assertEqual(results.index[0].month, 1)
self.assertEqual(results.index[0].day, 1)
self.assertEqual(results.index[1].day, 2)
self.assertEqual(results.index[2].day, 3)
self.assertEqual(results.values[0], 1)
self.assertEqual(results.values[1], 2)
self.assertEqual(results.values[2], 3)
示例4: test_update_and_append
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_update_and_append(self):
db = PhilDB(self.test_tsdb)
db.write('410730', 'D', pd.Series(index = [datetime(2014,1,2), datetime(2014,1,3), datetime(2014,1,4), datetime(2014,1,5), datetime(2014,1,6)], data = [2.5, 3.0, 4.0, 5.0, 6.0]), measurand = 'Q', source = 'DATA_SOURCE')
data = db.read('410730', 'D', measurand = 'Q', source = 'DATA_SOURCE')
self.assertEqual(1.0, data.values[0])
self.assertEqual(2.5, data.values[1])
self.assertEqual(3.0, data.values[2])
self.assertEqual(4.0, data.values[3])
self.assertEqual(5.0, data.values[4])
self.assertEqual(6.0, data.values[5])
self.assertEqual(datetime(2014,1,1), data.index[0].to_pydatetime())
self.assertEqual(datetime(2014,1,2), data.index[1].to_pydatetime())
self.assertEqual(datetime(2014,1,3), data.index[2].to_pydatetime())
self.assertEqual(datetime(2014,1,4), data.index[3].to_pydatetime())
self.assertEqual(datetime(2014,1,5), data.index[4].to_pydatetime())
self.assertEqual(datetime(2014,1,6), data.index[5].to_pydatetime())
示例5: test_new_write
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_new_write(self):
db = PhilDB(self.test_tsdb)
db.add_timeseries('410731')
db.add_timeseries_instance('410731', 'D', 'Foo', measurand = 'Q', source = 'DATA_SOURCE')
db.write('410731', 'D', pd.Series(index = [datetime(2014,1,1), datetime(2014,1,2), datetime(2014,1,3)], data = [1.0, 2.0, 3.0]), measurand = 'Q', source = 'DATA_SOURCE')
results = db.read('410731', 'D', measurand = 'Q', source = 'DATA_SOURCE')
self.assertEqual(results.index[0].year, 2014)
self.assertEqual(results.index[0].month, 1)
self.assertEqual(results.index[0].day, 1)
self.assertEqual(results.index[1].day, 2)
self.assertEqual(results.index[2].day, 3)
self.assertEqual(results.values[0], 1.0)
self.assertEqual(results.values[1], 2.0)
self.assertEqual(results.values[2], 3.0)
示例6: test_log_write
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
def test_log_write(self):
db = PhilDB(self.test_tsdb)
db.add_timeseries('410731')
db.add_timeseries_instance('410731', 'D', 'Foo', measurand = 'Q', source = 'DATA_SOURCE')
dates = [datetime(2014,1,1), datetime(2014,1,2), datetime(2014,1,3)]
db.write('410731', 'D', pd.Series(index = dates, data = [1.0, 2.0, 3.0]), measurand = 'Q', source = 'DATA_SOURCE')
db.write('410731', 'D', pd.Series(index = dates, data = [1.0, 2.5, 3.0]), measurand = 'Q', source = 'DATA_SOURCE')
db.write('410731', 'D', pd.Series(index = [datetime(2014,1,4)], data = [4.0]), measurand = 'Q', source = 'DATA_SOURCE')
results = db.read('410731', 'D')
self.assertEqual(results.values[0], 1.0)
self.assertEqual(results.values[1], 2.5)
self.assertEqual(results.values[2], 3.0)
self.assertEqual(results.values[3], 4.0)
with tables.open_file(db.get_file_path('410731', 'D', ftype='hdf5'), 'r') as hdf5_file:
log_grp = hdf5_file.get_node('/data')
self.assertEqual(log_grp.log[0][0], 1388534400)
self.assertEqual(log_grp.log[0][1], 1.0)
self.assertEqual(log_grp.log[0][2], 0)
self.assertEqual(log_grp.log[1][0], 1388620800)
self.assertEqual(log_grp.log[1][1], 2.0)
self.assertEqual(log_grp.log[2][0], 1388707200)
self.assertEqual(log_grp.log[2][1], 3.0)
self.assertEqual(log_grp.log[3][0], 1388620800)
self.assertEqual(log_grp.log[3][1], 2.5)
self.assertEqual(log_grp.log[4][0], 1388793600)
self.assertEqual(log_grp.log[4][1], 4.0)
示例7: PhilDB
# 需要導入模塊: from phildb.database import PhilDB [as 別名]
# 或者: from phildb.database.PhilDB import read [as 別名]
import sys
import numpy as np
from phildb.database import PhilDB
db = PhilDB(sys.argv[1])
ac = np.array(
[ (hrs_id, db.read(hrs_id, 'D', measurand = 'Q', source = 'BOM_HRS').autocorr()) for hrs_id in db.ts_list()],
dtype = [('name','S8'),('val',float)]
)
for station in ac[ac['val'] >= 0.95]:
print station['name'], station['val']