pyfli.simulator.calibration.sweep_combination#
Combine per-experiment calibrations into one sweep-style simulator setup.
Functions
|
|
|
|
|
|
|
Keys with one distinct value go to the fixed config, the rest to sweep + weights. |
|
Deduplicate values (keeping first-seen order) and add up their weights. |
|
Maximum difference between the two priors' CDFs, in physical units. |
|
|
|
Build the combined sweep setup from per-experiment |
|
Read |
|
|
|
Simulator for one IRF run of the combined setup: |
|
For every experiment of the combined setup, the coverage ( |
|
Write |
Classes
|
|
|
Draws every swept key independently with its weights, then simulates one pixel with pyfli's |
- class ExperimentCalibration(name: str, json_path: str, payload: dict, weight: float = 1.0)[source]#
Bases:
object
- cdf_error(old, new, n=2001)[source]#
Maximum difference between the two priors’ CDFs, in physical units.
- combine_calibrations(json_paths, output_dir, weighting='equal')[source]#
Build the combined sweep setup from per-experiment
calibrated_sim_config.jsonfiles (name -> path) and write it tooutput_dirascombined_sim_setup.json,combined_sim_setup.py(same constants, importable) andirfs/<name>.txt.weighting: “equal” (every experiment counts the same) or “pixels” (by number of sample pixels). Returns the setup dict.
- write_setup_module(setup, path)[source]#
Write
setupas an importable Python module of constants, plusSENSOR_SETUP.
- load_combined_setup(path)[source]#
Read
combined_sim_setup.jsonback, restoring the tuples the simulator expects.
- combination_generator(setup, sensor_type, mono_fraction=None)[source]#
pyfli.data_cc.ConfigCombinationGeneratorfor the combined setup (enumerates every combination).- Parameters:
- Return type:
- class IndependentSweepGenerator(irf_cube, base, sweep, weights, a_range, b_range, seed=None)[source]#
Bases:
objectDraws every swept key independently with its weights, then simulates one pixel with pyfli’s
SimGenerator. The resulting distribution is that ofConfigCombinationGenerator.sample/WeightedConfigSimGenerator(combination weight = product of per-key weights), but nothing is enumerated, so any number of experiments works.config_indexin the output gives the chosen value index per key.
- 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 withIRF_RUNS[run].exact_rangesuses that IRF’s own calibrateda_range/b_rangeand inactive time bins (IRF_RUN_INFO); otherwise the globalA_RANGE/B_RANGE.
- 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 byown 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.