Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def calculate_decay_factors(self):
arc = self.arar_constants
# only calculate decayfactors once
if not self.ar39decayfactor:
dc37 = nominal_value(arc.lambda_Ar37)
dc39 = nominal_value(arc.lambda_Ar39)
a37df, a39df = calculate_arar_decay_factors(dc37, dc39, self.chron_segments)
self.ar37decayfactor = a37df
self.ar39decayfactor = a39df
for pname, pv in d.iteritems():
pp = xmlp.add(pname, '', pr)
xmlp.add('value', nominal_value(pv), pp)
xmlp.add('error', std_dev(pv), pp)
isostag = xmlp.add('isotopes','', an)
for isotope in spec.isotopes.itervalues():
isok = isotope.name
det = isotope.detector
sfit = isotope.fit
isotag = xmlp.add(isok, '', isostag)
xmlp.add('detector', det, isotag)
xmlp.add('fit', sfit, isotag)
xmlp.add('intercept_value', nominal_value(isotope.uvalue), isotag)
xmlp.add('intercept_error', std_dev(isotope.uvalue), isotag)
baseline = isotope.baseline
xmlp.add('baseline_value', nominal_value(baseline.uvalue), isotag)
xmlp.add('baseline_error', std_dev(baseline.uvalue), isotag)
blank = isotope.blank
xmlp.add('blank_value', nominal_value(blank.uvalue), isotag)
xmlp.add('blank_error', std_dev(blank.uvalue), isotag)
datatag = xmlp.add('raw', '', isotag)
xmlp.add('signal',
base64.b64encode(self._make_timeblob(isotope.offset_xs,
isotope.ys)), datatag)
ag.weighted_age_error_kind = options.error_calc_method
ag.set_external_error(options.include_j_position_error,
options.include_j_error_in_mean,
options.include_decay_error, dirty=True)
mswd, valid_mswd, n, pvalue = self.analysis_group.get_mswd_tuple()
if options.mean_calculation_kind == 'kernel':
wm, we = 0, 0
peak_xs, peak_ys = fast_find_peaks(ys, xs)
wm = peak_xs[0]
# wm = np_max(maxs, axis=1)[0]
else:
wage = self.analysis_group.weighted_age
wm, we = nominal_value(wage), std_dev(wage)
return wm, we, mswd, valid_mswd, n, pvalue
def _monte_carlo_error_propagation(self, vr, m):
lambda_total = self._lambda_t
el = self._lambda_ec
f = self._f
vel = nominal_value(el) + std_dev(el) * randn(self._n)
vt = nominal_value(lambda_total) + std_dev(lambda_total) * randn(self._n)
vf = nominal_value(f) + std_dev(f) * randn(self._n)
vt_mc = ones(1, m) * vt
vf_mc = ones(1, m) * vf
vel_mc = ones(1, m) * vel
t_mc = log(vt_mc / vel_mc * vf_mc * vr + 1) / vt_mc
return mean(t_mc), std(t_mc)
db.add_current(dban, iso.value, iso.error, param, iso.units)
param = db.add_parameter('{}_blank'.format(key), iso.blank.units)
db.add_current(dban, iso.blank.value, iso.blank.error, param, iso.blank.units)
param = db.add_parameter('{}_bs_corrected'.format(key))
v = iso.get_baseline_corrected_value()
db.add_current(dban, nominal_value(v), std_dev(v), param, iso.units)
param = db.add_parameter('{}_ic_corrected'.format(key))
v = iso.get_ic_corrected_value()
db.add_current(dban, nominal_value(v), std_dev(v), param, iso.units)
param = db.add_parameter(key)
v = iso.get_non_detector_corrected_value()
db.add_current(dban, nominal_value(v), std_dev(v), param, iso.units)
param = db.add_parameter(iso.baseline.name)
db.add_current(dban, iso.baseline.value, iso.baseline.error, param, iso.baseline.units)
param = db.add_parameter('{}_n'.format(iso.baseline.name))
db.add_current(dban, iso.baseline.n, None, param, 'int')
param = db.add_parameter('{}_n'.format(iso.name))
db.add_current(dban, iso.n, None, param, 'int')
def f(x, k):
v = None
if k in x.interference_corrections:
v = x.interference_corrections[k]
elif k in x.production_ratios:
v = x.production_ratios[k]
if v is not None:
return nominal_value(v) if ve == 'value' else std_dev(v)
else:
return ''
#k39: 39Ar from potassium
f: F value rad40Ar/39Ar
age: age of monitor in years
solve age equation for J
"""
if isinstance(f, (list, tuple)):
f = ufloat(*f)
if isinstance(age, (list, tuple)):
age = ufloat(*age)
try:
if not lambda_k:
if arar_constants is None:
arar_constants = ArArConstants()
lambda_k = nominal_value(arar_constants.lambda_k)
j = (umath.exp(age * lambda_k) - 1) / f
return j
except ZeroDivisionError:
return ufloat(1, 0)
ais = list(ais)
n = len(ais)
ref = ais[0]
j = ref.j
ip = ref.irradiation_position
sample = ref.sample
x, y, r, idx = geom[ip - 1]
p = FluxPosition(identifier=identifier,
irradiation=self.irradiation,
level=self.level,
sample=sample, hole_id=ip,
saved_j=nominal_value(j),
saved_jerr=std_dev(j),
error_kind=ek,
monitor_age=monage,
analyses=ais,
lambda_k=lk,
x=x, y=y,
n=n)
p.set_mean_j(self.plotter_options.use_weighted_fit)
poss.append(p)
if prev:
slope = prev < p.j
prev = p.j
vs = self._sort_individuals(p, monage, lk, slope, padding)
if ans:
nv = ufloat(float(r['Ar40']), float(r['Ar40err'])) * 6240
dv = ufloat(float(r['Ar36']), float(r['Ar36err'])) * 6240
if tau:
dv = corrfunc(dv, tau * 1e-9)
vs.append((n, nv / dv))
key = lambda x: x[0]
vs = sorted(vs, key=key)
mxs = []
mys = []
mes = []
for n, gi in groupby(vs, key=key):
mxs.append(n)
ys, es = list(zip(*[(nominal_value(xi[1]), std_dev(xi[1])) for xi in gi]))
wm, werr = calculate_weighted_mean(ys, es)
mys.append(wm)
mes.append(werr)
return mxs, mys, mes
# new_monitor_age = None
# new_lambda_k = None
# age = convert_age(age, new_monitor_age, new_lambda_k)
self.uage_w_position_err = age
age = age_equation(self.j, f, include_decay_error=include_decay_error, arar_constants=arc)
# age = convert_age(age, new_monitor_age, new_lambda_k)
self.uage_w_j_err = age
j = copy(self.j)
j.std_dev = 0
age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc)
# age = convert_age(age, new_monitor_age, new_lambda_k)
self.uage = age
self.age = nominal_value(age)
self.age_err = std_dev(age)
self.age_err_wo_j = std_dev(age)
for iso in self.itervalues():
iso.age_error_component = self.get_error_component(iso.name)