numpy 拆分大型3D阵列并绘制成色彩Map表

8yoxcaq7  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(71)

我有一些3D结构化的数组数据,我想把它们处理成色彩Map表。
这个数组非常大,当我打印它时,它看起来像下面。

[[[9.24908975e-05 9.24908975e-05 9.24908975e-05 ... 9.52468407e-05
   9.52468407e-05 9.52468407e-05]
  [9.12154233e-05 9.12154233e-05 9.12154233e-05 ... 9.12154233e-05
   9.12154233e-05 9.12154233e-05]
  [9.23888998e-05 9.23888998e-05 9.23888998e-05 ... 9.23888998e-05
   9.23888998e-05 9.23888998e-05]
  ...
  [9.21707665e-05 9.21707665e-05 9.21707665e-05 ... 9.21707665e-05
   9.21707665e-05 9.21707665e-05]
  [9.17963675e-05 9.17963675e-05 9.17963675e-05 ... 9.17963675e-05
   9.17963675e-05 9.17963675e-05]
  [8.97908506e-05 8.97908506e-05 8.97908506e-05 ... 8.97908506e-05
   8.97908506e-05 8.97908506e-05]]

 [[9.22576003e-05 9.22576003e-05 9.22576003e-05 ... 9.36309637e-05
   9.36309637e-05 9.36309637e-05]
  [9.03873698e-05 9.03873698e-05 9.03873698e-05 ... 9.00975483e-05
   9.00975483e-05 9.00975483e-05]
  [8.98063145e-05 8.98063145e-05 8.98063145e-05 ... 9.98612139e-05
   9.98612139e-05 9.98612139e-05]
  ...
  [8.75216760e-05 8.75216760e-05 8.75216760e-05 ... 8.70995732e-05
   8.70995732e-05 8.70995732e-05]
  [9.43218047e-05 9.43218047e-05 9.43218047e-05 ... 9.43218047e-05
   9.43218047e-05 9.43218047e-05]
  [9.07522398e-05 9.07522398e-05 9.07522398e-05 ... 9.07522398e-05
   9.07522398e-05 9.07522398e-05]]

 [[8.90395026e-05 8.90395026e-05 8.90395026e-05 ... 8.90780029e-05
   8.90780029e-05 8.90780029e-05]
  [9.13763498e-05 9.13763498e-05 9.13763498e-05 ... 9.25795293e-05
   9.25795293e-05 9.25795293e-05]
  [8.81328146e-05 8.81328146e-05 8.81328146e-05 ... 1.11208607e-04
   1.11208607e-04 1.11208607e-04]
  ...
  [9.35448308e-05 9.35448308e-05 9.35448308e-05 ... 9.25673329e-05
   9.25673329e-05 9.25673329e-05]
  [9.34936602e-05 9.34936602e-05 9.34936602e-05 ... 9.34936602e-05
   9.34936602e-05 9.34936602e-05]
  [9.25817130e-05 9.25817130e-05 9.25817130e-05 ... 9.17516729e-05
   9.17516729e-05 9.17516729e-05]]

 ...

 [[9.12143559e-05 9.12143559e-05 9.12143559e-05 ... 9.34941116e-05
   9.34941116e-05 9.34941116e-05]
  [9.08949654e-05 9.08949654e-05 9.08949654e-05 ... 9.36052083e-05
   9.36052083e-05 9.36052083e-05]
  [9.12819229e-05 9.12819229e-05 9.12819229e-05 ... 1.01782794e-04
   1.01782794e-04 1.01782794e-04]
  ...
  [9.35687016e-05 9.35687016e-05 9.35687016e-05 ... 8.93653526e-05
   8.93653526e-05 8.93653526e-05]
  [9.03563247e-05 9.03563247e-05 9.03563247e-05 ... 9.19574670e-05
   9.19574670e-05 9.19574670e-05]
  [9.07462310e-05 9.07462310e-05 9.07462310e-05 ... 1.36651830e-04
   1.36651830e-04 1.36651830e-04]]

 [[8.71620653e-05 8.71620653e-05 8.71620653e-05 ... 8.93968411e-05
   8.93968411e-05 8.93968411e-05]
  [9.15776336e-05 9.15776336e-05 9.15776336e-05 ... 9.21726746e-05
   9.21726746e-05 9.21726746e-05]
  [9.02941371e-05 9.02941371e-05 9.02941371e-05 ... 9.77740590e-05
   9.77740590e-05 9.77740590e-05]
  ...
  [9.41974715e-05 9.41974715e-05 9.41974715e-05 ... 9.33400837e-05
   9.33400837e-05 9.33400837e-05]
  [9.20223845e-05 9.20223845e-05 9.20223845e-05 ... 9.20223845e-05
   9.20223845e-05 9.20223845e-05]
  [9.07600498e-05 9.07600498e-05 9.07600498e-05 ... 9.16629035e-05
   9.16629035e-05 9.16629035e-05]]

 [[9.49552855e-05 9.49552855e-05 9.49552855e-05 ... 9.49552855e-05
   9.49552855e-05 9.49552855e-05]
  [8.94452015e-05 8.94452015e-05 8.94452015e-05 ... 8.94452015e-05
   8.94452015e-05 8.94452015e-05]
  [8.66647224e-05 8.66647224e-05 8.66647224e-05 ... 8.66647224e-05
   8.66647224e-05 8.66647224e-05]
  ...
  [9.30367866e-05 9.30367866e-05 9.30367866e-05 ... 9.30367866e-05
   9.30367866e-05 9.30367866e-05]
  [9.42973310e-05 9.42973310e-05 9.42973310e-05 ... 9.42973310e-05
   9.42973310e-05 9.42973310e-05]
  [9.55101224e-05 9.55101224e-05 9.55101224e-05 ... 9.55101224e-05
   9.55101224e-05 9.55101224e-05]]]

字符串
在np. array中总共有48,400,000个数据。
实际上,它是1,000种不同条件下的484 * 10阵列。
我想显示一个484 * 10的数组,有1,000种不同的颜色,但由于我的知识有限,它不能在ATM上工作。
我的代码看起来像这样

import numpy as np
import matplotlib.pyplot as plt

data = np.load('C:/Users/**/***.npz', allow_pickle=True)
print(data.files)
print(data['weights'])

x = (data['weights'])
y = np.split(x, [4840]) # Here, i wanted to split data for each array
z = np.reshape(y, 4840*10) # Here, i wanted to reshape the array for colormap 

cs = plt.imshow(z)
plt.colorbar()
print(z.shape)
plt.show()

vpfxa7rd

vpfxa7rd1#

从你的代码开始,重塑你的数组,并对1000个2D数组中的每一个进行遍历:

import numpy as np
import matplotlib.pyplot as plt

data = np.load('C:/Users/**/***.npz', allow_pickle=True)
print(data.files)
print(data['weights'])

x = data['weights']
x = x.reshape((4840, 10, 1000))
for i in range(x.shape[2]): # x.shape[2] == 1000
    plt.imshow(x[:, i])
    plt.show()

字符串

相关问题