Skip to content

Commit

Permalink
Making sure this is backed up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mclaughlin6464 committed Dec 14, 2017
1 parent 0e6a433 commit 689d8c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion halotools/empirical_models/assembias_models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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', )
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down

2 comments on commit 689d8c4

@aphearin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mclaughlin6464 - sorry about this, but I just saw where your function uses bounds_enforcing_decorator_factory. However, I deleted this feature with PR #834 because nobody was using this decorator and I got complaints that it was cluttered. If you want to reimplement it, you can just copy-and-paste the code deleted in this commit: 41ebd71. Otherwise, it might make for easier-to-read code if you just implement bounds-clipping directly in the relevant function's namespace.

@mclaughlin6464
Copy link
Contributor Author

@mclaughlin6464 mclaughlin6464 commented on 689d8c4 Dec 15, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.