Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change example filename extension #93

Merged
merged 7 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions alea/examples/configs/unbinned_wimp_running.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ computation_options:
in_common:
{
hypotheses: ["free", "zero", "true"],
output_filename: "toymc_power_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.h5",
output_filename: "toymc_power_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.ii.h5",
n_mc: 5000,
n_batch: 40,
toydata_mode: "generate",
Expand All @@ -30,7 +30,7 @@ computation_options:
in_common:
{
hypotheses: ["free", "zero", "true"],
output_filename: "toymc_power_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.h5",
output_filename: "toymc_power_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.ii.h5",
n_mc: 5000,
n_batch: 40,
limit_threshold: "thresholds.json",
Expand All @@ -44,14 +44,14 @@ computation_options:
poi_expectation: 0.,
wimp_mass: 50,
hypotheses: ["free", "zero", "true"],
output_filename: "toymc_sensi_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.h5",
output_filename: "toymc_sensi_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.ii.h5",
n_mc: 5000,
n_batch: 40,
compute_confidence_interval: True,
limit_threshold: "thresholds.json",
asymptotic_dof: 1,
toydata_mode: "generate_and_store",
toydata_filename: "toyfile_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.h5",
toydata_filename: "toyfile_wimp_mass_{wimp_mass:d}_poi_expectation_{poi_expectation:.2f}.ii.h5",
}

slurm_configurations:
Expand Down
8 changes: 4 additions & 4 deletions alea/examples/configs/unbinned_wimp_statistical_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ likelihood_config:
- er_band_shift
named_parameters:
- er_band_shift
template_filename: er_template_{er_band_shift}.h5
template_filename: er_template_{er_band_shift}.ii.h5
histogram_scale_factor: 1

- name: wimp
Expand All @@ -100,7 +100,7 @@ likelihood_config:
- signal_efficiency
named_parameters:
- wimp_mass
template_filename: wimp{wimp_mass:d}gev_template.h5
template_filename: wimp{wimp_mass:d}gev_template.ii.h5
apply_efficiency: True
efficiency_name: signal_efficiency

Expand All @@ -122,7 +122,7 @@ likelihood_config:
- er_band_shift
named_parameters:
- er_band_shift
template_filename: er_template_{er_band_shift}.h5
template_filename: er_template_{er_band_shift}.ii.h5
histogram_scale_factor: 2

- name: wimp
Expand All @@ -133,6 +133,6 @@ likelihood_config:
- signal_efficiency
named_parameters:
- wimp_mass
template_filename: wimp{wimp_mass:d}gev_template.h5
template_filename: wimp{wimp_mass:d}gev_template.ii.h5
apply_efficiency: True
efficiency_name: signal_efficiency
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ likelihood_config:
- er_band_shift
named_parameters:
- er_band_shift
template_filename: er_template_{er_band_shift}.h5
template_filename: er_template_{er_band_shift}.ii.h5

- name: wimp
histname: wimp_template
parameters:
- wimp_rate_multiplier
- wimp_mass
template_filename: wimp50gev_template.h5
template_filename: wimp50gev_template.ii.h5
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ likelihood_config:
fixed_weight: 0.2
weight_names: [fixed_weight, er_band_shift] # not meaningful, just an example
histnames: [er_template, er_template, er_template]
template_filenames: [er_template_0.h5, er_template_1.h5, er_template_-1.h5]
template_filenames: [er_template_0.ii.h5, er_template_1.ii.h5, er_template_-1.ii.h5]
histogram_scale_factor: 100 # absolute rate, /year

- name: wimp
Expand All @@ -97,7 +97,7 @@ likelihood_config:
- wimp_rate_multiplier
- wimp_mass
- signal_efficiency
template_filename: wimp50gev_template.h5
template_filename: wimp50gev_template.ii.h5
apply_efficiency: True
efficiency_name: signal_efficiency

Expand All @@ -121,7 +121,7 @@ likelihood_config:
- er_band_shift
named_parameters:
- er_band_shift
template_filename: er_template_{er_band_shift}.h5
template_filename: er_template_{er_band_shift}.ii.h5

- name: wimp
class: alea.template_source.SpectrumTemplateSource
Expand All @@ -130,7 +130,7 @@ likelihood_config:
- wimp_rate_multiplier
- wimp_mass
- signal_efficiency
template_filename: wimp50gev_template.h5
template_filename: wimp50gev_template.ii.h5
spectrum_name: test_cs1_spectrum.json
apply_efficiency: True
efficiency_name: signal_efficiency
6 changes: 3 additions & 3 deletions alea/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Runner:
toydata mode, choice from 'read', 'generate', 'generate_and_store', 'no_toydata'
toydata_filename (str, optional (default=None)): toydata filename
only_toydata (bool, optional (default=False)): whether only generate toydata
output_filename (str, optional (default='test_toymc.h5')): output filename
output_filename (str, optional (default='test_toymc.ii.h5')): output filename
seed (int, optional (default=None)): random seed for runners before generating toydata
metadata (dict, optional (default=None)): metadata to be saved in output file

Expand All @@ -88,9 +88,9 @@ def __init__(
confidence_level: float = 0.9,
confidence_interval_kind: str = "central",
toydata_mode: str = "generate_and_store",
toydata_filename: str = "test_toydata_filename.h5",
toydata_filename: str = "test_toydata_filename.ii.h5",
only_toydata: bool = False,
output_filename: str = "test_output_filename.h5",
output_filename: str = "test_output_filename.ii.h5",
seed: Optional[int] = None,
metadata: Optional[dict] = None,
):
Expand Down
22 changes: 21 additions & 1 deletion docs/source/basics/runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@

Runners
=======
**UNDER CONSTRUCTION**

Data Format
===========
alea uses the
`inference_interface <https://github.com/XENONnT/inference_interface>`_
to handle storing fit results, toy data and to load _templates_
-- histograms that define a PDF for e.g. the blueice_extended_model.
inference_interface uses the pyhdf format, with specific fields for:
* fit results: uses numpy_to_toyfile and toyfile_to_numpy to write
and load best-fit values, upper/lower limits and other values from toy fits.
* toy data: uses toydata_to_file and toydata_from_file to
write and load toy data-- alea uses this format to read/write data.
* templates: uses template_to_multihist and
multihist_to_template, alternatively numpy_to_template,
template_to_numpy (root version also exists but is not uses)

To emphasize that we encourage this standard format for all
alea
read/writing,
we use the file
ending .ii.h5 for the files in these formats.
4 changes: 2 additions & 2 deletions notebooks/3_sensitivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
" generate_values={\"wimp_rate_multiplier\": 0.0},\n",
" compute_confidence_interval=True,\n",
" toydata_mode=\"generate\",\n",
" output_filename=\"out.h5\",\n",
" output_filename=\"out.ii.h5\",\n",
" **model_config\n",
")"
]
Expand Down Expand Up @@ -163,7 +163,7 @@
"metadata": {},
"outputs": [],
"source": [
"results = toyfiles_to_numpy(\"out.h5\")\n",
"results = toyfiles_to_numpy(\"out.ii.h5\")\n",
"uls = results[\"free\"][\"ul\"]"
]
},
Expand Down
15 changes: 15 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
# Set maximum width of the line to 100
max-line-length = 100

# Excluding some directories:
exclude =
.git
.github
docs*
notebooks*
*.yml
__pycache__
.venv
.eggs
*.egg
dist
*cfg


# E203 whitespace before ':'
# F401 imported but unused
# F403 unable to detect undefined names
Expand Down
2 changes: 1 addition & 1 deletion tests/test_blueice_extended_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setUp(cls):
]
ns = [len(c["likelihood_config"]["likelihood_terms"]) for c in cls.configs]
cls.n_likelihood_terms = ns
cls.toydata_filename = "simple_data.h5"
cls.toydata_filename = "simple_data.ii.h5"
cls.set_new_models(cls)

def set_new_models(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gaussian_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_data_generation(self):

def test_data_storage(self):
"""Test storage of data to file and retrieval of data from file."""
toydata_filename = "simple_data.h5"
toydata_filename = "simple_data.ii.h5"
self.model.data = self.model.generate_data(mu=0)
self.model.store_data(toydata_filename, [self.model.data])
stored_data = inference_interface.toydata_from_file(toydata_filename)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class TestRunner(TestCase):
def setUp(cls):
"""Initialise the Runner instance."""
cls.running_config = load_yaml("unbinned_wimp_running.yaml")
cls.toydata_filename = "simple_data.h5"
cls.output_filename = "test_toymc.h5"
cls.toydata_filename = "simple_data.ii.h5"
cls.output_filename = "test_toymc.ii.h5"
cls.n_mc = 3

def set_gaussian_runner(self, toydata_mode="generate_and_store"):
Expand Down
Loading