Skip to content

Commit

Permalink
Merge pull request #1727 from HEXRD/mirror-delta-parameters
Browse files Browse the repository at this point in the history
Mirror delta parameters from first detector
  • Loading branch information
psavery authored Sep 6, 2024
2 parents 8e85a77 + 9019abb commit e9a0174
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 20 additions & 3 deletions hexrdgui/calibration/calibration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def setup_connections(self):
self.on_engineering_constraints_changed)
self.ui.delta_boundaries.toggled.connect(
self.on_delta_boundaries_toggled)
self.ui.mirror_vary_from_first_detector.clicked.connect(
self.mirror_vary_from_first_detector)
self.ui.mirror_constraints_from_first_detector.clicked.connect(
self.mirror_constraints_from_first_detector)
self.ui.edit_picks_button.clicked.connect(self.on_edit_picks_clicked)
self.ui.save_picks_button.clicked.connect(self.on_save_picks_clicked)
self.ui.load_picks_button.clicked.connect(self.on_load_picks_clicked)
Expand Down Expand Up @@ -317,7 +317,7 @@ def on_delta_boundaries_toggled(self, b):
# The columns have changed, so we need to reinitialize the tree view
self.reinitialize_tree_view()

def mirror_vary_from_first_detector(self):
def mirror_constraints_from_first_detector(self):
config = self.tree_view.model().config
detector_iterator = iter(config['detectors'])
first_detector_name = next(detector_iterator)
Expand All @@ -332,6 +332,15 @@ def mirror_vary_from_first_detector(self):
},
}

if self.delta_boundaries:
# Mirror the delta values too
deltas = {
'tilt': {k: v['_delta'] for k, v in tilts.items()},
'translation': {
k: v['_delta'] for k, v in translations.items()
},
}

# Now loop through all other detectors and update them
for det_name in detector_iterator:
detector = config['detectors'][det_name]
Expand All @@ -341,6 +350,14 @@ def mirror_vary_from_first_detector(self):
det_transform[k]['_param'].vary = v
det_transform[k]['_vary'] = v

if self.delta_boundaries:
# Mirror the delta values too
for transform, delta_dict in deltas.items():
det_transform = detector['transform'][transform]
for k, v in delta_dict.items():
det_transform[k]['_param'].delta = v
det_transform[k]['_delta'] = v

self.tree_view.reset_gui()

def update_from_calibrator(self, calibrator):
Expand Down
8 changes: 4 additions & 4 deletions hexrdgui/resources/ui/calibration_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="mirror_vary_from_first_detector">
<widget class="QPushButton" name="mirror_constraints_from_first_detector">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If clicked, the &amp;quot;Vary&amp;quot; statuses of the first detector's tilt/translation parameters will be copied to all other detectors' tilt/translation parameters.&lt;/p&gt;&lt;p&gt;This is helpful if you have many detectors and want to modify all of their &amp;quot;Vary&amp;quot; settings in a similar way.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If clicked, the &amp;quot;Vary&amp;quot; and &amp;quot;Delta&amp;quot; (if &amp;quot;Use delta for boundaries&amp;quot; is checked) settings of the first detector's tilt/translation parameters will be copied to all other detectors' tilt/translation parameters.&lt;/p&gt;&lt;p&gt;This is helpful if you have many detectors and want to modify all of their &amp;quot;Vary&amp;quot; and &amp;quot;Delta&amp;quot; settings in a similar way.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Mirror &quot;Vary&quot; from First Detector</string>
<string>Mirror Constraints from First Detector</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -449,7 +449,7 @@ See scipy.optimize.least_squares for more details.</string>
<tabstop>draw_picks</tabstop>
<tabstop>engineering_constraints</tabstop>
<tabstop>delta_boundaries</tabstop>
<tabstop>mirror_vary_from_first_detector</tabstop>
<tabstop>mirror_constraints_from_first_detector</tabstop>
<tabstop>edit_picks_button</tabstop>
<tabstop>save_picks_button</tabstop>
<tabstop>load_picks_button</tabstop>
Expand Down

0 comments on commit e9a0174

Please sign in to comment.