From 375056d2fa8be0c998df717e2974afd23773f7c8 Mon Sep 17 00:00:00 2001 From: minhuanli Date: Wed, 10 Jul 2024 18:16:30 -0400 Subject: [PATCH] support mask in get_rfactors, for R4 calculation --- SFC_Torch/Fmodel.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/SFC_Torch/Fmodel.py b/SFC_Torch/Fmodel.py index 15e3a9d..b5fbd57 100644 --- a/SFC_Torch/Fmodel.py +++ b/SFC_Torch/Fmodel.py @@ -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