Skip to content

Commit

Permalink
linear boundary correction for 2d prior mask
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Jan 23, 2025
1 parent 8e43711 commit 06f3926
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion getdist/analysis_defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ smooth_scale_1D =-1

#0 is basic normalization correction
#1 is linear boundary kernel (should get gradient correct)
#2 is a higher order kernel, that also affects estimates way from the boundary (1D only)
#2 is a higher order kernel, that also affects estimates away from the boundary (1D only)
boundary_correction_order=1

#Correct for (over-smoothing) biases using multiplicative bias correction
Expand Down
9 changes: 5 additions & 4 deletions getdist/mcsamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,12 +1794,9 @@ def get2DDensityGridData(self, j, j2, num_plot_contours=None, get_density=False,
ix = a00 * bins2D > np.max(bins2D) * 1e-8
a00 = a00[ix]
normed = bins2D[ix] / a00
if boundary_correction_order == 0 or mask_function:
if boundary_correction_order == 0:
# simple boundary correction by normalization
bins2D[ix] = normed
if mask_function:
bool_mask = prior_mask[winw:-winw, winw:-winw] < 1e-8
bins2D[bool_mask] = 0
elif boundary_correction_order == 1:
# linear boundary correction
indexes = np.arange(-winw, winw + 1)
Expand Down Expand Up @@ -1827,6 +1824,10 @@ def get2DDensityGridData(self, j, j2, num_plot_contours=None, get_density=False,
else:
raise SettingError('unknown boundary_correction_order (expected 0 or 1)')

if mask_function:
bool_mask = prior_mask[winw:-winw, winw:-winw] < 1e-8
bins2D[bool_mask] = 0

if mult_bias_correction_order and not mask_function:
prior_mask = np.ones((ysize + 2 * winw, xsize + 2 * winw))
self._setEdgeMask2D(parx, pary, prior_mask, winw, alledge=True)
Expand Down

0 comments on commit 06f3926

Please sign in to comment.