Skip to content

Commit

Permalink
Merge pull request #42 from XENONnT/nt_likelihood_dataformat
Browse files Browse the repository at this point in the history
Change data format to only use structured arrays
  • Loading branch information
dachengx authored Jul 25, 2023
2 parents e4b29cd + 93fc829 commit 82f8d2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions alea/models/blueice_extended_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import scipy.stats as stats
from blueice.likelihood import LogAncillaryLikelihood, LogLikelihoodSum
from inference_interface import dict_to_structured_array

from alea.model import StatisticalModel
from alea.simulators import BlueiceDataGenerator
Expand Down Expand Up @@ -186,7 +187,7 @@ def _generate_data(self, **generate_values) -> list:
generate_values_anc = {k: v for k, v in generate_values.items() if k in ancillary_keys}
ancillary_measurements = self._generate_ancillary_measurements(
**generate_values_anc)
return science_data + [ancillary_measurements] + [generate_values]
return science_data + [ancillary_measurements] + [dict_to_structured_array(generate_values)]

def _generate_science_data(self, **generate_values) -> list:
science_data = [
Expand All @@ -208,7 +209,7 @@ def _generate_ancillary_measurements(self, **generate_values) -> dict:
parameter_meas = param.fit_limits[1]
ancillary_measurements[name] = parameter_meas

return ancillary_measurements
return dict_to_structured_array(ancillary_measurements)

def _set_efficiency(self, source, ll):
if "efficiency_name" not in source:
Expand Down Expand Up @@ -274,12 +275,12 @@ def constraint_terms(self) -> dict:
"""
return {name: func.logpdf for name, func in self.constraint_functions.items()}

def set_data(self, d: dict):
def set_data(self, d: np.array):
"""
Set the data of the ancillary likelihood (ancillary measurements).
Args:
d (dict): Data in this case is a dict of ancillary measurements.
d (np.array): Data of ancillary measurements, stored as numpy array
"""
# This results in shifted constraint terms.
if set(d.keys()) != set(self.parameters.names):
Expand Down

0 comments on commit 82f8d2d

Please sign in to comment.