一、tutorial 1
1.定義錶類particle
class particle(isdescription):
name = stringcol(16) # 16-character string
idnumber = int64col() # signed 64-bit integer
adccount = uint16col() # unsigned short integer
tdccount = uint8col() # unsigned byte
grid_i = int32col() # 32-bit integer
grid_j = int32col() # 32-bit integer
pressure = float32col() # float (single-precision)
energy = float64col() # double (double)
2.新建檔案
h5file = open_file("c:/tutorial1.h5", mode = "w", title = "test file")
3.根建立組detector
group = h5file.create_group("/", 'detector', 'detector information')
4.組建立表readout
table = h5file.create_table(group, 'readout', particle, "readout example")
5.獲取行指標
particle = table.row
6.填充資料
8.獲取表引用
table = h5file.root.detector.readout
9.使用filter獲取條件資料
1)通用方式
pressure = [x['pressure'] for x in table.iterrows() if x['tdccount'] > 3 and 20 <= x['pressure'] < 50]
>>> pressure
[25.0, 36.0, 49.0]
2)核心和索引查詢
names = [x['name'] for x in table.where("""(tdccount>3)&(20<=pressure)&(pressure<50)""")]
>>> names
['particle: 5', 'particle: 6', 'particle: 7']
10.建立group columns
gcolumns = h5file.create_group(h5file.root, "columns", "pressure and name")
11.插入資料
pressure資料
h5file.create_array(gcolumns, 'pressure', pressure,"pressure column selection")
names資料
h5file.create_array(gcolumns, 'name', names, "name column selection")
12.關閉檔案
h5file.close()
二、tutorial 訓練
1.enum
import tables
colorlist = ['red', 'green', 'blue', 'white', 'black']
colors = tables.enum(colorlist)
print "value of 'red' and 'white':", (colors.red, colors.white)
print "value of 'red' and 'white':", (colors['red'], colors['white'])
print "name of value %s:" % colors.red, colors(colors.red)
h5f = tables.open_file('c:/enum.h5', 'w')
class ballext(tables.isdescription):
balltime = tables.time32col()
ballcolor = tables.enumcol(colors, 'black', base='uint8')
3.nested struct
from tables import *
class info(isdescription):
"""a sub-structure of test"""
_v_pos = 2 # the position in the whole structure
name = stringcol(10)
value = float64col(pos=0)
colors = enum(['red', 'green', 'blue'])
class nesteddescr(isdescription):
"""a description that has several nested columns"""
color = enumcol(colors, 'red', base='uint32')
info1 = info()
class info2(isdescription):
_v_pos = 1
name = stringcol(10)
value = float64col(pos=0)
class info3(isdescription):
x = float64col(dflt=1)
y = uint8col(dflt=1)
fileh = open_file("c:/nested-tut.h5", "w")
table = fileh.create_table(fileh.root, 'table', nesteddescr)
table.flush()
table.nrows
三、tutorial 2 指令碼
from tables import *
from numpy import *
# describe a particle record
class particle(isdescription):
name = stringcol(itemsize=16) # 16-character string
lati = int32col() # integer
longi = int32col() # integer
pressure = float32col(shape=(2,3)) # array of floats (single-precision)
temperature = float64col(shape=(2,3)) # array of doubles (double-precision)
# native numpy dtype instances are also accepted
event = dtype([
("name" , "s16"),
("tdccount" , uint8),
("adccount" , uint16),
("xcoord" , float32),
("ycoord" , float32)
])# open a file in "w"rite mode
fileh = open_file(r"c:/tutorial2.h5", mode = "w")
# get the hdf5 root group
root = fileh.root
# create the groups:
for groupname in ("particles", "events"):
group = fileh.create_group(root, groupname)
C Primer Chapter One學習筆記
筆記 1.流 從io裝置上讀入或寫出的字串行,用來說明字元隨時間順序生成或消耗。2.輸入輸出符可連用原因 operator 或operator 返回stream物件。3.要測試程式那個語句出錯,使用cout 4.新建乙個內建型別,如int i 0 最好先初始化,不然用到的時候沒初始化會產生奇怪的錯誤...
BroadcastReceiver學習筆記
需要注意 的是,不要在 onreceive 方法中新增過多的邏輯或者進行任何的耗時操作,因為在廣播接收 器中是不允許開啟執行緒的,當 onreceive 方法執行了較長時間而沒有結束時,程式就會報錯。有序broadcast,sendorderedbroadcast intent,null abort...
CDISC SDTM SE domain 學習筆記
整理翻譯自 sdtm ig 3.2 www.cdisc.org sdtm se subject elements 鞏固每個subject的epochs和elements的起止時間點.se對於有多個 時期的試驗有著重要的用處 如crossover試驗 se包含乙個subject從乙個element進入...