コード例 #1
0
    def __init__(self,
                 parent: BaseTab,
                 measurement: Measurement,
                 global_settings: GlobalSettings,
                 statusbar: Optional[QtWidgets.QStatusBar] = None):
        """Inits depth profile dialog.
        
        Args:
            parent: a MeasurementTabWidget.
            measurement: a Measurement object
            global_settings: a GlobalSettings object
            statusbar: a QStatusBar object
        """
        super().__init__()
        uic.loadUi(gutils.get_ui_dir() / "ui_depth_profile_params.ui", self)

        self.parent = parent
        self.measurement = measurement
        self.statusbar = statusbar

        # Connect buttons
        self.OKButton.clicked.connect(self._accept_params)
        self.cancelButton.clicked.connect(self.close)

        locale = QLocale.c()
        self.spin_systerr.setLocale(locale)
        self.sbox_reference_density.setLocale(locale)

        m_name = self.measurement.name
        if m_name not in DepthProfileDialog.checked_cuts:
            DepthProfileDialog.checked_cuts[m_name] = set()

        gutils.fill_cuts_treewidget(self.measurement,
                                    self.treeWidget.invisibleRootItem(),
                                    use_elemloss=True)
        self.used_cuts = DepthProfileDialog.checked_cuts[m_name]

        gutils.set_btn_group_data(self.group_x_axis_units, DepthProfileUnit)
        self.x_axis_units = DepthProfileDialog.x_unit
        if self.x_axis_units == DepthProfileUnit.NM:
            self._show_reference_density()
        else:
            self._hide_reference_density()

        self.radioButtonNm.clicked.connect(self._show_reference_density)
        self.radioButtonAtPerCm2.clicked.connect(self._hide_reference_density)

        self.systematic_error = DepthProfileDialog.systerr
        self.show_scale_line = DepthProfileDialog.line_scale
        self.show_zero_line = DepthProfileDialog.line_zero

        self.cross_sections = global_settings.get_cross_sections()

        self._show_measurement_settings()
        self._show_efficiency_files()
        self.exec_()
コード例 #2
0
    def __init__(self,
                 parent,
                 measurement: Measurement,
                 statusbar: Optional[QtWidgets.QStatusBar] = None):
        """Inits element losses class.
        
         Args:
            parent: A MeasurementTabWidget.
            
        """
        super().__init__()
        uic.loadUi(gutils.get_ui_dir() / "ui_element_losses_params.ui", self)
        self.parent = parent
        self.measurement = measurement
        self.statusbar = statusbar
        self.cuts = []

        self.OKButton.clicked.connect(self.__accept_params)
        self.cancelButton.clicked.connect(self.close)
        # self.referenceCut.currentIndexChanged.connect(self.__load_targets)

        # TODO: Reads cut files twice. Requires Refactor.
        # Reference cuts
        m_name = self.measurement.name
        if m_name not in ElementLossesDialog.reference_cut:
            ElementLossesDialog.reference_cut[m_name] = None
        cuts, _ = self.measurement.get_cut_files()
        gutils.fill_combobox(self.referenceCut,
                             cuts,
                             text_func=lambda fp: fp.name)
        self.used_reference_cut = ElementLossesDialog.reference_cut[m_name]

        # Cuts and element losses
        if m_name not in ElementLossesDialog.checked_cuts:
            ElementLossesDialog.checked_cuts[m_name] = set()
        gutils.fill_cuts_treewidget(self.measurement,
                                    self.targetCutTree.invisibleRootItem(),
                                    use_elemloss=True)
        self.used_cuts = ElementLossesDialog.checked_cuts[m_name]

        self.partitionCount.setValue(ElementLossesDialog.split_count)
        self.radioButton_0max.setChecked(ElementLossesDialog.y_scale == 0)
        self.radioButton_minmax.setChecked(ElementLossesDialog.y_scale == 1)

        self.exec_()
コード例 #3
0
    def __init__(self,
                 parent: BaseTab,
                 spectrum_type: str = _MESU,
                 element_simulation: Optional[ElementSimulation] = None,
                 simulation: Optional[Simulation] = None,
                 measurement: Optional[Measurement] = None,
                 recoil_widget=None,
                 statusbar: Optional[QtWidgets.QStatusBar] = None,
                 spectra_changed=None):
        """Inits energy spectrum dialog.
        
        Args:
            parent: A TabWidget.
            spectrum_type: Whether spectrum is for measurement of simulation.
            element_simulation: ElementSimulation object.
            recoil_widget: RecoilElement widget.
            statusbar: QStatusBar
            spectra_changed: pyQtSignal that is emitted when recoil atom
                distribution is changed.
        """
        super().__init__()
        uic.loadUi(gutils.get_ui_dir() / "ui_energy_spectrum_params.ui", self)

        self.parent = parent
        if spectrum_type == EnergySpectrumWidget.MEASUREMENT:
            if measurement is None:
                raise ValueError(
                    f"Must provide a Measurement when spectrum type is "
                    f"{spectrum_type}")
        elif spectrum_type is EnergySpectrumWidget.SIMULATION:
            if simulation is None:
                raise ValueError(
                    f"Must provide a Simulation when spectrum type is "
                    f"{spectrum_type}")
            if element_simulation is None:
                raise ValueError(
                    f"Must provide an ElementSimulation when spectrum is "
                    f"{spectrum_type}")
        else:
            raise ValueError(f"Unexpected spectrum type: {spectrum_type}")

        self.spectrum_type = spectrum_type
        self.measurement = measurement
        self.simulation = simulation
        self.element_simulation = element_simulation
        self.statusbar = statusbar
        self.result_files = []

        self.use_eff_checkbox.stateChanged.connect(
            lambda *_: self.label_efficiency_files.setEnabled(self.
                                                              use_efficiency))
        self.use_efficiency = True

        locale = QLocale.c()
        self.histogramTicksDoubleSpinBox.setLocale(locale)

        # Connect buttons
        self.pushButton_Cancel.clicked.connect(self.close)

        self.external_tree_widget = QtWidgets.QTreeWidget()

        if self.spectrum_type == EnergySpectrumWidget.MEASUREMENT:
            EnergySpectrumParamsDialog.bin_width = \
                self.measurement.profile.channel_width
            self.pushButton_OK.clicked.connect(
                lambda: self.__accept_params(spectra_changed=spectra_changed))

            m_name = self.measurement.name
            if m_name not in EnergySpectrumParamsDialog.checked_cuts:
                EnergySpectrumParamsDialog.checked_cuts[m_name] = set()

            gutils.fill_cuts_treewidget(self.measurement,
                                        self.treeWidget.invisibleRootItem(),
                                        use_elemloss=True)
            self.measurement_cuts = \
                EnergySpectrumParamsDialog.checked_cuts[m_name]

            self.importPushButton.setVisible(False)
        else:
            EnergySpectrumParamsDialog.bin_width = \
                self.element_simulation.channel_width

            self._set_simulation_files(recoil_widget)
            self._set_measurement_files()
            self._set_external_files()

            # Change the bin width label text
            self.histogramTicksLabel.setText(
                "Simulation and measurement histogram bin width:")

            self.pushButton_OK.clicked.connect(
                self.__calculate_selected_spectra)
            self.importPushButton.clicked.connect(self.__import_external_file)

        self.used_bin_width = EnergySpectrumParamsDialog.bin_width
        # FIXME .eff files not shown in sim mode
        self.__update_eff_files()
        self.exec_()