Git Product home page Git Product logo

actigamma's Introduction

ActiGamma

Trivial gamma spec from activities

GitHub Actions Build Status Code Coverage

PyPI PyPI PyPI License

HitCount GitHub issues GitHub stars GitHub forks

ChartOfNuclides

GammaLinesAnimation

ActiGamma - Converts nuclide activities to gamma spec. Nothing more, nothing less.

Design goals

FISPACT-II can produce the gamma spectrum at each irradiation time interval, but this is largely overkill if you just want the gamma (or x-ray, beta, etc...) lines/spectrum given a set of radionuclides and corresponding activities. If you already have performed your activation and inventory simulation and want a gamma spec, then ActiGamma will do just that.

No dependencies. Doesn't require FISPACT-II. Pip install.

Even the decay data is included in the package in minified JSON format, you don't need to worry about reading it either.

Installation

The package is hosted on PyPi and is therefore available with pip3 directly.

A note on the nature of ActiGamma, it is written in Python3 and does not support Python2, therefore in order to use the package, you must have a version of Python3 installed along with pip3.

To install simply do

pip3 install actigamma

Usage

Simply import the package as below.

import actigamma as ag

Load the database (by default uses decay_2012 library but easy to extend to add others).

db = ag.Decay2012Database()

# get halflife of Co60
print(db.gethalflife("Co60"))

# get gamma lines of Co60
print(db.getenergies("Co60", spectype="gamma"))

Define an energy grid (binning). This can be anything (linspace, logspace, custom bounds).

# define an energy grid between 1 and 4 MeV with 5,000 bins
grid = ag.EnergyGrid(bounds=ag.linspace(1e6, 4e6, 5000))

Define a line aggregator, single-type (LineAggregator) or multi-type (MultiTypeLineAggregator) to combine mulitple nuclides and handle the binning.

# bin the lines appropriately using single type aggregator
lc = ag.LineAggregator(db, grid)

Define the inventory via activities (or convert from atoms if need be).

# define my unstable inventory by activities (Bq)
inv = ag.UnstablesInventory(data=[
    (db.getzai("Co60"), 9.87e13),
    (db.getzai("Pu238"), 4.e3),
    (db.getzai("U235"), 5.4e8)
])

To create an inventory from a list of atoms (instead of activities) use the following.

inv = ag.UnstablesInventory(data=[
    (db.getzai("Co60"), ag.activity_from_atoms(db, "Co60", 2.36853908671135e+22)),
    (db.getzai("Pu238"), ag.activity_from_atoms(db, "Pu238", 15970864933847.367)),
    (db.getzai("U235"), ag.activity_from_atoms(db, "U235", 1.730297451446211e+25))
])

Get the histogram and do what you want with it.

hist, bin_edges = lc(inv, spectype=SPECTYPE)

# plot here
...

Examples

Single type plot

Gamma lines from Co60 + U235 + Pu238 at different activities.

Lines

Is produced with the following code

import actigamma as ag

# normally gamma but could be something else - "alpha", "SF" if data exists!
SPECTYPE = "gamma"

# setup the DB - currently only decay 2012 exists
db = ag.Decay2012Database()

# define my unstable inventory by activities (Bq)
inv = ag.UnstablesInventory(data=[
    (db.getzai("Co60"), 9.87e13),
    (db.getzai("Pu238"), 4.e3),
    (db.getzai("U235"), 5.4e8)
])

# define an energy grid between 0 and 4 MeV with 10,000 bins
grid = ag.EnergyGrid(bounds=ag.linspace(0.0, 4e6, 1000))

# bin the lines appropriately
lc = ag.LineAggregator(db, grid)
hist, bin_edges = lc(inv, spectype=SPECTYPE)

# plot ...
Multi type plot

Gamma + x-ray lines from Co60 + U235 + Pu238 at different activities.

Is produced with the following code

import actigamma as ag

# normally gamma but could be something else - "alpha", "SF" if data exists!
SPECTYPES = [
    "gamma",
    "x-ray"
]

# setup the DB - currently only decay 2012 exists
db = ag.Decay2012Database()

# define my unstable inventory by activities (Bq)
inv = ag.UnstablesInventory(data=[
    (db.getzai("Co60"), 9.87e13),
    (db.getzai("Pu238"), 4.e3),
    (db.getzai("U235"), 5.4e8)
])

# define an energy grid between 0 and 4 MeV with 10,000 bins
grid = ag.EnergyGrid(bounds=ag.linspace(0.0, 4e6, 1000))

# bin the lines appropriately
lc = ag.MultiTypeLineAggregator(db, grid)
hist, bin_edges = lc(inv, spectype=SPECTYPES)

# plot ...

actigamma's People

Contributors

neutronics avatar thomasms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

markharley12

actigamma's Issues

Beta spectrum is nonsense

Placeholder - this is an issue with the data not the code, but the beta spectrum should be a continuous spectrum.

The correctness of the spectrum?

How do you ensure the correctness of the drawn energy spectrum? Have you verified it with someone else's paper or software or measured energy spectrum?

Another question

Another question:
I think the activities in the example shouble be called “the numbers of nuclide” rather than “the activitities”.Could you help me about this question?

Allowing averaging of energy bins

FISPACT-II uses an energy averaging effect to ensure that energy is conserved and keep the dose rate correct for coarse energy grids.

This is not always desirable, so add it as an option or provide a line aggregator that does the averaging.

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.