def _sync(self, obj): for dbiso in obj.isotopes: r = dbiso.results[-1] uv = r.Iso ee = r.IsoEr bv = r.Bkgd be = r.BkgdEr key = dbiso.Label n = dbiso.NumCnts iso = Isotope(name=key, value=uv, error=ee, n=n) det =dbiso.detector iso.ic_factor=ufloat(det.ICFactor, det.ICFactorEr) iso.fit = r.fit.Label.lower() iso.baseline = Baseline(name=key, reverse_unpack=True, dbrecord=dbiso.baseline, unpack=True, unpacker=lambda x: x.PeakTimeBlob, error_type='SEM', fit='average') iso.baseline.set_filter_outliers_dict() iso.blank = Blank(name=key, value=bv, error=be) self.isotopes[key] = iso
def setUp(self): self.arun = Arun() xs = linspace(0, 100) ys = 2 * xs + 4 # ar40 = Isotope(name='Ar40', xs=xs, ys=ys) ar40 = Isotope('Ar40', 'H1') ar40.xs = xs ar40.ys = ys ar40.fit = 'parabolic' ar40.baseline.value = 0.25 ar40.blank.value = 0.75 ys = 2 * xs + 1 ar39 = Isotope('Ar39', 'AX') ar39.fit = 'parabolic' ar39.xs = xs ar39.ys = ys # ar39.baseline.value = 0.25 # ar39.blank.value = 0.75 self.arun.isotope_group.isotopes = {'Ar40': ar40, 'Ar39': ar39} self.arun.isotope_group.age = 10
def _sync(self, obj): arar = obj.araranalyses[-1] if arar: self.j = ufloat(arar.JVal, arar.JEr) self.age = arar.Age self.age_err = arar.ErrAge self.age_err_wo_j = arar.ErrAgeWOErInJ self.rad40_percent = ufloat(arar.PctRad, arar.PctRadEr) for dbiso in obj.isotopes: r = dbiso.results[-1] uv = r.Iso ee = r.IsoEr bv = r.Bkgd be = r.BkgdEr key = dbiso.Label n = dbiso.NumCnts iso = Isotope(name=key, value=uv, error=ee, n=n) det =dbiso.detector iso.ic_factor=ufloat(det.ICFactor, det.ICFactorEr) iso.fit = r.fit.Label.lower() iso.baseline = Baseline(name=key, reverse_unpack=True, dbrecord=dbiso.baseline, unpack=True, unpacker=lambda x: x.PeakTimeBlob, error_type='SEM', fit='average') iso.baseline.set_filter_outliers_dict() iso.blank = Blank(name=key, value=bv, error=be) self.isotopes[key] = iso
def _sync(self, obj): self.j = ufloat(0, 0) self.age = 0 self.age_err = 0 self.age_err_wo_j = 0 self.radiogenic_yield = ufloat(0, 0) self.rad4039 = ufloat(0, 0) arar = None if obj.araranalyses: arar = obj.araranalyses[-1] if arar: self.j = ufloat(arar.JVal, arar.JEr) self.age = arar.Age self.age_err = arar.ErrAge self.age_err_wo_j = arar.ErrAgeWOErInJ self.radiogenic_yield = ufloat(arar.PctRad, arar.PctRadEr) self.rad4039 = ufloat(arar.Rad4039, arar.Rad4039Er) self.r3739 = ufloat(arar.R3739Cor, arar.ErR3739Cor) self.Cl3839 = ufloat(arar.Cl3839, 0) try: self.kca = ufloat(arar.CaOverK, arar.CaOverKEr)**-1 except ZeroDivisionError: self.kca = 0 try: self.kcl = ufloat(arar.ClOverK, arar.ClOverKEr)**-1 except ZeroDivisionError: self.kcl = 0 changeable = obj.changeable fo, fi, fs = 0, 0, 0 if changeable: self.comment = changeable.Comment self.tag = STATUS_MAP.get(changeable.StatusLevel) prefs = changeable.preferences_set if prefs: fo = prefs.DelOutliersAfterFit == 'true' fi = int(prefs.NFilterIter) fs = int(prefs.OutlierSigmaFactor) self.lambda_k = prefs.Lambda40Kepsilon + prefs.Lambda40KBeta self.lambda_Ar37 = prefs.LambdaAr37 self.lambda_Ar39 = prefs.LambdaAr39 self.lambda_Cl36 = prefs.LambdaCl36 for dbiso in obj.isotopes: r = dbiso.results[-1] uv, ee = self._intercept_value(r) key = dbiso.Label n = dbiso.NumCnts det = dbiso.detector iso = Isotope(key, det.detector_type.Label) iso.baseline_corrected = ufloat(uv, ee) tv, te = 0, 0 if arar: try: k = key[2:] tv, te = getattr(arar, 'Tot{}'.format(k)), getattr( arar, 'Tot{}Er'.format(k)) except AttributeError: pass iso.set_filter_outliers_dict(filter_outliers=fo, iterations=fi, std_devs=fs) iso.total_value = ufloat(tv, te) # iso.set_uvalue((uv, ee)) iso.n = n iso.ic_factor = ufloat(det.ICFactor, det.ICFactorEr) iso.fit = r.fit.Label.lower() if r.fit else '' iso.baseline = Baseline(key, det.detector_type.Label) iso.baseline.fit = 'average' iso.baseline.set_filter_outliers_dict(filter_outliers=fo, iterations=fi, std_devs=fs) iso.baseline.n = dbiso.baseline.NumCnts # uv = iso.baseline_corrected + iso.baseline.uvalue # print('asdf',key, uv, iso.baseline_corrected, iso.baseline.uvalue) # iso.value = nominal_value(uv) # iso.error = std_dev(uv) # iso.set_uvalue() blank = self._blank(r) if blank: iso.blank.set_uvalue(blank) self.isotopes[key] = iso
def _sync(self, obj): self.j = ufloat(0, 0) self.age = 0 self.age_err = 0 self.age_err_wo_j = 0 self.rad40_percent = ufloat(0, 0) self.rad4039 = ufloat(0, 0) arar = None if obj.araranalyses: arar = obj.araranalyses[-1] if arar: self.j = ufloat(arar.JVal, arar.JEr) self.age = arar.Age self.age_err = arar.ErrAge self.age_err_wo_j = arar.ErrAgeWOErInJ self.rad40_percent = ufloat(arar.PctRad, arar.PctRadEr) self.rad4039 = ufloat(arar.Rad4039, arar.Rad4039Er) self.r3739 = ufloat(arar.R3739Cor, arar.ErR3739Cor) self.Cl3839 = ufloat(arar.Cl3839, 0) self.kca = ufloat(arar.CaOverK, arar.CaOverKEr) ** -1 self.kcl = ufloat(arar.ClOverK, arar.ClOverKEr) ** -1 prefs = obj.changeable.preferences_set fo, fi, fs = 0, 0, 0 if prefs: fo = prefs.DelOutliersAfterFit == 'true' fi = int(prefs.NFilterIter) fs = int(prefs.OutlierSigmaFactor) self.lambda_k = prefs.Lambda40Kepsilon + prefs.Lambda40KBeta self.lambda_Ar37 = prefs.LambdaAr37 self.lambda_Ar39 = prefs.LambdaAr39 self.lambda_Cl36 = prefs.LambdaCl36 for dbiso in obj.isotopes: r = dbiso.results[-1] uv, ee = self._intercept_value(r) key = dbiso.Label n = dbiso.NumCnts det = dbiso.detector iso = Isotope(key, det.detector_type.Label) iso.baseline_corrected = ufloat(uv, ee) tv, te = 0, 0 if arar: try: k = key[2:] tv, te = getattr(arar, 'Tot{}'.format(k)), getattr(arar, 'Tot{}Er'.format(k)) except AttributeError: pass iso.total_value = ufloat(tv, te) # iso.set_uvalue((uv, ee)) iso.n = n iso.ic_factor = ufloat(det.ICFactor, det.ICFactorEr) iso.fit = r.fit.Label.lower() if r.fit else '' iso.baseline = Baseline(key, det.detector_type.Label) iso.baseline.fit = 'average' iso.baseline.set_filter_outliers_dict(filter_outliers=fo, iterations=fi, std_devs=fs) iso.baseline.n = dbiso.baseline.NumCnts blank = self._blank(r) if blank: iso.blank.set_uvalue(blank) self.isotopes[key] = iso