0

从掩码数组中提取数据时,我没想到会出现以下行为。

我有以下 MaskedArray:

import numpy as np

data = [[7374.0, 10244.0, 7386.0, -0.16211003970504823],
        [7433.0, 12013.0, 7569.0, -0.2269431110203248],
        [6788.0, 9744.0, 6963.0, -0.1664571736397917],
        [6895.0, 14311.0, 7358.0, -0.3208731367391204],
        [8143.0, 10208.0, 7777.0, -0.13516819571865443]]

mask=[[False, False, False, False],
        [False, False, False, False],
        [False, False, False, False],
        [False, False, False, False],
        [False, False, False, False]]

z = np.ma.MaskedArray(data, mask=mask)

np.ma.getdata(z)  # extract the data only

我期待以下结果:

array([[7374.0, 10244.0, 7386.0, -0.16211003970504823],
        [7433.0, 12013.0, 7569.0, -0.2269431110203248],
        [6788.0, 9744.0, 6963.0, -0.1664571736397917],
        [6895.0, 14311.0, 7358.0, -0.3208731367391204],
        [8143.0, 10208.0, 7777.0, -0.13516819571865443]])

但我得到了:

array([[ 7.37400000e+03,  1.02440000e+04,  7.38600000e+03,  -1.62110040e-01],
       [ 7.43300000e+03,  1.20130000e+04,  7.56900000e+03,  -2.26943111e-01],
       [ 6.78800000e+03,  9.74400000e+03,  6.96300000e+03,  -1.66457174e-01],
       [ 6.89500000e+03,  1.43110000e+04,  7.35800000e+03,  -3.20873137e-01],
       [ 8.14300000e+03,  1.02080000e+04,  7.77700000e+03,  -1.35168196e-01]])
4

0 回答 0