Skip to content

Commit 48d86bb

Browse files
committed
Convert to using time dependent data for non-sampled concs
1 parent 8a0798d commit 48d86bb

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

mosden/countrate.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ def sample_parameter(val: ufloat, dist: str) -> float:
200200
lam_post_data = dict()
201201
conc_post_data = dict()
202202

203+
is_warned = False
204+
203205
for nuc in net_similar_nucs:
204206
Pn_data = self.emission_prob_data[nuc]
205207
Pn = ufloat(
@@ -223,6 +225,7 @@ def sample_parameter(val: ufloat, dist: str) -> float:
223225
vals.append(val)
224226
uncertainties.append(uncertainty)
225227
concentration_array = unumpy.uarray(vals, uncertainties)
228+
nominal_concs = vals
226229
conc = concentration_array[post_irrad_index]
227230

228231
if conc < 1e-24:
@@ -232,14 +235,23 @@ def sample_parameter(val: ufloat, dist: str) -> float:
232235
if Pn < 1e-24:
233236
continue
234237

238+
239+
if self.post_irrad_only:
240+
index_offset = post_irrad_index
241+
else:
242+
index_offset = 0
243+
235244
if MC_run and sampler_func:
236-
if not single_time_val:
245+
if not single_time_val and not is_warned:
237246
msg = 'Concentration not sampled over time; using initial'
238247
self.logger.warning(msg)
248+
if not is_warned:
249+
self.logger.warning('Using nominal concentration')
250+
is_warned = True
251+
conc = concentration_array[post_irrad_index].n
239252
Pn = sample_parameter(Pn, sampler_func)
240253
halflife = sample_parameter(halflife, sampler_func)
241254
decay_const = np.log(2) / halflife
242-
conc = sample_parameter(concentration_array[post_irrad_index], sampler_func)
243255

244256
if conc < 0.0:
245257
conc = 1e-12
@@ -248,18 +260,20 @@ def sample_parameter(val: ufloat, dist: str) -> float:
248260
if Pn < 0.0:
249261
Pn = 1e-12
250262

251-
counts = Pn * decay_const * conc * \
252-
np.exp(-decay_const * use_times)
263+
if self.no_post_irrad:
264+
conc_vals = nominal_concs[:post_irrad_index+1]
265+
else:
266+
conc_vals = nominal_concs[index_offset:]
267+
268+
assert len(conc_vals) == len(use_times)
269+
270+
counts = Pn * decay_const * np.asarray(conc_vals)
253271
count_rate += counts
254272
else:
255273
if single_time_val:
256274
counts = Pn * decay_const * concentration_array[post_irrad_index] * \
257275
unumpy.exp(-decay_const * use_times)
258276
else:
259-
if self.post_irrad_only:
260-
index_offset = post_irrad_index
261-
else:
262-
index_offset = 0
263277
if self.no_post_irrad:
264278
counts = Pn * decay_const * concentration_array[:post_irrad_index+1]
265279
else:

0 commit comments

Comments
 (0)