Ejemplo n.º 1
0
    def _get_signals(self, meas_analysis, dbisos, unpack, selected_histories):
        d = self.isotopes
        default_fit = self._default_fit_factory('linear', 'SEM')
        for iso in dbisos:
            mw = iso.molecular_weight
            # print iso.kind, iso.detector
            if not iso.kind == 'signal' or not mw:
                continue
            if not iso.detector:
                continue

            det = iso.detector.name
            isoname = mw.name
            key = isoname
            if isoname in d:
                key = '{}{}'.format(isoname, det)

            result = None
            # todo: this needs to be fixed to handle data_reduction_tag
            # if analysis has a dr tag then get its associated select_histories entry
            # the get the select_fits then the associated results
            if selected_histories is None:
                try:
                    result = iso.results[-1]
                except IndexError:
                    result = None
            # r = Isotope(mass=mw.mass,
            #             dbrecord=iso,
            #             dbresult=result,
            #             name=isoname,
            #             detector=det,
            #             unpack=unpack)
            r = Isotope(isoname, det)
            if unpack:
                r.unpack_data(iso.signal.data)

            r.mass = mw.mass
            if result:
                r.value = result.signal_
                r.error = result.signal_err

            if r.unpack_error:
                self.warning('Bad isotope {} {}. error: {}'.format(
                    self.record_id, key, r.unpack_error))
                self.temp_status = 1
            else:
                fit = self.get_db_fit(meas_analysis, isoname, 'signal',
                                      selected_histories)
                if fit is None:
                    fit = default_fit()
                r.set_fit(fit, notify=False)
                d[key] = r
Ejemplo n.º 2
0
    def _get_signals(self, meas_analysis, dbisos, unpack, selected_histories):
        d = self.isotopes
        default_fit = self._default_fit_factory('linear', 'SEM')
        for iso in dbisos:
            mw = iso.molecular_weight
            # print iso.kind, iso.detector
            if not iso.kind == 'signal' or not mw:
                continue
            if not iso.detector:
                continue

            det = iso.detector.name
            isoname = mw.name
            key = isoname
            if isoname in d:
                key = '{}{}'.format(isoname, det)

            result = None
            # todo: this needs to be fixed to handle data_reduction_tag
            # if analysis has a dr tag then get its associated select_histories entry
            # the get the select_fits then the associated results
            if selected_histories is None:
                try:
                    result = iso.results[-1]
                except IndexError:
                    result = None
            # r = Isotope(mass=mw.mass,
            #             dbrecord=iso,
            #             dbresult=result,
            #             name=isoname,
            #             detector=det,
            #             unpack=unpack)
            r = Isotope(isoname, det)
            if unpack:
                r.unpack_data(iso.signal.data)

            r.mass = mw.mass
            if result:
                r.value = result.signal_
                r.error = result.signal_err

            if r.unpack_error:
                self.warning('Bad isotope {} {}. error: {}'.format(self.record_id, key, r.unpack_error))
                self.temp_status = 1
            else:
                fit = self.get_db_fit(meas_analysis, isoname, 'signal', selected_histories)
                if fit is None:
                    fit = default_fit()
                r.set_fit(fit, notify=False)
                d[key] = r