clophfit.prtecan.export#

Export data and fit results from Titration objects.

Functions#

generate_combinations()

Generate parameter combinations for export and fitting.

apply_combination(titration, combination)

Apply a combination of parameters to the Titration.

prepare_output_folder(titration, base_path)

Prepare the output folder for a given combination of parameters.

export_residuals(outfit, fit_results, index)

Export fit residuals and their statistics to files.

export_trace_summary(trace, outfit, tag)

Write posterior statistics and the trace of a sampled model.

export_bad_wells(outfit, global_res)

Export a list of bad wells flagged during global fits.

run_pre_fit_detection(titration, subfolder)

Run pre-fit detection of bad wells and write discarded_wells.txt.

fit_single_mcmc(titration, datasets, outfit, spec)

Run optional PyMC fits for export, per well or jointly.

export_plate_fit(titration, datasets, outfit, method)

Fit the whole plate at once, classically, and write K per well.

export_fit(titration, subfolder, config[, spec, plate_fit])

Export all fitted parameters, plots, and data files.

export_data_fit(titration, tecan_config[, mcmc, plate_fit])

Export dat files [x,y1,..,yN] from copy of titration.data.

Module Contents#

clophfit.prtecan.export.generate_combinations()#

Generate parameter combinations for export and fitting.

Return type:

list[tuple[tuple[bool, …], str]]

clophfit.prtecan.export.apply_combination(titration, combination)#

Apply a combination of parameters to the Titration.

Parameters:
Return type:

None

clophfit.prtecan.export.prepare_output_folder(titration, base_path)#

Prepare the output folder for a given combination of parameters.

Parameters:
Return type:

pathlib.Path

clophfit.prtecan.export.export_residuals(outfit, fit_results, index)#

Export fit residuals and their statistics to files.

Parameters:
Return type:

None

clophfit.prtecan.export.export_trace_summary(trace, outfit, tag)#

Write posterior statistics and the trace of a sampled model.

Sampling and then keeping nothing from it is not a usable result: the multi-well path inferred x_true, a per-well K and the whole ye_mag family, and dropped the trace on return, so a run could be performed but not inspected. This writes trace_summary_<tag>.csv - mean, sd, HDI, r_hat and ESS per variable, the numbers that say whether to trust the rest - and the full trace as NetCDF for anything the summary does not cover.

Failures here are logged and swallowed. The summary describes a fit that has already succeeded, and a diagnostic must not be able to destroy the run it reports on.

Parameters:
  • trace (object) – PyMC/ArviZ inference data from the fit. None writes nothing.

  • outfit (Path) – Directory to write into.

  • tag (str) – Suffix identifying the model, e.g. "multi".

Return type:

None

clophfit.prtecan.export.export_bad_wells(outfit, global_res)#

Export a list of bad wells flagged during global fits.

Parameters:
Return type:

None

clophfit.prtecan.export.run_pre_fit_detection(titration, subfolder)#

Run pre-fit detection of bad wells and write discarded_wells.txt.

Parameters:
Return type:

None

clophfit.prtecan.export.fit_single_mcmc(titration, datasets, outfit, spec)#

Run optional PyMC fits for export, per well or jointly.

Parameters:
  • titration (Titration) – Titration object containing the plate scheme, fit keys, and background noise.

  • datasets (dict[str, Any]) – Mapping from well identifiers to datasets to fit.

  • outfit (Path) – Output directory used for residual-refit diagnostic CSV files.

  • spec (McmcSpec | None) – Sampling request deciding whether and how to run MCMC. None disables MCMC export.

Returns:

Per-well PyMC fit results when spec is provided. Returns None when spec is None.

Return type:

TitrationResults | None

clophfit.prtecan.export.export_plate_fit(titration, datasets, outfit, method)#

Fit the whole plate at once, classically, and write K per well.

The per-well fits above give each well its own noise scale; this fits every well in one least-squares problem with the observation-noise scale profiled per label across the plate, and each control group pooled onto one K. It is a separate output rather than a replacement: it produces a K and a standard error per well, not the fit objects the plot and dataset exports consume.

Parameters:
  • titration (Titration) – Supplies the plate scheme, whose control groups set which wells pool.

  • datasets (dict[str, Any]) – Well identifier to global Dataset, as built for the other fits.

  • outfit (Path) – Fit output directory.

  • method (str) – "lm" for the plate-wide least squares, "odr" to also let each titration step’s x move within its recorded uncertainty.

Returns:

The CSV written, or None when no wells were fitted.

Return type:

Path | None

clophfit.prtecan.export.export_fit(titration, subfolder, config, spec=None, plate_fit=None)#

Export all fitted parameters, plots, and data files.

Parameters:
Return type:

None

clophfit.prtecan.export.export_data_fit(titration, tecan_config, mcmc=None, plate_fit=None)#

Export dat files [x,y1,..,yN] from copy of titration.data.

Parameters:
Return type:

None