Skip to content

Commit

Permalink
Merge pull request #1708 from HEXRD/guess-engineering-constraints
Browse files Browse the repository at this point in the history
Filter down engineering constraint types
  • Loading branch information
saransh13 authored Jun 25, 2024
2 parents 57f8e31 + 60129ec commit 5a09f2d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
8 changes: 5 additions & 3 deletions hexrdgui/calibration/auto/powder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@

from hexrdgui.async_runner import AsyncRunner
from hexrdgui.calibration.auto import PowderCalibrationDialog
from hexrdgui.calibration.calibration_dialog import CalibrationDialog
from hexrdgui.calibration.calibration_dialog import (
CalibrationDialog,
guess_engineering_constraints,
)
from hexrdgui.calibration.material_calibration_dialog_callbacks import (
format_material_params_func,
MaterialCalibrationDialogCallbacks,
)
from hexrdgui.create_hedm_instrument import create_hedm_instrument
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.utils import masks_applied_to_panel_buffers
from hexrdgui.utils.guess_instrument_type import guess_instrument_type


class PowderRunner(QObject):
Expand Down Expand Up @@ -67,7 +69,7 @@ def _run(self):
else:
fwhm_estimate = options['initial_fwhm']

engineering_constraints = guess_instrument_type(self.instr.detectors)
engineering_constraints = guess_engineering_constraints(self.instr)

# Get an intensity-corrected masked dict of the images
img_dict = HexrdConfig().masked_images_dict
Expand Down
14 changes: 14 additions & 0 deletions hexrdgui/calibration/calibration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,17 @@ def data(self, index, role):
('xyz', True): ('X', 'Y', 'Z'),
('zxz', False): ('Z', "X'", "Z''"),
}


def guess_engineering_constraints(instr) -> str | None:
# First guess the instrument type.
instr_type = guess_instrument_type(instr.detectors)

# If it matches one of our expected engineering constraints, use it.
expected_options = [
'TARDIS',
]
if instr_type in expected_options:
return instr_type

return None
6 changes: 4 additions & 2 deletions hexrdgui/calibration/pick_based_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
LaueCalibrator,
PowderCalibrator,
)
from hexrdgui.calibration.calibration_dialog import (
guess_engineering_constraints,
)
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.utils.guess_instrument_type import guess_instrument_type


def make_calibrators_from_picks(instr, processed_picks, materials, img_dict,
Expand Down Expand Up @@ -40,7 +42,7 @@ def make_calibrators_from_picks(instr, processed_picks, materials, img_dict,

def create_instrument_calibrator(picks, instr, img_dict, materials):
euler_convention = HexrdConfig().euler_angle_convention
engineering_constraints = guess_instrument_type(instr.detectors)
engineering_constraints = guess_engineering_constraints(instr)
calibrators = make_calibrators_from_picks(instr, picks, materials,
img_dict, euler_convention)

Expand Down
8 changes: 5 additions & 3 deletions hexrdgui/calibration/structureless/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

from hexrd.fitting.calibration import StructurelessCalibrator

from hexrdgui.calibration.calibration_dialog import CalibrationDialog
from hexrdgui.calibration.calibration_dialog import (
CalibrationDialog,
guess_engineering_constraints,
)
from hexrdgui.calibration.calibration_dialog_callbacks import (
CalibrationDialogCallbacks,
)
Expand All @@ -21,7 +24,6 @@
from hexrdgui.tree_views import GenericPicksTreeViewDialog
from hexrdgui.utils.conversions import angles_to_cart, cart_to_angles
from hexrdgui.utils.dialog import add_help_url
from hexrdgui.utils.guess_instrument_type import guess_instrument_type
from hexrdgui.utils.tth_distortion import apply_tth_distortion_if_needed

from .picks_io import load_picks_from_file, save_picks_to_file
Expand Down Expand Up @@ -199,7 +201,7 @@ def _hand_picking_finished(self):
def show_calibration_dialog(self, calibrator_lines):
self.previous_picks_data = calibrator_lines

engineering_constraints = guess_instrument_type(self.instr.detectors)
engineering_constraints = guess_engineering_constraints(self.instr)

# Create the structureless calibrator with the data
# FIXME: add the tth_distortion dict here, if present
Expand Down

0 comments on commit 5a09f2d

Please sign in to comment.