pyfli.simulator.calibration.sweep_combination#

Combine per-experiment calibrations into one sweep-style simulator setup.

Functions

_parts(setup, sensor_type, mono_fraction)

_prior(d)

_py(obj[, indent])

_split(per_key, weights)

Keys with one distinct value go to the fixed config, the rest to sweep + weights.

_sweep_entry(values, weights)

Deduplicate values (keeping first-seen order) and add up their weights.

cdf_error(old, new[, n])

Maximum difference between the two priors' CDFs, in physical units.

combination_generator(setup, sensor_type[, ...])

pyfli.data_cc.ConfigCombinationGenerator for the combined setup (enumerates every combination).

combine_calibrations(json_paths, output_dir)

Build the combined sweep setup from per-experiment calibrated_sim_config.json files (name -> path) and write it to output_dir as combined_sim_setup.json, combined_sim_setup.py (same constants, importable) and irfs/<name>.txt.

load_combined_setup(path)

Read combined_sim_setup.json back, restoring the tuples the simulator expects.

load_experiment(json_path[, name])

make_combined_generator(setup_path[, run, ...])

Simulator for one IRF run of the combined setup: gen.simulate_once() draws a combination of the calibrated values and simulates one pixel with IRF_RUNS[run].

verify_combined(setup_path[, n_sim, n_exp, seed])

For every experiment of the combined setup, the coverage (coverage_fractions()) of its sample pixels by

write_setup_module(setup, path)

Write setup as an importable Python module of constants, plus SENSOR_SETUP.

Classes

ExperimentCalibration(name, json_path, payload)

IndependentSweepGenerator(irf_cube, base, ...)

Draws every swept key independently with its weights, then simulates one pixel with pyfli's SimGenerator.

class ExperimentCalibration(name: str, json_path: str, payload: dict, weight: float = 1.0)[source]#

Bases: object

Parameters:
name: str#
json_path: str#
payload: dict#
weight: float = 1.0#
property config: dict#
property kwargs: dict#
property detector: str#
irf_template()[source]#
Return type:

ndarray

load_experiment(json_path, name=None)[source]#
Parameters:
  • json_path (str)

  • name (str | None)

Return type:

ExperimentCalibration

cdf_error(old, new, n=2001)[source]#

Maximum difference between the two priors’ CDFs, in physical units.

Parameters:
Return type:

float

combine_calibrations(json_paths, output_dir, weighting='equal')[source]#

Build the combined sweep setup from per-experiment calibrated_sim_config.json files (name -> path) and write it to output_dir as combined_sim_setup.json, combined_sim_setup.py (same constants, importable) and irfs/<name>.txt.

weighting: “equal” (every experiment counts the same) or “pixels” (by number of sample pixels). Returns the setup dict.

Parameters:
Return type:

dict

write_setup_module(setup, path)[source]#

Write setup as an importable Python module of constants, plus SENSOR_SETUP.

Parameters:
Return type:

None

load_combined_setup(path)[source]#

Read combined_sim_setup.json back, restoring the tuples the simulator expects.

Parameters:

path (str)

Return type:

dict

combination_generator(setup, sensor_type, mono_fraction=None)[source]#

pyfli.data_cc.ConfigCombinationGenerator for the combined setup (enumerates every combination).

Parameters:
  • setup (dict)

  • sensor_type (str)

  • mono_fraction (float | None)

Return type:

ConfigCombinationGenerator

class IndependentSweepGenerator(irf_cube, base, sweep, weights, a_range, b_range, seed=None)[source]#

Bases: object

Draws every swept key independently with its weights, then simulates one pixel with pyfli’s SimGenerator. The resulting distribution is that of ConfigCombinationGenerator.sample / WeightedConfigSimGenerator (combination weight = product of per-key weights), but nothing is enumerated, so any number of experiments works. config_index in the output gives the chosen value index per key.

Parameters:
simulate_once()[source]#
Return type:

dict

make_combined_generator(setup_path, run=0, mono_fraction=None, seed=None, exact_ranges=True)[source]#

Simulator for one IRF run of the combined setup: gen.simulate_once() draws a combination of the calibrated values and simulates one pixel with IRF_RUNS[run]. exact_ranges uses that IRF’s own calibrated a_range / b_range and inactive time bins (IRF_RUN_INFO); otherwise the global A_RANGE / B_RANGE.

Parameters:
  • setup_path (str)

  • run (int)

  • mono_fraction (float | None)

  • seed (int | None)

  • exact_ranges (bool)

verify_combined(setup_path, n_sim=10000, n_exp=20000, seed=0)[source]#

For every experiment of the combined setup, the coverage (coverage_fractions()) of its sample pixels by

  • own values: the combination made of that experiment’s sweep values, i.e. its own calibration after re-expression on the common supports;

  • combined: the whole combined distribution (all combinations, with weights).

Both use the experiment’s own IRF run. The experimental pixels are re-loaded from the experiment’s data file with its calibration’s bin radius and sample mask. The table is also written next to the setup as coverage_per_experiment.csv.

Parameters:
Return type:

DataFrame