def __init__(self, fname): self.f = minnow.open(fname) magic, version, self.file_type = self.f.header(0, "qqq") assert (magic == MAGIC) assert (version == VERSION) self.text = self.f.header(1, "s") self.names = self.f.header(2, "s") raw_columns = self.f.header(3, _column_type) self.L, self.boundary, self.cells = self.f.header(4, "ffq") self.blocks = self.f.header(5, "q") self.block_lengths = self.f.header(6, np.int64) self.columns = [None] * len(raw_columns) for i in range(len(raw_columns)): self.columns[i] = Column(raw_columns["type"][i], raw_columns["log"][i], raw_columns["low"][i], raw_columns["high"][i], raw_columns["dx"][i]) self.names = self.names.split("$") self.length = np.sum(self.block_lengths)
def read_int_record(fname): f = minnow.open(fname) magic, blocks = f.header(0, "qq") text = f.header(1, "s") lengths = f.header(2, np.int64) xs = [f.data(i) for i in range(blocks)] return text, xs
def open_q_float_record(fname): f = minnow.open(fname) dx1, dx2, low, high, x1_len, x2_len = f.header(0, "ffffqq") x1, x2 = [None] * x1_len, [None] * x2_len for i1 in range(x1_len): x1[i1] = f.data(i1) for i2 in range(x2_len): x2[i2] = f.data(i2 + x1_len) f.close() return x1, x2
def read_bit_int_record(fname): f = minnow.open(fname) x2_len = f.header(0, np.int64) x1 = f.data(0) x2 = [None] * x2_len for i in range(x2_len): x2[i] = f.data(1 + i) x3 = f.data(x2_len + 1) f.close() return x1, x2, x3
def read_group_record(fname): f = minnow.open(fname) bi, ni = f.header(0, "qq") bf, nf = f.header(1, "qq") text = f.header(2, "s") xi = np.zeros(ni * bi, dtype=np.int64) xf = np.zeros(nf * bf, dtype=np.float32) for i in range(bi): xi[i * ni:(i + 1) * ni] = f.data(i) for i in range(bf): xf[i * nf:(i + 1) * nf] = f.data(i + bi) return xi, xf, text