python 如何在曲线拟合时忽略某些值(例如NaNs)?

ss2ws0br  于 2022-12-17  发布在  Python
关注(0)|答案(1)|浏览(241)

看一下下面的图像。在左边,你可以看到一个2D数组img_roiplt.imshow图。在右边,我首先确定最大值,然后沿着垂直方向切割,即

centre = np.unravel_index(np.argmax(img_roi, axis=None), img_roi.shape)
x_profile = img_roi[:, centre[1]]

然后我用正态分布拟合曲线,可以看出,由于每隔一个像素就有一个特定的因子,所以拟合看起来并不好,尽管曲线明显是高斯的。
为完整起见,数据如下

x_profile = [ 1.50000000e+00 -7.00000000e-01 -2.70000000e+00  2.80000000e+00
  3.00000000e-01  5.00000000e-01  2.50000000e+00  1.10000000e+00
 -1.00000000e-01  8.10000000e+00  6.90000000e+00  7.53000000e+01
  2.14000000e+01  2.31000000e+02  4.68000000e+01  4.84900000e+02
  8.91000000e+01  7.47500000e+02  1.16400000e+02  8.62900000e+02
  1.13100000e+02  7.01300000e+02  8.74000000e+01  4.46700000e+02
  4.70000000e+01  2.01900000e+02  1.69000000e+01  4.68000000e+01
  7.50000000e+00  1.60000000e+00  3.50000000e+00  4.20000000e+00
  4.00000000e-01  9.10000000e+00  7.10542736e-15  5.50000000e+00
  2.60000000e+00  5.00000000e-01  2.50000000e+00  1.40000000e+00]

我的目标是仅使用亮像素值拟合高斯,而不丢失它们不是近邻而是次近邻的信息。

我知道有一些“简单”的修复方法,例如:每隔一个像素,拟合,然后重新缩放。

x_profile_squish = x_profile[::2] - Fit to this

把“不太亮”的像素设置为零是行不通的。我可以缩放它们来匹配亮的像素,但这没有抓住重点。如何进行高斯拟合是很清楚的。

问题是否有办法将每隔一个像素设置为empty或Python在拟合时直接丢弃的某个值?或者是否有另一种方法告诉scipy在拟合时忽略某些值?

编辑:这里是完整的2D数据(它相当大)

img_roi = [[ 3.10000000e+00  1.60000000e+00 -3.90000000e+00  4.10000000e+00
  -4.10000000e+00  3.10000000e+00  4.00000000e-01 -6.00000000e-01
   1.60000000e+00 -2.00000000e-01 -3.00000000e-01  3.00000000e-01
   3.00000000e-01  1.30000000e+00  9.00000000e-01  2.70000000e+00
  -1.80000000e+00 -6.00000000e-01  3.50000000e+00  2.00000000e+00
   1.30000000e+00 -7.00000000e-01  9.00000000e-01  7.10542736e-15
  -4.00000000e-01 -3.00000000e-01  3.00000000e-01  2.50000000e+00
  -2.20000000e+00  7.00000000e-01  2.40000000e+00 -9.00000000e-01
   7.00000000e-01  6.00000000e-01  2.70000000e+00  7.00000000e-01
   1.50000000e+00  1.40000000e+00  1.30000000e+00  9.00000000e-01]
 [ 7.00000000e-01  2.10000000e+00  1.30000000e+00  1.20000000e+00
   7.00000000e-01 -1.30000000e+00  3.20000000e+00 -3.90000000e+00
   2.50000000e+00 -2.40000000e+00  3.00000000e-01  1.70000000e+00
   6.00000000e-01  1.30000000e+00 -9.00000000e-01  1.00000000e-01
   1.00000000e+00  3.00000000e+00  2.00000000e-01  2.00000000e+00
   1.10000000e+00  2.00000000e-01 -1.00000000e-01  1.20000000e+00
   1.20000000e+00  6.00000000e-01  5.00000000e-01  9.00000000e-01
  -4.00000000e-01  7.00000000e-01 -1.00000000e-01 -9.00000000e-01
   3.10000000e+00  4.00000000e-01  1.10000000e+00  6.00000000e-01
   2.00000000e-01  3.00000000e-01 -1.00000000e-01  3.00000000e-01]
 [-3.30000000e+00 -3.00000000e-01 -2.00000000e-01  7.00000000e-01
   1.40000000e+00  4.00000000e-01  1.40000000e+00 -6.00000000e-01
   5.00000000e-01 -5.00000000e-01  2.20000000e+00  2.00000000e-01
   1.60000000e+00  3.00000000e-01 -2.60000000e+00  4.00000000e-01
   9.00000000e-01  3.10000000e+00 -5.00000000e-01  2.00000000e-01
   1.70000000e+00  8.00000000e-01 -1.50000000e+00  7.10542736e-15
   6.00000000e-01 -3.00000000e-01  1.70000000e+00 -1.10000000e+00
   1.10000000e+00 -1.00000000e-01  1.10000000e+00  2.00000000e-01
   2.60000000e+00  1.00000000e-01 -6.00000000e-01  3.00000000e-01
   3.50000000e+00  5.30000000e+00  4.10000000e+00  4.90000000e+00]
 [-4.00000000e-01 -2.00000000e-01  7.00000000e-01  1.40000000e+00
   8.00000000e-01  1.40000000e+00  6.00000000e-01  3.30000000e+00
  -4.00000000e-01  1.40000000e+00 -4.00000000e-01  3.20000000e+00
   1.10000000e+00  2.70000000e+00  8.00000000e-01  1.50000000e+00
   4.00000000e-01  1.50000000e+00 -4.40000000e+00  1.60000000e+00
   3.00000000e-01  3.90000000e+00 -4.00000000e-01  2.00000000e+00
  -9.00000000e-01  1.00000000e-01  2.00000000e-01  2.80000000e+00
   5.00000000e-01 -3.00000000e-01  8.00000000e-01 -3.00000000e-01
   5.20000000e+00  2.80000000e+00  5.70000000e+00  3.10000000e+00
   4.60000000e+00 -6.00000000e-01  9.60000000e+00  1.30000000e+00]
 [ 7.00000000e-01  7.00000000e-01  5.00000000e-01  2.30000000e+00
  -2.40000000e+00  7.00000000e-01  8.00000000e-01  2.00000000e-01
   3.20000000e+00  1.00000000e-01  1.00000000e-01 -2.00000000e-01
   1.40000000e+00  1.00000000e+00 -4.20000000e+00  8.00000000e-01
   4.00000000e-01  3.30000000e+00  5.00000000e-01  4.00000000e-01
  -4.00000000e-01 -4.00000000e-01 -4.00000000e-01 -3.00000000e-01
   1.00000000e+00  8.00000000e-01  3.70000000e+00  7.00000000e-01
   9.00000000e-01 -6.00000000e-01  1.20000000e+00  6.20000000e+00
   1.10000000e+00  4.70000000e+00 -1.00000000e-01  9.90000000e+00
   1.80000000e+00  1.31000000e+01 -5.00000000e-01  8.70000000e+00]
 [-6.00000000e-01  1.30000000e+00  9.00000000e-01  8.00000000e-01
   0.00000000e+00 -6.00000000e-01  1.40000000e+00  6.00000000e-01
   1.80000000e+00  1.60000000e+00  5.20000000e+00  3.70000000e+00
  -8.00000000e-01  3.00000000e-01 -3.70000000e+00 -8.00000000e-01
   5.00000000e-01  3.10000000e+00  3.00000000e-01 -2.00000000e-01
   6.00000000e-01  2.20000000e+00 -9.00000000e-01  1.00000000e+00
  -7.00000000e-01  1.20000000e+00  2.00000000e+00  2.00000000e-01
   3.60000000e+00  1.90000000e+00  8.50000000e+00 -2.00000000e-01
   7.60000000e+00  1.30000000e+00  1.48000000e+01  3.80000000e+00
   1.24000000e+01  3.00000000e-01  1.33000000e+01  2.60000000e+00]
 [ 1.00000000e-01  3.00000000e-01  1.50000000e+00  6.00000000e-01
   3.00000000e-01  5.00000000e-01  1.40000000e+00  3.20000000e+00
  -4.60000000e+00  9.00000000e-01  1.10000000e+00  4.00000000e-01
   1.60000000e+00 -1.00000000e-01  5.00000000e-01  2.20000000e+00
   6.00000000e-01  2.00000000e+00  1.10000000e+00  7.00000000e-01
   2.00000000e+00  0.00000000e+00 -2.90000000e+00 -5.00000000e-01
   7.00000000e-01  3.20000000e+00  7.00000000e-01  2.60000000e+00
  -1.70000000e+00  4.30000000e+00  1.20000000e+00  5.00000000e+00
   1.80000000e+00  9.00000000e+00  1.60000000e+00  1.36000000e+01
   8.00000000e-01  2.18000000e+01  2.50000000e+00  2.26000000e+01]
 [ 5.40000000e+00 -6.00000000e-01 -2.00000000e-01  4.00000000e-01
  -2.00000000e-01 -2.00000000e-01 -6.00000000e-01  2.00000000e+00
   1.00000000e+00  8.00000000e-01  4.00000000e-01  4.10000000e+00
  -4.00000000e-01  3.10000000e+00 -2.70000000e+00  3.00000000e+00
   1.10000000e+00  2.80000000e+00  2.40000000e+00  4.00000000e-01
   2.90000000e+00 -1.70000000e+00 -7.00000000e-01  9.00000000e-01
   1.10000000e+00  7.00000000e-01  2.30000000e+00  1.70000000e+00
   5.00000000e-01 -3.10000000e+00  7.00000000e-01  2.70000000e+00
   4.90000000e+00  2.20000000e+00  1.17000000e+01  7.00000000e+00
   1.53000000e+01  2.60000000e+00  2.80000000e+01  4.40000000e+00]
 [ 3.30000000e+00 -1.00000000e-01  5.00000000e-01 -6.00000000e-01
   2.80000000e+00  1.90000000e+00  2.10000000e+00  5.00000000e-01
   2.30000000e+00 -8.00000000e-01  3.20000000e+00  4.10000000e+00
   1.00000000e+00 -9.00000000e-01  1.50000000e+00  8.00000000e-01
   1.30000000e+00  3.20000000e+00 -6.00000000e-01  3.00000000e-01
   2.30000000e+00  1.00000000e-01  3.60000000e+00  1.20000000e+00
   1.00000000e-01 -2.00000000e-01  1.00000000e+00  8.00000000e-01
   1.60000000e+00  1.90000000e+00 -1.00000000e-01  6.70000000e+00
  -6.00000000e-01  1.37000000e+01  6.00000000e-01  1.55000000e+01
   6.80000000e+00  2.90000000e+01  4.10000000e+00  2.77000000e+01]
 [-6.00000000e-01  2.00000000e+00  3.00000000e-01  4.00000000e-01
   0.00000000e+00  6.00000000e-01  1.50000000e+00  2.80000000e+00
   1.40000000e+00  1.70000000e+00  1.00000000e-01  2.50000000e+00
  -3.00000000e-01  3.00000000e+00  2.40000000e+00  2.60000000e+00
   6.00000000e+00  1.70000000e+00  4.00000000e+00  1.00000000e+00
   1.00000000e-01  9.00000000e-01 -3.00000000e-01 -1.40000000e+00
   1.03000000e+01  3.10000000e+00  1.11000000e+01  8.00000000e-01
   8.20000000e+00  6.00000000e-01  9.20000000e+00  1.00000000e+00
   1.29000000e+01  6.00000000e-01  1.79000000e+01  4.90000000e+00
   2.35000000e+01  5.30000000e+00  2.31000000e+01  7.40000000e+00]
 [ 1.00000000e-01  2.50000000e+00  2.80000000e+00  4.10000000e+00
  -3.00000000e+00 -8.00000000e-01  2.90000000e+00 -3.00000000e-01
   2.40000000e+00 -1.00000000e-01  3.20000000e+00  2.90000000e+00
  -5.00000000e-01  7.00000000e-01 -4.00000000e-01  6.50000000e+00
  -3.00000000e-01  4.30000000e+00  1.20000000e+00  4.60000000e+00
  -6.00000000e-01  3.20000000e+00  2.50000000e+00  1.97000000e+01
   4.40000000e+00  2.58000000e+01  4.80000000e+00  3.30000000e+01
   1.00000000e-01  2.34000000e+01  0.00000000e+00  1.72000000e+01
   3.60000000e+00  2.74000000e+01 -2.00000000e-01  3.04000000e+01
   5.70000000e+00  3.94000000e+01  5.00000000e+00  3.15000000e+01]
 [ 2.60000000e+00  3.60000000e+00 -4.00000000e-01  2.60000000e+00
   5.00000000e-01  2.30000000e+00  2.30000000e+00  7.00000000e-01
   4.00000000e-01  1.20000000e+00  9.00000000e-01  0.00000000e+00
   5.20000000e+00  1.60000000e+00  5.30000000e+00  2.90000000e+00
   5.90000000e+00  5.00000000e-01  6.00000000e-01  3.50000000e+00
   8.00000000e-01  3.40000000e+00  2.31000000e+01  5.10000000e+00
   5.82000000e+01  1.01000000e+01  7.56000000e+01  7.70000000e+00
   6.34000000e+01  8.50000000e+00  4.76000000e+01  7.50000000e+00
   4.03000000e+01  6.00000000e+00  4.40000000e+01  3.90000000e+00
   4.30000000e+01  3.40000000e+00  4.10000000e+01  9.70000000e+00]
 [ 3.00000000e-01  5.00000000e-01 -4.10000000e+00  1.00000000e-01
  -6.00000000e-01  2.90000000e+00  2.10000000e+00  3.00000000e-01
   3.10000000e+00 -4.00000000e-01 -1.10000000e+00  4.50000000e+00
   1.90000000e+00  2.90000000e+00  1.70000000e+00  4.10000000e+00
  -1.00000000e-01  5.60000000e+00  1.50000000e+00  2.50000000e+00
   1.30000000e+00  2.47000000e+01  1.17000000e+01  7.51000000e+01
   1.50000000e+01  1.15200000e+02  2.28000000e+01  1.30900000e+02
   1.29000000e+01  1.09500000e+02  1.21000000e+01  7.60000000e+01
   1.13000000e+01  6.12000000e+01  6.30000000e+00  5.38000000e+01
   4.20000000e+00  4.44000000e+01  4.70000000e+00  4.59000000e+01]
 [ 9.00000000e-01  4.00000000e-01  1.80000000e+00  5.00000000e-01
   2.00000000e-01  5.00000000e-01 -3.00000000e-01  5.00000000e-01
   8.00000000e-01  2.30000000e+00  1.80000000e+00  2.80000000e+00
   1.20000000e+00  3.00000000e+00  4.90000000e+00 -1.00000000e-01
   5.20000000e+00  4.00000000e-01  1.30000000e+00  3.70000000e+00
   2.45000000e+01  1.48000000e+01  8.45000000e+01  3.01000000e+01
   1.60100000e+02  3.88000000e+01  2.24200000e+02  3.32000000e+01
   2.21900000e+02  2.77000000e+01  1.59000000e+02  2.22000000e+01
   1.14200000e+02  1.60000000e+01  8.95000000e+01  1.01000000e+01
   5.86000000e+01  1.03000000e+01  5.06000000e+01  5.00000000e+00]
 [ 3.10000000e+00  2.00000000e-01  6.00000000e-01 -1.20000000e+00
   3.50000000e+00  4.00000000e-01  2.00000000e+00  3.00000000e-01
  -3.00000000e-01  1.10000000e+00  1.50000000e+00  9.00000000e-01
   1.00000000e+00  4.40000000e+00  2.50000000e+00 -2.00000000e-01
   2.90000000e+00  2.00000000e-01  1.90000000e+00  1.76000000e+01
   1.19000000e+01  8.60000000e+01  2.25000000e+01  2.11800000e+02
   4.67000000e+01  3.03900000e+02  4.53000000e+01  3.38200000e+02
   3.98000000e+01  2.85500000e+02  2.98000000e+01  2.05900000e+02
   2.00000000e+01  1.42400000e+02  1.32000000e+01  9.68000000e+01
   1.12000000e+01  5.57000000e+01  6.40000000e+00  4.90000000e+01]
 [-4.00000000e+00  0.00000000e+00 -2.90000000e+00  3.00000000e+00
   4.00000000e-01  3.10000000e+00  1.40000000e+00  8.00000000e-01
  -1.10000000e+00  8.00000000e-01  1.30000000e+00  0.00000000e+00
   4.10000000e+00  2.10000000e+00  5.30000000e+00  2.80000000e+00
  -1.00000000e-01  1.30000000e+00  1.60000000e+01  1.42000000e+01
   7.20000000e+01  2.89000000e+01  2.05000000e+02  5.11000000e+01
   3.58600000e+02  7.71000000e+01  4.28900000e+02  7.63000000e+01
   4.32700000e+02  5.68000000e+01  3.30600000e+02  4.14000000e+01
   2.33900000e+02  3.12000000e+01  1.50400000e+02  1.80000000e+01
   8.39000000e+01  9.40000000e+00  5.02000000e+01  6.70000000e+00]
 [ 1.60000000e+00  5.00000000e-01  6.00000000e-01  5.00000000e-01
   6.00000000e-01  1.00000000e+00  2.00000000e+00  6.00000000e-01
  -6.00000000e-01  3.00000000e-01  1.20000000e+00  8.00000000e-01
   2.30000000e+00  1.00000000e-01  3.40000000e+00  6.00000000e-01
   1.90000000e+00  4.60000000e+00  6.70000000e+00  5.37000000e+01
   1.62000000e+01  1.82300000e+02  5.04000000e+01  3.82500000e+02
   6.97000000e+01  5.40600000e+02  7.82000000e+01  5.44800000e+02
   7.65000000e+01  4.89900000e+02  5.67000000e+01  3.57800000e+02
   3.81000000e+01  2.19400000e+02  2.04000000e+01  1.48500000e+02
   1.32000000e+01  6.97000000e+01  6.10000000e+00  4.51000000e+01]
 [ 1.00000000e-01 -2.90000000e+00 -4.00000000e-01 -3.90000000e+00
   3.30000000e+00  8.00000000e-01 -9.00000000e-01  4.00000000e-01
   5.00000000e-01  1.80000000e+00  2.90000000e+00  1.00000000e-01
   9.00000000e-01 -1.60000000e+00 -9.00000000e-01  1.30000000e+00
   4.30000000e+00  6.00000000e+00  3.76000000e+01  2.17000000e+01
   1.44300000e+02  4.89000000e+01  3.33400000e+02  8.32000000e+01
   5.66200000e+02  1.09800000e+02  6.62000000e+02  1.16500000e+02
   6.38900000e+02  8.49000000e+01  4.89100000e+02  6.72000000e+01
   3.42200000e+02  4.13000000e+01  2.06000000e+02  2.02000000e+01
   1.09900000e+02  1.01000000e+01  4.38000000e+01  4.80000000e+00]
 [ 1.00000000e-01  7.00000000e-01 -3.30000000e+00  0.00000000e+00
   1.90000000e+00  2.20000000e+00  1.30000000e+00  7.10542736e-15
   7.00000000e-01  0.00000000e+00 -3.70000000e+00 -9.00000000e-01
   1.80000000e+00  3.80000000e+00  2.60000000e+00  2.50000000e+00
   3.10000000e+00  1.96000000e+01  9.80000000e+00  9.64000000e+01
   2.91000000e+01  2.77500000e+02  6.83000000e+01  5.17200000e+02
   8.77000000e+01  6.69000000e+02  1.14300000e+02  7.31000000e+02
   7.97000000e+01  6.14700000e+02  6.81000000e+01  4.53100000e+02
   4.72000000e+01  2.86100000e+02  3.10000000e+01  1.53000000e+02
   1.61000000e+01  6.66000000e+01  6.10000000e+00  3.09000000e+01]
 [ 3.30000000e+00 -9.00000000e-01  8.00000000e-01  6.00000000e-01
  -3.60000000e+00  1.10000000e+00 -2.00000000e-01  1.30000000e+00
   1.40000000e+00  3.00000000e-01  1.60000000e+00  1.00000000e-01
   0.00000000e+00 -5.00000000e-01  1.20000000e+00  6.00000000e-01
   8.40000000e+00  6.40000000e+00  5.73000000e+01  2.63000000e+01
   1.93700000e+02  6.28000000e+01  4.26900000e+02  9.50000000e+01
   6.18500000e+02  1.27700000e+02  7.38200000e+02  1.29800000e+02
   6.68100000e+02  9.69000000e+01  5.17600000e+02  6.49000000e+01
   3.69900000e+02  5.00000000e+01  2.18600000e+02  2.18000000e+01
   9.12000000e+01  9.20000000e+00  3.50000000e+01  2.50000000e+00]
 [ 8.00000000e-01 -2.90000000e+00  1.30000000e+00  2.50000000e+00
   1.50000000e+00 -5.80000000e+00  1.60000000e+00 -1.00000000e-01
   5.00000000e-01 -9.00000000e-01  4.00000000e-01 -6.00000000e-01
   1.80000000e+00  3.00000000e-01  2.70000000e+00  7.20000000e+00
   3.00000000e-01  2.53000000e+01  1.51000000e+01  1.14600000e+02
   3.40000000e+01  2.82100000e+02  6.08000000e+01  5.11400000e+02
   9.37000000e+01  6.59200000e+02  1.05600000e+02  7.09900000e+02
   9.21000000e+01  5.78900000e+02  6.34000000e+01  4.09200000e+02
   4.77000000e+01  2.77700000e+02  2.03000000e+01  1.27500000e+02
   1.08000000e+01  5.07000000e+01  7.00000000e+00  1.34000000e+01]
 [-3.10000000e+00  5.00000000e-01 -8.00000000e-01 -1.00000000e-01
   6.00000000e-01  4.90000000e+00 -1.30000000e+00  5.00000000e-01
  -4.00000000e-01  1.60000000e+00  1.00000000e-01 -4.00000000e-01
   1.30000000e+00  1.00000000e-01  2.70000000e+00  3.50000000e+00
   9.70000000e+00  5.40000000e+00  5.08000000e+01  2.58000000e+01
   1.67700000e+02  5.84000000e+01  3.53500000e+02  9.03000000e+01
   5.34100000e+02  1.15000000e+02  6.15400000e+02  1.13100000e+02
   5.86700000e+02  9.07000000e+01  4.21400000e+02  5.94000000e+01
   2.93800000e+02  3.84000000e+01  1.50200000e+02  1.29000000e+01
   6.51000000e+01  5.70000000e+00  1.63000000e+01  2.00000000e+00]
 [ 1.10000000e+00  9.00000000e-01 -1.00000000e-01  1.40000000e+00
  -1.20000000e+00  1.60000000e+00  8.00000000e-01 -4.00000000e-01
   4.00000000e-01 -9.00000000e-01  4.00000000e-01 -4.00000000e-01
   7.00000000e-01 -3.00000000e-01  9.00000000e-01  4.80000000e+00
   4.00000000e-01  2.11000000e+01  1.01000000e+01  8.35000000e+01
   2.32000000e+01  2.22400000e+02  4.82000000e+01  3.86300000e+02
   7.43000000e+01  4.94700000e+02  7.49000000e+01  5.27900000e+02
   6.54000000e+01  4.16900000e+02  4.92000000e+01  2.88200000e+02
   3.27000000e+01  1.70000000e+02  1.68000000e+01  7.52000000e+01
   7.10000000e+00  2.23000000e+01  2.70000000e+00  5.00000000e+00]
 [-4.00000000e-01  1.70000000e+00  1.50000000e+00  1.20000000e+00
  -5.00000000e-01 -7.00000000e-01 -1.20000000e+00  1.00000000e+00
   1.10000000e+00  1.30000000e+00  4.00000000e-01  2.00000000e-01
   1.10000000e+00  6.00000000e-01  1.60000000e+00  5.00000000e-01
   6.50000000e+00  5.80000000e+00  2.94000000e+01  1.96000000e+01
   1.01200000e+02  3.35000000e+01  2.30600000e+02  5.66000000e+01
   3.44300000e+02  6.62000000e+01  3.91000000e+02  7.62000000e+01
   3.59600000e+02  5.39000000e+01  2.44500000e+02  3.76000000e+01
   1.66200000e+02  1.88000000e+01  7.38000000e+01  9.60000000e+00
   2.49000000e+01 -6.00000000e-01  5.70000000e+00  3.70000000e+00]
 [-3.90000000e+00 -1.40000000e+00  6.00000000e-01 -4.30000000e+00
   3.20000000e+00  1.00000000e-01 -2.20000000e+00  8.00000000e-01
   2.00000000e-01  3.50000000e+00  2.20000000e+00 -2.00000000e-01
   2.60000000e+00  1.10000000e+00 -7.00000000e-01  6.50000000e+00
  -3.00000000e-01  1.62000000e+01  5.70000000e+00  4.84000000e+01
   1.29000000e+01  1.05300000e+02  2.76000000e+01  2.04400000e+02
   4.00000000e+01  2.86700000e+02  4.98000000e+01  2.74100000e+02
   4.12000000e+01  2.00200000e+02  3.19000000e+01  1.44300000e+02
   1.66000000e+01  7.23000000e+01  5.70000000e+00  2.51000000e+01
   9.00000000e-01  6.40000000e+00 -2.00000000e-01  1.30000000e+00]
 [ 2.60000000e+00  7.00000000e-01 -9.00000000e-01  9.00000000e-01
  -1.00000000e-01  7.00000000e-01  5.00000000e-01  1.70000000e+00
  -2.00000000e-01  7.00000000e-01  2.40000000e+00 -6.00000000e-01
   5.70000000e+00  1.10000000e+00  6.00000000e-01  7.00000000e-01
   4.30000000e+00  3.40000000e+00  1.38000000e+01  5.10000000e+00
   3.73000000e+01  1.86000000e+01  8.89000000e+01  2.53000000e+01
   1.55600000e+02  3.42000000e+01  1.67700000e+02  2.87000000e+01
   1.50400000e+02  2.54000000e+01  1.02000000e+02  1.38000000e+01
   5.65000000e+01  5.10000000e+00  2.24000000e+01 -2.00000000e-01
   7.60000000e+00  1.30000000e+00  6.00000000e-01  2.10000000e+00]
 [ 3.30000000e+00  1.30000000e+00  2.00000000e-01  2.30000000e+00
  -2.40000000e+00  7.00000000e-01 -9.00000000e-01  3.00000000e-01
   4.00000000e-01  3.20000000e+00  4.00000000e-01  5.70000000e+00
   1.40000000e+00  5.60000000e+00  2.10000000e+00  4.30000000e+00
   1.80000000e+00  7.00000000e+00 -5.00000000e-01  1.27000000e+01
   5.30000000e+00  3.72000000e+01  9.80000000e+00  6.43000000e+01
   1.13000000e+01  8.53000000e+01  1.39000000e+01  9.43000000e+01
   1.15000000e+01  6.44000000e+01  5.40000000e+00  3.70000000e+01
   5.80000000e+00  1.56000000e+01  5.00000000e-01  6.50000000e+00
  -2.10000000e+00  3.40000000e+00 -1.00000000e-01 -2.00000000e-01]
 [-4.00000000e-01  6.00000000e-01 -1.00000000e-01  3.40000000e+00
  -4.10000000e+00  3.00000000e-01  7.10542736e-15 -7.00000000e-01
   1.30000000e+00 -2.00000000e-01  1.60000000e+00  3.10000000e+00
   4.60000000e+00  6.00000000e-01  1.03000000e+01  2.60000000e+00
   5.90000000e+00  1.60000000e+00  4.20000000e+00  2.50000000e+00
   4.90000000e+00  7.20000000e+00  1.71000000e+01  1.05000000e+01
   3.25000000e+01  8.60000000e+00  3.43000000e+01  7.10000000e+00
   3.49000000e+01  5.80000000e+00  1.75000000e+01  2.70000000e+00
   6.50000000e+00  1.80000000e+00  3.20000000e+00  2.30000000e+00
  -2.00000000e-01  2.20000000e+00  1.10000000e+00 -1.00000000e-01]
 [-8.00000000e-01  4.10000000e+00  6.00000000e-01  1.00000000e+00
   0.00000000e+00  2.00000000e-01  3.00000000e-01  1.60000000e+00
  -1.20000000e+00 -1.00000000e-01  2.30000000e+00  5.70000000e+00
  -5.00000000e-01  5.50000000e+00  2.90000000e+00  6.70000000e+00
   3.10000000e+00  8.70000000e+00  2.10000000e+00  5.30000000e+00
   2.10000000e+00  5.20000000e+00  6.00000000e-01  8.40000000e+00
   4.50000000e+00  1.25000000e+01  3.60000000e+00  1.36000000e+01
   4.00000000e-01  6.30000000e+00  3.00000000e-01 -5.00000000e-01
   2.00000000e+00  1.70000000e+00  1.90000000e+00 -3.00000000e-01
   1.70000000e+00  8.00000000e-01  2.10000000e+00  4.50000000e+00]
 [ 2.60000000e+00 -2.70000000e+00  3.10000000e+00 -2.10000000e+00
   2.00000000e-01 -3.00000000e+00 -6.00000000e-01  5.00000000e-01
  -4.00000000e-01  9.00000000e-01  5.00000000e+00  3.20000000e+00
   5.10000000e+00 -1.00000000e-01  9.50000000e+00  1.50000000e+00
   1.03000000e+01  2.70000000e+00  1.25000000e+01  5.00000000e-01
   9.90000000e+00  1.00000000e+00  1.00000000e-01  1.20000000e+00
   6.00000000e-01  3.00000000e+00  8.00000000e-01  9.00000000e-01
   1.30000000e+00  1.70000000e+00 -4.30000000e+00  2.00000000e-01
   3.00000000e-01  3.30000000e+00 -1.40000000e+00 -2.40000000e+00
   3.30000000e+00  2.20000000e+00  4.50000000e+00  1.50000000e+00]
 [ 5.00000000e-01  4.00000000e-01 -5.00000000e-01  1.00000000e-01
   9.00000000e-01  8.00000000e-01  1.80000000e+00 -1.00000000e-01
   2.00000000e-01  3.00000000e-01  2.20000000e+00  5.70000000e+00
   3.00000000e-01  4.20000000e+00  3.00000000e-01  1.59000000e+01
   6.00000000e-01  1.37000000e+01  1.60000000e+00  1.19000000e+01
   1.70000000e+00  8.50000000e+00  4.00000000e-01  3.70000000e+00
   1.00000000e-01  9.00000000e-01  2.00000000e-01 -7.00000000e-01
   1.80000000e+00  7.00000000e-01  1.80000000e+00  0.00000000e+00
   3.00000000e+00 -1.00000000e-01  1.70000000e+00  5.00000000e-01
   1.60000000e+00  1.50000000e+00  3.00000000e-01  3.80000000e+00]
 [ 3.10000000e+00 -4.00000000e-01  7.00000000e-01 -4.00000000e-01
   6.00000000e-01  1.60000000e+00  6.00000000e-01 -1.10000000e+00
  -4.00000000e-01  8.00000000e-01  1.00000000e+00  1.40000000e+00
   7.00000000e-01 -3.00000000e-01  9.70000000e+00  2.10000000e+00
   1.30000000e+01  1.00000000e-01  1.75000000e+01  4.00000000e-01
   1.58000000e+01  6.00000000e-01  1.12000000e+01  1.80000000e+00
   8.00000000e+00 -3.00000000e+00  4.00000000e+00  2.20000000e+00
   3.90000000e+00  1.00000000e+00  4.40000000e+00  1.00000000e-01
  -1.00000000e-01  6.00000000e-01  0.00000000e+00  1.90000000e+00
   4.30000000e+00  3.00000000e+00  5.20000000e+00 -2.00000000e-01]
 [ 8.00000000e-01 -6.00000000e-01 -4.00000000e+00 -9.00000000e-01
   1.00000000e+00  3.10000000e+00  3.00000000e-01 -5.00000000e-01
   1.80000000e+00 -5.00000000e-01 -7.00000000e-01  3.30000000e+00
  -3.70000000e+00  4.70000000e+00  1.70000000e+00  9.90000000e+00
  -5.00000000e-01  1.18000000e+01  2.20000000e+00  1.34000000e+01
   1.20000000e+00  1.32000000e+01  1.20000000e+00  9.10000000e+00
   3.00000000e+00  9.00000000e+00  3.60000000e+00  7.10000000e+00
   1.10000000e+00  5.20000000e+00  2.70000000e+00  6.10000000e+00
   2.10000000e+00  4.50000000e+00  2.00000000e+00  7.60000000e+00
   1.00000000e+00  5.20000000e+00  1.90000000e+00  9.30000000e+00]
 [ 5.00000000e-01  2.80000000e+00 -7.00000000e-01  0.00000000e+00
   1.00000000e-01  8.00000000e-01 -3.70000000e+00  4.00000000e-01
   4.00000000e-01  4.50000000e+00  2.20000000e+00  8.00000000e-01
  -1.00000000e-01 -2.00000000e-01  1.50000000e+00  2.10000000e+00
   4.20000000e+00  3.40000000e+00  1.04000000e+01  1.60000000e+00
   9.80000000e+00  3.20000000e+00  1.07000000e+01  2.80000000e+00
   1.01000000e+01  1.30000000e+00  9.40000000e+00  5.10000000e+00
   6.90000000e+00  1.70000000e+00  4.70000000e+00  1.00000000e+00
   3.80000000e+00  2.20000000e+00  5.20000000e+00  1.20000000e+00
   9.40000000e+00  5.00000000e-01  4.10000000e+00  2.40000000e+00]
 [ 8.00000000e-01  6.00000000e-01 -3.00000000e-01 -1.00000000e+00
  -5.00000000e-01  5.00000000e-01 -3.00000000e-01  2.90000000e+00
  -2.40000000e+00  1.40000000e+00  3.40000000e+00  1.80000000e+00
  -6.00000000e-01 -4.10000000e+00  2.30000000e+00  1.30000000e+00
   1.50000000e+00  3.60000000e+00  1.10000000e+00  7.70000000e+00
   3.80000000e+00  1.08000000e+01  1.00000000e-01  1.37000000e+01
   7.00000000e-01  9.60000000e+00  2.00000000e-01  5.30000000e+00
   2.80000000e+00  8.60000000e+00  1.70000000e+00  2.50000000e+00
   3.70000000e+00  4.30000000e+00  5.00000000e-01  4.00000000e+00
  -2.00000000e-01  4.70000000e+00  2.70000000e+00  4.30000000e+00]
 [-3.60000000e+00 -5.00000000e-01  1.00000000e-01  6.00000000e-01
  -5.00000000e-01 -3.00000000e-01  4.00000000e-01  9.00000000e-01
   1.00000000e-01  6.00000000e-01  1.00000000e-01 -5.10000000e+00
   4.20000000e+00  1.10000000e+00  1.00000000e-01  1.90000000e+00
   7.10542736e-15  0.00000000e+00  4.60000000e+00  0.00000000e+00
   6.10000000e+00  4.00000000e-01  8.00000000e+00  1.60000000e+00
   3.50000000e+00  1.20000000e+00  6.50000000e+00 -4.00000000e-01
   9.20000000e+00  8.00000000e-01  4.20000000e+00  2.40000000e+00
   4.90000000e+00  3.00000000e+00  5.80000000e+00  2.80000000e+00
   4.40000000e+00 -7.00000000e-01 -1.00000000e-01  7.00000000e-01]
 [-2.00000000e-01  4.00000000e-01  3.00000000e+00  3.00000000e+00
  -3.60000000e+00 -4.10000000e+00 -1.00000000e-01 -1.42108547e-14
   5.00000000e-01 -1.00000000e-01 -4.00000000e-01 -1.00000000e-01
   2.20000000e+00  2.00000000e+00  1.40000000e+00  9.00000000e-01
   5.00000000e-01  1.80000000e+00 -6.00000000e-01 -6.00000000e-01
   2.60000000e+00  2.70000000e+00 -8.00000000e-01  3.00000000e-01
   3.10000000e+00  4.90000000e+00  1.40000000e+00  6.90000000e+00
   5.00000000e-01  5.30000000e+00  2.20000000e+00  4.70000000e+00
   2.20000000e+00  4.50000000e+00  1.30000000e+00 -1.10000000e+00
   4.10000000e+00  7.00000000e-01  1.30000000e+00  1.20000000e+00]
 [ 1.80000000e+00 -3.20000000e+00 -9.00000000e-01  1.80000000e+00
  -7.00000000e-01  8.00000000e-01  1.70000000e+00  3.40000000e+00
  -1.30000000e+00 -1.60000000e+00  4.00000000e-01  1.90000000e+00
   1.70000000e+00  2.00000000e-01 -3.80000000e+00 -1.00000000e-01
   6.00000000e-01  3.20000000e+00 -3.40000000e+00  1.10000000e+00
   2.00000000e+00  3.30000000e+00  1.00000000e+00  1.00000000e+00
  -3.00000000e-01  2.10000000e+00  1.50000000e+00  2.80000000e+00
   8.00000000e-01  2.60000000e+00  4.20000000e+00 -5.00000000e-01
   6.00000000e+00  3.70000000e+00  1.30000000e+00  2.80000000e+00
   1.20000000e+00  1.80000000e+00  0.00000000e+00  1.40000000e+00]
 [ 1.00000000e-01  2.30000000e+00 -1.50000000e+00  6.00000000e-01
  -4.00000000e-01  1.50000000e+00  1.00000000e-01  1.30000000e+00
  -8.00000000e-01 -6.00000000e-01  2.00000000e-01  1.10000000e+00
  -1.42108547e-14  1.20000000e+00 -3.40000000e+00  2.60000000e+00
  -2.50000000e+00  3.40000000e+00  6.00000000e-01 -2.00000000e-01
   1.00000000e+00 -2.00000000e-01  9.00000000e-01 -2.90000000e+00
   2.10000000e+00  1.50000000e+00 -1.20000000e+00  2.00000000e+00
   2.80000000e+00  7.50000000e+00 -9.00000000e-01  1.10000000e+00
   3.20000000e+00  5.30000000e+00  1.80000000e+00  3.10000000e+00
  -2.40000000e+00  5.00000000e-01  8.00000000e-01  3.60000000e+00]
 [ 7.00000000e-01  9.00000000e-01 -1.00000000e-01 -4.40000000e+00
   3.20000000e+00  0.00000000e+00  2.00000000e-01  1.00000000e-01
   0.00000000e+00  7.00000000e-01  1.90000000e+00  1.50000000e+00
  -3.00000000e-01 -2.00000000e+00  2.00000000e-01 -3.90000000e+00
   3.00000000e+00  1.00000000e+00 -1.00000000e-01  1.00000000e-01
   1.00000000e-01  1.20000000e+00 -2.50000000e+00  2.70000000e+00
  -3.90000000e+00  2.80000000e+00  0.00000000e+00  9.00000000e-01
   2.00000000e-01  1.30000000e+00  6.70000000e+00  2.90000000e+00
  -1.00000000e-01 -3.90000000e+00  2.00000000e-01 -2.90000000e+00
   3.10000000e+00  1.00000000e-01 -1.20000000e+00 -2.00000000e-01]]
bnlyeluc

bnlyeluc1#

我发现了一个相关的帖子,描述了一个适用于scipy.optimize.leastsq例程的解决方案。我首先将不相关的数据点设置为nan,然后使用mask = ~np.isnan(img_roi)屏蔽它们。
这对于上述目的是足够的。
答案链接:https://stackoverflow.com/a/30791245/12460839

相关问题