def _read_raw_field(self, grid, field):
field_name = field[1]
base_dir = self.ds.index.raw_file
box_list = self.ds.index.raw_field_map[field_name][0]
fn_list = self.ds.index.raw_field_map[field_name][1]
offset_list = self.ds.index.raw_field_map[field_name][2]
lev = grid.Level
filename = base_dir + "Level_%d/" % lev + fn_list[grid.id]
offset = offset_list[grid.id]
box = box_list[grid.id]
lo = box[0]
hi = box[1]
shape = hi - lo + 1
with open(filename, "rb") as f:
f.seek(offset)
f.readline() # always skip the first line
arr = np.fromfile(f, 'float64', np.product(shape))
arr = arr.reshape(shape, order='F')
return arr
评论列表
文章目录