From 689d8c43eb67c84076331b431bd0aafc5847055f Mon Sep 17 00:00:00 2001 From: Sean McLaughlin Date: Thu, 14 Dec 2017 13:55:46 -0800 Subject: [PATCH] Making sure this is backed up. --- .../empirical_models/assembias_models/__init__.py | 2 +- .../assembias_models/continuous_assembias.py | 11 ++++++++--- .../assembias_models/free_split_assembias.py | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/halotools/empirical_models/assembias_models/__init__.py b/halotools/empirical_models/assembias_models/__init__.py index f67f6e447..cff4cb48d 100644 --- a/halotools/empirical_models/assembias_models/__init__.py +++ b/halotools/empirical_models/assembias_models/__init__.py @@ -1,3 +1,3 @@ from .heaviside_assembias import HeavisideAssembias +from .free_split_assembias import FreeSplitAssembias from .continuous_assembias import ContinuousAssembias -from .free_split_assembias import FreeSplitAssembias \ No newline at end of file diff --git a/halotools/empirical_models/assembias_models/continuous_assembias.py b/halotools/empirical_models/assembias_models/continuous_assembias.py index 742725485..32c12e1e1 100644 --- a/halotools/empirical_models/assembias_models/continuous_assembias.py +++ b/halotools/empirical_models/assembias_models/continuous_assembias.py @@ -14,6 +14,7 @@ from ...custom_exceptions import HalotoolsError from ...utils.array_utils import custom_len from ...utils.table_utils import compute_conditional_percentile_values, compute_conditional_averages +from ...utils.table_utils import compute_conditional_percentiles __all__ = ('ContinuousAssembias', 'FreeSplitContinuousAssembias' ) __author__ = ('Sean McLaughlin', ) @@ -86,7 +87,7 @@ def _initialize_assembias_param_dict(self, assembias_strength=0.5, assembias_slo # This formula ensures that the most extreme value will experience F times the maximum displacement # Otherwise, slope could arbitrarily cancel out strength. - @model_helpers.bounds_enforcing_decorator_factory(np.log10(np.log((1+F)/(1-F))), 10) + #@model_helpers.bounds_enforcing_decorator_factory(np.log10(np.log((1+F)/(1-F))), 10) def assembias_slope(self, prim_haloprop): """ Returns the slope of disp_func as a function of prim_haloprop @@ -154,13 +155,16 @@ def _galprop_perturbation(self, **kwargs): # the average displacement acts as a normalization we need. max_displacement = self._disp_func(sec_haloprop=sec_haloprop, slope=slope) disp_average = compute_conditional_averages(vals=max_displacement,prim_haloprop=prim_haloprop) - # disp_average = np.ones((prim_haloprop.shape[0], ))*0.5 + #disp_average = np.ones((prim_haloprop.shape[0], ))*0.5 result = np.zeros(len(prim_haloprop)) greater_than_half_avg_idx = disp_average > 0.5 less_than_half_avg_idx = disp_average <= 0.5 + #print max_displacement + #print strength, slope + if len(max_displacement[greater_than_half_avg_idx]) > 0: base_pos = baseline_result[greater_than_half_avg_idx] strength_pos = strength[greater_than_half_avg_idx] @@ -296,7 +300,8 @@ def wrapper(*args, **kwargs): else: perturbation = self._galprop_perturbation( prim_haloprop=prim_haloprop[no_edge_mask], - sec_haloprop=pv_sub_sec_haloprop/np.max(np.abs(pv_sub_sec_haloprop)), + #sec_haloprop=pv_sub_sec_haloprop/np.max(np.abs(pv_sub_sec_haloprop)), + sec_haloprop = compute_conditional_percentiles(prim_haloprop = prim_haloprop[no_edge_mask], sec_haloprop=sec_haloprop[no_edge_mask])-no_edge_split, baseline_result=no_edge_result) no_edge_result += perturbation diff --git a/halotools/empirical_models/assembias_models/free_split_assembias.py b/halotools/empirical_models/assembias_models/free_split_assembias.py index 6e4b8f948..3e41b8d0f 100644 --- a/halotools/empirical_models/assembias_models/free_split_assembias.py +++ b/halotools/empirical_models/assembias_models/free_split_assembias.py @@ -61,7 +61,7 @@ def _set_percentile_splitting(self, split=0.5, **kwargs): self.param_dict[self._get_free_split_assembias_param_dict_key(ipar)] = val def _get_free_split_assembias_param_dict_key(self, ipar): - return self._method_name_to_decorate + '_' + self.gal_type + '_split' + str(ipar + 1) + return self._method_name_to_decorate + '_' + self.gal_type + '_assembias_split' + str(ipar + 1) @model_helpers.bounds_enforcing_decorator_factory(0, 1) def percentile_splitting_function(self, prim_haloprop): @@ -81,8 +81,9 @@ def percentile_splitting_function(self, prim_haloprop): """ #retrieve ordinates from our dictionary - split_ordinates = (self.param_dict[self._get_free_split_assembias_param_dict_key(ipar)] - for ipar in xrange(len(self._split_abscissa))) + split_ordinates = np.array([self.param_dict[self._get_free_split_assembias_param_dict_key(ipar)] + for ipar in xrange(len(self._split_abscissa))]) + if self._loginterp: spline_function = model_helpers.custom_spline( np.log10(self._split_abscissa), split_ordinates, k=3)