Skip to content

Commit

Permalink
Merge pull request #33 from apkrelling/apply_precommit
Browse files Browse the repository at this point in the history
delete/comment unused code
  • Loading branch information
ocefpaf authored Jun 14, 2021
2 parents ea91614 + f8d4162 commit b276ea5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 36 deletions.
1 change: 0 additions & 1 deletion ERDDAP_timeseries_explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
" f_widget_search_max_time,\n",
" f_widget_search_min_time,\n",
" f_widget_std_names,\n",
" map_click_handler,\n",
" widget_replot_button,\n",
" widget_replot_button_handler,\n",
" widget_search_button,\n",
Expand Down
15 changes: 4 additions & 11 deletions erddap_app/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import ipywidgets as ipyw
import numpy as np
import pandas as pd
import pendulum
from erddapy import ERDDAP
from erddapy.url_handling import urlopen
from requests import HTTPError
Expand Down Expand Up @@ -44,17 +43,12 @@ def search_datasets(e, standard_name, cdm_data_type, min_time, max_time, skip_da
try:
row = df.loc[df["Dataset ID"] == skip_dataset].index[0]
df.drop(row, inplace=True)
except IndexError:
except IndexError: # this error arises when the stdname doesn't have any datasets to be skipped.
continue

except HTTPError:
df = []
if len(var) > 14:
v = f"{standard_name[:15]}..."
else:
v = standard_name
figure.title = f"No {v} found in this time range. Pick another variable."
figure.marks[0].y = 0.0 * figure.marks[0].y

return df


Expand Down Expand Up @@ -230,7 +224,7 @@ def get_valid_stdnames(server_name):
server.get("max_time"),
server.get("skip_datasets"),
)
except NameError:
except NameError: # this error arises when there is no df for this stdname.
continue

try:
Expand All @@ -243,7 +237,7 @@ def get_valid_stdnames(server_name):
if var != []:
valid_standard_names.append(standard_name)

except IndexError:
except IndexError: # this error arises when the only dataset available for this stdname was skipped.
del features, datasets
continue

Expand All @@ -268,7 +262,6 @@ def plot_datasets(server, e):
server.get("skip_datasets"),
)

dataset_id = datasets[0]
feature_layer = ipyl.GeoJSON(data=features)

# feature_layer.on_click(map_click_handler(e=e))
Expand Down
49 changes: 25 additions & 24 deletions erddap_app/widgets.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import ipyleaflet as ipyl
import ipywidgets as ipyw
import pendulum
from requests import HTTPError

from erddap_app.plots import stdname2geojson, update_timeseries_plot

# from requests import HTTPError

def map_click_handler(event=None, id=None, properties=None, feature=None):
"""The map_click_handler function updates the time series plot when a station marker is clicked"""

dataset_id = properties["datasetID"]
# def map_click_handler(event=None, id=None, properties=None, feature=None):
# """The map_click_handler function updates the time series plot when a station marker is clicked"""

min_time = pendulum.parse(widget_search_min_time.value)
max_time = pendulum.parse(widget_search_max_time.value)
constraints = {"time>=": min_time, "time<=": max_time}
# dataset_id = properties["datasetID"]

standard_name = widget_std_names.value
widget_dsnames.value = dataset_id
# min_time = pendulum.parse(widget_search_min_time.value)
# max_time = pendulum.parse(widget_search_max_time.value)
# constraints = {"time>=": min_time, "time<=": max_time}

# standard_name = widget_std_names.value
# widget_dsnames.value = dataset_id

try:
update_timeseries_plot(
e,
dataset=dataset_id,
standard_name=standard_name,
constraints=constraints,
)
except HTTPError:
print(
"No",
standard_name,
"data for this station. Please choose another station.",
)
# try:
# update_timeseries_plot(
# e,
# dataset=dataset_id,
# standard_name=standard_name,
# constraints=constraints,
# )
# except HTTPError:
# print(
# "No",
# standard_name,
# "data for this station. Please choose another station.",
# )


def widget_replot_button_handler(change):
Expand Down Expand Up @@ -137,7 +138,7 @@ def f_widget_search_max_time(server):
return widget_search_max_time


"""Create the Update Search button"""
# Create the Update Search button
widget_search_button = ipyw.Button(
value=False,
description="Update Search",
Expand Down Expand Up @@ -166,7 +167,7 @@ def f_widget_plot_stop_time(server):
return widget_plot_stop_time


"""Create the Update TimeSeries button """
# Create the Update TimeSeries button
widget_replot_button = ipyw.Button(
value=False,
description="Update TimeSeries",
Expand Down

0 comments on commit b276ea5

Please sign in to comment.