Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 使用某些数组从屏蔽数据中获取数据_Python 3.x_Numpy - Fatal编程技术网

Python 3.x 使用某些数组从屏蔽数据中获取数据

Python 3.x 使用某些数组从屏蔽数据中获取数据,python-3.x,numpy,Python 3.x,Numpy,如何使用某些数组从屏蔽数据中获取数据,例如,我有如下数据: x = np.random.normal(90,120,[100,1]) y = np.random.normal(-11,21,[100,1]) x1 = np.array([50,0,150,200,50]) y1 = np.array([10,-50,-60,0,10]) import numpy as np import matplotlib.pyplot as plt x = np.random.normal(90,120

如何使用某些数组从屏蔽数据中获取数据,例如,我有如下数据:

x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
area = (20*np.random.rand(100))**2
r = np.sqrt(x*x+y*y)
rb = np.sqrt(x1*x1+y1*y1)
area1 = np.ma.masked_where(r<rb,area)
area2 = np.ma.masked_where(r>=rb,area)
对于这样的帧,我有两个数组:

x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
area = (20*np.random.rand(100))**2
r = np.sqrt(x*x+y*y)
rb = np.sqrt(x1*x1+y1*y1)
area1 = np.ma.masked_where(r<rb,area)
area2 = np.ma.masked_where(r>=rb,area)
我想从之前创建的两个数组区域中获取一个文件

顺便说一句,我的完整脚本如下所示:

x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(90,120,[100,1])
y = np.random.normal(-11,21,[100,1])
x1 = np.array([50,0,150,200,50])
y1 = np.array([10,-50,-60,0,10])
area = (20*np.random.rand(100))**2
r = np.sqrt(x*x+y*y)
rb = np.sqrt(x1*x1+y1*y1)
area1 = np.ma.masked_where(r<rb,area)
area2 = np.ma.masked_where(r>=rb,area)
将numpy导入为np
将matplotlib.pyplot作为plt导入
x=np.随机.正态(90120[100,1])
y=np.随机.正态(-11,21,[100,1])
x1=np.数组([50,0150200,50])
y1=np.数组([10,-50,-60,0,10])
面积=(20*np.rand.rand(100))**2
r=np.sqrt(x*x+y*y)
rb=np.sqrt(x1*x1+y1*y1)
区域1=np.ma.屏蔽,其中(r=rb,区域)

签出
matplotlib.path.path.contains\u points
。这正是你想要的

下面是一个使用您对x、y、x1和y1的定义的示例(您可以随意调整):


您的问题可能重复,并提供了一些可能的解决方案,包括在实际问题中使用matplotlib的解决方案。@planetmaker,我仅将matplotlib用于数据可视化。我想要的目标是如何从要帧的数组中获取数据