1212def indices_from_times (sim_output : SimulationResults , times_ref : list [pint .Quantity ]):
1313 i_matching = [np .argmin (np .abs (sim_output .times - t )) for t in times_ref ]
1414 times_matching = [sim_output .times [i ] for i in i_matching ]
15+
16+ assert len (i_matching ) == len (times_ref )
1517 return i_matching , times_matching
1618
1719
@@ -20,14 +22,18 @@ def plot_profile(
2022 ax : plt .Axes ,
2123 var_name : str ,
2224 times : list [pint .Quantity ],
25+ colors : list = None ,
26+ ** kwargs ,
2327):
2428 i_to_plot , _ = indices_from_times (sim_output , times )
2529 y_to_plot = getattr (sim_output , var_name )
26- for i in i_to_plot :
30+ for j , idx in enumerate ( i_to_plot ) :
2731 ax .plot (
2832 sim_output .x_ct ,
29- y_to_plot [i ],
30- label = f"t = { sim_output .times [i ] / 3600 :.2f} h" ,
33+ y_to_plot [idx ],
34+ label = f"t = { sim_output .times [idx ]:.2f} " ,
35+ c = colors [j ] if colors is not None else None ,
36+ ** kwargs ,
3137 )
3238 ax .legend ()
3339 ax .set_xlabel (r"z [m]" )
@@ -36,15 +42,9 @@ def plot_profile(
3642 ax .grid ()
3743
3844
39- def plot_signal (sim_output : SimulationResults , ax : plt .Axes , var_name : str ):
40- y_to_plot = getattr (sim_output , var_name )
41- ax .plot (
42- sim_output .times ,
43- y_to_plot ,
44- label = var_name ,
45- )
46- ax .legend ()
47- ax .set_xlabel (r"t [s]" )
48- ax .set_ylabel (var_name ) # TODO leverage pint for units
49- ax .set_title (var_name + " profile" )
50- ax .grid ()
45+ def plot_signal (sim_output : SimulationResults , ax : plt .Axes , var_name : str , ** kwargs ):
46+ ax .plot (sim_output .times , getattr (sim_output , var_name ), ** kwargs )
47+ # ax.set_xlabel(r"t [s]")
48+ # ax.set_ylabel(var_name) # TODO leverage pint for units
49+ # ax.set_title(var_name + " profile")
50+ # ax.grid()
0 commit comments