Python: How to create a loop to change longitude data -


i using python 3.6 map precipitation data onto continent. problem data have has longitude values ranging 0 360 , need data -180 180 in order map it. need create loop states if longitude > 180 new longitude= longitude-360. data: want loop through 56 years. x have longitude values stored

here have far:

lon=[] n in range(0,56):     lon=x[n]     if lon > 180:         lon=lon-360 np.save('filename',lon) 

does right? there examples similar problem? thanks!

check :

x=[100,200,400,500,100,181,179] lon=[] n in x:     if n > 180:         lon.append(n-360)     else:         lon.append(n) 

by using np.where:

x=np.asarray(x) np.where(x >180,x-360,x) 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -