@@ -966,8 +966,8 @@ def plot_phase_weights(
966966 if total_intensity_normalize :
967967 sub = self .int_total > 0.0
968968 for a0 in range (self .num_fits ):
969- phase_weights [:, :, a0 ][sub ] /= self .int_total [sub ]
970- phase_residuals [sub ] /= self .int_total [sub ]
969+ phase_weights [:, :, a0 ][sub ] /= self .int_total [sub ] + 1e-12
970+ phase_residuals [sub ] /= self .int_total [sub ] + 1e-12
971971
972972 # intensity range for plotting
973973 if weight_normalize :
@@ -1112,7 +1112,7 @@ def plot_phase_maps(
11121112 if total_intensity_normalize :
11131113 sub = self .int_total > 0.0
11141114 for a0 in range (self .num_fits ):
1115- phase_weights [:, :, a0 ][sub ] /= self .int_total [sub ]
1115+ phase_weights [:, :, a0 ][sub ] /= self .int_total [sub ] + 1e-12
11161116
11171117 # intensity range for plotting
11181118 if weight_normalize :
@@ -1228,7 +1228,8 @@ def plot_phase_maps(
12281228 def plot_dominant_phase (
12291229 self ,
12301230 use_correlation_scores = False ,
1231- reliability_range = (0.0 , 1.0 ),
1231+ reliability_range = None ,
1232+ correlation_range = None ,
12321233 normalize_exp_intensity = True ,
12331234 sigma = 0.0 ,
12341235 phase_colors = None ,
@@ -1248,7 +1249,9 @@ def plot_dominant_phase(
12481249 use_correlation_scores: bool
12491250 Set to True to use correlation scores instead of reliabiltiy from intensity residuals.
12501251 reliability_range: (float, float)
1251- Plotting intensity range
1252+ Plotting intensity range from reliability
1253+ correlation_range: (float, float)
1254+ Plotting intensity range from correlation score
12521255 sigma: float
12531256 Smoothing in units of probe position.
12541257 phase_colors: np.array
@@ -1323,16 +1326,40 @@ def plot_dominant_phase(
13231326 sub = phase_sig [a0 ] > phase_corr
13241327 phase_map [sub ] = a0
13251328 phase_corr [sub ] = phase_sig [a0 ][sub ]
1329+ self .phase_corr_total = np .sum (phase_corr , axis = 0 )
13261330
1327- if self .single_phase :
1328- phase_scale = np .clip (
1329- (self .phase_reliability - reliability_range [0 ])
1330- / (reliability_range [1 ] - reliability_range [0 ]),
1331- 0 ,
1332- 1 ,
1331+ phase_scale = np .ones (
1332+ (
1333+ self .phase_sig .shape [1 ],
1334+ self .phase_sig .shape [2 ],
13331335 )
1336+ )
1337+ # if self.single_phase:
1338+ # if reliability_range is not None:
1339+ # phase_scale *= np.clip(
1340+ # (self.phase_reliability - reliability_range[0])
1341+ # / (reliability_range[1] - reliability_range[0]),
1342+ # 0,
1343+ # 1,
1344+ # )
1345+ # if correlation_range is not None:
1346+ # phase_scale *= np.clip(
1347+ # (self.phase_corr_total - correlation_range[0])
1348+ # / (correlation_range[1] - correlation_range[0]),
1349+ # 0,
1350+ # 1,
1351+ # )
1352+
1353+ # phase_scale = np.clip(
1354+ # (self.phase_reliability - reliability_range[0])
1355+ # / (reliability_range[1] - reliability_range[0]),
1356+ # 0,
1357+ # 1,
1358+ # )
1359+
1360+ # else:
1361+ if not self .single_phase :
13341362
1335- else :
13361363 # find the second correlation score for each crystal and match index
13371364 for a0 in range (self .num_crystals ):
13381365 corr = phase_sig [a0 ].copy ()
@@ -1345,14 +1372,28 @@ def plot_dominant_phase(
13451372
13461373 # normalize the reliability by the intensity of each experimental pattern
13471374 if normalize_exp_intensity :
1348- phase_rel /= self .int_total
1349-
1350- phase_scale = np .clip (
1351- (phase_rel - reliability_range [0 ])
1375+ phase_rel /= self .int_total + 1e-12
1376+
1377+ # phase_scale = np.clip(
1378+ # (phase_rel - reliability_range[0])
1379+ # / (reliability_range[1] - reliability_range[0]),
1380+ # 0,
1381+ # 1,
1382+ # )
1383+ if reliability_range is not None :
1384+ phase_scale *= np .clip (
1385+ (self .phase_reliability - reliability_range [0 ])
13521386 / (reliability_range [1 ] - reliability_range [0 ]),
13531387 0 ,
13541388 1 ,
13551389 )
1390+ if correlation_range is not None :
1391+ phase_scale *= np .clip (
1392+ (self .phase_corr_total - correlation_range [0 ])
1393+ / (correlation_range [1 ] - correlation_range [0 ]),
1394+ 0 ,
1395+ 1 ,
1396+ )
13561397
13571398 # Print the total area of fraction of each phase
13581399 if print_fractions :
0 commit comments