From ccea5f82409694648e23241230df95f1ad5801ff Mon Sep 17 00:00:00 2001 From: Sandy Yuan Date: Tue, 9 Jan 2024 12:45:19 -0800 Subject: [PATCH] bug fix keys() --- abacusnbody/hod/abacus_hod.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/abacusnbody/hod/abacus_hod.py b/abacusnbody/hod/abacus_hod.py index b92667a..09910bf 100644 --- a/abacusnbody/hod/abacus_hod.py +++ b/abacusnbody/hod/abacus_hod.py @@ -153,7 +153,9 @@ def __init__(self, sim_params, HOD_params, clustering_params = None, chunk=-1, n self.shearbins = np.linspace(-0.5, 0.5, 101) self.halo_mass_func, edges = np.histogramdd( - np.vstack((np.log10(self.halo_data['hmass']), self.halo_data['hdeltac'], self.halo_data['hfenv'])).T, + np.vstack((np.log10(self.halo_data['hmass']), + self.halo_data.get('hdeltac', np.zeros(len(self.halo_data['hmass']))), + self.halo_data.get('hfenv', np.zeros(len(self.halo_data['hmass']))))).T, bins = [self.logMbins, self.deltacbins, self.fenvbins], weights = self.halo_data['hmultis']) else: @@ -161,8 +163,15 @@ def __init__(self, sim_params, HOD_params, clustering_params = None, chunk=-1, n meta = get_meta(self.sim_name, redshift=0.1) self.lbox = meta['BoxSize'] + if self.want_AB: + assert 'hfenv' in self.halo_data.keys() + assert 'hdeltac' in self.halo_data.keys() + if self.want_shear: + assert 'hshear' in self.halo_data.keys() + self.halo_mass_func_wshear, edges = np.histogramdd( - np.vstack((np.log10(self.halo_data['hmass']), self.halo_data.get('hdeltac', np.zeros(len(self.halo_data['hmass']))), + np.vstack((np.log10(self.halo_data['hmass']), + self.halo_data.get('hdeltac', np.zeros(len(self.halo_data['hmass']))), self.halo_data.get('hfenv', np.zeros(len(self.halo_data['hmass']))), self.halo_data.get('hshear', np.zeros(len(self.halo_data['hmass']))))).T, bins = [self.logMbins, self.deltacbins, self.fenvbins, self.shearbins],