LoginSignup
2
1

More than 5 years have passed since last update.

Numpy 配列の保存

Posted at

時間のかかる解析をしてできた配列を保存して、また使いたいときのために。

import numpy as np

pi = np.pi
x = np.linspace(-pi,pi,128)
y = np.cos(x)

filename = 'test'
np.savez(filename,x=x,y=y)

カレントディレクトリにtest.npzというファイル生成される。

import numpy as np

filename = 'test.npz'
data = np.load(filename)
x = data['x']
y = data['y']

import matplotlib.pyplot as plt

plt.plot(x,y)
plt.show()

cos.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1