@@ -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
@@ -1273,6 +1276,7 @@ def plot_dominant_phase(
12731276
12741277 """
12751278
1279+
12761280 if phase_colors is None :
12771281 phase_colors = np .array (
12781282 [
@@ -1323,16 +1327,38 @@ def plot_dominant_phase(
13231327 sub = phase_sig [a0 ] > phase_corr
13241328 phase_map [sub ] = a0
13251329 phase_corr [sub ] = phase_sig [a0 ][sub ]
1330+ self .phase_corr_total = np .sum (phase_corr ,axis = 0 )
1331+
1332+ phase_scale = np .ones ((
1333+ self .phase_sig .shape [1 ],
1334+ self .phase_sig .shape [2 ],
1335+ ))
1336+ # if self.single_phase:
1337+ # if reliability_range is not None:
1338+ # phase_scale *= np.clip(
1339+ # (self.phase_reliability - reliability_range[0])
1340+ # / (reliability_range[1] - reliability_range[0]),
1341+ # 0,
1342+ # 1,
1343+ # )
1344+ # if correlation_range is not None:
1345+ # phase_scale *= np.clip(
1346+ # (self.phase_corr_total - correlation_range[0])
1347+ # / (correlation_range[1] - correlation_range[0]),
1348+ # 0,
1349+ # 1,
1350+ # )
1351+
1352+ # phase_scale = np.clip(
1353+ # (self.phase_reliability - reliability_range[0])
1354+ # / (reliability_range[1] - reliability_range[0]),
1355+ # 0,
1356+ # 1,
1357+ # )
1358+
1359+ # else:
1360+ if not self .single_phase :
13261361
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 ,
1333- )
1334-
1335- else :
13361362 # find the second correlation score for each crystal and match index
13371363 for a0 in range (self .num_crystals ):
13381364 corr = phase_sig [a0 ].copy ()
@@ -1345,14 +1371,28 @@ def plot_dominant_phase(
13451371
13461372 # normalize the reliability by the intensity of each experimental pattern
13471373 if normalize_exp_intensity :
1348- phase_rel /= self .int_total
1349-
1350- phase_scale = np .clip (
1351- (phase_rel - reliability_range [0 ])
1374+ phase_rel /= (self .int_total + 1e-12 )
1375+
1376+ # phase_scale = np.clip(
1377+ # (phase_rel - reliability_range[0])
1378+ # / (reliability_range[1] - reliability_range[0]),
1379+ # 0,
1380+ # 1,
1381+ # )
1382+ if reliability_range is not None :
1383+ phase_scale *= np .clip (
1384+ (self .phase_reliability - reliability_range [0 ])
13521385 / (reliability_range [1 ] - reliability_range [0 ]),
13531386 0 ,
13541387 1 ,
13551388 )
1389+ if correlation_range is not None :
1390+ phase_scale *= np .clip (
1391+ (self .phase_corr_total - correlation_range [0 ])
1392+ / (correlation_range [1 ] - correlation_range [0 ]),
1393+ 0 ,
1394+ 1 ,
1395+ )
13561396
13571397 # Print the total area of fraction of each phase
13581398 if print_fractions :
0 commit comments