|
5 | 5 | # & Institut Laue - Langevin
|
6 | 6 | # SPDX - License - Identifier: GPL - 3.0 +
|
7 | 7 |
|
| 8 | +from typing import Optional |
| 9 | + |
8 | 10 | from sans.common.enums import SANSInstrument, ReductionMode, DetectorType, RangeStepType, FitModeForMerge, DataType, FitType, RebinType
|
9 | 11 | from sans.common.general_functions import get_bank_for_spectrum_number, get_detector_types_from_instrument
|
10 | 12 | from sans.state.IStateParser import IStateParser
|
|
16 | 18 | from sans.state.StateObjects.StateMaskDetectors import get_mask_builder, StateMaskDetectors
|
17 | 19 | from sans.state.StateObjects.StateMoveDetectors import get_move_builder
|
18 | 20 | from sans.state.StateObjects.StateNormalizeToMonitor import get_normalize_to_monitor_builder
|
19 |
| -from sans.state.StateObjects.StatePolarization import StatePolarization |
| 21 | +from sans.state.StateObjects.StatePolarization import StatePolarization, StateComponent |
20 | 22 | from sans.state.StateObjects.StateReductionMode import StateReductionMode
|
21 | 23 | from sans.state.StateObjects.StateSave import StateSave
|
22 | 24 | from sans.state.StateObjects.StateScale import StateScale
|
@@ -74,7 +76,7 @@ def get_state_normalize_to_monitor(self, _):
|
74 | 76 | def get_state_reduction_mode(self):
|
75 | 77 | return self._implementation.reduction_mode
|
76 | 78 |
|
77 |
| - def get_state_polarization(self): |
| 79 | + def get_state_polarization(self) -> Optional[StatePolarization]: |
78 | 80 | return self._implementation.polarization
|
79 | 81 |
|
80 | 82 | def get_state_save(self):
|
@@ -521,6 +523,24 @@ def _parse_polarization(self):
|
521 | 523 | polarization_dict = self.get_val("polarization")
|
522 | 524 | self.polarization.flipper_configuration = self.get_val("flipper_configuration", polarization_dict)
|
523 | 525 | self.polarization.spin_configuration = self.get_val("spin_configuration", polarization_dict)
|
| 526 | + flipper_dicts = self.get_val("flipper", polarization_dict) |
| 527 | + if flipper_dicts: |
| 528 | + for flipper_dict in flipper_dicts.values(): |
| 529 | + self.polarization.flippers.append(self._parse_component(flipper_dict)) |
| 530 | + |
| 531 | + def _parse_component(self, flipper_dict: dict) -> StateComponent: |
| 532 | + flipper_state = StateComponent() |
| 533 | + flipper_state.idf_component_name = self.get_val("idf_component_name", flipper_dict) |
| 534 | + flipper_state.device_name = self.get_val("device_name", flipper_dict) |
| 535 | + flipper_state.device_type = self.get_val("device_type", flipper_dict) |
| 536 | + location_dict = self.get_val("location", flipper_dict) |
| 537 | + if location_dict: |
| 538 | + flipper_state.location_x = self.get_val("x", location_dict) |
| 539 | + flipper_state.location_y = self.get_val("y", location_dict) |
| 540 | + flipper_state.location_z = self.get_val("z", location_dict) |
| 541 | + flipper_state.transmission = self.get_val("transmission", flipper_dict) |
| 542 | + flipper_state.efficiency = self.get_val("efficiency", flipper_dict) |
| 543 | + return flipper_state |
524 | 544 |
|
525 | 545 | @staticmethod
|
526 | 546 | def _get_1d_min_max(one_d_binning: str):
|
|
0 commit comments