Skip to content

Commit

Permalink
Fixed bug where wavelength_weight was not being set.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed Mar 22, 2024
1 parent 647a1a7 commit 04bc8e3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/dials/algorithms/refinement/reflection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ def laue_manager(

## Weighting strategy

# check incompatible weighting strategy
if params.weighting_strategy.override == "statistical":
raise DialsRefineConfigError(
'The "statistical" weighting strategy is not compatible '
"with laue refinement"
params.weighting_strategy.override == "statistical_laue"
elif params.weighting_strategy.override == "constant":
params.weighting_strategy.override = "constant_laue"
elif params.weighting_strategy.override is not None:
raise ValueError(
f"{params.weighting_strategy.override} not compatible with Laue data"
)
if params.weighting_strategy.override == "constant":
params.weighting_strategy.override = "constant_stills"

weighting_strategy = ReflectionManagerFactory.get_weighting_strategy_override(
params
Expand All @@ -420,6 +420,7 @@ def laue_manager(
scan_margin=params.scan_margin,
outlier_detector=outlier_detector,
weighting_strategy_override=weighting_strategy,
wavelength_weight=params.weighting_strategy.wavelength_weight,
)

@staticmethod
Expand Down Expand Up @@ -448,16 +449,14 @@ def get_weighting_strategy_override(
*params.weighting_strategy.constants
)

elif params.weighting_strategy.override == "laue_statistical":
elif params.weighting_strategy.override == "statistical_laue":
return weighting_strategies.LaueStatisticalWeightingStrategy(
params.weighting_strategy.init_wavelength_weight,
params.weighting_strategy.delta_wavelength_weight,
params.weighting_strategy.wavelength_weight,
)

elif params.weighting_strategy.override == "laue_mixed":
elif params.weighting_strategy.override == "constant_laue":
return weighting_strategies.LaueMixedWeightingStrategy(
params.weighting_strategy.init_wavelength_weight,
params.weighting_strategy.delta_wavelength_weight,
params.weighting_strategy.wavelength_weight,
)

return None
Expand Down Expand Up @@ -957,9 +956,6 @@ def print_stats_on_matches(self):


class LaueReflectionManager(ReflectionManager):
"""Overloads for a Reflection Manager that does not exclude
reflections too close to the spindle, and reports only information
about X, and Y residuals"""

_weighting_strategy = weighting_strategies.LaueStatisticalWeightingStrategy()
experiment_type = "laue"
Expand All @@ -975,6 +971,7 @@ def __init__(
scan_margin=0.0,
outlier_detector=None,
weighting_strategy_override=None,
wavelength_weight=1e7,
):

if len(reflections) == 0:
Expand Down Expand Up @@ -1049,6 +1046,10 @@ def __init__(
# set weights for all kept reflections
if weighting_strategy_override is not None:
self._weighting_strategy = weighting_strategy_override
else:
self._weighting_strategy = (
weighting_strategies.LaueStatisticalWeightingStrategy(wavelength_weight)
)
self._weighting_strategy.calculate_weights(self._reflections)

# not known until the manager is finalised
Expand Down

0 comments on commit 04bc8e3

Please sign in to comment.