@@ -838,7 +838,11 @@ def plot_cell_scalar(self, frame):
838838 mcds = pyMCDS (xml_file_root , self .output_dir , microenv = False , graph = False , verbose = False )
839839 total_min = mcds .get_time () # warning: can return float that's epsilon from integer value
840840 # Get the cell data
841- df_all_cells = mcds .get_cell_df ()
841+ try :
842+ df_all_cells = mcds .get_cell_df ()
843+ except :
844+ print ("vis_tab.py: plot_cell_scalar(): error performing mcds.get_cell_df()" )
845+ return
842846
843847 if self .celltype_filter :
844848 df_cells = df_all_cells .loc [ df_all_cells ['cell_type' ].isin (self .celltype_filter ) ]
@@ -952,6 +956,7 @@ def plot_cell_scalar(self, frame):
952956 days = int (hrs / 24 )
953957 # print(f"mins={mins}, hrs={hrs}, days={days}")
954958 self .title_str = '%d days, %d hrs, %d mins' % (days , hrs - days * 24 , mins - hrs * 60 )
959+ # self.title_str = '%f mins' % (total_min) # rwh: custom
955960 self .title_str += " (" + str (num_cells ) + " agents)"
956961
957962 axes_min = mcds .get_mesh ()[0 ][0 ][0 ][0 ]
@@ -1001,14 +1006,21 @@ def plot_cell_scalar(self, frame):
10011006 handles = [lp (self .discrete_variable .index (i )) for i in sorted (list (self .discrete_variable_observed )) if i in self .discrete_variable ]
10021007 self .ax0 .legend (handles = handles ,labels = names_observed , loc = 'upper center' , bbox_to_anchor = (0.5 , - 0.15 ),ncols = 4 )
10031008
1004- else :
1009+ else : # Note: vis_tab_ecm.py seems to avoid any memory leak and with simpler code
10051010 # If it's not there, we create it
10061011 if self .cax2 is None :
10071012 self .cax2 = self .figure .add_subplot (self .gs [1 ,0 ])
10081013 # ax2_divider = make_axes_locatable(self.ax0)
10091014 # self.cax2 = ax2_divider.append_axes("bottom", size="4%", pad="8%")
1010- self .cbar2 = self .figure .colorbar (cell_plot , ticks = None , cax = self .cax2 , orientation = "horizontal" )
1011- self .cbar2 .ax .tick_params (labelsize = self .fontsize )
1015+ if self .cbar2 is None :
1016+ self .cbar2 = self .figure .colorbar (cell_plot , ticks = None , cax = self .cax2 , orientation = "horizontal" )
1017+ self .cbar2 .ax .tick_params (labelsize = self .fontsize )
1018+ elif self .cell_scalar_updated :
1019+ self .cbar2 = self .figure .colorbar (cell_plot , ticks = None , cax = self .cax2 , orientation = "horizontal" )
1020+ self .cell_scalar_updated = False
1021+ else :
1022+ self .cbar2 .update_normal (cell_plot ) # partial fix for memory leak
1023+
10121024 self .cbar2 .ax .set_xlabel (cell_scalar_humanreadable_name , fontsize = self .cbar_label_fontsize )
10131025
10141026 self .ax0 .set_title (self .title_str , fontsize = self .title_fontsize )
0 commit comments