-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (32 loc) · 1.57 KB
/
main.py
File metadata and controls
37 lines (32 loc) · 1.57 KB
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
import json
from data_visualization import Visualization
from data_processing import WeatherProcessing
class Weather:
#my main function which will help to build the project and get it running
def __init__(self):
self.visualization = Visualization()
self.data_processor = WeatherProcessing()
def open_weather_data(self):
# process the data from NOAA using the json file which i have saved all the data
# from the api in - retrieved from the website usign the api key they gave me when i signed up
#this website didnt give lots of data but it still worked pretty well.
try:
with open("noaa_weather_data_30_days.json", "r") as file:
noaa_data = json.load(file)
processed_noaa_data = self.data_processor.process_noaa_data(noaa_data)
if not processed_noaa_data.empty:
self.visualization.plot_noaa_data(processed_noaa_data)
except Exception as e:
print(f"Error with NOAA data: {e}")
# next up is to get the data from the meteo cvs, meteo did not require an api key, so the csv file given was used.
try:
self.data_processor.meteo_yearly_averages(
"open_meteo_climate_data.csv", "open_meteo_yearly_averages.csv"
)
self.visualization.plot_meteo_yearly_averages("open_meteo_yearly_averages.csv")
except Exception as e:
print(f"Error with Open-Meteo data: {e}")
if __name__ == "__main__":
#an instance
weather_info = Weather()
weather_info.open_weather_data()