Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
1705196
+ neutronics materials file
SteSeg Dec 13, 2024
fa48055
Merge branch 'LIBRA-project:main' into neutronics
SteSeg Dec 13, 2024
dfcbc4d
Merge branch 'LIBRA-project:main' into neutronics
SteSeg Dec 19, 2024
1a73ee8
- neutronics materials file
SteSeg Dec 19, 2024
8fa9d8d
Merge branch 'LIBRA-project:main' into neutronics
SteSeg Dec 19, 2024
96ca43e
+ neutronics mat file & examples
SteSeg Dec 19, 2024
d511a43
initial commit
RemDelaporteMathurin Apr 18, 2025
3340742
refactoring + header
RemDelaporteMathurin Apr 18, 2025
9dcf53b
added test
RemDelaporteMathurin Apr 18, 2025
468deb8
improved tests
RemDelaporteMathurin Apr 18, 2025
1de8d06
added data files
RemDelaporteMathurin Apr 18, 2025
bd0d8f2
Merge pull request #65 from LIBRA-project/read-one-compass-file
RemDelaporteMathurin Apr 18, 2025
8f40b52
test for COINC_2
RemDelaporteMathurin Apr 18, 2025
53fe9b0
fixed test
RemDelaporteMathurin Apr 18, 2025
df992bf
tests for coinc3 and 4
RemDelaporteMathurin Apr 18, 2025
b41b85c
vectorised functions
RemDelaporteMathurin Apr 18, 2025
23d4127
lowercase function names
RemDelaporteMathurin Apr 18, 2025
17b55ae
refactored calculate_coincidence
RemDelaporteMathurin Apr 18, 2025
7e11d2f
test for calculate coincidence
RemDelaporteMathurin Apr 18, 2025
8362d27
vectorised anti_1 + tests for anti-coincidence
RemDelaporteMathurin Apr 18, 2025
e7f4d8e
tests + vectorised other functions
RemDelaporteMathurin Apr 18, 2025
69471da
removed unused arguments in anti-coincidence functions
RemDelaporteMathurin Apr 18, 2025
b9673c2
lowercase ANTI
RemDelaporteMathurin Apr 18, 2025
e539ed0
documentation + type hinting
RemDelaporteMathurin Apr 18, 2025
92623ed
re-ran notebook
RemDelaporteMathurin Apr 18, 2025
6e64fcf
Merge pull request #66 from LIBRA-project/coincidence
RemDelaporteMathurin Apr 18, 2025
8b0c852
Added get_start_stop_time function
cdunn314 Apr 25, 2025
85c5fca
Reformatted file structure and added test
cdunn314 Apr 25, 2025
4209f20
Actually added test_get_start_stop_time()
cdunn314 Apr 25, 2025
71a590c
better error message
RemDelaporteMathurin Apr 25, 2025
19d26ec
pathlib
RemDelaporteMathurin Apr 25, 2025
b2c1d0d
added test
RemDelaporteMathurin Apr 25, 2025
b3ca47e
refactoring
RemDelaporteMathurin Apr 25, 2025
e326e24
new test
RemDelaporteMathurin Apr 25, 2025
fc61f32
instead of storing files we can create them
RemDelaporteMathurin Apr 25, 2025
d0984f3
slight refactor
RemDelaporteMathurin Apr 25, 2025
44cdda3
Merge pull request #67 from cdunn314/add_time
RemDelaporteMathurin Apr 25, 2025
fe21c5a
Added test and test files for get_livetime func
cdunn314 Apr 26, 2025
306a5ee
Fixed typo in doc string
cdunn314 Apr 26, 2025
f97a779
I think I added the uproot dependency
cdunn314 Apr 26, 2025
150675f
Update libra_toolbox/neutron_detection/activation_foils/compass.py
cdunn314 Apr 29, 2025
242345c
Update libra_toolbox/neutron_detection/activation_foils/compass.py
cdunn314 Apr 29, 2025
bf88ee2
Merge pull request #68 from cdunn314/livecount_time
RemDelaporteMathurin Apr 29, 2025
f30a84c
Initial add
cdunn314 May 7, 2025
15b2a8f
black
RemDelaporteMathurin May 7, 2025
34ed2e0
create the detector objects
RemDelaporteMathurin May 7, 2025
cc296f4
minor refactor
RemDelaporteMathurin May 7, 2025
bcbde2a
added histogramme
RemDelaporteMathurin May 7, 2025
2b2836a
documentation to get_live_time from root
RemDelaporteMathurin May 7, 2025
995d781
working example
RemDelaporteMathurin May 7, 2025
6c38398
docstrings
RemDelaporteMathurin May 7, 2025
4e2a60d
Merge branch 'main' into rem/class-structure-compass-measurements
RemDelaporteMathurin May 7, 2025
ec8de0d
removed example file
RemDelaporteMathurin May 7, 2025
9c8e5b3
fixed error message
RemDelaporteMathurin May 7, 2025
1dee848
added test
RemDelaporteMathurin May 7, 2025
7f6fb1e
extended test
RemDelaporteMathurin May 7, 2025
723a332
test no root file case
RemDelaporteMathurin May 7, 2025
9edff03
test for different bins
RemDelaporteMathurin May 7, 2025
86add5e
black
RemDelaporteMathurin May 7, 2025
c05f508
background substraction initial
RemDelaporteMathurin May 7, 2025
899d106
info file can be optional
RemDelaporteMathurin May 7, 2025
b4f5e2c
Merge branch 'rem/class-structure-compass-measurements' into rem/spec…
RemDelaporteMathurin May 7, 2025
be29ab5
added old peak fitting functions
RemDelaporteMathurin May 7, 2025
0923cb9
raise error if not optional
RemDelaporteMathurin May 7, 2025
db36657
Merge branch 'rem/class-structure-compass-measurements' into rem/spec…
RemDelaporteMathurin May 7, 2025
6719adc
fixed background substraction
RemDelaporteMathurin May 7, 2025
975a028
calibrate per channel nb
RemDelaporteMathurin May 7, 2025
f406e22
example notebook
RemDelaporteMathurin May 7, 2025
0ee985e
split into two function for calib. data
RemDelaporteMathurin May 7, 2025
1864edc
added documentation + fix indices vs channel
RemDelaporteMathurin May 8, 2025
6fcee62
fixed typo
RemDelaporteMathurin May 8, 2025
b31003e
added detection efficiency calculation
RemDelaporteMathurin May 8, 2025
98b521a
removed unneeded functions
RemDelaporteMathurin May 8, 2025
ecc757d
added classes for check sources
RemDelaporteMathurin May 8, 2025
383703a
mass attribute to activation foil
RemDelaporteMathurin May 8, 2025
3bccace
Merge branch 'activation-foil-classes' into rem/spectrum-fit
RemDelaporteMathurin May 8, 2025
31982bb
make use of check source class
RemDelaporteMathurin May 8, 2025
4ca727d
added half life
RemDelaporteMathurin May 8, 2025
3cb53d2
removed test
RemDelaporteMathurin May 8, 2025
5ea084a
Merge branch 'activation-foil-classes' into rem/spectrum-fit
RemDelaporteMathurin May 8, 2025
8400b7b
re-ran notebook
RemDelaporteMathurin May 8, 2025
8dadd43
everything in one file for simplicity
RemDelaporteMathurin May 8, 2025
e778326
ran notebook
RemDelaporteMathurin May 8, 2025
e6ec09e
nuclide class
RemDelaporteMathurin May 8, 2025
b5432e9
docstrings
RemDelaporteMathurin May 8, 2025
ed6349a
Merge branch 'activation-foil-classes' into rem/spectrum-fit
RemDelaporteMathurin May 8, 2025
f9f939c
changed check source files used
RemDelaporteMathurin May 8, 2025
1e44906
removed "double" + exposed search width + same timezone + overlap thr…
RemDelaporteMathurin May 8, 2025
1c969ce
removed double
RemDelaporteMathurin May 8, 2025
566ad43
Merge branch 'rem/class-structure-compass-measurements' into rem/spec…
RemDelaporteMathurin May 8, 2025
1681225
updated docstrings
RemDelaporteMathurin May 8, 2025
a58b82f
Merge branch 'activation-foil-classes' into rem/spectrum-fit
RemDelaporteMathurin May 8, 2025
1751f74
Merge pull request #70 from LIBRA-project/rem/class-structure-compass…
RemDelaporteMathurin May 9, 2025
0775c8e
Merge pull request #73 from LIBRA-project/activation-foil-classes
RemDelaporteMathurin May 9, 2025
df3d04c
fixed bins is None
RemDelaporteMathurin May 9, 2025
7eec77a
added test for background substraction
RemDelaporteMathurin May 9, 2025
1a48c38
Merge branch 'main' into rem/spectrum-fit
RemDelaporteMathurin May 9, 2025
36f9ae0
added some tests
RemDelaporteMathurin May 9, 2025
ed2dbcf
removed unused function
RemDelaporteMathurin May 9, 2025
085de98
list instead of dict
RemDelaporteMathurin May 9, 2025
e6c729a
test for multipeak area
RemDelaporteMathurin May 9, 2025
72757b5
more robust test
RemDelaporteMathurin May 9, 2025
246845f
removed 2 unused functions
RemDelaporteMathurin May 10, 2025
975b4fd
more robust test
RemDelaporteMathurin May 10, 2025
c3f0eda
get_peaks is now a method
RemDelaporteMathurin May 10, 2025
9e63635
simplified peak finding params
RemDelaporteMathurin May 10, 2025
8c946f9
more counts
RemDelaporteMathurin May 10, 2025
b3e2f17
added possibility to provide custom peak finding parameters
RemDelaporteMathurin May 10, 2025
7b186ea
docstrings + removed unused function
RemDelaporteMathurin May 12, 2025
8b2a8fb
improved bins in default mode
RemDelaporteMathurin May 16, 2025
52ac019
improved efficiency calculation
RemDelaporteMathurin May 16, 2025
b08ccfb
moved get expected activity to checksource
RemDelaporteMathurin May 16, 2025
225329b
intensity multiplication moved to expected counts instead of measured…
RemDelaporteMathurin May 16, 2025
c61e420
var naming
RemDelaporteMathurin May 16, 2025
f740deb
Merge pull request #71 from LIBRA-project/rem/spectrum-fit
RemDelaporteMathurin May 16, 2025
63272f8
compute gamma emmissions for SampleMeasurement
RemDelaporteMathurin May 17, 2025
9c78b9a
I've got _a_ neutron flux
RemDelaporteMathurin May 20, 2025
8111af9
divide by avogadro
RemDelaporteMathurin May 20, 2025
6d25a49
added get_detector method
RemDelaporteMathurin May 20, 2025
1048782
new get_neutron_flux method
RemDelaporteMathurin May 20, 2025
d14d2cd
energy, intensity, half life optional in Nuclide
RemDelaporteMathurin May 21, 2025
e52f751
added tests + renamed method
RemDelaporteMathurin May 21, 2025
3436e7b
re-ran notebook
RemDelaporteMathurin May 21, 2025
ccc091f
more events to reduce chance of failing test
RemDelaporteMathurin May 21, 2025
1ea2909
removed unused method
RemDelaporteMathurin May 21, 2025
e9f704d
split in two methods (flux and rate)
RemDelaporteMathurin May 21, 2025
ba85c87
documentation
RemDelaporteMathurin May 21, 2025
21ba6d8
unused variable
RemDelaporteMathurin May 21, 2025
98bb711
moved example
RemDelaporteMathurin May 22, 2025
4f004b0
use get_detector
RemDelaporteMathurin May 22, 2025
d5a1fee
more readable
RemDelaporteMathurin May 23, 2025
f1f8385
add assertion for negative counts
RemDelaporteMathurin May 23, 2025
14f9591
fixed typo
RemDelaporteMathurin Jun 3, 2025
4a7c4ab
moved example
RemDelaporteMathurin Jun 3, 2025
01cf1d7
Merge pull request #74 from LIBRA-project/final-push
RemDelaporteMathurin Jun 3, 2025
c97469f
Added zirconium reactions and updated foil data and usage
cdunn314 Jun 30, 2025
437fb1f
Added density argument to tests (not actually tested)
cdunn314 Jul 1, 2025
e7f254c
Removed density argument from tests and added default abundance
cdunn314 Jul 2, 2025
3001797
Added density, thickness check and test of check
cdunn314 Jul 2, 2025
bb031f1
Update libra_toolbox/neutron_detection/activation_foils/calibration.py
cdunn314 Jul 2, 2025
0fa9dd3
Added documentation for abundance and atomic_mass
cdunn314 Jul 2, 2025
16fd472
Merge branch 'main' of github.com:cdunn314/libra-toolbox into main
cdunn314 Jul 2, 2025
05f7156
Merge pull request #77 from cdunn314/main
RemDelaporteMathurin Jul 2, 2025
1c37171
added to_h5 and from_h5 methods
RemDelaporteMathurin Jul 3, 2025
3de320a
added way to only store the spectrum and energy bins
RemDelaporteMathurin Jul 3, 2025
c172223
fix channel nb comparison
RemDelaporteMathurin Jul 3, 2025
01bf29d
additional fixes
RemDelaporteMathurin Jul 3, 2025
e0535af
adapted example
RemDelaporteMathurin Jul 3, 2025
7740c4b
updated example
RemDelaporteMathurin Jul 3, 2025
12149de
Merge pull request #78 from LIBRA-project/h5_activation
RemDelaporteMathurin Jul 3, 2025
e8bed53
Merge branch 'main' into spectrum
RemDelaporteMathurin Jul 3, 2025
67a8f04
removed the events cutoff and scale bg everytime + use live time by d…
RemDelaporteMathurin Jul 15, 2025
8644e0a
Merge pull request #79 from LIBRA-project/spectrum
RemDelaporteMathurin Jul 15, 2025
44b628d
fixed get_events() for waveform csv
cdunn314 Jul 25, 2025
47471ae
Fixed csv_file_path bug
cdunn314 Jul 26, 2025
55720c0
test for reading in csvs with waveform data
cdunn314 Jul 26, 2025
981ecc5
changed test function name
cdunn314 Jul 30, 2025
f460865
Merge pull request #82 from cdunn314/main
RemDelaporteMathurin Jul 30, 2025
e798efe
some comments
SteSeg Jul 31, 2025
7f19fc3
+ neutronics materials file
SteSeg Dec 13, 2024
c46c721
- neutronics materials file
SteSeg Dec 19, 2024
cbb5900
+ neutronics mat file & examples
SteSeg Dec 19, 2024
1bf7eba
some comments
SteSeg Jul 31, 2025
3357f73
Merge branch 'neutronics' of github.com:SteSeg/libra-toolbox into neu…
SteSeg Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/examples/prt.ipynb

Large diffs are not rendered by default.

1,202 changes: 1,202 additions & 0 deletions docs/non_tested_examples/example.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import explicit, settings, calculations
from . import explicit, settings, calculations, calibration, compass
246 changes: 210 additions & 36 deletions libra_toolbox/neutron_detection/activation_foils/calibration.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,213 @@
from dataclasses import dataclass
from typing import List
import datetime
import numpy as np

def get_decay_lines(nuclides:list[str])->dict:
""" Creates dictionary of check source data
given a list of check source nuclides. """
# energy is the gamma energy in units of eV
# intensity is the percentage of decays that result in this energy gamma
all_decay_lines = {'Ba133':{'energy':[80.9979, 276.3989, 302.8508, 356.0129, 383.8485],
'intensity':[0.329, 0.0716, 0.1834, 0.6205, 0.0894],
'half_life':[10.551*365.25*24*3600],
'activity_date':datetime.date(2014, 3, 19),
'activity':1 * 3.7e4},
'Co60':{'energy':[1173.228, 1332.492],
'intensity':[0.9985, 0.999826],
'half_life':[1925.28*24*3600],
'actvity_date':datetime.date(2014, 3, 19),
'activity':0.872 * 3.7e4},
'Na22':{'energy':[511, 1274.537],
'intensity':[1.80, 0.9994],
'half_life':[2.6018*365.25*24*3600],
'actvity_date':datetime.date(2014, 3, 19),
'activity': 5 * 3.7e4},
'Cs137':{'energy':[661.657],
'intensity':[0.851],
'half_life':[30.08*365.25*24*3600],
'actvity_date':datetime.date(2014, 3, 19),
'activity':4.66 * 3.7e4},
'Mn54':{'energy':[834.848],
'intensity':[0.99976],
'half_life':[312.20*24*3600],
'actvity_date':datetime.date(2016, 5, 2),
'activity':6.27 * 3.7e4}}
decay_lines = {}
for nuclide in nuclides:
if nuclide in all_decay_lines.keys():
decay_lines[nuclide] = all_decay_lines[nuclide]

@dataclass
class Nuclide:
"""
Class to hold the information of a nuclide.

Attributes
----------
name :
The name of the nuclide.
energy :
The energy of the gamma rays emitted by the nuclide (in keV).
intensity :
The intensity of the gamma rays emitted by the nuclide.
half_life :
The half-life of the nuclide in seconds.
atomic_mass :
The atomic mass of the nuclide in atomic mass units (amu).
abundance :
The natural abundance of the nuclide as a fraction (default is 1.00).
"""

name: str
energy: List[float] = None
intensity: List[float] = None
half_life: float = None
atomic_mass: float = None
abundance: float = 1.00

@property
def decay_constant(self):
"""
Returns the decay constant of the nuclide in 1/s.
"""
return np.log(2) / self.half_life


ba133 = Nuclide(
name="Ba133",
energy=[80.9979, 276.3989, 302.8508, 356.0129, 383.8485],
intensity=[0.329, 0.0716, 0.1834, 0.6205, 0.0894],
half_life=10.551 * 365.25 * 24 * 3600,
)
co60 = Nuclide(
name="Co60",
energy=[1173.228, 1332.492],
intensity=[0.9985, 0.999826],
half_life=1925.28 * 24 * 3600,
)
na22 = Nuclide(
name="Na22",
energy=[511, 1274.537],
intensity=[1.80, 0.9994],
half_life=2.6018 * 365.25 * 24 * 3600,
)
cs137 = Nuclide(
name="Cs137",
energy=[661.657],
intensity=[0.851],
half_life=30.08 * 365.25 * 24 * 3600,
)
mn54 = Nuclide(
name="Mn54",
energy=[834.848],
intensity=[0.99976],
half_life=312.20 * 24 * 3600,
)

nb92m = Nuclide(
name="Nb92m",
energy=[934.44],
intensity=[0.9915],
half_life=10.25 * 24 * 3600,
)

nb93 = Nuclide(
name="Nb93",
atomic_mass=92.90637,
abundance=1.00
)

zr89 = Nuclide(
name="Zr89",
energy=[909.15],
intensity = [0.9904],
half_life=78.41 * 3600
)

zr90 = Nuclide(
name="Zr90",
atomic_mass=89.90469876,
abundance=0.515
)


@dataclass
class Reaction:
reactant: Nuclide
product: Nuclide
cross_section: float
"""
Class to hold the information of a reaction.
Attributes
----------
reactant :
The reactant of the reaction.
product :
The product of the reaction.
cross_section :
The cross section of the reaction in cm2.
"""

nb93_n2n = Reaction(
reactant=nb93,
product=nb92m,
cross_section=0.45966e-24 # cm2 at 14.1 MeV from IRDF-II 2020
)

zr90_n2n = Reaction(
reactant=zr90,
product=zr89,
cross_section=0.62389e-24 # cm2 at 14.1 MeV from IRDF-II 2020
)


@dataclass
class CheckSource:
nuclide: Nuclide
activity_date: datetime.date
activity: float

"""
Class to hold the information of a check source.
Attributes
----------
nuclide :
The nuclide of the check source.
activity_date :
The date of the calibrated activity of the check source.
activity :
The activity of the check source in Bq.
"""

def get_expected_activity(self, date: datetime.date) -> float:
"""
Returns the expected activity of the check source at a given date.

Args:
date: the date to calculate the expected activity for.

Returns:
the expected activity of the check source in Bq
"""

decay_constant = np.log(2) / self.nuclide.half_life

# Convert date to datetime if needed
if isinstance(self.activity_date, datetime.date) and not isinstance(
self.activity_date, datetime.datetime
):

activity_datetime = datetime.datetime.combine(
self.activity_date, datetime.datetime.min.time()
)
# add a timezone
activity_datetime = activity_datetime.replace(tzinfo=date.tzinfo)
else:
raise ValueError(f'{nuclide} not yet added to get_decay_lines()')
return decay_lines
activity_datetime = self.activity_date

time = (date - activity_datetime).total_seconds()
act_expec = self.activity * np.exp(-decay_constant * time)
return act_expec


@dataclass
class ActivationFoil:
reaction: Reaction
mass: float
name: str
density: float = None
thickness: float = None

"""Class to hold the information of an activation foil.
Attributes
----------
reaction :
The reaction that produces the nuclide.
mass :
The mass of the foil in grams.
name :
The name of the foil.
density :
The density of the foil in g/cm3.
thickness :
The thickness of the foil in cm.
"""

def __post_init__(self):
if (self.thickness is None) != (self.density is None):
raise ValueError("Thickness and density must either both be floats or both be None.")

@property
def nb_atoms(self) -> float:
"""
Returns the number of atoms in the foil.
"""
avogadro = 6.022e23 # part/mol
return self.reaction.reactant.abundance * (self.mass / self.reaction.reactant.atomic_mass * avogadro)
Loading
Loading