diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cli.py | 6 | ||||
-rw-r--r-- | lib/utils.py | 17 |
2 files changed, 23 insertions, 0 deletions
@@ -523,6 +523,12 @@ def add_standard_arguments(parser): "Note that this may remove entire function calls from the model.", ) parser.add_argument( + "--filter-observation", + metavar="<key>:<attribute>[,<key>:<attribute>...]", + type=str, + help="Only consider measurements of <key> <attribute>", + ) + parser.add_argument( "--ignore-param", metavar="<parameter name>[,<parameter name>,...]", type=str, diff --git a/lib/utils.py b/lib/utils.py index 40d8b69..4282a14 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -580,6 +580,23 @@ def shift_param_in_aggregate(aggregate, parameters, parameter_shift): ) +def filter_aggregate_by_observation(aggregate, observation_filter): + if observation_filter is None: + return + to_pop = dict() + for name in aggregate.keys(): + to_pop[name] = list() + for attribute in aggregate[name]["attributes"]: + if (name, attribute) not in observation_filter: + to_pop[name].append(attribute) + for name, attributes in to_pop.items(): + for attribute in attributes: + aggregate[name]["attributes"].remove(attribute) + aggregate[name].pop(attribute) + if len(aggregate[name]["attributes"]) == 0: + aggregate.pop(name) + + def filter_aggregate_by_param(aggregate, parameters, parameter_filter): """ Remove entries which do not have certain parameter values from `aggregate`. |