ProcessingParameters¶
ProcessingParameters holds all analysis settings, grouped by topic. See
Processing Parameters for a guide to the
individual groups. Import it with from calocem import ProcessingParameters.
calocem.ProcessingParameters
dataclass
¶
All processing parameters of CaloCem, grouped by topic.
Create an instance, change the values you need and pass it to the methods
of :class:calocem.Measurement. See the Processing Parameters guide for
which analyses use which settings.
Attributes:
| Name | Type | Description |
|---|---|---|
cutoff |
CutOffParameters
|
Initial period excluded from the analysis. |
time_constants |
TianCorrectionParameters
|
Time constants for the Tian correction. |
peakdetection |
PeakDetectionParameters
|
Peak detection in the heat flow. |
gradient_peakdetection |
GradientPeakDetectionParameters
|
Reserved, currently not used. |
rolling_mean |
RollingMeanParameters
|
Rolling mean of the heat flow before differentiation. |
median_filter |
MedianFilterParameters
|
Median filter of the derivatives. |
nonlin_savgol |
NonLinSavGolParameters
|
Reserved, currently not used. |
spline_interpolation |
SplineInterpolationParameters
|
Smoothing splines of the derivatives. |
downsample |
DownSamplingParameters
|
Adaptive downsampling while loading. |
preprocess |
PreProcessParameters
|
Reserved, currently not used. |
slope_analysis |
SlopeAnalysisParameters
|
Slope analyses of the main hydration peak. |
deconvolution |
DeconvolutionParameters
|
Peak deconvolution. |
plotting |
PlottingParameters
|
Appearance of the analysis plots. |
sample_param_rules |
list of SampleParamRule
|
Sample-specific overrides, see :meth: |
Examples:
>>> processparams = ProcessingParameters()
>>> processparams.cutoff.cutoff_min = 30
>>> processparams.spline_interpolation.apply = True
add_sample_param_rule ¶
add_sample_param_rule(
pattern: str,
overrides: dict[str, Any],
priority: int = 100,
) -> None
Add a regex rule to override parameters for matching sample names.
Note
Rules are currently only honoured by the first-ascending-slope analysis,
i.e. get_mainpeak_params(method="ascending"). All other analyses use
the base parameters for every sample.
Examples:
>>> processparams.add_sample_param_rule(
... r"^c3a", {"slope_analysis": {"first_ascending_range_method": "delta"}}
... )
resolve_for_sample ¶
resolve_for_sample(
sample_name: str,
) -> ProcessingParameters
Resolve effective parameters for a sample based on regex override rules.
Parameter groups¶
SampleParamRule
dataclass
¶
Regex-based override rule for sample-specific processing parameters.
Created with :meth:ProcessingParameters.add_sample_param_rule.
Attributes:
| Name | Type | Description |
|---|---|---|
pattern |
str
|
Regular expression searched in the sample name. |
overrides |
dict
|
Nested dictionary of parameter groups and values to override, e.g.
|
priority |
int
|
Rules are applied in ascending priority, so higher values win. |
CutOffParameters
dataclass
¶
Initial period excluded from the analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
cutoff_min |
float
|
Time in minutes; data before |
cutoff_max |
int
|
Reserved, currently not used. |
TianCorrectionParameters
dataclass
¶
RollingMeanParameters
dataclass
¶
MedianFilterParameters
dataclass
¶
NonLinSavGolParameters
dataclass
¶
SplineInterpolationParameters
dataclass
¶
Smoothing splines fitted to the first and second derivative of the heat flow.
Uses :class:scipy.interpolate.UnivariateSpline.
Attributes:
| Name | Type | Description |
|---|---|---|
apply |
bool
|
Apply the splines. Default False. |
smoothing_1st_deriv |
float
|
Smoothing factor |
smoothing_2nd_deriv |
float
|
Smoothing factor |
PeakDetectionParameters
dataclass
¶
Settings of :func:scipy.signal.find_peaks for peak detection in the heat flow.
Attributes:
| Name | Type | Description |
|---|---|---|
prominence |
float
|
Minimum peak prominence in W/g. Default 1e-5. |
distance |
int
|
Minimum distance between peaks in data points. Default 100. |
GradientPeakDetectionParameters
dataclass
¶
Reserved, currently not used.
use_largest_width_height
class-attribute
instance-attribute
¶
use_largest_width_height: bool = False
DownSamplingParameters
dataclass
¶
Adaptive downsampling applied when a Measurement is created.
More points are kept where the heat flow curve bends, fewer in flat regions. Values are picked from the measured data, not interpolated.
Attributes:
| Name | Type | Description |
|---|---|---|
apply |
bool
|
Apply downsampling. Default False. |
num_points |
int
|
Target number of points per sample (upper bound). Default 1000. |
smoothing_factor |
float
|
Relative smoothing of the spline used to estimate the curvature; scaled internally by the number of points and the variance of the heat flow. Default 1e-6. |
baseline_weight |
float
|
Weight of evenly spread points, so flat regions keep some points. Default 0.1. |
section_split |
bool
|
Downsample the data before and after |
section_split_time_s |
int
|
Split time in seconds. Default 1000. |
PreProcessParameters
dataclass
¶
Reserved, currently not used.
SlopeAnalysisParameters
dataclass
¶
Settings of the slope analyses of the main hydration peak.
Attributes:
| Name | Type | Description |
|---|---|---|
flank_fraction_start |
float
|
Start of the ascending flank as fraction of the height between the minimum before the peak and the peak. Default 0.35. |
flank_fraction_end |
float
|
End of the ascending flank, same scale. Default 0.55. |
window_size |
float
|
Width of the averaging windows as fraction of the time span of the flank. Default 0.1. |
first_ascending_fraction_of_max |
float
|
|
first_ascending_range_method |
str
|
|
first_ascending_delta_y_w_g |
float
|
Heat flow rise in W/g for the "delta" method. Default 0.001. |
flexible |
float
|
"delta" method: increases the delta for high peaks; 0 (default) disables the adaptation. |
first_ascending_fraction_of_max
class-attribute
instance-attribute
¶
first_ascending_fraction_of_max: float = 0.2
first_ascending_range_method
class-attribute
instance-attribute
¶
first_ascending_range_method: str = 'fraction'
first_ascending_delta_y_w_g
class-attribute
instance-attribute
¶
first_ascending_delta_y_w_g: float = 0.001
DeconvolutionParameters
dataclass
¶
Settings of the peak deconvolution fit.
Attributes:
| Name | Type | Description |
|---|---|---|
n_peaks |
int
|
Number of fitted peaks. Default 2. |
peak_shape |
str
|
Currently ignored; select the shape with the |
baseline_mode |
str
|
"constant" (default), "linear", "chebyshev" or "none". |
chebyshev_degree |
int
|
Degree of the Chebyshev baseline. Default 2. |
max_nfev |
int
|
Maximum number of optimizer iterations. Default 5000. |
max_fit_points |
int
|
The data is subsampled to at most this many points. Default 2500. |
min_points |
int
|
Samples with fewer points after the cutoff are skipped. Default 30. |
min_peak_distance_fraction |
float
|
Minimum distance of the initial peak guesses as fraction of the number of points. Default 0.05. |
min_sigma_fraction, max_sigma_fraction |
float
|
Width bounds of Gaussian peaks as fraction of the time range. Defaults 0.005 and 0.3. |
min_peak_time_separation_fraction |
float
|
Minimum separation of the fitted peak times as fraction of the time range. Default 1e-4. |
relative_intensity_upper_bounds |
list of float or None
|
One value per peak in (0, 1]: maximum share of the total amplitude. |
peak_width_upper_bounds |
list of float or None
|
One value per peak: maximum width. |
min_peak_distance_fraction
class-attribute
instance-attribute
¶
min_peak_distance_fraction: float = 0.05
min_peak_time_separation_fraction
class-attribute
instance-attribute
¶
min_peak_time_separation_fraction: float = 0.0001
relative_intensity_upper_bounds
class-attribute
instance-attribute
¶
relative_intensity_upper_bounds: list[float] | None = None
peak_width_upper_bounds
class-attribute
instance-attribute
¶
peak_width_upper_bounds: list[float] | None = None
PlottingParameters
dataclass
¶
Appearance of the analysis plots of get_mainpeak_params.
Measurement.plot does not use these settings; plot_heatflow_with_gradient
uses figsize only.
Attributes:
| Name | Type | Description |
|---|---|---|
figsize |
tuple of float
|
Figure size in inches, used when no axes is passed. Default (10, 6). |
time_unit |
str
|
"seconds" (default), "minutes" or "hours". |
heat_unit |
str
|
"W" (default) or "mW". |
show_plot_title |
bool
|
Show a title. Default True. |
legend_pos |
str
|
"best" (default) or "outside" (right of the plot). |
plot_title |
str or list of str
|
With metadata loaded: metadata columns whose values form the title, e.g.
|
xlims, ylims |
tuple of float or None
|
Axis limits in plot units. |