Skip to content

Commit

Permalink
Add relative constraints to structuress calibrator
Browse files Browse the repository at this point in the history
I'm not sure if this will get used, but let's add it for consistency.
It actually makes some changes elsewhere easier.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
  • Loading branch information
psavery committed Oct 10, 2024
1 parent f2813a7 commit 090402d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion hexrd/fitting/calibration/structureless.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
create_instr_params,
create_tth_parameters,
DEFAULT_EULER_CONVENTION,
RelativeConstraints,
tth_parameter_prefixes,
update_instrument_from_params,
)
Expand Down Expand Up @@ -38,20 +39,26 @@ def __init__(self,
data,
tth_distortion=None,
engineering_constraints=None,
relative_constraints=RelativeConstraints.none,
euler_convention=DEFAULT_EULER_CONVENTION):

self._instr = instr
self._data = data
self._tth_distortion = tth_distortion
self._engineering_constraints = engineering_constraints
self._relative_constraints = relative_constraints
self.euler_convention = euler_convention
self._update_tth_distortion_panels()
self.make_lmfit_params()
self.set_minimizer()

def make_lmfit_params(self):
params = []
params += create_instr_params(self.instr, self.euler_convention)
params += create_instr_params(
self.instr,
self.euler_convention,
self.relative_constraints,
)
params += create_tth_parameters(self.instr, self.meas_angles)

params_dict = lmfit.Parameters()
Expand All @@ -66,6 +73,7 @@ def calc_residual(self, params):
self.instr,
params,
self.euler_convention,
self.relative_constraints,
)

# Store these in variables so they are only computed once.
Expand Down Expand Up @@ -154,6 +162,18 @@ def _update_tth_distortion_panels(self):
for det_key, obj in self.tth_distortion.items():
obj.panel = self.instr.detectors[det_key]

@property
def relative_constraints(self):
return self._relative_constraints

@relative_constraints.setter
def relative_constraints(self, v):
if v == self._relative_constraints:
return

self._relative_constraints = v
self.make_lmfit_params()

@property
def engineering_constraints(self):
return self._engineering_constraints
Expand Down

0 comments on commit 090402d

Please sign in to comment.