tohsato-lab / bdmleditor

This is a editor for hdf5's file
0 stars 0 forks source link

指定した時間の指定したobjectを削除できるようにする #35

Open yukako opened 3 years ago

get-me-power commented 3 years ago

https://docs.h5py.org/en/stable/

ここから調べています

get-me-power commented 3 years ago

サンプルコード

import h5py
import numpy as np

with h5py.File('./data/AZ244-WT-3D-181218-01_fullmanual_edited.bd5.h5', 'r+') as f:
    swap_data = f['data/0/object/0'][()]
    print(swap_data[0])
    swap_data = np.delete(swap_data, 0)
    print(len(swap_data))
    print(swap_data[0])
    f.close()
get-me-power commented 3 years ago

プレスイベントのサンプリコード

import sys
import numpy as np
import matplotlib.pyplot as plt

def press(event):
    print('press', event.key)
    sys.stdout.flush()
    if event.key == 'x':
        print("ここ通ってる?")
        visible = xl.get_visible()
        xl.set_visible(not visible)
        print(visible)
        fig.canvas.draw()

# Fixing random state for reproducibility
np.random.seed(19680801)

fig, ax = plt.subplots()

fig.canvas.mpl_connect('key_press_event', press)

ax.plot(np.random.rand(12), np.random.rand(12), 'go')
xl = ax.set_xlabel('easy come, easy go')
ax.set_title('Press a key')
plt.show()
get-me-power commented 3 years ago
fig.canvas.mpl_disconnect(cid)

disconnectできるやんけ