-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.py
34 lines (20 loc) · 795 Bytes
/
main.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
import yaml
from pathlib import Path
import pandas as pd
from src.power_api import PowerAPI
def main():
# ------- Read configuration -------
config_file = 'config.yaml'
with open(config_file, 'rb') as f:
conf = yaml.load(f, Loader=yaml.FullLoader)
latitude = conf.get('lat', 0)
longitude = conf.get('lon', 0)
start_date = conf.get('start_date', 0)
end_date = conf.get('end_date', 0)
output_dir = conf.get('output_dir', 0)
output_dir = Path(output_dir) / f"{longitude};{latitude}.csv"
nasa_weather = PowerAPI(start=pd.Timestamp(str(start_date)), end=pd.Timestamp(str(end_date)), long=longitude, lat=latitude)
weather_df = nasa_weather.get_weather()
weather_df.to_csv(output_dir, sep=";")
if __name__ == '__main__':
main()