diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2022-09-20 16:27:14 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2022-09-20 16:27:14 +0200 |
commit | 3a389b159d0fd3ba0afac1ffad2bf8c891c438e7 (patch) | |
tree | 907b547fcfa74f19bb79e2e8cbcb98412530d5d6 /lib | |
parent | 6445f148320fc855d4381ceff466c8550742ac09 (diff) |
utils: add support for more efficient observations file format
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/utils.py b/lib/utils.py index 1868b10..bd8f004 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -316,7 +316,17 @@ def observations_ignore_param(observations: list, ignored_parameters: list) -> l ) -def observations_to_by_name(observations: list): +def observation_dict_to_by_name(observation): + parameter_names = observation["param_names"] + by_name = observation["by_name"] + assert parameter_names == sorted(parameter_names) + for name in by_name: + for attribute in by_name[name]["attributes"]: + by_name[name][attribute] = np.array(by_name[name][attribute]) + return by_name, parameter_names + + +def observations_to_by_name(observations): """ Convert observation list to by_name dictionary for AnalyticModel analysis @@ -330,6 +340,8 @@ def observations_to_by_name(observations: list): :returns: tuple (by_name, parameter_names) which can be passed to AnalyticModel """ + if type(observations) is dict: + return observation_dict_to_by_name(observations) parameter_names = set() attributes_by_name = dict() by_name = dict() |