Plotting¶
The Measurement object loads all calorimetry files of a folder. Its plot method draws the heat flow (or any other data column) of all samples into one figure and returns the Matplotlib axes, which can then be customized with the usual Matplotlib methods.
This page is a Jupyter notebook that is executed when the documentation is built, so all plots below are generated from the example data in the repository.
from pathlib import Path
import matplotlib.pyplot as plt
from calocem import Measurement
# relative path from the docs folder to the example data of the repository
datapath = Path("../calocem/DATA")
tam = Measurement(datapath, regex=r".*bm2\.csv", show_info=False)
fig, ax = plt.subplots()
tam.plot(ax=ax)
ax.set_xlim(0, 30)
ax.set_ylim(0, 5)
plt.show()
Plotting insitu_bm2
In your own project, point Path to the folder containing the exported files. For a script myscript.py next to a folder calo_data
.
├── myscript.py
└── calo_data
├── calofile1.csv
└── calofile2.csv
use datapath = Path(__file__).parent / "calo_data". The optional regex argument selects files by name.
Choosing what to plot¶
plot accepts
y: the column to plot, e.g."normalized_heat_flow_w_g"(default) or"normalized_heat_j_g",t_unit: the time unit,"s","min","h"(default) or"d",y_unit_milli: show the y-values in mW/g or mJ/g instead of W/g or J/g (defaultTrue),regex: plot only the samples whose name matches,ax: an existing Matplotlib axes to draw into.
ax = tam.plot(y="normalized_heat_j_g", t_unit="h", y_unit_milli=False)
ax.set_xlim(0, 48)
ax.set_ylim(0, 300)
plt.show()
Plotting insitu_bm2
Heat flow and heat in subplots¶
Because plot draws into a given axes, several views can be combined. Here, the early reaction and the main hydration period are shown for both the heat flow and the cumulated heat.
tam = Measurement(datapath, regex=r".*bm.*", show_info=False)
plot_configs = [
{"ycol": "normalized_heat_flow_w_g", "xlim": 1, "ylim": 0.050},
{"ycol": "normalized_heat_flow_w_g", "xlim": 48, "ylim": 0.005},
{"ycol": "normalized_heat_j_g", "xlim": 1, "ylim": 30},
{"ycol": "normalized_heat_j_g", "xlim": 48, "ylim": 300},
]
fig, axs = plt.subplots(2, 2, layout="constrained")
for ax, config in zip(axs.flatten(), plot_configs):
tam.plot(y=config["ycol"], t_unit="h", y_unit_milli=False, ax=ax)
ax.set_xlim(0, config["xlim"])
ax.set_ylim(0, config["ylim"])
ax.get_legend().remove()
plt.show()
Plotting insitu_bm Plotting insitu_bm2 Plotting insitu_bm Plotting insitu_bm2 Plotting insitu_bm Plotting insitu_bm2 Plotting insitu_bm Plotting insitu_bm2
Heat flow with its gradient¶
plot_heatflow_with_gradient adds the time derivative of the heat flow on a second y-axis and returns both axes. This is useful to check the smoothing settings before running a slope analysis (see Processing Parameters).
from calocem import ProcessingParameters
processparams = ProcessingParameters()
processparams.cutoff.cutoff_min = 30
processparams.spline_interpolation.apply = True
tam = Measurement(datapath, regex=r"calorimetry_data_1\.csv", show_info=False)
ax, ax_gradient = tam.plot_heatflow_with_gradient(processparams, t_unit="h", show_info=False)
ax.set_xlim(0, 48)
plt.show()
tam = Measurement(
datapath,
regex=r"calorimetry_data_[1-4]\.csv",
show_info=False,
metadata_path="../tests/mini_metadata.csv",
metadata_id_column="experiment_nr",
)
for cement, ax in tam.plot_by_category("cement_name"):
ax.set_xlim(0, 48)
plt.show()