I was trying to plot data only on continent. I asked a question about this before and I’ve got the answer here.
Now when I implemented it in the code, the program will run without giving an error.
However, it RUNS FOREVER. When I use ctrl + C to force stop it, it traces back to "if not (map.is_land(X[i], Y[i])):", so I think there’s something wrong here. But I can’t figure it out.
Here is the part of code that involves picking out non-continental data and removing them:
X, Y = map(Lon,Lat)
ocean = []
for i in range(len(X)):
if not (map.is_land(X[i], Y[i])):
ocean.append(i)
X_new = np.delete(X, ocean)
Y_new = np.delete(Y, ocean)
HDO_new = np.delete(HDO, ocean)
Since you use a
forloop, the program should stop anyway, the only problem is how large isX. I can only give two suggestions:1) try to print the value of
len(X)before entering the for cicle to see how big is2) try to use
xrangeinstead ofrange, if you use python 2.xKeep also in mind that using list with some hundred thousand element seems to be slow.
Eventually try using a smaller data sample, if you can