Giter Club home page Giter Club logo

sandialabs / pyriid Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 2.0 883 KB

ML-based radioisotope identification and estimation from gamma spectra in Python.

Home Page: https://sandialabs.github.io/PyRIID/

License: BSD 3-Clause "New" or "Revised" License

Python 99.41% Shell 0.02% PowerShell 0.03% Mako 0.55%
gamma-spectra machine-learning python tensorflow2 radioisotope-identification radiation radiation-sensor neural-networks scr-2618 snl-applications

pyriid's Introduction

PyRIID

Python PyPI

Welcome to PyRIID! PyRIID is a Python package providing models and data synthesis utilities supporting machine learning-based research into radioisotope-related detection, identification, and quantification.

Installation

These instructions assume you meet the following requirements:

  • Python version: 3.8 to 3.10
  • Operating systems: Windows, Mac, or Ubuntu

A virtual environment is recommended.

Tests and examples are run via Actions on many combinations of Python version and operating system. You can verify support for your platform by checking the workflow files.

For Use

To use the latest version on PyPI (note: changes are slower to appear here), run:

pip install riid

For the latest features, run:

pip install git+https://github.com/sandialabs/pyriid.git@main

For Development

If you are developing PyRIID, clone this repository and run:

pip install -e ".[dev]"

If you have trouble with Pylance resolving imports for an editable install, try this:

pip install -e ".[dev]" --config-settings editable_mode=compat

Examples

Examples for how to use this package can be found here.

Tests

Unit tests for this package can be found here.

Run all unit tests with the following:

python -m unittest tests/*.py -v

You can also run one of the run_tests.* scripts, whichever is appropriate for your platform.

Docs

API documentation can be found here.

Build the docs with the following:

pip install -r pdoc/requirements.txt
pdoc riid -o docs/ --html --template-dir pdoc

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate and adhere to our code of conduct.

Contacts

Maintainers and authors can be found here.

Copyright

Full copyright details can be found here.

Acknowledgements

Thank you to the U.S. Department of Energy, National Nuclear Security Administration, Office of Defense Nuclear Nonproliferation Research and Development (DNN R&D) for funding that has led to version 2.x.

Additionally, thank you to the following individuals who have provided invaluable subject-matter expertise:

  • Paul Thelen (also an author)
  • Ben Maestas
  • Greg Thoreson
  • Michael Enghauser
  • Elliott Leonard

pyriid's People

Contributors

alanjvano avatar anbusto avatar lcross-sandia avatar tymorrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyriid's Issues

gadras.py - _smpl_to_pcf() throws unexpected error

Error thrown when this line is reached for a SampleSet that contains no Seed level labels (where the MultiIndex exists, but the value for Seed is None for all labels).
Actual error is created in SampleSet.get_row_labels(), which attempts to get the argmax() for an empty sequence when the target_level is empty.

Truncated error:

  ...
  result = values.argmax(axis)  # type: ignore[var-annotated]
  ValueError: attempt to get argmax of an empty sequence

Proposed solution:
Add the following check before level-wise calculation in SampleSet.get_row_labels():

  target_level_index = SampleSet.SOURCES_MULTI_INDEX_NAMES.index(target_level)
  if df.columns.levshape[target_level_index] == 0:
      return []

Additional consideration needs to be made for the remaining use of seeds and isotopes in gadras._smpl_to_pcf(), as there is a use case where a SampleSet's various DataFrames could have ''missing" values at various levels in the MultiIndex, and it can no longer be assumed that there is a corresponding Isotope and Seed level for each SampleSet.source column.

Python and Dependency Upgrades

This issue is for upgrading all dependencies as high as possible and targeting Python 3.9.
While Python 3.9 will be targeted, we will review other Python versions 3.7-3.10 to see if they past the test procedure detailed below.

Steps:

  1. Upgrade dependencies as high as possible for a Python 3.9 environment.
    • Set dependencies to allow version changes at the build level (1.1.X)
  2. Test
    • Run unit tests
    • Run all examples
    • Document where the package will or will not work
  3. Repeat Test procedure for other Python environments and document in this issue for now.

Notes:

Results:

Python version support

Platform Python 3.7 Python 3.8 Python 3.9 Python 3.10
Windows Server 2022
macOS Monterey (12.6)
Ubuntu 20.04

⏳ = Pending
✅ = Supported
❌ = Not supported
🤷 = No plans to check

Expanded Configs

def get_expanded_config(config: dict, rng: np.random.Generator = np.random.default_rng()) -> dict: 
    """Expands sampling objects within the given config into value lists and returns a new, equivalent config dictionary. 
    """
    pass

def get_detector_setups(expanded_config: dict) -> list[dict]: 
    """Permutate the lists of values in the expanded config to generate a list of detector setups.
    """
    pass

example/synthesize_seeds.py error

On ubuntu

Commands:

conda create --name pyriid python=3.7
conda activate pyriid
git clone
pip install .
cd examples
python synthesize_seeds.py

Output:
ModuleNotFoundError: No module named 'yaml'

Review Poisson-Bayes TF Implementation

Adding an issue as a reminder to review the TF implementation of Poisson-Bayes and reconcile it with the old predict method.

Steps:

  1. Verify TF implementation works
  2. Review and fix saving/loading as necessary

Investigate TF Data Pipelines

Investigate TF Data Pipelines that will utilize the StaticSynthesizer where the next batch's data is loaded on the current batch's run.

https://www.tensorflow.org/guide/data_performance

Open questions:

  • Can StaticSynthesizer provide the same results given a seed?
    • If not, a paradigm that loads from StaticSynthesizer and saves data on disk on the first epoch , then uses data on disk for subsequent epochs?

run_test.sh doesn't work

On ubuntu system.

Command:
conda create --name pyriid python=3.7
conda activate pyriid
git clone
pip install .
./run_tests.sh

Output:
./run_tests.sh: line 2: coverage: command not found

Wrong versions of dependency packages installed

Steps to reproduce:

conda create --name pyriid python=3.7
conda activate pyriid
pip install riid

Output:

Collecting riid
  Using cached riid-1.0.2-py3-none-any.whl (41 kB)
Collecting pandas==1.0.5
  Using cached pandas-1.0.5-cp37-cp37m-manylinux1_x86_64.whl (10.1 MB)
Collecting h5py<3.0.0
  Using cached h5py-2.10.0-cp37-cp37m-manylinux1_x86_64.whl (2.9 MB)
Collecting scikit-learn==0.22
  Using cached scikit_learn-0.22-cp37-cp37m-manylinux1_x86_64.whl (7.0 MB)
Collecting tensorflow-model-optimization==0.1.3
  Using cached tensorflow_model_optimization-0.1.3-py2.py3-none-any.whl (81 kB)
Collecting tqdm
  Using cached tqdm-4.64.1-py2.py3-none-any.whl (78 kB)
Collecting matplotlib==3.1.2
  Using cached matplotlib-3.1.2-cp37-cp37m-manylinux1_x86_64.whl (13.1 MB)
Collecting tables==3.6.1
  Using cached tables-3.6.1-cp37-cp37m-manylinux1_x86_64.whl (4.3 MB)
Collecting seaborn==0.10.1
  Using cached seaborn-0.10.1-py3-none-any.whl (215 kB)
Collecting numpy==1.17.4
  Using cached numpy-1.17.4-cp37-cp37m-manylinux1_x86_64.whl (20.0 MB)
Collecting tensorflow==2.0.0

setup.py requires:

REQUIREMENTS = [
    "tensorflow==2.5.0",
    "tensorflow-probability==0.12.1",
    "tensorflow-model-optimization==0.6.0",
    "numpy~=1.19.2",
    "pandas==1.0.5",
    "matplotlib==3.5.2",
    "scikit-learn==0.24",
    "tables==3.6.1",
    "seaborn==0.11.1",
]

As you can see tensorflow==2.5.0 however the pip install installs tensorflow 2.0.

Maybe this is due to using Anaconda for the virtual environment?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.