-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobe_temp.py
47 lines (39 loc) · 1.06 KB
/
globe_temp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 18 18:54:34 2020
Getting weather over the globe by coordinates
@author: evgeniy
"""
import pyowm
import time
import pandas as pd
coord_list=[]
temperature_list=[]
temp_list=[]
longitude = -180
latitude = -90
i=0
while latitude <= 90:
while longitude<=180:
temp_list=[latitude,longitude]
coord_list.append(temp_list)
temp_list=[]
longitude = longitude+10
longitude = -180
latitude = latitude + 10
owm = pyowm.OWM('03730ab5ecad7256cbf0cd4e4ba95d0e')
temp_list=[]
while i<len(coord_list):
observation = owm.weather_at_coords(coord_list[i][0],coord_list[i][1])
w = observation.get_weather()
temp_list=w.get_temperature('celsius')# {'temp_max': 10.5, 'temp': 9.7, 'temp_min': 9.0}
del temp_list['temp_max']
del temp_list['temp_min']
del temp_list['temp_kf']
temp_list['latitude']=coord_list[i][0]
temp_list['longitude']=coord_list[i][1]
temperature_list.append(temp_list)
time.sleep(2)
temp_list=[]
i = i+1