-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexplorer.py
More file actions
176 lines (148 loc) · 7.27 KB
/
explorer.py
File metadata and controls
176 lines (148 loc) · 7.27 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
"""
Stingray Explorer Main Application File
This module serves as the entry point for the Stingray Explorer dashboard application.
It handles the initialization of the Panel/Holoviews environment and sets up the
dashboard layout and components.
The dashboard provides an interactive interface for analyzing X-ray astronomy data
using the Stingray library, with various visualization and analysis tools.
Key Components:
- Header: Main navigation and branding
- Sidebar: Control panel for data loading and analysis
- Main Area: Primary workspace for data visualization
- Plots Area: Container for generated plots and charts
- Resource Monitor: System resource usage display
- Help/Info Sections: Documentation and support resources
"""
import panel as pn
import holoviews as hv
from modules.Home.HomeContent import (
create_home_header,
create_home_main_area,
create_home_output_box,
create_home_warning_box,
create_home_help_area,
create_home_footer,
create_home_plots_area,
create_home_resource_monitor,
)
from utils.sidebar import create_sidebar
from utils.app_context import AppContext
# Initialize Panel and Holoviews extensions with required features
# Note: 'filedropper' is required for FileDropper widgets used in data loading
pn.extension('floatpanel', 'mathjax', 'echarts', 'filedropper', nthreads=0)
hv.extension('bokeh')
# Create a boolean status indicator to show system activity
# Note: In Panel 1.8+, we don't pass custom busy indicators to avoid param warnings
# The template will use its default busy indicator
# busy_status = pn.indicators.BooleanStatus(
# value=True, color="warning", width=30, height=30
# )
# =============================================================================
# Create Application Context
# =============================================================================
# Initialize the application context that will hold all containers and state
context = AppContext()
# Create the main dashboard header with branding and navigation
header = create_home_header()
# Create resource monitor to display system usage statistics
resource_monitor = create_home_resource_monitor()
# Create the main workspace area for data visualization and analysis
main_area = create_home_main_area()
# Create the output console for displaying analysis results and messages
output_box = create_home_output_box()
# Create the warning box for displaying important alerts and notifications
warning_box = create_home_warning_box()
# Create the help box containing documentation and support resources
help_box = create_home_help_area()
# Create the footer with copyright and additional information
footer = create_home_footer()
# Create the plots area container for visualization outputs
plots_area = create_home_plots_area()
# =============================================================================
# Register All Containers with AppContext
# =============================================================================
# Create containers for each section and register them with the context
context.register_container('header', pn.Column(header), {'purpose': 'Main navigation and branding'})
context.register_container('resource_monitor', pn.Column(resource_monitor), {'purpose': 'System resource usage display'})
context.register_container('main_area', pn.Column(main_area), {'purpose': 'Primary workspace for data visualization'})
context.register_container('output_box', pn.Column(output_box), {'purpose': 'Analysis results and messages'})
context.register_container('warning_box', pn.Column(warning_box), {'purpose': 'Important alerts and notifications'})
context.register_container('plots', pn.FlexBox(plots_area, flex_direction='row', align_content='space-evenly', align_items="center", justify_content="center", flex_wrap="wrap"), {'purpose': 'Visualization outputs'})
context.register_container('help_box', pn.Column(help_box), {'purpose': 'Documentation and support resources'})
context.register_container('footer', pn.Column(footer), {'purpose': 'Copyright and additional information'})
context.register_container('float_panel', pn.Column(pn.pane.Markdown("This is not a bug that this container is scrolling, it's a container to hold Floating Plots. You can ignore it completely.")), {'purpose': 'Floating plot container'})
# Create the sidebar with navigation and control elements
# Now passing a single AppContext instead of 9 individual parameters!
sidebar = create_sidebar(context)
"""
Create the main dashboard layout using Panel's FastGridTemplate
The layout organizes all components into a responsive grid system with:
- Header at the top
- Sidebar on the left
- Main content area in the center
- Output and warning box on the right of main layout
- Plots and help section below the main content
- Footer at the bottom
The grid is fully responsive and adapts to different screen sizes.
"""
layout = pn.template.FastGridTemplate(
# Basic Panel layout components
main=[],
header="Next-Generation Spectral Timing Made Easy",
sidebar=[sidebar],
modal=True,
# Parameters for the FastGridTemplate
site="", # Not shown as already doing in title
site_url="StingrayExplorer",
logo="assets/images/stingray_explorer.png",
title="Stingray Explorer",
favicon="assets/images/stingray_explorer.png",
# sidebar_footer="Sidebar Footer",
# config= (TemplateConfig): Contains configuration options similar to pn.config but applied to the current Template only. (Currently only css_files is supported) But css_files are now deprecated.
# busy_indicator removed to avoid param warnings in Panel 1.8+ (uses default)
# For configuring the grid
cols={"lg": 12, "md": 12, "sm": 12, "xs": 4, "xxs": 2},
breakpoints={"lg": 1200, "md": 996, "sm": 768, "xs": 480, "xxs": 0},
row_height=10,
dimensions={"minW": 0, "maxW": float("inf"), "minH": 0, "maxH": float("inf")},
prevent_collision=False,
save_layout=True,
# Styling parameter
theme="default",
theme_toggle=False,
background_color="#FFFFFF",
neutral_color="#D3D3D3",
accent_base_color="#5ead61",
header_background="#000000",
header_color="#c4e1c5",
header_neutral_color="#D3D3D3",
header_accent_base_color="#c4e1c5",
corner_radius=7,
# font="",
# font_url="",
shadow=True,
main_layout="card",
# Layout parameters
collapsed_sidebar=False,
sidebar_width=250,
main_max_width="100%",
# Meta data
meta_description="Stingray Explorer Dashboard",
meta_keywords="Stingray, Explorer, Dashboard, Astronomy, Stingray Explorer, X-ray Astronomy, X-ray Data Analysis",
meta_author="Kartik Mandar",
meta_refresh="",
meta_viewport="width=device-width, initial-scale=1",
base_url="/",
base_target="_self",
)
layout.main[0:10, 0:6] = context.get_container('header')
layout.main[0:10, 6:12] = context.get_container('resource_monitor')
layout.main[10:55, 0:8] = context.get_container('main_area')
layout.main[10:33, 8:12] = context.get_container('output_box')
layout.main[33:55, 8:12] = context.get_container('warning_box')
layout.main[55:100, 0:12] = context.get_container('plots')
layout.main[100:140, 0:12] = context.get_container('help_box')
layout.main[140:170, 0:12] = context.get_container('footer')
layout.main[170:170, 0:12] = context.get_container('float_panel')
# Make the layout available for serving
layout.servable()