-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add expanded config support to
SeedSynthesizer
.
Co-authored-by: Alan Van Omen <[email protected]>
- Loading branch information
Showing
4 changed files
with
211 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). | ||
# Under the terms of Contract DE-NA0003525 with NTESS, | ||
# the U.S. Government retains certain rights in this software. | ||
"""This example demonstrates how to generate synthetic seeds from GADRAS using PyRIID's | ||
configuration expansion features.""" | ||
import yaml | ||
|
||
from riid.data.synthetic.seed import SeedSynthesizer | ||
from riid.gadras.api import get_expanded_config, validate_inject_config | ||
|
||
seed_synth_config = """ | ||
--- | ||
gamma_detector: | ||
name: Generic\\NaI\\2x4x16 | ||
parameters: | ||
distance_cm: | ||
- 10 | ||
- 100 | ||
- 1000 | ||
height_cm: 100 | ||
dead_time_per_pulse: 5 | ||
latitude_deg: 35.0 | ||
longitude_deg: 253.4 | ||
elevation_m: 1620 | ||
sources: | ||
- isotope: Cs137 | ||
configurations: | ||
- Cs137,100uCi | ||
- name: Cs137 | ||
activity: | ||
- 1 | ||
- 0.5 | ||
activity_units: Ci | ||
shielding_atomic_number: | ||
min: 10 | ||
max: 40.0 | ||
dist: uniform | ||
num_samples: 5 | ||
shielding_aerial_density: | ||
mean: 120 | ||
std: 2 | ||
num_samples: 5 | ||
- isotope: Cosmic | ||
configurations: | ||
- Cosmic | ||
- isotope: K40 | ||
configurations: | ||
- PotassiumInSoil | ||
- isotope: Ra226 | ||
configurations: | ||
- UraniumInSoil | ||
- isotope: Th232 | ||
configurations: | ||
- ThoriumInSoil | ||
... | ||
""" | ||
seed_synth_config = yaml.safe_load(seed_synth_config) | ||
validate_inject_config(seed_synth_config) | ||
from pprint import pprint | ||
pprint(len(get_expanded_config(seed_synth_config)["sources"][0]["configurations"])) | ||
|
||
try: | ||
seeds_ss = SeedSynthesizer().generate( | ||
seed_synth_config, | ||
verbose=True | ||
) | ||
print(seeds_ss) | ||
|
||
# At this point, you could save out the seeds via: | ||
seeds_ss.to_hdf("seeds.h5") | ||
|
||
# or start separating your backgrounds from foreground for use with the StaticSynthesizer | ||
fg_seeds_ss, bg_seeds_ss = seeds_ss.split_fg_and_bg() | ||
|
||
print(fg_seeds_ss) | ||
print(bg_seeds_ss) | ||
|
||
fg_seeds_ss.to_hdf("./fg_seeds.h5") | ||
bg_seeds_ss.to_hdf("./bg_seeds.h5") | ||
except FileNotFoundError: | ||
pass # Happens when not on Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.