Skip to content

Commit

Permalink
support mask in get_rfactors, for R4 calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
minhuanli committed Jul 10, 2024
1 parent f1afaaf commit 375056d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions SFC_Torch/Fmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,14 +1200,16 @@ def summarize(self, Ftotal_HKL=None):
print(f"r_free: {assert_numpy(self.r_free):<7.3f}")
print(f"Number of outliers: {np.sum(self.Outlier):<7d}")

def get_rfactors(self, ftotal=None):
def get_rfactors(self, ftotal=None, mask=None):
if ftotal is None:
ftotal = self.Ftotal_HKL.detach().clone()

if mask is None:
mask = np.ones(len(self.Fo)).astype(bool)
bool_array = (~self.Outlier) & mask
r_work, r_free = r_factor(
self.Fo[~self.Outlier],
torch.abs(ftotal)[~self.Outlier],
self.free_flag[~self.Outlier],
self.Fo[bool_array],
torch.abs(ftotal)[bool_array],
self.free_flag[bool_array],
)
return r_work, r_free

Expand Down

0 comments on commit 375056d

Please sign in to comment.