pyfli.simulator.calibration.pooled_calibration#

One simulator config that covers several experiments.

Functions

_background_fraction(dcr, b, photons, ...)

Fraction of a pixel's counts that is flat background: dark counts plus the IRF baseline b.

combine_states(sessions, weights, fm[, ...])

covering_background(sessions, library, ...)

One dark-count rate cannot reproduce experiments whose backgrounds differ 100-fold, and too much background pulls the raw phasors of clean experiments out of the simulated cloud.

covering_beta(samples, weights, offset, scale)

Beta on [offset, offset + scale] matched to the weighted mixture of samples, then widened until each sample set's q_exp interval lies inside the Beta's q_cov interval.

find_session_configs(root[, pattern])

name -> calibrated_sim_config.json for every calibrated experiment under root.

load_session_calibration(json_path[, name, ...])

Rebuild the calibrated CalibrationState from a calibrated_sim_config.json.

photon_range_photons(state)

pooled_pixels(sessions, n_per_exp[, seed, ...])

Equal-size random subsets of each experiment's sample pixels; returns (decays (N, T), experiment index (N,)).

Classes

PooledCalibrator(session_jsons, output_dir)

Build one covering simulator config from per-experiment calibrations.

PooledResult(config, sim_generator_kwargs, ...)

SessionCalibration(name, folder, json_path, ...)

class SessionCalibration(name: str, folder: str, json_path: str, payload: dict, state: CalibrationState)[source]#

Bases: object

Parameters:
name: str#
folder: str#
json_path: str#
payload: dict#
state: CalibrationState#
property n_bins: int#
load_session_calibration(json_path, name='', folder='')[source]#

Rebuild the calibrated CalibrationState from a calibrated_sim_config.json.

Parameters:
Return type:

SessionCalibration

covering_beta(samples, weights, offset, scale, q_exp=(0.01, 0.99), q_cov=(1e-3, 1 - 1e-3), min_shape=1.0)[source]#

Beta on [offset, offset + scale] matched to the weighted mixture of samples, then widened until each sample set’s q_exp interval lies inside the Beta’s q_cov interval.

Parameters:
Return type:

tuple[BetaPrior, dict]

combine_states(sessions, weights, fm, n_samples=20000, seed=0)[source]#
Parameters:
Return type:

tuple[CalibrationState, dict]

covering_background(sessions, library, n_samples, rng, q=0.995)[source]#

One dark-count rate cannot reproduce experiments whose backgrounds differ 100-fold, and too much background pulls the raw phasors of clean experiments out of the simulated cloud. The combined config therefore uses the lowest dark-count rate and gets the rest from the per-pixel IRF baseline b ~ U(0, b_max_k) (background proportional to signal). Background belongs to the detector channel, so each library IRF k gets its own b_max_k, chosen so that experiment k’s background fractions are reached. A single shared range would make the low-background channel’s clean pixels rare.

Parameters:
Return type:

tuple[float, ndarray, dict]

pooled_pixels(sessions, n_per_exp, seed=0, decay_name='clean_decay.npy', mask_name='final_mask.npy')[source]#

Equal-size random subsets of each experiment’s sample pixels; returns (decays (N, T), experiment index (N,)).

Parameters:
Return type:

tuple[ndarray, ndarray]

class PooledResult(config: dict, sim_generator_kwargs: dict, state: CalibrationState, coverage: DataFrame, prior_report: dict, validation: dict, output_dir: str, files: dict = <factory>)[source]#

Bases: object

Parameters:
config: dict#
sim_generator_kwargs: dict#
state: CalibrationState#
coverage: DataFrame#
prior_report: dict#
validation: dict#
output_dir: str#
files: dict#
class PooledCalibrator(session_jsons, output_dir, weighting='equal', n_per_exp=4000, n_validation=20000, target_coverage=0.90, max_flatten=8, flatten_factor=0.8, seed=0, folders=None)[source]#

Bases: object

Build one covering simulator config from per-experiment calibrations.

Parameters:
  • session_jsons (dict[str, str]) – experiment name -> calibrated_sim_config.json of that experiment.

  • weighting (str) – “equal” (each experiment counts the same) or “pixels” (by number of sample pixels).

  • target_coverage (float) – Required fraction of every experiment’s pixels inside the simulated phasor clouds (harmonics 1 and 2). Priors are flattened up to max_flatten times to reach it.

  • output_dir (str)

  • n_per_exp (int)

  • n_validation (int)

  • max_flatten (int)

  • flatten_factor (float)

  • seed (int)

  • folders (dict[str, str] | None)

run()[source]#
Return type:

PooledResult

find_session_configs(root, pattern='*')[source]#

name -> calibrated_sim_config.json for every calibrated experiment under root.

Parameters:
Return type:

dict[str, str]

photon_range_photons(state)[source]#
Parameters:

state (CalibrationState)

Return type:

tuple[float, float]