Skip to content

Commit 651fc4d

Browse files
authored
Merge branch 'LIBRA-project:main' into compass_collin
2 parents 7f91f3c + 197f0c1 commit 651fc4d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

libra_toolbox/neutron_detection/diamond/process_data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_count_rate(self, bin_time: float, energy_window: tuple = None):
7474
time_values = self.time_values.copy()
7575
energy_values = self.energy_values.copy()
7676

77-
time_bins = np.arange(0, time_values[-2], bin_time)
77+
time_bins = np.arange(time_values.min(), time_values[-2], bin_time)
7878

7979
if energy_window is not None:
8080
peak_mask = (energy_values > energy_window[0]) & (
@@ -113,10 +113,10 @@ def get_avg_rate(self, t_min: float, t_max: float, energy_window: tuple = None):
113113
time_values = time_values[peak_mask]
114114

115115
# Create mask to only count pulses of any energy in section time window
116-
idx = np.logical_and(self.time_values > t_min, self.time_values < t_max)
116+
idx = np.logical_and(time_values > t_min, time_values < t_max)
117117

118-
counts = len(self.time_values[idx])
119-
error = np.sqrt(len(self.time_values[idx]))
118+
counts = len(time_values[idx])
119+
error = np.sqrt(len(time_values[idx]))
120120
delta_t = t_max - t_min
121121
count_rate = counts / delta_t
122122
count_rate_err = error / delta_t

libra_toolbox/neutronics/vault.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def build_vault_model(
44
added_cells=[],
55
added_materials=[],
66
overall_exclusion_region=None,
7+
cross_sections_destination="cross_sections",
78
) -> "openmc.model.Model":
89
"""
910
Builds a complete OpenMC model for a simulation setup representing a
@@ -95,6 +96,7 @@ def build_vault_model(
9596
libraries=["ENDFB-8.0-NNDC"],
9697
set_OPENMC_CROSS_SECTIONS=True,
9798
particles=["neutron"],
99+
destination=cross_sections_destination,
98100
)
99101
#
100102
# Definition of the spherical void/blackhole boundary

test/neutron_detection/test_diamond.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,18 @@ def test_get_count_rate(tmpdir):
143143
assert np.allclose(count_rates_peak2, expected_count_rate_peak2, rtol=0.1)
144144

145145
assert len(count_rate_bins_total) == total_time_s / bin_time
146+
147+
148+
def test_count_rate_doesnt_ignore_data():
149+
"""Test to catch the bug in #48"""
150+
151+
# create a processor with time from -100 to 100 and energy values from -100 to 100
152+
processor = DataProcessor()
153+
processor.time_values = np.linspace(-100, 100, 1000)
154+
processor.energy_values = np.linspace(-100, 100, 1000)
155+
156+
# calculate the count rates
157+
count_rates, time_bins = processor.get_count_rate(bin_time=1)
158+
159+
# the first time bin should be -100
160+
assert np.isclose(time_bins[0], -100)

0 commit comments

Comments
 (0)