-
Notifications
You must be signed in to change notification settings - Fork 0
/
EcmWeatherTools.py
52 lines (37 loc) · 1.21 KB
/
EcmWeatherTools.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
48
49
50
51
52
## Name of file: EcmWeatherTools.py
## Description: functions to grab often used weather data points
## Last Edited: 9/19/2022
## Last Edited By: jfitzpatrick
## Time in Development: 1 hour
# GOALS
# 7 day forecast based on zipcode https://api.weather.gov/gridpoints/BOX/71,90
# avg hi/low this week
# avg humidity this week
# projected wind speeds/ direction
# solar radiation for solar power projections https://openweathermap.org/api/solar-radiation
# solar projections?
# wind projections
import requests
import pgeocode
def getforecast(latlong):
url = 'https://api.weather.gov/points/' + str(latlong[0]) + ',' + str(latlong[1])
r = requests.get(url)
data = r.json()
return data['properties']['forecast']
def weekforecast(zipcode):
location = tolatlong(zipcode)
URL = getforecast(location)
r = requests.get(url = URL)
data = r.json()['properties']['periods']
print(data)
def solarRadiation(zipcode):
return True
def windForecast(zipcode):
return True
def humidityForecast(zipcode):
return True
def tolatlong(zipcode):
nomi = pgeocode.Nominatim('us')
place = nomi.query_postal_code(zipcode)
return [place['latitude'], place['longitude']]
weekforecast(14150)