Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -216,13 +216,25 @@ def vectors_plot(ds, bathy, longitude_range, latitude_range ,
|
|
| 216 |
return fig
|
| 217 |
|
| 218 |
class SADCP_Viewer(param.Parameterized):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
df = load_csv()
|
| 220 |
bathy = load_bathymetry()
|
| 221 |
tree=load_zarr()
|
| 222 |
file_names = df["file_name"].tolist()
|
| 223 |
years = sorted(df["year"].unique())
|
| 224 |
|
| 225 |
-
# Widgets
|
| 226 |
year_slider = pn.widgets.IntRangeSlider(name="Year Range", start=df["year"].min(), end=df["year"].max())
|
| 227 |
file_dropdown = pn.widgets.Select(name="File Selector")
|
| 228 |
longitude_slider = pn.widgets.RangeSlider(name="Longitude Range", start=-180, end=180, step=1)
|
|
@@ -243,6 +255,13 @@ class SADCP_Viewer(param.Parameterized):
|
|
| 243 |
download_button = pn.widgets.Button(name="Download", button_type="primary")
|
| 244 |
|
| 245 |
def __init__(self, **params):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
super(SADCP_Viewer, self).__init__(**params)
|
| 247 |
self.file_dropdown.objects = self.file_names
|
| 248 |
self.file_dropdown.value = (
|
|
@@ -338,10 +357,10 @@ class SADCP_Viewer(param.Parameterized):
|
|
| 338 |
|
| 339 |
# Generate plots which will be plotted on the left row.
|
| 340 |
self.plot_left = pn.Column(
|
| 341 |
-
|
| 342 |
-
|
| 343 |
pn.pane.Matplotlib(vector_plot, dpi=144),
|
| 344 |
-
#
|
| 345 |
sizing_mode="stretch_both")
|
| 346 |
|
| 347 |
# Generate additional plots which will be plotted on the right row.
|
|
@@ -392,5 +411,3 @@ template = pn.template.FastListTemplate(
|
|
| 392 |
title="SADCP data Viewer", sidebar=sidebar, main=[tabs]
|
| 393 |
)
|
| 394 |
template.servable()
|
| 395 |
-
|
| 396 |
-
|
|
|
|
| 216 |
return fig
|
| 217 |
|
| 218 |
class SADCP_Viewer(param.Parameterized):
|
| 219 |
+
"""
|
| 220 |
+
A parameterized class for viewing SADCP data.
|
| 221 |
+
|
| 222 |
+
This class provides widgets for selecting data parameters, updating data based on selections,
|
| 223 |
+
and generating plots to visualize the SADCP data.
|
| 224 |
+
|
| 225 |
+
Available functions:
|
| 226 |
+
- update_name_options: Update dropdown options and slider ranges based on selected years and file.
|
| 227 |
+
- update_plots: Update plots based on selected data and parameters.
|
| 228 |
+
"""
|
| 229 |
+
|
| 230 |
+
# Load data and initialize widgets
|
| 231 |
df = load_csv()
|
| 232 |
bathy = load_bathymetry()
|
| 233 |
tree=load_zarr()
|
| 234 |
file_names = df["file_name"].tolist()
|
| 235 |
years = sorted(df["year"].unique())
|
| 236 |
|
| 237 |
+
# Widgets for selecting data parameters
|
| 238 |
year_slider = pn.widgets.IntRangeSlider(name="Year Range", start=df["year"].min(), end=df["year"].max())
|
| 239 |
file_dropdown = pn.widgets.Select(name="File Selector")
|
| 240 |
longitude_slider = pn.widgets.RangeSlider(name="Longitude Range", start=-180, end=180, step=1)
|
|
|
|
| 255 |
download_button = pn.widgets.Button(name="Download", button_type="primary")
|
| 256 |
|
| 257 |
def __init__(self, **params):
|
| 258 |
+
"""
|
| 259 |
+
Initialize the SADCP_Viewer class.
|
| 260 |
+
|
| 261 |
+
Parameters:
|
| 262 |
+
**params: Additional parameters to be passed to the superclass.
|
| 263 |
+
"""
|
| 264 |
+
|
| 265 |
super(SADCP_Viewer, self).__init__(**params)
|
| 266 |
self.file_dropdown.objects = self.file_names
|
| 267 |
self.file_dropdown.value = (
|
|
|
|
| 357 |
|
| 358 |
# Generate plots which will be plotted on the left row.
|
| 359 |
self.plot_left = pn.Column(
|
| 360 |
+
# Here adjust the style option later TODO
|
| 361 |
+
# https://panel.holoviz.org/how_to/styling/matplotlib.html
|
| 362 |
pn.pane.Matplotlib(vector_plot, dpi=144),
|
| 363 |
+
# Add here the hvplot block of contour TODO
|
| 364 |
sizing_mode="stretch_both")
|
| 365 |
|
| 366 |
# Generate additional plots which will be plotted on the right row.
|
|
|
|
| 411 |
title="SADCP data Viewer", sidebar=sidebar, main=[tabs]
|
| 412 |
)
|
| 413 |
template.servable()
|
|
|
|
|
|