-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmission_utils.py
More file actions
50 lines (38 loc) · 1.12 KB
/
mission_utils.py
File metadata and controls
50 lines (38 loc) · 1.12 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
38
39
40
41
42
43
44
45
46
47
48
49
50
# mission_utils.py
import pandas as pd
df = pd.read_csv("mission_ids.csv")
df.set_index(["Mission"], inplace=True)
def get_missions():
"""
Get a list of mission options for dropdowns.
s
Returns:
list: List of dictionaries with 'label' and 'value' for each mission.
"""
missions = df.index
options = [{"label": mission, "value": mission} for mission in missions]
return options
def get_missions_ids(mission):
"""
Get a list of buoy IDs for a given mission.
Args:
mission (str): Mission name.
Returns:
list: List of buoy IDs.
"""
ids = df.loc[mission]["Buoy_ids"].split()
return ids
def get_mission_time(mission):
"""
Get the start and end times for a given mission.
Args:
mission (str): Mission name.
Returns:
tuple: Start and end times as datetime objects. End time can be None if not available.
"""
start = pd.Timestamp(df.loc[mission]["Starttime"])
end = df.loc[mission]["Endtime"].strip()
if end == "None":
return start, None
end = pd.Timestamp(end)
return start, end