forked from ShubhamBhut/ocean_garbage_trajectory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (28 loc) · 1.39 KB
/
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
33
34
35
36
37
38
from trajectory_model.garbage_math_model import Garbage, simulate_garbage_movement
from data_collection.weatherData import meteomatics_data
import os
import datetime as dt
latitude = float(input("Enter the latitude: "))
longitude = float(input("Enter the longitude: "))
username = os.getenv("WEATHER_USERNAME")
password = os.getenv("WEATHER_PASSWORD")
parameters_meteomatics = ['wind_speed_2m:ms', 'wind_dir_2m:d', 'ocean_current_speed:ms', 'ocean_current_direction:d']
garbage = Garbage(latitude, longitude)
positions = [[latitude, longitude]]
startdate = dt.datetime.utcnow()
interval = dt.timedelta(hours=12)
year_balance = dt.timedelta(hours=8760)
for i in range(50):
latitude, longitude = garbage.get_position()
weather_data = meteomatics_data(username, password, latitude, longitude, parameters_meteomatics, startdate)[0]
world_map = meteomatics_data(username, password, latitude, longitude, parameters_meteomatics)[1]
current_velocity = weather_data.iloc[0]*18/5, weather_data.iloc[1]
air_velocity = weather_data.iloc[2]*18/5, weather_data.iloc[3]
map_Lon_lim = [-180,180]
if world_map == "Land":
for i in range(10-i):
positions.append(list(garbage.get_position()))
break
positions.append(simulate_garbage_movement(garbage, current_velocity, air_velocity, map_Lon_lim))
startdate = startdate + interval
print(positions)