plot_utils: let plot_temperature accept an array of Runs()
Makes more sense
diff --git a/cr2/__init__.py b/cr2/__init__.py
index 8a6baaa..e86d48b 100644
--- a/cr2/__init__.py
+++ b/cr2/__init__.py
@@ -54,9 +54,7 @@
if "title" in plot_temp_kwords:
del plot_temp_kwords["title"]
- temperature_data = {title: [run_data.thermal, run_data.thermal_governor]}
-
- plot_utils.plot_temperature(temperature_data, **plot_temp_kwords)
+ plot_utils.plot_temperature([run_data], **plot_temp_kwords)
run_data.in_power.plot_load(map_label, **kwords)
run_data.plot_allfreqs(map_label, **kwords)
run_data.pid_controller.plot_controller(**kwords)
diff --git a/cr2/plot_utils.py b/cr2/plot_utils.py
index d76e49d..27ba514 100644
--- a/cr2/plot_utils.py
+++ b/cr2/plot_utils.py
@@ -90,27 +90,24 @@
set_ylim(ax, ylim)
set_xlim(ax, xlim)
-def plot_temperature(thermal_dict, width=None, height=None, ylim="range"):
+def plot_temperature(runs, width=None, height=None, ylim="range"):
"""Plot temperatures
- thermal_dict is a dictionary with the first argument being the
- label in the legend and the values a Thermal and ThermalGovernor
- instance. Extract the control_temp from the governor data and
- plot the temperatures reported by the thermal framework. The
- governor doesn't track temperature when it's off, so the thermal
- framework trace is more reliable.
+ runs is an array of Run() instances. Extract the control_temp
+ from the governor data and plot the temperatures reported by the
+ thermal framework. The governor doesn't track temperature when
+ it's off, so the thermal framework trace is more reliable.
"""
ax = pre_plot_setup(width, height)
- for name, data in thermal_dict.iteritems():
- (thermal, gov) = data
- current_temp = gov.data_frame["current_temperature"]
- delta_temp = gov.data_frame["delta_temperature"]
+ for run in runs:
+ current_temp = run.thermal_governor.data_frame["current_temperature"]
+ delta_temp = run.thermal_governor.data_frame["delta_temperature"]
control_temp_series = (current_temp + delta_temp) / 1000
- thermal.plot_temperature(control_temperature=control_temp_series, ax=ax,
- legend_label=name)
+ run.thermal.plot_temperature(control_temperature=control_temp_series,
+ ax=ax, legend_label=run.name)
post_plot_setup(ax, title="Temperature", ylim=ylim)
plt.legend(loc="best")
diff --git a/tests/test_plot_utils.py b/tests/test_plot_utils.py
index d350f05..90bf0d9 100644
--- a/tests/test_plot_utils.py
+++ b/tests/test_plot_utils.py
@@ -89,9 +89,9 @@
def test_plot_temperature(self):
"""Test that plot_utils.plot_temperature() doesn't bomb"""
- thrm = cr2.Thermal()
- gov = cr2.ThermalGovernor()
- data = {"first": [thrm, gov], "second": [thrm, gov]}
+ run1 = cr2.Run(name="first")
+ run2 = cr2.Run(name="second")
+ runs = [run1, run2]
- plot_utils.plot_temperature(data, ylim="default")
+ plot_utils.plot_temperature(runs, ylim="default")
matplotlib.pyplot.close('all')