Esempio n. 1
0
    def setup_facilities_group(self):
        facilities = sorted(ConfigService.getFacilityNames())
        if not facilities:
            return
        self.view.facility.addItems(facilities)
        self.view.instrument = instrumentselector.InstrumentSelector()
        self.view.horizontalLayout_4.replaceWidget(self.view.instrument_dummy,
                                                   self.view.instrument)
        self.view.instrument_dummy.setVisible(False)

        try:
            default_facility = ConfigService.getFacility().name()
        except RuntimeError:
            default_facility = facilities[0]
        self.view.facility.setCurrentIndex(
            self.view.facility.findText(default_facility))
        self.action_facility_changed(default_facility)
        self.view.facility.currentTextChanged.connect(
            self.action_facility_changed)

        try:
            default_instrument = ConfigService.getInstrument().name()
        except RuntimeError:
            default_instrument = self.view.instrument.itemText(0)
        self.action_instrument_changed(default_instrument)
        self.view.instrument.currentTextChanged.connect(
            self.action_instrument_changed)
Esempio n. 2
0
    def setup_facilities_group(self):
        facilities = ConfigService.getFacilityNames()
        if not facilities:
            return
        self.view.facility.addItems(facilities)

        try:
            default_facility = ConfigService.getFacility().name()
        except RuntimeError:
            default_facility = facilities[0]
        self.view.facility.setCurrentIndex(
            self.view.facility.findText(default_facility))
        self.action_facility_changed(default_facility)
        self.view.facility.currentTextChanged.connect(
            self.action_facility_changed)

        try:
            default_instrument = ConfigService.getInstrument().name()
            self.view.instrument.setCurrentIndex(
                self.view.instrument.findText(default_instrument))
        except RuntimeError:
            default_instrument = self.view.instrument.itemText(0)
        self.action_instrument_changed(default_instrument)
        self.view.instrument.currentTextChanged.connect(
            self.action_instrument_changed)
Esempio n. 3
0
    def PyExec(self):
        wksp = self.getProperty("InputWorkspace").value
        # these items are not grabbed from the logs
        geometryContainer = self.getProperty("ContainerGeometry").value
        materialContainer = self.getProperty("ContainerMaterial").value

        # get a convenient handle to the logs
        runObject = wksp.run()

        # this is used for determining some of the log names
        instrEnum = ConfigService.getInstrument(
            wksp.getInstrument().getFullName())

        # get information from the logs
        material = self._createMaterial(runObject)
        geometry = self._createGeometry(runObject, instrEnum)
        environment = self._createEnvironment(runObject, instrEnum)

        # let SetSample generate errors if anything is wrong
        SetSample(InputWorkspace=wksp,
                  Material=material,
                  Geometry=geometry,
                  Environment=environment,
                  ContainerGeometry=geometryContainer,
                  ContainerMaterial=materialContainer)

        # validate that sample shape was set to something with volume!=0
        if (wksp.sample().getShape().volume() == 0):
            raise RuntimeError("Resulting sample shape has volume of 0")
Esempio n. 4
0
    def should_show_on_startup():
        """ Determines if the first time dialog should be shown
        :return: True if the dialog should be shown
        """
        # first check the facility and instrument
        facility = ConfigService.getString(AboutPresenter.FACILITY)
        instrument = ConfigService.getString(AboutPresenter.INSTRUMENT)
        if not facility:
            return True
        else:
            # check we can get the facility and instrument
            try:
                facilityInfo = ConfigService.getFacility(facility)
                instrumentInfo = ConfigService.getInstrument(instrument)
                logger.information("Default facility '{0}', instrument '{1}'\n".format(facilityInfo.name(),
                                                                                       instrumentInfo.name()))
            except RuntimeError:
                # failed to find the facility or instrument
                logger.error("Could not find your default facility '{0}' or instrument '{1}' in facilities.xml, "
                             + "showing please select again.\n".format(facility, instrument))
                return True

        settings = QSettings()
        settings.beginGroup(AboutPresenter.DO_NOT_SHOW_GROUP)
        doNotShowUntilNextRelease =int(settings.value(AboutPresenter.DO_NOT_SHOW, '0'))
        lastVersion = settings.value(AboutPresenter.LAST_VERSION, "")
        settings.endGroup()

        if not doNotShowUntilNextRelease:
            return True

        # Now check if the version has changed since last time
        version = release_notes_url()
        return version != lastVersion
Esempio n. 5
0
    def __init__(self, base_directory="Muon Data", load_data=MuonLoadData()):
        """
        Currently, only a single run is loaded into the Home/Grouping tab at once. This is held in the _current_data
        member. The load widget may load multiple runs at once, these are stored in the _loaded_data member.
        Groups and Pairs associated to the current run are stored in _grousp and _pairs as ordered dictionaries.
        """
        self._loaded_data = load_data

        self._current_runs = []
        self._main_field_direction = ''

        self._instrument = ConfigService.getInstrument().name() if ConfigService.getInstrument().name()\
            in allowed_instruments else 'EMU'

        self.instrumentNotifier = MuonDataContext.InstrumentNotifier(self)
        self.message_notifier = MuonDataContext.MessageNotifier(self)
        self.base_directory = base_directory
Esempio n. 6
0
    def __init__(self, load_data=MuonLoadData()):
        """
        Currently, only a single run is loaded into the Home/Grouping tab at once. This is held in the _current_data
        member. The load widget may load multiple runs at once, these are stored in the _loaded_data member.
        Groups and Pairs associated to the current run are stored in _grousp and _pairs as ordered dictionaries.
        """
        self._groups = OrderedDict()
        self._pairs = OrderedDict()

        self._loaded_data = load_data
        self._gui_variables = {}
        self._current_data = {
            "workspace": load_utils.empty_loaded_data()
        }  # self.get_result(False)

        self._current_runs = []

        self._instrument = ConfigService.getInstrument().name() if ConfigService.getInstrument().name()\
            in allowed_instruments else 'EMU'

        self.instrumentNotifier = MuonDataContext.InstrumentNotifier(self)
def get_default_grouping(instrument, main_field_direction):
    parameter_name = "Default grouping file"
    if instrument == "MUSR":
        parameter_name += " - " + main_field_direction
    try:
        grouping_file = ConfigService.getInstrument(instrument).getStringParameter(parameter_name)[0]
    except IndexError:
        return [], []
    instrument_directory = ConfigServiceImpl.Instance().getInstrumentDirectory()
    filename = instrument_directory + grouping_file
    new_groups, new_pairs = load_utils.load_grouping_from_XML(filename)
    return new_groups, new_pairs
Esempio n. 8
0
    def setup_facilities_group(self):
        facilities = ConfigService.getFacilityNames()
        self.view.facility.addItems(facilities)

        default_facility = ConfigService.getFacility().name()
        self.view.facility.setCurrentIndex(self.view.facility.findText(default_facility))
        self.action_facility_changed(default_facility)
        self.view.facility.currentTextChanged.connect(self.action_facility_changed)

        default_instrument = ConfigService.getInstrument().name()
        self.view.instrument.setCurrentIndex(self.view.instrument.findText(default_instrument))
        self.action_instrument_changed(default_instrument)
        self.view.instrument.currentTextChanged.connect(self.action_instrument_changed)
def get_default_grouping(instrument, main_field_direction):
    parameter_name = "Default grouping file"
    if instrument == "MUSR":
        parameter_name += " - " + main_field_direction
    try:
        grouping_file = ConfigService.getInstrument(
            instrument).getStringParameter(parameter_name)[0]
    except IndexError:
        return [], []
    instrument_directory = ConfigServiceImpl.Instance().getInstrumentDirectory(
    )
    filename = instrument_directory + grouping_file
    new_groups, new_pairs = load_utils.load_grouping_from_XML(filename)
    return new_groups, new_pairs
Esempio n. 10
0
    def setup_facilities_group(self):
        facilities = ConfigService.getFacilityNames()
        self.view.facility.addItems(facilities)

        default_facility = ConfigService.getFacility().name()
        self.view.facility.setCurrentIndex(
            self.view.facility.findText(default_facility))
        self.action_facility_changed(default_facility)
        self.view.facility.currentTextChanged.connect(
            self.action_facility_changed)

        default_instrument = ConfigService.getInstrument().name()
        self.view.instrument.setCurrentIndex(
            self.view.instrument.findText(default_instrument))
        self.action_instrument_changed(default_instrument)
        self.view.instrument.currentTextChanged.connect(
            self.action_instrument_changed)
    def __updateAlignAndFocusArgs(self, wkspname):
        self.log().debug('__updateAlignAndFocusArgs(%s)' % wkspname)
        # if the files are missing, there is nothing to do
        if (CAL_FILE not in self.kwargs) and (GROUP_FILE not in self.kwargs):
            self.log().debug('--> Nothing to do')
            return
        self.log().debug('--> Updating')

        # delete the files from the list of kwargs
        if CAL_FILE in self.kwargs:
            del self.kwargs[CAL_FILE]
        if CAL_FILE in self.kwargs:
            del self.kwargs[GROUP_FILE]

        # get the instrument name
        instr = mtd[wkspname].getInstrument().getName()
        instr = ConfigService.getInstrument(instr).shortName()

        # use the canonical names if they weren't specifed
        for key, ext in zip((CAL_WKSP, GRP_WKSP, MASK_WKSP),
                            ('_cal', '_group', '_mask')):
            if key not in self.kwargs:
                self.kwargs[key] = instr + ext
    def __updateAlignAndFocusArgs(self, wkspname):
        self.log().debug('__updateAlignAndFocusArgs(%s)' % wkspname)
        # if the files are missing, there is nothing to do
        if (CAL_FILE not in self.kwargs) and (GROUP_FILE not in self.kwargs):
            self.log().debug('--> Nothing to do')
            return
        self.log().debug('--> Updating')

        # delete the files from the list of kwargs
        if CAL_FILE in self.kwargs:
            del self.kwargs[CAL_FILE]
        if CAL_FILE in self.kwargs:
            del self.kwargs[GROUP_FILE]

        # get the instrument name
        instr = mtd[wkspname].getInstrument().getName()
        instr = ConfigService.getInstrument(instr).shortName()

        # use the canonical names if they weren't specifed
        for key, ext in zip((CAL_WKSP, GRP_WKSP, MASK_WKSP),
                            ('_cal', '_group', '_mask')):
            if key not in self.kwargs:
                self.kwargs[key] = instr + ext
Esempio n. 13
0
 def _get_leading_zeroes(self, run_number):
     run_number_int = int(run_number)
     total_digits_for_inst = ConfigService.getInstrument(
         self.instrument_string).zeroPadding(run_number_int)
     zeros_to_add = total_digits_for_inst - len(run_number)
     return zeros_to_add * "0"
Esempio n. 14
0
 def instrument(self):
     inst = ConfigService.getInstrument()
     return inst
Esempio n. 15
0
 def instrument(self):
     inst = ConfigService.getInstrument()
     return inst
Esempio n. 16
0
 def _get_leading_zeroes(self, run_number):
     run_number_int = int(run_number)
     total_digits_for_inst = ConfigService.getInstrument(self.instrument_string).zeroPadding(run_number_int)
     zeros_to_add = total_digits_for_inst - len(run_number)
     return zeros_to_add * "0"