Skip to content

Commit 77875cc

Browse files
committed
Fix count rate for CFY solve
1 parent 56731e9 commit 77875cc

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

mosden/countrate.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, input_path: str) -> None:
1818
Path to the input file
1919
"""
2020
super().__init__(input_path)
21+
self.is_warned = False
2122

2223
return None
2324

@@ -200,8 +201,6 @@ def sample_parameter(val: ufloat, dist: str) -> float:
200201
lam_post_data = dict()
201202
conc_post_data = dict()
202203

203-
is_warned = False
204-
205204
for nuc in net_similar_nucs:
206205
Pn_data = self.emission_prob_data[nuc]
207206
Pn = ufloat(
@@ -242,13 +241,16 @@ def sample_parameter(val: ufloat, dist: str) -> float:
242241
index_offset = 0
243242

244243
if MC_run and sampler_func:
245-
if not single_time_val and not is_warned:
244+
if not single_time_val and not self.is_warned:
246245
msg = 'Concentration not sampled over time; using initial'
247246
self.logger.warning(msg)
248-
if not is_warned:
249247
self.logger.warning('Using nominal concentration')
250-
is_warned = True
251-
conc = concentration_array[post_irrad_index].n
248+
self.is_warned = True
249+
250+
if not single_time_val:
251+
conc = concentration_array[post_irrad_index].n
252+
else:
253+
conc = sample_parameter(conc, sampler_func)
252254
Pn = sample_parameter(Pn, sampler_func)
253255
halflife = sample_parameter(halflife, sampler_func)
254256
decay_const = np.log(2) / halflife
@@ -265,9 +267,12 @@ def sample_parameter(val: ufloat, dist: str) -> float:
265267
else:
266268
conc_vals = nominal_concs[index_offset:]
267269

268-
assert len(conc_vals) == len(use_times)
269-
270-
counts = Pn * decay_const * np.asarray(conc_vals)
270+
if not single_time_val:
271+
assert len(conc_vals) == len(use_times)
272+
counts = Pn * decay_const * np.asarray(conc_vals)
273+
else:
274+
counts = (Pn * decay_const * conc *
275+
np.exp(-decay_const * use_times))
271276
count_rate += counts
272277
else:
273278
if single_time_val:

0 commit comments

Comments
 (0)