@@ -667,15 +667,32 @@ def create_plot_output_1d_tab(self, tab_control):
667667 command = self .toggle_y_limits )
668668 auto_ylimits_check .grid (row = 4 , column = 2 , rowspan = 2 , sticky = W , pady = 2 )
669669
670- # Create frame for visualization
670+ # Create frame for domain overview
671+ overview_frame = ttk .LabelFrame (tab6 , text = "Domain Overview" , padding = 10 )
672+ overview_frame .grid (row = 1 , column = 0 , padx = 10 , pady = (0 , 10 ), sticky = (N , S , E , W ))
673+
674+ # Create matplotlib figure for domain overview (smaller size)
675+ self .output_1d_overview_fig = Figure (figsize = (3.5 , 3.5 ), dpi = 80 )
676+ self .output_1d_overview_fig .subplots_adjust (left = 0.15 , right = 0.95 , top = 0.92 , bottom = 0.12 )
677+ self .output_1d_overview_ax = self .output_1d_overview_fig .add_subplot (111 )
678+
679+ # Create canvas for the overview figure (centered, not expanded)
680+ self .output_1d_overview_canvas = FigureCanvasTkAgg (self .output_1d_overview_fig , master = overview_frame )
681+ self .output_1d_overview_canvas .draw ()
682+ # Center the canvas both horizontally and vertically without expanding to fill
683+ canvas_widget = self .output_1d_overview_canvas .get_tk_widget ()
684+ canvas_widget .pack (expand = True )
685+
686+ # Create frame for transect visualization
671687 plot_frame_1d = ttk .LabelFrame (tab6 , text = "1D Transect Visualization" , padding = 10 )
672- plot_frame_1d .grid (row = 0 , column = 1 , padx = 10 , pady = 10 , sticky = (N , S , E , W ))
688+ plot_frame_1d .grid (row = 0 , column = 1 , rowspan = 2 , padx = 10 , pady = 10 , sticky = (N , S , E , W ))
673689
674690 # Configure grid weights to allow expansion
675691 tab6 .columnconfigure (1 , weight = 1 )
676692 tab6 .rowconfigure (0 , weight = 1 )
693+ tab6 .rowconfigure (1 , weight = 1 )
677694
678- # Create matplotlib figure for 1D output
695+ # Create matplotlib figure for 1D transect output
679696 self .output_1d_fig = Figure (figsize = (7 , 6 ), dpi = 100 )
680697 self .output_1d_ax = self .output_1d_fig .add_subplot (111 )
681698
@@ -1107,6 +1124,9 @@ def update_1d_plot(self):
11071124 # Add grid
11081125 self .output_1d_ax .grid (True , alpha = 0.3 )
11091126
1127+ # Update the overview map showing the transect location
1128+ self .update_1d_overview (transect_idx )
1129+
11101130 # Redraw the canvas
11111131 self .output_1d_canvas .draw ()
11121132
@@ -1115,6 +1135,90 @@ def update_1d_plot(self):
11151135 error_msg = f"Failed to update 1D plot: { str (e )} \n \n { traceback .format_exc ()} "
11161136 print (error_msg ) # Print to console for debugging
11171137
1138+ def update_1d_overview (self , transect_idx ):
1139+ """Update the overview map showing the domain and transect location"""
1140+ try :
1141+ # Clear the overview axes
1142+ self .output_1d_overview_ax .clear ()
1143+
1144+ # Get the selected variable for background
1145+ var_name = self .variable_var_1d .get ()
1146+
1147+ # Get time index from slider
1148+ time_idx = int (self .time_slider_1d .get ())
1149+
1150+ # Check if variable exists in cache
1151+ if var_name not in self .nc_data_cache_1d ['vars' ]:
1152+ return
1153+
1154+ # Get the data for background
1155+ var_data = self .nc_data_cache_1d ['vars' ][var_name ]
1156+
1157+ # Extract 2D slice at current time
1158+ if var_data .ndim == 4 :
1159+ z_data = var_data [time_idx , :, :, :].mean (axis = 2 )
1160+ else :
1161+ z_data = var_data [time_idx , :, :]
1162+
1163+ # Get coordinates
1164+ x_data = self .nc_data_cache_1d ['x' ]
1165+ y_data = self .nc_data_cache_1d ['y' ]
1166+
1167+ # Plot the background
1168+ if x_data is not None and y_data is not None :
1169+ self .output_1d_overview_ax .pcolormesh (x_data , y_data , z_data ,
1170+ shading = 'auto' , cmap = 'terrain' , alpha = 0.7 )
1171+ xlabel = 'X (m)'
1172+ ylabel = 'Y (m)'
1173+ else :
1174+ self .output_1d_overview_ax .imshow (z_data , origin = 'lower' ,
1175+ aspect = 'auto' , cmap = 'terrain' , alpha = 0.7 )
1176+ xlabel = 'S-index'
1177+ ylabel = 'N-index'
1178+
1179+ # Draw the transect line
1180+ if self .transect_direction_var .get () == 'cross-shore' :
1181+ # Horizontal line at fixed y-index (n)
1182+ if x_data is not None and y_data is not None :
1183+ if x_data .ndim == 2 :
1184+ x_line = x_data [transect_idx , :]
1185+ y_line = np .full_like (x_line , y_data [transect_idx , 0 ])
1186+ else :
1187+ x_line = x_data
1188+ y_line = np .full_like (x_line , y_data [transect_idx ])
1189+ self .output_1d_overview_ax .plot (x_line , y_line , 'r-' , linewidth = 2 , label = 'Transect' )
1190+ else :
1191+ self .output_1d_overview_ax .axhline (y = transect_idx , color = 'r' , linewidth = 2 , label = 'Transect' )
1192+ else :
1193+ # Vertical line at fixed x-index (s)
1194+ if x_data is not None and y_data is not None :
1195+ if x_data .ndim == 2 :
1196+ x_line = np .full_like (y_data [:, transect_idx ], x_data [0 , transect_idx ])
1197+ y_line = y_data [:, transect_idx ]
1198+ else :
1199+ x_line = np .full_like (y_data , x_data [transect_idx ])
1200+ y_line = y_data
1201+ self .output_1d_overview_ax .plot (x_line , y_line , 'r-' , linewidth = 2 , label = 'Transect' )
1202+ else :
1203+ self .output_1d_overview_ax .axvline (x = transect_idx , color = 'r' , linewidth = 2 , label = 'Transect' )
1204+
1205+ # Set labels and title
1206+ self .output_1d_overview_ax .set_xlabel (xlabel , fontsize = 8 )
1207+ self .output_1d_overview_ax .set_ylabel (ylabel , fontsize = 8 )
1208+ self .output_1d_overview_ax .set_title ('Transect Location' , fontsize = 9 )
1209+ self .output_1d_overview_ax .tick_params (labelsize = 7 )
1210+
1211+ # Add equal aspect ratio
1212+ self .output_1d_overview_ax .set_aspect ('equal' , adjustable = 'box' )
1213+
1214+ # Redraw the overview canvas
1215+ self .output_1d_overview_canvas .draw ()
1216+
1217+ except Exception as e :
1218+ # Silently fail if overview can't be drawn
1219+ import traceback
1220+ print (f"Failed to update overview: { str (e )} \n { traceback .format_exc ()} " )
1221+
11181222 def on_variable_changed_2d (self , event ):
11191223 """Update plot when variable selection changes in 2D tab"""
11201224 if hasattr (self , 'nc_data_cache' ) and self .nc_data_cache is not None :
0 commit comments