Skip to content

Commit cd9ac03

Browse files
authored
Merge pull request #11 from SASlabgroup/remove-time-selection
2 parents b10f51d + 11a306c commit cd9ac03

3 files changed

Lines changed: 9 additions & 58 deletions

File tree

app.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Set the default mission to the first mission in the list.
2929
all_missions = get_missions()
30-
default_mission = all_missions[0]['value']
30+
default_mission = all_missions[0]["value"]
3131

3232
# Define the layout of the app
3333
app.layout = html.Div(
@@ -50,13 +50,6 @@
5050
html.Br(),
5151
dcc.Dropdown(id="buoy_id"),
5252
html.Br(),
53-
html.Div(
54-
[
55-
html.P("Time Selection | Frequency v Energy"),
56-
dcc.Dropdown(id="time_dropdown"),
57-
],
58-
id="time_selection",
59-
),
6053
html.Hr(),
6154
dbc.Card(id="latest_info", body=True),
6255
html.Footer("Version 0.8"),
@@ -108,17 +101,15 @@ def update_ids(mission):
108101
[
109102
Output("graph_area", "children"),
110103
Output("latest_info", "children"),
111-
Output("time_selection", "style"),
112104
],
113105
[Input("buoy_id", "value")],
114106
)
115107
def update_layout(buoy_id):
116108
if buoy_id == "All":
117-
style = {"display": "none"}
118-
return multi_layout, multi_info_card, style
109+
return multi_layout, multi_info_card
119110
else:
120111
style = {"display": "block"}
121-
return single_layout, single_info_card, style
112+
return single_layout, single_info_card
122113

123114

124115
# Update multi-buoy graphs
@@ -145,24 +136,6 @@ def update_multi(buoy_id, mission):
145136
return no_update, no_update, no_update, no_update
146137

147138

148-
# Update time dropdown options for single buoy
149-
@callback(
150-
[Output("time_dropdown", "options"), Output("time_dropdown", "value")],
151-
[Input("buoy_id", "value"), Input("mission_dropdown", "value")],
152-
)
153-
def update_time_dropdown(buoy_id, mission):
154-
if buoy_id != "All":
155-
start_date, end_date = get_mission_time(mission)
156-
df = get_swift_data([buoy_id], start_date, end_date)
157-
if df is not None:
158-
df["times"] = pd.to_datetime(df["time"])
159-
date_strings = df["times"].dt.strftime("%Y-%m-%d %H:%M:%S%z").tolist()
160-
options = [{"label": date, "value": date} for date in date_strings]
161-
value = date_strings[0]
162-
return options, value
163-
return no_update, no_update
164-
165-
166139
# Update single buoy graphs and info
167140
@callback(
168141
[
@@ -181,10 +154,9 @@ def update_time_dropdown(buoy_id, mission):
181154
[
182155
Input("buoy_id", "value"),
183156
Input("mission_dropdown", "value"),
184-
Input("time_dropdown", "value"),
185157
],
186158
)
187-
def update_single(buoy_id, mission, selected_time_str):
159+
def update_single(buoy_id, mission):
188160
if buoy_id != "All":
189161
start_date, end_date = get_mission_time(mission)
190162
df = get_swift_data([buoy_id], start_date, end_date)
@@ -198,7 +170,7 @@ def update_single(buoy_id, mission, selected_time_str):
198170
spectrogram_fig=no_update,
199171
)
200172
if df is not None:
201-
single_graphs = get_single_graphs(df, buoy_id, selected_time_str)
173+
single_graphs = get_single_graphs(df)
202174
# Info Card
203175
single_graphs.current_id = buoy_id
204176
single_graphs.buoy_info = single_card(df, buoy_id)

graphs.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
self.buoy_info = no_update
6464

6565

66-
def get_single_graphs(df, buoy_id, selected_time_str) -> SingleGraphs:
66+
def get_single_graphs(df) -> SingleGraphs:
6767
# Time Series Graphs
6868
# peak_direction = px.line(df, x='time', y='peak_direction', title='Peak Direction Over Time')
6969
# peak_period = px.line(df, x='time', y='peak_period', title='Peak Period Over Time')
@@ -101,30 +101,6 @@ def get_single_graphs(df, buoy_id, selected_time_str) -> SingleGraphs:
101101
hover_data=hover_data,
102102
)
103103

104-
# Frequency vs Energy Graphs
105-
selected_time = pd.to_datetime(selected_time_str)
106-
plot_df = pd.DataFrame(
107-
{
108-
"Frequency (Hz)": df.loc[(buoy_id, selected_time), "frequency"],
109-
"Energy Density": df.loc[(buoy_id, selected_time), "energy_density"],
110-
}
111-
)
112-
113-
# loglog = px.line(
114-
# plot_df,
115-
# x="Frequency (Hz)",
116-
# y="Energy Density",
117-
# title="Energy Density vs. Frequency (LogLog)",
118-
# log_x=True,
119-
# log_y=True,
120-
# )
121-
# linear = px.line(
122-
# plot_df,
123-
# x="Frequency (Hz)",
124-
# y="Energy Density",
125-
# title="Energy Density vs. Frequency (Linear)",
126-
# )
127-
128104
# Spectrogram
129105
spectrogram_fig = spectrogram(df)
130106

spectrogram_plot.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def spectrogram(microswift_df):
88
time_1d = microswift_df["time"]
99
time_2d = np.tile(time_1d, (frequency_2d.shape[1], 1)).T
1010

11+
# Replace zero or negative values with a small positive value (e.g., 1e-10)
12+
energy_density_2d[energy_density_2d <= 0] = 1e-10
13+
1114
fig = go.Figure(
1215
data=go.Heatmap(
1316
x=frequency_2d.flatten(),

0 commit comments

Comments
 (0)