def _set_age_values(self, f, include_decay_error=False): arc = self.arar_constants j = copy(self.j) if j is None: j = ufloat(1e-4, 1e-7) j.tag = 'Position' j.std_dev = self.position_jerr or 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage_w_position_err = age j = self.j if j is None: j = ufloat(1e-4, 1e-7, tag='J') age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage_w_j_err = age j = copy(self.j) if j is None: j = ufloat(1e-4, 1e-7, tag='J') j.std_dev = 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) 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)
def _set_age_values(self, f, include_decay_error=False): if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) arc = self.arar_constants age = age_equation( j, f, include_decay_error=include_decay_error, # lambda_k=self.lambda_k, arar_constants=arc) # age = ufloat((1, 0.1)) self.uage_w_j_err = age # self.age = age.nominal_value # self.age_err = age.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) j.std_dev = 0 age = age_equation( j, f, include_decay_error=include_decay_error, # lambda_k=self.lambda_k, arar_constants=arc) self.age = nominal_value(age) self.age_err = std_dev(age) self.age_err_wo_j = float(age.std_dev) self.uage = ufloat(self.age, self.age_err) self.uage_wo_j_err = ufloat(self.age, self.age_err_wo_j) # if self.j is not None: # j = copy(self.j) # else: # j = ufloat(1e-4, 1e-7) # # age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, # arar_constants=arc) # # self.age_err_wo_irrad = age.std_dev # j.std_dev = 0 # self.age_err_wo_j_irrad = age.std_dev # for iso in self.isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)
def _calculate_integrated_age(self, ans, weighting): ret = ufloat(0, 0) if ans and all((not isinstance(a, InterpretedAgeGroup) for a in ans)): rs = array([a.get_computed_value('rad40') for a in ans]) ks = array([a.get_computed_value('k39') for a in ans]) sks = ks.sum() weights = None if weighting == 'Volume': weights = ks / sks elif weighting == 'Variance': weights = [1 / std_dev(k) ** 2 for k in rs/ks] if weights is not None: wmean, sum_weights = average([nominal_value(fi) for fi in rs / ks], weights=weights, returned=True) werr = sum_weights ** -0.5 f = ufloat(wmean, werr) else: f = rs.sum() / sks a = ans[0] j = a.j try: ret = age_equation(f, j, a.arar_constants) # / self.age_scalar except ZeroDivisionError: pass return ret
def _get_integrated_age(self): rad40, k39 = zip(*[(a.get_computed_value('rad40'), a.get_computed_value('k39')) for a in self.analyses]) rad40 = sum(rad40) k39 = sum(k39) j = a.j return age_equation(rad40 / k39, j, a.arar_constants)
def _set_age_values(self, f, include_decay_error=False): if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) arc = self.arar_constants age = age_equation(j, f, include_decay_error=include_decay_error, # lambda_k=self.lambda_k, arar_constants=arc) # age = ufloat((1, 0.1)) self.uage_w_j_err = age # self.age = age.nominal_value # self.age_err = age.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) j.std_dev = 0 age = age_equation(j, f, include_decay_error=include_decay_error, # lambda_k=self.lambda_k, arar_constants=arc) self.age = nominal_value(age) self.age_err = std_dev(age) self.age_err_wo_j = float(age.std_dev) self.uage = ufloat(self.age, self.age_err) # if self.j is not None: # j = copy(self.j) # else: # j = ufloat(1e-4, 1e-7) # # age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, # arar_constants=arc) # # self.age_err_wo_irrad = age.std_dev # j.std_dev = 0 # self.age_err_wo_j_irrad = age.std_dev # for iso in self.isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)
def _set_age_values(self, f, include_decay_error=False): arc = self.arar_constants for iso in self.itervalues(): iso.age_error_component = self.get_error_component(iso.name) if self.j is None: return j = copy(self.j) # if j is None: # j = ufloat(1e-4, 1e-7) j.tag = 'Position' j.std_dev = self.position_jerr or 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage_w_position_err = age j = self.j # if j is None: # j = ufloat(1e-4, 1e-7, tag='J') age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage_w_j_err = age j = copy(self.j) # if j is None: # j = ufloat(1e-4, 1e-7, tag='J') j.std_dev = 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage = age self.age = nominal_value(age) self.age_err = std_dev(age) self.age_err_wo_j = std_dev(age)
def _get_integrated_age(self): rad40, k39 = zip(*[(a.get_computed_value('rad40'), a.get_computed_value('k39')) for a in self.clean_analyses()]) rad40 = sum(rad40) k39 = sum(k39) j = a.j try: return age_equation(rad40 / k39, j, a.arar_constants) except ZeroDivisionError: return nan
def _set_age_values(self, f, include_decay_error=False): arc = self.arar_constants for iso in self.itervalues(): iso.age_error_component = self.get_error_component(iso.name) if self.j is None: return j = copy(self.j) j.tag = 'Position' j.std_dev = self.position_jerr or 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) # 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)
def _calculate_integrated_age(self, ans, weighting=None): ret = ufloat(0, 0) if ans and all((not isinstance(a, InterpretedAgeGroup) for a in ans)): rs = array([a.get_computed_value('rad40') for a in ans]) ks = array([a.get_computed_value('k39') for a in ans]) # sks = ks.sum() # fs = rs / ks if weighting is None: weighting = self.integrated_age_weighting # if weighting == 'Volume': # vpercent = array([nominal_value(v) for v in ks / sks]) # errs = array([std_dev(f) for f in fs]) # weights = (vpercent * errs) ** 2 # # elif weighting == 'Variance': # weights = [std_dev(f) ** -2 for f in fs] # # if weights is not None: # wmean, sum_weights = average([nominal_value(fi) for fi in fs], weights=weights, returned=True) # if weighting == 'Volume': # werr = sum_weights ** 0.5 # else: # werr = sum_weights ** -0.5 # # f = ufloat(wmean, werr) # else: # f = rs.sum() / sks f = self._calculate_integrated_mean_error(weighting, ks, rs) j = self.j if not self.include_j_error_in_integrated: j = nominal_value(j) try: ret = age_equation(f, j, arar_constants=self.arar_constants) except ZeroDivisionError: pass return ret
def _calculate_age(self, include_decay_error=None): """ approx 2/3 of the calculation time is in _assemble_ar_ar_isotopes. Isotope.get_intensity takes about 5ms. """ isos = self._assemble_ar_ar_isotopes() if not isos: return arc = self.arar_constants isos = abundance_sensitivity_correction(isos, arc.abundance_sensitivity) isos[1] *= self.ar39decayfactor isos[3] *= self.ar37decayfactor f, f_wo_irrad, non_ar, computed, interference_corrected = calculate_F( isos, decay_time=self.decay_days, interferences=self.interference_corrections, arar_constants=self.arar_constants, ) self.non_ar_isotopes = non_ar self.computed = computed self.rad40_percent = computed["rad40_percent"] for k, v in interference_corrected.iteritems(): self.isotopes[k].interference_corrected_value = v self.uF = f self.F = f.nominal_value self.F_err = f.std_dev self.F_err_wo_irrad = f_wo_irrad.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=self.arar_constants) self.uage = age self.age = float(age.nominal_value) self.age_err = float(age.std_dev) j.std_dev = 0 self.age_err_wo_j = float(age.std_dev) if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, arar_constants=self.arar_constants) self.age_err_wo_irrad = float(age.std_dev) j.std_dev = 0 self.age_err_wo_j_irrad = float(age.std_dev) # print 'asddsadf' # print self.age_err # print self.age_err_wo_j # print self.age_err_wo_j_irrad for iso in self.isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)
def _calculate_age(self, include_decay_error=None): """ approx 2/3 of the calculation time is in _assemble_ar_ar_isotopes. Isotope.get_intensity takes about 5ms. """ isos = self._assemble_ar_ar_isotopes() if not isos: return arc = self.arar_constants isos = abundance_sensitivity_correction(isos, arc.abundance_sensitivity) isos[1] *= self.ar39decayfactor isos[3] *= self.ar37decayfactor f, f_wo_irrad, non_ar, computed, interference_corrected = calculate_F(isos, decay_time=self.decay_days, interferences=self.interference_corrections, arar_constants=self.arar_constants) self.non_ar_isotopes = non_ar self.computed = computed self.rad40_percent = computed['rad40_percent'] for k, v in interference_corrected.iteritems(): self.isotopes[k].interference_corrected_value = v self.uF = f self.F = f.nominal_value self.F_err = f.std_dev self.F_err_wo_irrad = f_wo_irrad.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4,1e-7) age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=self.arar_constants) self.uage = age self.age = float(age.nominal_value) self.age_err = float(age.std_dev) j.std_dev = 0 self.age_err_wo_j = float(age.std_dev) if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, arar_constants=self.arar_constants) self.age_err_wo_irrad = float(age.std_dev) j.std_dev = 0 self.age_err_wo_j_irrad = float(age.std_dev) #print 'asddsadf' #print self.age_err #print self.age_err_wo_j #print self.age_err_wo_j_irrad for iso in self.isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)
def _rebuild_graph(self): g = self.graph g.clear() plot1 = g.new_plot(ytitle='Delta Age (ka)', xtitle='Time (s)', padding_left=70, padding_right=25 ) plot2 = g.new_plot(ytitle='Ar39 (fA)', padding_left=70, padding_right=25 ) plot3 = g.new_plot(ytitle='Ar40 (fA)', padding_left=70, padding_right=25 ) Ar40 = self.Ar40.intensity Ar39 = self.Ar39.intensity if not (Ar40 and Ar39): return plot2.value_range.low_setting = Ar39 * .95 plot2.value_range.high_setting = Ar39 * 1.05 plot3.value_range.low_setting = Ar40 * .95 plot3.value_range.high_setting = Ar40 * 1.01 R = Ar40 / Ar39 xma = self.max_time rs = [] ns = [] ds = [] if self.vary_time_zero: posts = (15,) xs = list(range(0, 15)) index = xs else: posts = list(range(5, 30)) xs = (0,) index = posts for pi in posts: for ti in xs: # subplot(311) n = self.calc_intercept(Ar40, pi, self.Ar40.equil_rate, self.Ar40.static_rate, xma, 2, time_zero=ti ) # subplot(312) d = self.calc_intercept(Ar39, pi, self.Ar39.equil_rate, self.Ar39.static_rate, xma, 1, time_zero=ti) ns.append(n) ds.append(d) # rs.append(((n / d) - R) / R * 100) rs.append((n / d)) # print ns # g.new_series(xs, ns, plotid=2) # g.new_series(xs, ds, plotid=1) # g.new_series(to, rs, plotid=0) mon_age = 28 j = calculate_flux((Ar40, 0), (Ar39, 0), mon_age) ages = [(age_equation(j[0], abs(ri)) - mon_age) * 1000 for ri in rs] g.new_series(index, ages, plotid=0)
def _rebuild_graph(self): g = self.graph g.clear() plot1 = g.new_plot(ytitle='Delta Age (ka)', xtitle='Time (s)', padding_left=70, padding_right=25) plot2 = g.new_plot(ytitle='Ar39 (fA)', padding_left=70, padding_right=25) plot3 = g.new_plot(ytitle='Ar40 (fA)', padding_left=70, padding_right=25) Ar40 = self.Ar40.intensity Ar39 = self.Ar39.intensity if not (Ar40 and Ar39): return plot2.value_range.low_setting = Ar39 * .95 plot2.value_range.high_setting = Ar39 * 1.05 plot3.value_range.low_setting = Ar40 * .95 plot3.value_range.high_setting = Ar40 * 1.01 R = Ar40 / Ar39 xma = self.max_time rs = [] ns = [] ds = [] if self.vary_time_zero: posts = (15, ) xs = range(0, 15) index = xs else: posts = range(5, 30) xs = (0, ) index = posts for pi in posts: for ti in xs: # subplot(311) n = self.calc_intercept(Ar40, pi, self.Ar40.equil_rate, self.Ar40.static_rate, xma, 2, time_zero=ti) # subplot(312) d = self.calc_intercept(Ar39, pi, self.Ar39.equil_rate, self.Ar39.static_rate, xma, 1, time_zero=ti) ns.append(n) ds.append(d) # rs.append(((n / d) - R) / R * 100) rs.append((n / d)) # print ns # g.new_series(xs, ns, plotid=2) # g.new_series(xs, ds, plotid=1) # g.new_series(to, rs, plotid=0) mon_age = 28 j = calculate_flux((Ar40, 0), (Ar39, 0), mon_age) ages = [(age_equation(j[0], abs(ri)) - mon_age) * 1000 for ri in rs] g.new_series(index, ages, plotid=0)
def _calculate_age(self, include_decay_error=None): """ approx 2/3 of the calculation time is in _assemble_ar_ar_isotopes. Isotope.get_intensity takes about 5ms. """ # self.debug('calculate age') iso_intensities = self._assemble_isotope_intensities() if not iso_intensities: return self.Ar39_decay_corrected = iso_intensities[1] self.Ar37_decay_corrected = iso_intensities[3] self.isotopes["Ar37"].decay_corrected = self.Ar37_decay_corrected self.isotopes["Ar39"].decay_corrected = self.Ar39_decay_corrected # self.debug('allow_negative ca correction {}'.format(arc.allow_negative_ca_correction)) self.corrected_intensities = dict( Ar40=iso_intensities[0], Ar39=iso_intensities[1], Ar38=iso_intensities[2], Ar37=iso_intensities[3], Ar36=iso_intensities[4], ) f, f_wo_irrad, non_ar, computed, interference_corrected = self._calculate_F(iso_intensities) self.non_ar_isotopes = non_ar self.computed = computed self.rad40_percent = computed["rad40_percent"] isotopes = self.isotopes for k, v in interference_corrected.iteritems(): isotopes[k].interference_corrected_value = v if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) arc = self.arar_constants age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage = age self.age = age.nominal_value self.age_err = age.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) j.std_dev = 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.age_err_wo_j = float(age.std_dev) self.uage_wo_j_err = ufloat(self.age, self.age_err_wo_j) if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, arar_constants=arc) self.age_err_wo_irrad = age.std_dev j.std_dev = 0 self.age_err_wo_j_irrad = age.std_dev for iso in isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)
def _calculate_age(self, include_decay_error=None): """ approx 2/3 of the calculation time is in _assemble_ar_ar_isotopes. Isotope.get_intensity takes about 5ms. """ # self.debug('calculate age') iso_intensities = self._assemble_isotope_intensities() if not iso_intensities: return self.Ar39_decay_corrected = iso_intensities[1] self.Ar37_decay_corrected = iso_intensities[3] self.isotopes['Ar37'].decay_corrected = self.Ar37_decay_corrected self.isotopes['Ar39'].decay_corrected = self.Ar39_decay_corrected # self.debug('allow_negative ca correction {}'.format(arc.allow_negative_ca_correction)) self.corrected_intensities = dict(Ar40=iso_intensities[0], Ar39=iso_intensities[1], Ar38=iso_intensities[2], Ar37=iso_intensities[3], Ar36=iso_intensities[4]) f, f_wo_irrad, non_ar, computed, interference_corrected = self._calculate_F( iso_intensities) self.non_ar_isotopes = non_ar self.computed = computed self.rad40_percent = computed['rad40_percent'] isotopes = self.isotopes for k, v in interference_corrected.iteritems(): isotopes[k].interference_corrected_value = v if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) arc = self.arar_constants age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.uage = age self.age = age.nominal_value self.age_err = age.std_dev if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) j.std_dev = 0 age = age_equation(j, f, include_decay_error=include_decay_error, arar_constants=arc) self.age_err_wo_j = float(age.std_dev) self.uage_wo_j_err = ufloat(self.age, self.age_err_wo_j) if self.j is not None: j = copy(self.j) else: j = ufloat(1e-4, 1e-7) age = age_equation(j, f_wo_irrad, include_decay_error=include_decay_error, arar_constants=arc) self.age_err_wo_irrad = age.std_dev j.std_dev = 0 self.age_err_wo_j_irrad = age.std_dev for iso in isotopes.itervalues(): iso.age_error_component = self.get_error_component(iso.name)