Skip to content

Commit

Permalink
Improve use of G function
Browse files Browse the repository at this point in the history
  • Loading branch information
pafonine committed Sep 22, 2023
1 parent 6eab6a8 commit 132d6b0
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions cctbx/miller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,14 @@ def regularize(self):
result = result.select(selection_positive)
return result.set_info(info)

def g_function(self, R, volume_scale=False):
# reciprocal sphere
s = 1./self.d_spacings().data()
arg = 2*math.pi*s*R
vol=1
if(volume_scale): vol = 4*math.pi*R**3/3
return vol*3*(flex.sin(arg) - arg*flex.cos(arg))/(arg)**3

def as_double(self):
"""
Create a copy of the array with the data converted to a flex.double type.
Expand Down Expand Up @@ -4572,8 +4580,7 @@ def local_standard_deviation_map(self, radius,
# This should really have been called "local_variance_map" because the
# square root is not taken after local averaging of density-squared
complete_set = self.complete_set()
sphere_reciprocal=get_sphere_reciprocal(
complete_set=complete_set,radius=radius)
sphere_reciprocal = self.g_function(R=radius)
fft = self.fft_map(
resolution_factor=resolution_factor,
d_min=d_min,
Expand Down Expand Up @@ -4611,13 +4618,10 @@ def local_overlap_map(self, other, radius,
# Based on local_standard_deviation_map above
assert self.crystal_symmetry().unit_cell().is_similar_to(
other.crystal_symmetry().unit_cell())

complete_set = self.complete_set()
sphere_reciprocal=get_sphere_reciprocal(
complete_set=complete_set,radius=radius)
sphere_reciprocal = self.g_function(R=radius)
if d_min is None:
d_min=self.d_min()

fft = self.fft_map(
resolution_factor=resolution_factor,
d_min=d_min,
Expand All @@ -4628,7 +4632,6 @@ def local_overlap_map(self, other, radius,
assert_shannon_sampling=assert_shannon_sampling,
f_000=f_000)
fft.apply_sigma_scaling()

other_fft = other.fft_map(
resolution_factor=resolution_factor,
d_min=d_min,
Expand Down Expand Up @@ -6139,13 +6142,6 @@ def as_dsn6_map(self,
gridding_last=gridding_last,
map_data=map_data)

def get_sphere_reciprocal(complete_set=None,radius=None):
stol = flex.sqrt(complete_set.sin_theta_over_lambda_sq().data())
w = 4 * stol * math.pi * radius
sphere_reciprocal = 3 * (flex.sin(w) - w * flex.cos(w))/flex.pow(w, 3)
return sphere_reciprocal


def patterson_map(crystal_gridding, f_patt, f_000=None,
sharpening=False,
origin_peak_removal=False):
Expand Down

0 comments on commit 132d6b0

Please sign in to comment.