Beispiel #1
0
        def get_attr(attrname):
            if attrname == 'labnumber':
                if self.user_defined_aliquot and not self.is_special():
                    v = make_rid(self.labnumber, self.aliquot)
                else:
                    v = self.labnumber
            elif attrname.endswith('script'):
                # remove mass spectrometer name
                v = getattr(self, attrname)
                # v = self._remove_mass_spectrometer_name(v)
                v = remove_extension(v)

            elif attrname == 'overlap':
                o, m = self.overlap
                if m:
                    v = '{},{}'.format(*self.overlap)
                else:
                    v = o
            else:
                try:
                    v = getattr(self, attrname)
                except AttributeError as e:
                    v = ''

            return v
Beispiel #2
0
    def make_gosub(self):
        selection = self.control.code.textCursor().selectedText()
        dlg = FileDialog(action='save as',
                         default_directory=os.path.dirname(self.path))

        p = None
        # root = os.path.dirname(self.path)
        # p = os.path.join(root, 'common', 'test_gosub.py')
        if dlg.open():
            p = dlg.path

        if p:
            p = add_extension(p, '.py')
            # p='/Users/ross/Desktop/foosub.py'
            with open(p, 'w') as wfile:
                wfile.write('# Extracted Gosub\n')
                wfile.write('# Source: from {}\n'.format(self.path))
                wfile.write('# Date: {}\n'.format(datetime.now().strftime('%m-%d-%Y %H:%M')))
                wfile.write('def main():\n')
                for li in selection.split(u'\u2029'):
                    wfile.write(u'    {}\n'.format(li.lstrip()))

            p = remove_extension(p)
            rp = os.path.relpath(p, self.path)
            rp = rp.replace('/', ':')
            self.control.code.replace_selection("gosub('{}')".format(rp[3:]))
Beispiel #3
0
        def get_attr(attrname):
            if attrname == 'labnumber':
                if self.user_defined_aliquot and not self.is_special():
                    v = make_rid(self.labnumber, self.aliquot)
                else:
                    v = self.labnumber
            elif attrname.endswith('script'):
                # remove mass spectrometer name
                v = getattr(self, attrname)
                # v = self._remove_mass_spectrometer_name(v)
                v = remove_extension(v)

            elif attrname == 'overlap':
                o, m = self.overlap
                if m:
                    v = '{},{}'.format(*self.overlap)
                else:
                    v = o
            else:
                try:
                    v = getattr(self, attrname)
                except AttributeError as e:
                    v = ''

            return v
Beispiel #4
0
    def _sync_measurement(self, meas_analysis, load_aux):
        if meas_analysis:
            meas = meas_analysis.measurement
            if meas:
                if meas.script:
                    self.measurement_script_name = remove_extension(meas.script.name)

                self.analysis_type = meas.analysis_type.name
                self.mass_spectrometer = meas.mass_spectrometer.name.lower()
                self.collection_time_zero_offset = meas.time_zero_offset or 0

                if load_aux:
                    try:
                        sp = meas.spectrometer_parameters

                        keys = QTEGRA_SOURCE_KEYS
                        names = QTEGRA_SOURCE_NAMES
                        sd = [DValue(n, getattr(sp, k)) for n, k in zip(names, keys)]

                        self.source_parameters = sd

                    except AttributeError, e:
                        # self.source_parameters = [DValue(str(i), i) for i in range(10)]
                        self.debug('No source parameters available')

                    defls = meas.deflections

                    try:
                        names = sort_detectors([di.detector.name for di in meas.deflections])
                        self.deflections = [DValue(ni, defls[i].deflection or '---') for i, ni in enumerate(names)]
                    except AttributeError, e:
                        # self.deflections = [DValue(str(i), i * 34) for i in range(10)]
                        self.debug('No deflection available')
Beispiel #5
0
    def _sync_measurement(self, meas_analysis):
        if meas_analysis:
            meas = meas_analysis.measurement
            if meas:
                if meas.script:
                    self.measurement_script_name = remove_extension(meas.script.name)

                self.analysis_type = meas.analysis_type.name
                self.mass_spectrometer = meas.mass_spectrometer.name.lower()
                self.collection_time_zero_offset = meas.time_zero_offset or 0
Beispiel #6
0
    def _sync_extraction(self, meas_analysis):
        extraction = meas_analysis.extraction
        if extraction:
            if extraction.script:
                self.extraction_script_name = remove_extension(extraction.script.name)

            # sensitivity
            if meas_analysis.selected_histories:
                shist = meas_analysis.selected_histories.selected_sensitivity
                if shist:
                    sm = extraction.sensitivity_multiplier or 1
                    s = shist.sensitivity.value
                    self.sensitivity = sm * s

            self.extract_device = self._get_extraction_device(extraction)
            self.extract_value = extraction.extract_value

            # add extract units to meas_ExtractionTable
            #             eu = extraction.extract_units or 'W'
            #             self.extract_units = eu
            self.extract_units = 'W'

            self.cleanup = extraction.cleanup_duration
            self.duration = extraction.extract_duration
            self.position = get_position(extraction)
            self.xyz_position = get_xyz_position(extraction)

            for attr in ('beam_diameter', 'pattern',
                         'ramp_rate', 'ramp_duration'):
                v = getattr(extraction, attr)
                if v is None:
                    v = ''
                setattr(self, attr, v)

            # uv
            if 'uv' in self.extract_device:
                for attr in ('reprate', 'mask_position', 'mask_name', 'attenuator'):
                    v = getattr(extraction, attr)
                    if v is None:
                        v = ''
                    setattr(self, attr, v)

            snapshots = extraction.snapshots
            if snapshots:
                self.snapshots = [Snapshot(path=si.path,
                                           name=os.path.basename(si.path),
                                           remote_path=si.remote_path,
                                           image=si.image) for si in snapshots]
Beispiel #7
0
    def _add_defaults(self, defaults, root, dbfunc=None):
        commit = False
        repo = self.meta_repo
        for name, txt in defaults:
            p = os.path.join(repo.path, root, name)
            if not os.path.isfile(p):
                with open(p, 'w') as wfile:
                    wfile.write(txt)
                repo.add(p, commit=False)
                commit = True
                if dbfunc:
                    name = remove_extension(name)
                    dbfunc(name)

        if commit:
            repo.commit('added default {}'.format(root.replace('_', ' ')))
Beispiel #8
0
    def _add_defaults(self, defaults, root, dbfunc=None):
        commit = False
        repo = self.meta_repo
        for name, txt in defaults:
            p = os.path.join(repo.path, root, name)
            if not os.path.isfile(p):
                with open(p, 'w') as wfile:
                    wfile.write(txt)
                repo.add(p, commit=False)
                commit = True
                if dbfunc:
                    name = remove_extension(name)
                    dbfunc(name)

        if commit:
            repo.commit('added default {}'.format(root.replace('_', ' ')))
Beispiel #9
0
        def get_attr(attrname):
            if attrname == "labnumber":
                if self.user_defined_aliquot and not self.is_special():
                    v = make_rid(self.labnumber, self.aliquot)
                else:
                    v = self.labnumber
            elif attrname.endswith("script"):
                # remove mass spectrometer name
                v = getattr(self, attrname)
                # v = self._remove_mass_spectrometer_name(v)
                v = remove_extension(v)

            elif attrname == "overlap":
                o, m = self.overlap
                if m:
                    v = "{},{}".format(*self.overlap)
                else:
                    v = o
            else:
                try:
                    v = getattr(self, attrname)
                except AttributeError, e:
                    v = ""
Beispiel #10
0
    def _remove_file_extension(self, name):
        if name is NULL_STR:
            return NULL_STR

        return remove_extension(name)
Beispiel #11
0
    def list_exp_dir(self):
        root = paths.experiment_dir

        for i, di in enumerate((di for di in os.listdir(root) if os.path.isfile(os.path.join(root, di)))):
            self.console_event = {"message": remove_extension(di), "indent": i}
Beispiel #12
0
    def list_exp_dir(self):
        root = paths.experiment_dir

        for i, di in enumerate((di for di in os.listdir(root) if os.path.isfile(os.path.join(root, di)))):
            self.console_event = {'message':remove_extension(di), 'indent':i}