Measurement¶
Measurement loads the calorimetry files of a folder and provides all
plotting and analysis methods. Import it with from calocem import Measurement.
calocem.Measurement ¶
Measurement(
folder: Optional[Union[str, Path]] = None,
show_info: bool = True,
regex: Optional[str] = None,
auto_clean: bool = False,
cold_start: bool = True,
processparams: Optional[ProcessingParameters] = None,
new_code: Optional[bool] = None,
processed: bool = False,
metadata_path: Optional[Union[str, Path]] = None,
metadata_id_column: Optional[str] = None,
save_cache: bool = False,
)
Isothermal heat flow calorimetry data of one or more samples.
A Measurement reads all calorimetry files of a folder into one long-format DataFrame and provides methods for plotting and analysing the samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
str or Path
|
Folder with the exported calorimetry files ( |
None
|
show_info
|
bool
|
Print information while loading, by default True. |
True
|
regex
|
str
|
Regular expression matched against the beginning of the file names; only matching files are loaded. |
None
|
auto_clean
|
bool
|
Drop rows without heat flow values and merge differently named
temperature columns into |
False
|
cold_start
|
bool
|
If True (default), read the files. If False, read |
True
|
processparams
|
ProcessingParameters
|
Default processing parameters for all analysis methods. The |
None
|
new_code
|
bool
|
Deprecated, has no effect. |
None
|
processed
|
bool
|
Read plain CSV files previously written from :meth: |
False
|
metadata_path
|
str or Path
|
CSV or Excel file with one row of metadata per sample, see
:meth: |
None
|
metadata_id_column
|
str
|
Column of the metadata file holding the sample names. Required together
with |
None
|
save_cache
|
bool
|
Write |
False
|
Raises:
| Type | Description |
|---|---|
AutoCleanException
|
If |
ColdStartException
|
If |
Examples:
>>> from calocem import Measurement, ProcessingParameters
>>> tam = Measurement(folder="calo_data", regex=r"opc_.*", show_info=False)
>>> tam.get_sample_names()
['opc_1', 'opc_2']
get_data ¶
get_data() -> pd.DataFrame
Return the calorimetry data of all samples.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Long-format data with one row per sample and time. Typical columns are
|
Notes
The returned DataFrame is the internal data, not a copy. Use .copy()
before modifying it.
get_information ¶
get_information() -> pd.DataFrame
Return the sample information stored in the calorimetry files.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Information such as the sample mass, with |
get_metadata ¶
get_metadata() -> tuple[pd.DataFrame, str]
Return the metadata added with :meth:add_metadata_source.
Returns:
| Type | Description |
|---|---|
tuple of (pd.DataFrame, str)
|
The metadata table and the name of its sample ID column. Both are empty if no metadata was added. |
get_data_with_metadata ¶
get_data_with_metadata() -> pd.DataFrame
Return the data joined with its metadata as one tidy DataFrame.
Works on per-sample data and after :meth:average_by_metadata alike.
For averaged data, only metadata that is constant within each group is
attached. The data is returned unchanged when no metadata has been
added via :meth:add_metadata_source.
Export with, e.g.,
m.get_data_with_metadata().to_csv(path, index=False).
get_sample_names ¶
get_sample_names() -> list[str]
Return the names of all loaded samples.
Returns:
| Type | Description |
|---|---|
list of str
|
Sample names, i.e. the file names without extension. After
:meth: |
save ¶
save(path: Union[str, Path]) -> None
Save this Measurement to a named pickle file for fast reloading.
The whole object is stored, so the processed (e.g. downsampled) data,
info, added metadata and processparams are all preserved and the
object can be restored with :meth:load in a downstream script.
This file is a convenience cache, not an archive: the raw source files remain the source of truth. A file that fails to load -- for instance because it was written by an incompatible calocem version -- can always be regenerated by re-running from the original folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination file. The |
required |
load
classmethod
¶
load(path: Union[str, Path]) -> Measurement
Load a Measurement previously written with :meth:save.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
File written by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Measurement
|
The restored object, ready for plotting and analysis. |
Raises:
| Type | Description |
|---|---|
DataProcessingException
|
If the file cannot be unpickled, e.g. because it was written by an incompatible calocem version. Regenerate it from the raw folder. |
plot ¶
plot(
t_unit: str = "h",
y: str = "normalized_heat_flow_w_g",
y_unit_milli: bool = True,
regex: Optional[str] = None,
show_info: bool = True,
ax=None,
)
Plot a data column of all samples over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_unit
|
str
|
Time unit of the x-axis: "s", "min", "h" (default) or "d". |
'h'
|
y
|
str
|
Column to plot, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
y_unit_milli
|
bool
|
Show heat flow and heat in milli units (mW/g, mJ/g), by default True. |
True
|
regex
|
str
|
Plot only samples whose name matches this regular expression. |
None
|
show_info
|
bool
|
Print the name of each plotted sample, by default True. |
True
|
ax
|
Axes
|
Axes to draw into. A new figure is created if None. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes with one line per sample. |
Examples:
>>> ax = tam.plot(y="normalized_heat_j_g", t_unit="h", y_unit_milli=False)
>>> ax.set_xlim(0, 48)
plot_heatflow_with_gradient ¶
plot_heatflow_with_gradient(
processparams: Optional[ProcessingParameters] = None,
t_unit: str = "h",
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
y_unit_milli: bool = True,
gradient_unit_milli: bool = True,
gradient_color: Optional[str] = "orange",
align_zeros: bool = True,
show_zero_line: bool = False,
grid: bool = False,
regex: Optional[str] = None,
show_info: bool = True,
ax=None,
)
Plot heat flow curve(s) with their gradient on a secondary y-axis.
The gradient is computed using the smoothing settings (rolling mean,
median filter, spline interpolation) from processparams (or the
instance's processparams when not provided).
Returns:
| Type | Description |
|---|---|
(ax, ax_grad) : tuple of matplotlib.axes.Axes
|
Primary (heat flow) and secondary (gradient) axes. |
plot_by_category ¶
plot_by_category(
categories: Union[str, list[str]],
t_unit: str = "h",
y: str = "normalized_heat_flow_w_g",
y_unit_milli: bool = True,
)
Plot the samples group-wise, grouped by one or more metadata columns.
Requires metadata added via metadata_path or :meth:add_metadata_source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
str or list of str
|
Metadata column(s) to group by. |
required |
t_unit
|
str
|
Time unit, see :meth: |
'h'
|
y
|
str
|
Column to plot, see :meth: |
'normalized_heat_flow_w_g'
|
y_unit_milli
|
bool
|
See :meth: |
True
|
Yields:
| Type | Description |
|---|---|
tuple
|
|
Examples:
>>> for value, ax in tam.plot_by_category(["date", "cement_name"]):
... ax.set_ylim(0, 3)
... plt.show()
get_peaks ¶
get_peaks(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
regex: Optional[str] = None,
cutoff_min: Optional[float] = None,
show_plot: bool = True,
plt_right_s: float = 200000.0,
plt_top: float = 0.01,
ax=None,
xunit: str = "s",
plot_labels: Optional[bool] = None,
xmarker: bool = False,
) -> pd.DataFrame
Detect peaks in the heat flow of each sample.
Peaks are searched after processparams.cutoff.cutoff_min with
:func:scipy.signal.find_peaks, using processparams.peakdetection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
cutoff_min
|
float
|
Deprecated, use |
None
|
show_plot
|
bool
|
Plot each sample with its peaks, by default True. |
True
|
plt_right_s
|
float
|
Currently have no effect. |
200000.0
|
plt_top
|
float
|
Currently have no effect. |
200000.0
|
xunit
|
float
|
Currently have no effect. |
200000.0
|
plot_labels
|
float
|
Currently have no effect. |
200000.0
|
xmarker
|
float
|
Currently have no effect. |
200000.0
|
ax
|
Axes
|
Axes to draw into. If None, one figure per sample is created. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per peak: the data row at the peak ( |
get_peak_onsets ¶
get_peak_onsets(
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
time_discarded_s: float = 900,
rolling: int = 1,
gradient_threshold: float = 0.0005,
show_plot: bool = False,
exclude_discarded_time: bool = False,
regex: Optional[str] = None,
ax=None,
)
Find the first time at which the heat flow gradient exceeds a threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
time_discarded_s
|
float
|
Ignore data before this time in seconds, by default 900. |
900
|
rolling
|
int
|
Window (number of points) of a rolling mean applied before the gradient is taken, by default 1 (no smoothing). |
1
|
gradient_threshold
|
float
|
Gradient threshold in W/g/s, by default 0.0005. |
0.0005
|
show_plot
|
bool
|
Deprecated, have no effect. |
False
|
ax
|
bool
|
Deprecated, have no effect. |
False
|
exclude_discarded_time
|
bool
|
Also remove the discarded data before computing the gradient, by default False. |
False
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with the data row at the onset and its |
Notes
This method does not use the processing parameters. The default threshold is too high for typical cement pastes; values around 1e-8 W/g/s are a better starting point.
get_deconvolution ¶
get_deconvolution(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
regex: Optional[str] = None,
n_peaks: Optional[int] = None,
peak_shape: str = "lognormal",
baseline_mode: Optional[str] = None,
relative_intensity_upper_bounds: Optional[
list[float]
] = None,
peak_width_upper_bounds: Optional[list[float]] = None,
show_plot: bool = False,
ax=None,
) -> pd.DataFrame
Fit the heat flow of each sample as a sum of peaks plus a baseline.
The data after processparams.cutoff.cutoff_min is fitted with
n_peaks lognormal or Gaussian components by constrained least squares.
If the fit with the requested baseline fails, simpler baselines are tried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
n_peaks
|
int
|
Number of components. Defaults to |
None
|
peak_shape
|
str
|
"lognormal" (default) or "gaussian". |
'lognormal'
|
baseline_mode
|
str
|
"constant", "linear", "chebyshev" or "none". Defaults to
|
None
|
relative_intensity_upper_bounds
|
list of float
|
One value per component in (0, 1]: maximum share of the total amplitude. |
None
|
peak_width_upper_bounds
|
list of float
|
One value per component: maximum width. |
None
|
show_plot
|
bool
|
Plot the data, the components and the fit, by default False. |
False
|
ax
|
Axes
|
Axes to draw into. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample and component with |
Notes
For lognormal components, width is the dimensionless standard deviation
of ln(t) and center_time_s the median; for Gaussian components both are
in seconds. A component with an amplitude close to zero has a meaningless
peak_time_s.
get_left_peak_inflection_tangent_intersection ¶
get_left_peak_inflection_tangent_intersection(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
regex: Optional[str] = None,
n_peaks: Optional[int] = None,
peak_shape: str = "lognormal",
baseline_mode: Optional[str] = None,
deconvolution_results: Optional[DataFrame] = None,
) -> pd.DataFrame
Determine an onset from the tangent at the inflection point of the first peak.
The earliest fitted component of :meth:get_deconvolution is taken, and the
tangent at the inflection point of its ascending flank is intersected with
the time axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
n_peaks
|
Optional[int]
|
Passed to :meth: |
None
|
peak_shape
|
Optional[int]
|
Passed to :meth: |
None
|
baseline_mode
|
Optional[int]
|
Passed to :meth: |
None
|
deconvolution_results
|
DataFrame
|
Result of :meth: |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
get_maximum_slope ¶
get_maximum_slope(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
show_plot: bool = False,
regex: Optional[str] = None,
ax=None,
save_path: Optional[Path] = None,
xunit: Optional[str] = None,
) -> pd.DataFrame
Determine the maximum slope of the main hydration peak.
Runs :meth:get_mainpeak_params and returns only the maximum slope columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
show_plot
|
bool
|
Plot the analysis for each sample, by default False. |
False
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
ax
|
Axes
|
Axes to draw into. |
None
|
save_path
|
Optional[Path]
|
Deprecated, have no effect. |
None
|
xunit
|
Optional[Path]
|
Deprecated, have no effect. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
get_mainpeak_params ¶
get_mainpeak_params(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
show_plot: bool = False,
save_plot: bool = False,
plot_type: str = "mean",
regex: Optional[str] = None,
plotpath: Optional[Path] = None,
ax=None,
method: str = "mean",
monochrome: bool = False,
marker_size: float = 1.0,
) -> pd.DataFrame
Characterize the main hydration peak: slopes, onset times and peak values.
With method="mean" (default) two analyses are combined:
- maximum slope: the maximum of the time derivative of the heat flow (after optional smoothing), and the onset where the tangent at this point meets the dormant heat flow or the time axis;
- mean slope: a tangent averaged over the ascending flank between
slope_analysis.flank_fraction_startandflank_fraction_endof the peak height, and its onset.
With method="ascending" the slope of the first ascending segment up to
a threshold (slope_analysis.first_ascending_*) is determined instead.
This is the only analysis that honours sample parameter rules.
In both cases the dormant period (:meth:get_dormant_period_heatflow) and
ASTM C1679 (:meth:get_astm_c1679_characteristics) values are added.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
show_plot
|
bool
|
Plot the analysis for each sample, by default False. |
False
|
save_plot
|
bool
|
Save each plot as PNG to |
False
|
plot_type
|
str
|
For |
'mean'
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
plotpath
|
Path
|
Folder for |
None
|
ax
|
Axes
|
Axes to draw into. If None, one figure per sample is created and shown. |
None
|
method
|
str
|
"mean" (default) or "ascending". |
'mean'
|
monochrome
|
bool
|
Draw all markers in black, by default False. |
False
|
marker_size
|
float
|
Scale factor for marker sizes, by default 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample. For |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> processparams = ProcessingParameters()
>>> processparams.spline_interpolation.apply = True
>>> result = tam.get_mainpeak_params(processparams, show_plot=True, plot_type="max")
>>> result[["sample_short", "gradient_from_max_slope", "onset_time_s_from_max_slope"]]
get_peak_onset_via_max_slope ¶
get_peak_onset_via_max_slope(
processparams: Optional[ProcessingParameters] = None,
show_plot: bool = False,
ax=None,
regex: Optional[str] = None,
age_col: str = "time_s",
target_col: str = "normalized_heat_flow_w_g",
time_discarded_s: Optional[float] = None,
save_path: Optional[Path] = None,
xscale: Optional[str] = None,
xunit: Optional[str] = None,
intersection: Optional[str] = None,
)
Determine the onset of the main hydration peak from the maximum slope.
Equivalent to get_mainpeak_params(processparams, plot_type="max").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
show_plot
|
bool
|
Plot the analysis for each sample, by default False. |
False
|
ax
|
Axes
|
Axes to draw into. |
None
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
time_discarded_s
|
Optional[float]
|
Deprecated, have no effect. Use |
None
|
save_path
|
Optional[float]
|
Deprecated, have no effect. Use |
None
|
xscale
|
Optional[float]
|
Deprecated, have no effect. Use |
None
|
xunit
|
Optional[float]
|
Deprecated, have no effect. Use |
None
|
intersection
|
Optional[float]
|
Deprecated, have no effect. Use |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
The full result of :meth: |
get_ascending_flank_tangent ¶
get_ascending_flank_tangent(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
flank_fraction_start: Optional[float] = None,
flank_fraction_end: Optional[float] = None,
window_size: Optional[float] = None,
cutoff_min: Optional[float] = None,
show_plot: bool = False,
regex: Optional[str] = None,
plotpath: Optional[Path] = None,
ax=None,
) -> pd.DataFrame
Determine a tangent to the ascending flank of the main peak.
Linear fits in windows along the flank between flank_fraction_start and
flank_fraction_end of the peak height are combined to one tangent, which
is intersected with the time axis and with the minimum heat flow before the
peak.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
flank_fraction_start
|
float
|
Override |
None
|
flank_fraction_end
|
float
|
Override |
None
|
window_size
|
float
|
Override |
None
|
cutoff_min
|
float
|
Override |
None
|
show_plot
|
bool
|
Deprecated, have no effect. Use
|
False
|
plotpath
|
bool
|
Deprecated, have no effect. Use
|
False
|
ax
|
bool
|
Deprecated, have no effect. Use
|
False
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
get_dormant_period_heatflow ¶
get_dormant_period_heatflow(
processparams: Optional[ProcessingParameters] = None,
regex: Optional[str] = None,
cutoff_min: Optional[int] = None,
upper_dormant_thresh_w_g: float = 0.002,
plot_right_boundary: Optional[float] = None,
prominence: Optional[float] = None,
show_plot: bool = False,
) -> pd.DataFrame
Determine the minimum heat flow of the dormant period.
The minimum of normalized_heat_flow_w_g between
processparams.cutoff.cutoff_min and the first peak found by
:meth:get_peaks is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
cutoff_min
|
Optional[int]
|
Deprecated, have no effect. Use |
None
|
plot_right_boundary
|
Optional[int]
|
Deprecated, have no effect. Use |
None
|
prominence
|
Optional[int]
|
Deprecated, have no effect. Use |
None
|
show_plot
|
Optional[int]
|
Deprecated, have no effect. Use |
None
|
upper_dormant_thresh_w_g
|
float
|
Currently has no effect. |
0.002
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
get_astm_c1679_characteristics ¶
get_astm_c1679_characteristics(
processparams: Optional[ProcessingParameters] = None,
individual: bool = True,
show_plot: bool = False,
ax=None,
regex: Optional[str] = None,
xscale: Optional[str] = None,
xunit: str = "s",
) -> pd.DataFrame
Determine the half-maximum point of the main peak according to ASTM C1679.
For each sample, the last point on the ascending flank whose heat flow is at most half of the highest peak is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
individual
|
bool
|
If True (default), use half of each sample's own peak height. If False, use half of the mean peak height of all samples. |
True
|
show_plot
|
bool
|
Plot the curves with the ASTM points, by default False. |
False
|
ax
|
Axes
|
Axes to draw into. |
None
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
xscale
|
Optional[str]
|
Deprecated, has no effect. |
None
|
xunit
|
str
|
Time unit of the plot: "s" (default), "min", "h" or "d". |
's'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
get_cumulative_heat_at_hours ¶
get_cumulative_heat_at_hours(
processparams: Optional[ProcessingParameters] = None,
target_h: float = 4,
**kwargs,
) -> pd.DataFrame
Return the heat released up to a given age.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_h
|
float
|
Age in hours, by default 4. |
4
|
**kwargs
|
|
{}
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
Notes
The heat released before processparams.cutoff.cutoff_min is subtracted.
With the default cutoff of 60 min the result is the heat released between
1 h and target_h; set the cutoff to 0 for the total heat. For the heat
between two arbitrary times, see :meth:get_heat_between.
get_cumulated_heat_at_hours ¶
get_cumulated_heat_at_hours(
processparams: Optional[ProcessingParameters] = None,
target_h: float = 4,
**kwargs,
) -> pd.DataFrame
Deprecated alias of :meth:get_cumulative_heat_at_hours.
get_heat_between ¶
get_heat_between(
start_s: Union[float, Mapping[str, float]],
end_s: Union[float, Mapping[str, float]],
regex: Optional[str] = None,
) -> pd.DataFrame
Return the heat released between two times.
The cumulative heat normalized_heat_j_g is linearly interpolated at
start_s and end_s and the difference is returned. The cutoff of
the processing parameters has no effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_s
|
float or mapping
|
Start and end of the interval in seconds. Either one time for all
samples, or one time per sample as a dict or pd.Series keyed by
|
required |
end_s
|
float or mapping
|
Start and end of the interval in seconds. Either one time for all
samples, or one time per sample as a dict or pd.Series keyed by
|
required |
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
Examples:
Heat released between 30 min and the onset of the main peak:
>>> onsets = tam.get_mainpeak_params(processparams).set_index("sample_short")
>>> tam.get_heat_between(
... start_s=1800, end_s=onsets["onset_time_s_from_max_slope"]
... )
get_average_slope ¶
get_average_slope(
processparams: Optional[ProcessingParameters] = None,
target_col: str = "normalized_heat_flow_w_g",
age_col: str = "time_s",
regex: Optional[str] = None,
show_plot: bool = False,
ax=None,
save_path: Optional[Path] = None,
xunit: Optional[str] = None,
) -> pd.DataFrame
Determine the mean slope of the ascending flank of the main hydration peak.
Runs :meth:get_mainpeak_params and returns only the mean slope columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters. If None, the parameters of the Measurement are used. |
None
|
target_col
|
str
|
Column with the heat flow, by default "normalized_heat_flow_w_g". |
'normalized_heat_flow_w_g'
|
age_col
|
str
|
Column with the time in seconds, by default "time_s". |
'time_s'
|
regex
|
str
|
Regular expression; only samples whose name matches are analysed. |
None
|
show_plot
|
bool
|
Plot the analysis for each sample, by default False. |
False
|
ax
|
Axes
|
Axes to draw into. |
None
|
save_path
|
Optional[Path]
|
Deprecated, have no effect. |
None
|
xunit
|
Optional[Path]
|
Deprecated, have no effect. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per sample with |
normalize_sample_to_mass ¶
normalize_sample_to_mass(
sample_short: str, mass_g: float, show_info: bool = True
)
Recalculate the normalized heat flow and heat of one sample for a new mass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_short
|
str
|
Name of the sample. |
required |
mass_g
|
float
|
Sample mass in grams. |
required |
show_info
|
bool
|
Print a confirmation, by default True. |
True
|
apply_tian_correction ¶
apply_tian_correction(
processparams: Optional[ProcessingParameters] = None,
) -> None
Apply Tian correction to the heat flow data.
Corrects the measured heat flow for the thermal inertia of the calorimeter using one or two time constants (tau1, tau2) from processparams.
Single time constant (tau2 = None): hf_corrected = dHF/dt * tau1 + HF
Dual time constants: hf_corrected = dHF/dt * (tau1 + tau2) + d²HF/dt² * tau1*tau2 + HF
Results are written to three new columns:
- normalized_heat_flow_w_g_tian
- gradient_normalized_heat_flow_w_g
- normalized_heat_j_g_tian
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processparams
|
ProcessingParameters
|
Processing parameters containing time_constants.tau1 and time_constants.tau2. Uses instance processparams if not provided. |
None
|
add_metadata_source ¶
add_metadata_source(
file: Union[str, Path],
sample_id_column: str,
show_info: bool = True,
)
Add metadata from external source (CSV or Excel file).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str or Path
|
Path to metadata file (CSV, Excel, etc.) |
required |
sample_id_column
|
str
|
Column name in metadata file that matches sample names |
required |
show_info
|
bool
|
Whether to print informative messages, by default True |
True
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the metadata file does not exist |
ValueError
|
If the sample_id_column is not found in the metadata file |
average_by_metadata ¶
average_by_metadata(
groupby: str | list[str], bin_width_s: int = 60
) -> None
Replace individual samples with group averages defined by metadata.
Requires :meth:add_metadata_source to have been called first.
The averaged data replaces self._data in-place so that all
downstream methods (plot, get_cumulative_heat_at_hours, …)
operate on the grouped curves. Call :meth:undo_average_by_metadata
to restore the original data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groupby
|
str or list of str
|
Metadata column(s) to group by, e.g. |
required |
bin_width_s
|
int
|
Width of each time bin in seconds. Default is 60 s. |
60
|
undo_average_by_metadata ¶
undo_average_by_metadata() -> None
Restore the individual samples after :meth:average_by_metadata.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data has not been averaged. |
remove_pickle_files ¶
remove_pickle_files()
Delete the cache files _data.pickle and _info.pickle.
The files are removed from the current working directory, if present. See
the save_cache argument of :class:Measurement.