@@ -181,21 +181,23 @@ def tplot_restore(filename):
181181 pytplot .data_quants [data_name ].attrs ['plot_options' ]['trange' ] = temp_tplot ['dq' ][i ][4 ].tolist ()
182182 pytplot .data_quants [data_name ].attrs ['plot_options' ]['create_time' ] = temp_tplot ['dq' ][i ][6 ]
183183
184- for option_name in temp_tplot ['tv' ][0 ][0 ].dtype .names :
185- # the following should be set on the tplot variable, not for the entire session
186- #if option_name == 'TRANGE':
187- # # x_range of [0, 0] causes tplot to create an empty figure
188- # if temp_tplot['tv'][0][0][option_name][0][0] != 0 or temp_tplot['tv'][0][0][option_name][0][1] != 0:
189- # tplot_options('x_range', temp_tplot['tv'][0][0][option_name][0])
190- if option_name == 'WSIZE' :
191- tplot_options ('wsize' , temp_tplot ['tv' ][0 ][0 ][option_name ][0 ])
192- if option_name == 'VAR_LABEL' :
193- tplot_options ('var_label' , temp_tplot ['tv' ][0 ][0 ][option_name ][0 ])
194- if 'P' in temp_tplot ['tv' ][0 ][1 ].tolist ():
195- for option_name in temp_tplot ['tv' ][0 ][1 ]['P' ][0 ].dtype .names :
196- if option_name == 'TITLE' :
197- tplot_options ('title' , temp_tplot ['tv' ][0 ][1 ]['P' ][0 ][option_name ][0 ])
198-
184+ if not np .isscalar (temp_tplot ['tv' ]): # Skip if it is a scalar
185+ for option_name in temp_tplot ['tv' ][0 ][0 ].dtype .names :
186+ # the following should be set on the tplot variable, not for the entire session
187+ #if option_name == 'TRANGE':
188+ # # x_range of [0, 0] causes tplot to create an empty figure
189+ # if temp_tplot['tv'][0][0][option_name][0][0] != 0 or temp_tplot['tv'][0][0][option_name][0][1] != 0:
190+ # tplot_options('x_range', temp_tplot['tv'][0][0][option_name][0])
191+ if option_name == 'WSIZE' :
192+ tplot_options ('wsize' , temp_tplot ['tv' ][0 ][0 ][option_name ][0 ])
193+ if option_name == 'VAR_LABEL' :
194+ tplot_options ('var_label' , temp_tplot ['tv' ][0 ][0 ][option_name ][0 ])
195+ if 'P' in temp_tplot ['tv' ][0 ][1 ].tolist ():
196+ for option_name in temp_tplot ['tv' ][0 ][1 ]['P' ][0 ].dtype .names :
197+ if option_name == 'TITLE' :
198+ tplot_options ('title' , temp_tplot ['tv' ][0 ][1 ]['P' ][0 ][option_name ][0 ])
199+
200+
199201 # correct legend_names array
200202 plt_options = pytplot .data_quants [data_name ].attrs ['plot_options' ]
201203 yaxis_opts = plt_options .get ('yaxis_opt' )
0 commit comments