def add_scenecam(fname, cal_path): data_table = tables.openFile(fname, mode='r') data = data_table.root.ramppi11.rawdata[:] coords = [] sid = np.nan for row in data: # change calibration file according to session direction = [ row['g_direction_x'], row['g_direction_y'], row['g_direction_z'] ] if sid != row['session_id']: sid = row['session_id'] print sid fpath = os.path.join(cal_path, str(sid) + '.cal') if not os.path.exists(fpath): sys.exit('missing cal file: %s' %fpath) calibration = loadCalibration(fpath) result = LinearMappingXYZ2RK(calibration, direction) coords.append(result) if len(data) == len(coords): print 'writing...' x, y = zip(*coords) new_rec = tru.rec.append_field(data, 'scenecam_x', x, np.float) new_rec = tru.rec.append_field(new_rec, 'scenecam_y', y, np.float) newname = fname[:-5] + '_sc.hdf5' new_h5 = open_h5file(newname, 'ramppi11', mode="w") new_h5.createTable('/ramppi11', 'rawdata', new_rec) new_h5.close() else: print 'some data is missing - no output' data_table.close()
def add_to_h5(naksu_data, h5path): h5file = open_h5file(h5path, 'ramppi11', mode='a') set_table(h5file, 'ramppi11', 'naksu_data', naksu_data) h5file.close()