-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.py
44 lines (38 loc) · 1.34 KB
/
scheduler.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
from apscheduler.schedulers.blocking import BlockingScheduler
import sys
import datetime as dt
from oceanData import *
def plot_maps():
"""
Calls sst function with current date and time
"""
# by default, the function will use the current date. Iterate backwards by 1 day to get previous day's data.
start_date_ = dt.date.today() - dt.timedelta(days=1)
# start_date_ = dt.date.today()
end_date_ = dt.date.today()
# obtain current time in format '%Y-%m-%dT%H:%M:%SZ'
end_time_ = dt.datetime.now().strftime("%H:%M:%S")
# obtain start time 12h before end time
start_time_ = (dt.datetime.now() - dt.timedelta(hours=12)).strftime("%H:%M:%S")
sst(
start_date=f"{start_date_}",
start_time=start_time_,
end_date=f"{end_date_}",
end_time=f"{end_time_}",
bounding_box=(-45, -45, 45, 45),
plot_type="local"
)
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "test":
"""
Test plot maps function if argument "test" is passed
"""
print("Running one instance of plot_maps")
plot_maps()
else:
"""
Main function that calls plot_maps function for interval of 1 hour
"""
scheduler = BlockingScheduler()
scheduler.add_job(plot_maps, "interval", hours=1)
scheduler.start()