microcalorimetry.analysis

This module contains high-level routines for performing microcalorimetry analysis.

This module should contain static functions which take in configuration objects, and primative types (strings, numbers) that are then used to process the data. Where possible, they should use math functions defined in the math module.

These functions should be interfaceable via either a command line interface or a GUI where the user can only enter string-like inputs.

These function should utilize DataModelContainers when referring to inputs that represent inputs that cant be described by a short string (i.e. something convenient for a command line interface). This enables the passing of in-memory representations of data via the DataModelContainers so that it isn’t required to serialize the output of one function in order to pass it to the input of another.

Functions

make_correction_factor(...)

Calculate the correction factor for a given sensor model.

gc_from_model(→ tuple[microcalorimetry.configs.GCLike, ...)

Supply a parsed RF sweep and a python function to generate a GC model.

review_correction_factor(...)

Review a correction factor model.

fit_thermoelectric(...)

Fit sensitivity coefficients to a dcsweep measurement of a thermoelectric.

make_eta(...)

Make an effective efficiency measurement.

review_eta(→ tuple[matplotlib.pyplot.Figure, ...)

Make review plots of effective efficiency data.

make_eta_repeatability_model(...)

Generate a historical repeatability model from sensor data.

make_classical_eta_unc_model(...)

Generate a classical uncertainty model for an eta measurement.

dc_lead_correction(...)

Applies a dc lead correction.

apply_uncertainty_model(...)

Applies uncertainty models of effective efficiency measurements.

compression_check(...)

Check the compression ratio of of a measurement.

Package Contents

microcalorimetry.analysis.make_correction_factor(gc_regressor_rows: microcalorimetry.configs.CorrectionFactorModelInputs, correction_terms: int, calc_thermal_weights: bool = False, make_plots: bool = True, nominals: bool = False, cache_s11: bool = True, freq_resolution: int = 4) → tuple[microcalorimetry.configs.GCLike, list[matplotlib.pyplot.Figure]][source]

Calculate the correction factor for a given sensor model.

The normal_standards and special_standards are used to generate the regressor matrix. All possible combinations of connect cycles that use the same splitter_id are used to build the regressor matrix.

Parameters:
  • gcinputs (configs.CorrectionFactorDataInputs) – Dictionary of CorrectionFactorDataInputs.

  • correction_terms (int) – Number of terms in correction factor. Usually 1.

  • calc_thermal_weights (bool, optional) – If true, returns thermal weighting coefficients isntead of the correction factors (g_ci = wi/W0) where W0 is the sensitivity of the calorimeter.

  • make_plots (bool, optional) – Makes plots. The default is True.

  • nominals (bool, optional) – If true, propagates uncertainties.

  • cache_s11 (bool, optional) – If true, read ins every s-parameter file once to avoid redundant loading of files, memory intensive.

Returns:

  • gc (RMEMeas) – Correction factor in RMEMeas format.

  • figs (list[Figure]) – Matplotlib figures generated (if asked to make plots.)

microcalorimetry.analysis.gc_from_model(frequency: numpy.array, model: microcalorimetry.configs.PythonFunction, terms: int = 1) → tuple[microcalorimetry.configs.GCLike, matplotlib.pyplot.Figure][source]

Supply a parsed RF sweep and a python function to generate a GC model.

Parameters:
  • frequency (np.array) – Frequencies to evaluate model at.

  • model (configs.PythonFunction) – Python function that takes in a frequency (GHz) list and outputs correction factor values with the same shape.

  • terms (int, optional) – How many terms int he gc model. Default is 1.

Raises:

NotImplementedError – Only 1 term currently supported.

Returns:

  • gc (configs.GCLike) – Correction factor object.

  • fig (plt.Figure) – Plot of the generated GC.

microcalorimetry.analysis.review_correction_factor(gc: microcalorimetry.configs.GCLike, units: str = '', budget: bool = True) → list[matplotlib.pyplot.Figure, ...][source]

Review a correction factor model.

Parameters:
  • gc (configs.GCLike) – Correction factor model.

  • units (str, optional) – Units string for y-axis. The default is ‘’.

  • budget (bool, optional) – Plot the uncertainty budget. The default is True.

Returns:

List of figures generated.

Return type:

list[plt.Figure,…]

microcalorimetry.analysis.fit_thermoelectric(parsed_dcsweep: microcalorimetry.configs.ParsedDCSweep, thermometer_corrected: bool = False, constrain_zero: bool = False, p_of_e: bool = False, deg: int = 2, min_p: float = 0.001, make_plots: bool = True) → tuple[rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.KDCTemInd | microcalorimetry.arrays.KDCTempDep], matplotlib.pyplot.Figure][source]

Fit sensitivity coefficients to a dcsweep measurement of a thermoelectric.

Takes in a parsed dc measurement and generates sensitivity coefficients.

Parameters:
  • parsed_dcsweep (microcalorimetry.configs.ParsedDCSweep) – Steps parsed from sensitivity measurement. The first field is the applied voltage, the second field is the applied current, and the last field is the measure thermopile voltage.

  • thermometer_corrected (bool, optional) – Use a thermometer corrected model. Requires a thermometer voltage and current to be present in the parsed DC sweep. The default is False.

  • constrain_zero (bool, optional) – Constrains the fit to zero, only applies to non-thermometer corrected models. The default is False.

  • p_of_e (bool, optional) – Fit power as a function of thermopile voltage if True. If False, fits thermopile voltage as a function of power. Only applies to non thermometer corrected models. The default is False.

  • deg (int, optional) – Fit degrees of polynomial for non thermometer corrected models. Only applies to non thermometer corrected models. The default is 2.

  • min_p (float, optional) – The minimum power value to include in the fit. Values below this will be included as part of the residuals. The default is 0.001 (1 mW).

  • make_plots (bool, optional) – Output plots if True.

Returns:

  • sensitivity (RMEMeas[arrays.KDCTemInd | arrays.KDCTempDep]) – Sensitivity coefficients

  • figures (list[plt.Figure]) – List of figures generated (empty if not made). Fit and residuals.

microcalorimetry.analysis.make_eta(gc: microcalorimetry.configs.GCLike, s11: microcalorimetry.configs.S11Like, parsed_rfsweep: microcalorimetry.configs.ParsedRFSweep, clrm_sensitivity: microcalorimetry.configs.KDCLike = None, repeatability_model: microcalorimetry.configs.EtaLike = None, extra_eta_uncertainties: list[pathlib.Path] = None, historical_data: microcalorimetry.configs.EtaHistorical = None, legacy_uncertainties: bool = False, make_plots: bool = True) → tuple[list[matplotlib.pyplot.Figure] | None, rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.Eta]][source]

Make an effective efficiency measurement.

Parameters:
  • gc (configs.GCLike) – Calorimetric correction factor terms.

  • s11 (configs.S11Like) – Reflection coefficient of the sensor.

  • parsed_rfsweep (configs.ParsedRFSweep) – Parsed RF sweep output.

  • clrm_sensitivity (configs.KDCLike, optional) – If provided, assumes the correction factor is weighted by the calorimeters sensitivity and provide in units of (V/W). These coefficents will be used to calculate the dimensionless correction factor. The default is None.

  • repeatability_model (configs.EtaLike, optional) – Supply a repeatability model of the microcalorimeter to apply as uncertainty mechanisms and use in review charts. The default is None.

  • extra_eta_uncertainties (list[Path], optional) – Supply additional uncertainty models of eta that should be applied after the correction. The default is None.

  • historical_data (configs.EtaHistorical, optional) – Supply a historical Eta configuration object to use a reference measurements in the review charts. The default is None.

  • legacy_uncertainties (bool, optional) – If legacy uncertainties are selected, than uncertainties will not be carried forward from the supplied reflection coefficient, correction factor, dc measurements, and or sensitivity model. All uncertainties are expected to be supplied via the extra_eta_uncertainties or repeatability_model options. This is to support legacy microcalorimeter systems which do not forward propagate uncertainties from their measurement. The default is False.

  • make_plots (bool, optional) – Make plots during the analsysis,otherwise figs will be an empty list. The default is True. Plots are made by passing off to the review eta function.

Returns:

  • fig (List[plt.Figure] | None) – Any figures generated.

  • eta (RMEMeas[arrays.Eta]) – Effective efficiency.

microcalorimetry.analysis.review_eta(eta: microcalorimetry.configs.EtaLike, historical_data: microcalorimetry.configs.EtaHistorical = None, repeatability_model: microcalorimetry.configs.EtaLike = None, k: int = 2, frequency_precision: int = 4, max_hist_legend: int = None, hist_avg: bool = True) → tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Figure][source]

Make review plots of effective efficiency data.

Parameters:
  • eta (configs.EtaLike) – Effective efficiency being reviewed.

  • historical_data (configs.EtaHistorical) – Historical data to review against.

  • repeatability_model (configs.EtaLike) – Model of calorimeter’s repeatability to plot.

  • k (int, optional) – Expansion factor, by default 2

  • frequency_precision (int, optional) – Precision (decimal places) to round off frequencies to before averaging and comparing measurements.

  • max_hist_legend (int, optional) – Maxmium number of historical measurmeents to include in the legend. If None, will include all. Many historical measurements will result in large legends.

  • hist_avg (bool, optional) – If True, include the average of historical measurements in the plot.

Returns:

  • fig_hist – Figure of effectice efficiency measurement plotted against reference data provided.

  • fig_budget – Figure of uncertainty budget for effective efficiency measurement.

microcalorimetry.analysis.make_eta_repeatability_model(historical_data: dict[microcalorimetry.configs.EtaHistorical], make_plots: bool = True, dist: str = 'gaussian', coverage: float = 2, ddof: int = 1, min_points: int = 3, model_type: str = 'expanding_quadratic', categories: dict = {'Type': 'A', 'Origin': 'Repeatability'}, umech_id_basename: str = 'Repeatability', frequencies: numpy.array = None) → tuple[rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.Eta], list[matplotlib.pyplot.Figure], rmellipse.uobjects.RMEMeas][source]

Generate a historical repeatability model from sensor data.

Parameters:
  • historical_data (dict[configs.EtaHistorical]) – List of EtaHistorical configuration objects for different sensors. The key of each entry is the name of a sensor, and the values are the EtaHistorical objects.

  • make_plots (bool, optional) – Generate figures if True.

  • dist (str, optional) – Assume a type of distribution. Options are ‘guassian’ or ‘uniform’. By default ‘gaussian’.

  • coverage (int, optional) – Attempts to have 1 std uncertainty meet this coverage factor. The default is 2.

  • ddof (int, optional) – Delta degrees of freedom when calculating standard uncertainty frequency by frequency, only relevant for gaussian distributions.

  • min_points (int, optional) – Minimum number of required samples per frequency point to be included as part of the fit. The default is 3.

  • model_type (str, optional, {'expanding_quadratic','expanding_quadratic_linear','quadratic','constant','line'}) – Type of repeatability model to use. Expanding models are a constant value up to a cut off frequency, at which point they transition to a increasing function. One of ‘expanding_quadratic’,’expanding_quadratic_linear’,’quadratic’,’constant’,’line’.

  • categories (dict, optional) – Create category metadata for uncertainy mechnisms. The default is {‘Type’: ‘A’, ‘Origin’:’Repeatability’}.

  • umech_id_basename (str, optional) – Basename for the umech_id generated.

  • frequencies (np.array, optional) – If provided, will apply the repeatability model to the provided frequencies.

Returns:

  • hist_model (RMEMeas) – RMEMeas object of eff centered at 0 with uncertainties describing historical repeatability. Can be added to an effective efficiency measurement to add repeatability uncertainties.

  • fig (plt.Figure) – Figure reporting the model. None if no figure

  • coeffs (RMEMeas) – Fit coefficients generated from the repeatability model.

microcalorimetry.analysis.make_classical_eta_unc_model(frequency: numpy.array, model: microcalorimetry.configs.PythonFunction, u_type: str, correlate_frequencies: bool = True, make_plots: bool = True) → tuple[rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.Eta], matplotlib.pyplot.Figure][source]

Generate a classical uncertainty model for an eta measurement.

uA_model and uB_model are python functions that take in a frequency list and output a standard uncertainty (Type A and B respectively).

This model can be used to apply uncertainties to an eta calculate after it has been calculated. Is is zero nominal, so uncertainties are added to an eta measurement by simply adding it to to an effective efficiency measurement.

Uncertainties are assumed to be independent across frequency.

Parameters:
  • frequency (np.array) – Frequency in GHz.

  • model (configs.PythonFunction) – Python function that outputs type B uncertainty.

  • u_type (str) – Type of uncertainty (A or B)

  • correlate_frequencies (bool, optional) – Treat uncertainties as correlated if True. The default is True.

  • make_plots (bool, optional) – If True, make plots.

Returns:

  • eta_unc (RMEMeas[arrays.Eta]) – Eta configuration object with zero nominal and uncertainties derived from uA_model and uB_model.

  • fig (plt.Figure | None) – Matplotlib figure object generated.

microcalorimetry.analysis.dc_lead_correction(eta: microcalorimetry.configs.EtaLike, R_lead: float, R_bolo: float, R_lead_min_coverage: float = 0.14) → tuple[rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.Eta]][source]

Applies a dc lead correction.

Corrects for heat lost between the dc connector and the 4-wire connection of a resistor inside the sensor. See ERROR IN CALORIMETRIC EFFECTIVE EFFICIENCY MEASUREMENTS DUE TO DC LOSSES, T.P Crowley and B.F. Riddle for more details.

Parameters:
  • eta (configs.EtaLike) – Path to an effective efficiency measurement to apply the correction to.

  • R_lead (float) – Sum of resistance for Force and Sense leads of sensor, positive and negative sides.

  • R_bolo (float) – Bolometer resistance, usually 200 ohms for bolometer sensors.

  • R_lead_min_coverage (float, optional) – Uncertainties applied as a result of the dc lead correction will cover a minimun lead resistance of this value. If the lead resistance is greater than this value, then the associated uncertainty will be calculated useing the provided R_lead. The default value is 0.14 Ohms.

Returns:

eta – Corrected eta value

Return type:

RMEMeas[arrays.Eta]

microcalorimetry.analysis.apply_uncertainty_model(eta: microcalorimetry.configs.EtaLike, model: microcalorimetry.configs.EtaLike, make_unique: bool = False) → rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.Eta][source]

Applies uncertainty models of effective efficiency measurements.

Uncertainties are applied by adding model to eta, assuming model is zero nominal.

Parameters:
  • eta (configs.EtaLike) – Eta that will have unertainties applied.

  • model (configs.EtaLike) – Model of uncertainties that will be applied to eta. Should be nominaly zero.

  • make_unique (bool, optional) – If True, renames all uncertainty mechanisms so they are unique and independent from all other uncertainty mechanisms. Should be set to True for repeatability models.

Returns:

eta – Same nominal as the input eta, but with new uncertainties.

Return type:

RMEMeas[arrays.Eta]

microcalorimetry.analysis.compression_check(power: microcalorimetry.configs.RFSweepLike, power_minus_1dB: microcalorimetry.configs.RFSweepLike, k: int = 2) → tuple[rmellipse.uobjects.RMEMeas[microcalorimetry.arrays.RFSweep], matplotlib.pyplot.Figure][source]

Check the compression ratio of of a measurement.

Requires a parsed rfsweep at desired power, and another at the same frequency list backed off on the source by 1 dBm.

Parameters:
  • power (configs.RFSweepLike) – Power of sensor at desired output.

  • power_minus_1dB (configs.RFSweepLike) – Power measured by sensor backed off by 1dB at source from desired output.

  • k (int, optional) – Expansion factor to plot. The default is 2.

Returns:

  • compression_ratio (RMEMeas[arrays.RFSweep]) – Compression ratio.

  • fig (plt.Figure) – Figure object.