简体   繁体   English

Python使用2d数组数据绘制轮廓线并找到中心

[英]Python plot contour lines using a 2d array data and find the center

I was reading a paper named 'Geolocation assessment for CrIS sensor data records', and there was a figure like this 我正在阅读一篇名为“ CrIS传感器数据记录的地理位置评估”的论文,上面有一个这样的图 在此处输入图片说明

The cost function is defined as the RMSE varying with the number of shifted pixels in the along- and cross-track directions. which means [-5,-5] is the pixel shift 5 steps along left and 5 steps along down from [0,0], and the value of [-5,-5] is a rmse between two dataset, which has been calculated. 这表示[-5,-5]是从[0,0]向左5步和向下5步的像素偏移,[-5,-5]的值是两个数据集之间的均方根值,计算。

I have a similar problem like this, but I have no idea how to plot the image like this, anyone knows? 我有类似的问题,但是我不知道如何绘制这样的图像,有人知道吗?

Edit: 编辑:

Now I know using pyplot.imshow(rmsedataset,...) could be plot like this, and they look like ellipses, how can I find the center of smallest ellipse(where + is)? 现在我知道使用pyplot.imshow(rmsedataset,...)可以这样绘制,并且它们看起来像椭圆,我如何找到最小椭圆的中心(其中+是)?

According to the paper. 根据论文。 Since each contour line can be treated as a closed ellipse, a fitting ellipse can be found, and the center of the ellipse reflects the minimum of the cost function.

Here is an example using numpy and matplotlib 这是使用numpymatplotlib的示例

First we create random numbers between 1500 to 5500 and create a 50 x 100 numpy array , then we simply plott the data that gives a color bar. 首先,我们创建1500至5500之间的随机数,并创建50 x 100 numpy数组,然后简单地绘制给出颜色条的数据。

Hope this helps. 希望这可以帮助。

Demo Code: 演示代码:

import numpy as np
from numpy import array
import matplotlib.pyplot as plt
import random


#Generate a list of 5000 int between 1200,5500
M = 5000
myList = [random.randrange(1200,5500)  for i in xrange(0,M)]

#Convert to 50 x 100 list
n = 50
newList = [myList[i:i+n] for i in range(0, len(myList), n)]

#Convert to 50 x 100 numpy array
nArray = array(newList)
print nArray

a11=nArray.reshape(50,100)
fig = plt.figure()
fig.suptitle('Test Title')
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.imshow(a11, cmap='hot')
plt.colorbar()
plt.show()

Plot 情节

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM