Program runs forever without giving an error when plotting data only on continent [closed]
2024/11/15 17:17:02
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)
Answer
Since you use a for loop, the program should stop anyway, the only problem is how large is X. I can only give two suggestions:
1) try to print the value of len(X) before entering the for cicle to see how big is
2) try to use xrange instead of range, if you use python 2.x
Keep 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
1st i need to get two equation of two longest line length i put lenghths with eq in list like these [( length 1 , eq 1 ) ,.....]
sort list with reverse
get two equation of two longest line when run the…
I have a problem ... How can i press P on my keyboard and close the entire program faster ( i would like instantly ) ? The script that i made runs in a loop ( Loop B ) and checks for an image on deskt…
the program asks user to enter 5 unique number, if the number is already in the list, ask for a new number. after 5 unique numbers have been entered, display the listnumbers = [1,2,3,4,5]
count = 0
ind…
Given the following nested list,myList=([1,[2,3],[[4,5,[6],7],8,9]])I want to reverse it to be converted into:myList= [[[4, 5, [6], 7], 8, 9], [2, 3], 1]How do I do that?
Thanks.
Is there any way to extract a street address from a string (say, email) using python? The address does not come in a set format. It can come without state, zip code, city, but I can guess and supply t…
This question already has an answer here:Hawaiian pronouncer(1 answer)Closed 1 year ago.Hitting a snag with an assignment and thought Id ask for help. The goal is to be able to pronounce Hawaiian words…
Ive tried to use pyscript in html but i can only get it to work in one line of code can somebody help me get it to work for the following code?
def vpn(website):from selenium import webdriverfrom sele…
I have a Windows command which I want to write to stdout and to a file. For now, I only have 0 string writen in my file:#!/usr/bin/env python3
#! -*- coding:utf-8 -*-import subprocesswith open(auto_cha…