From 9dd9522b87888288b53fa86ff512de55cda001f8 Mon Sep 17 00:00:00 2001 From: Josue De Santiago Date: Wed, 3 Apr 2024 10:36:18 -0600 Subject: [PATCH] Added option for z_truth to be inside an hdf5 group (#94) * I added the option for z_truth to be inside an hdf5 group * Fixing bug * Testing hdf5_groupname with ifs * add hdf5_groupname to override shared_params in test * added pragma statement * I changed the default goupname to empty string "". With this modification it is not necessary to change the test --------- Co-authored-by: sschmidt23 Co-authored-by: Eric Charles --- src/rail/evaluation/evaluator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rail/evaluation/evaluator.py b/src/rail/evaluation/evaluator.py index 869f51b..92eccfa 100644 --- a/src/rail/evaluation/evaluator.py +++ b/src/rail/evaluation/evaluator.py @@ -25,6 +25,7 @@ class Evaluator(RailStage): nzbins=Param(int, 301, msg="# of bins in zgrid"), pit_metrics=Param(str, 'all', msg='PIT-based metrics to include'), point_metrics=Param(str, 'all', msg='Point-estimate metrics to include'), + hdf5_groupname=Param(str, '', msg='Name of group in hdf5 where redshift data is located'), do_cde=Param(bool, True, msg='Evaluate CDE Metric'), redshift_col=SHARED_PARAMS) inputs = [('input', QPHandle), @@ -79,7 +80,12 @@ def run(self): """ pz_data = self.get_data('input') - z_true = self.get_data('truth')[self.config.redshift_col] + if self.config.hdf5_groupname: # pragma: no cover + specz_data = self.get_data('truth')[self.config.hdf5_groupname] + else: + specz_data = self.get_data('truth') + z_true = specz_data[self.config['redshift_col']] + zgrid = np.linspace(self.config.zmin, self.config.zmax, self.config.nzbins+1) # Create an instance of the PIT class