radiation 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjYzYWE2MzQ4NTIyY2EyOTcyODg3N2E0OGE4ZGQ1NmEyMTdlNjI4Mw==
5
+ data.tar.gz: !binary |-
6
+ YTM5MmIxOGRmYzU0Zjc3MmU0NmI1MTEyYTMwZGY4MWUwMDYyY2NmOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTFlYmNlNWQ3ZDgwMTBlMzc5ZTI1N2Q4YjhiMWMyOTBlZDA2YjJjZjNhYWZk
10
+ MDU0ZjQ2YTJkOWVkYjExMTliYjYyYjZjM2Q3MTJmMGRjNDM5MDdhYTNmY2U0
11
+ MWFlNzM2NDI1ZTZlNzVmNTY4NTJjMGI1MDhkNGYzYTZkZDViM2E=
12
+ data.tar.gz: !binary |-
13
+ NzI5MDE3OGY2YmI1NDhiZGNmMWY1YTIwODQ4ZTQ4N2ZiYThiMzU4YmE3ZmQx
14
+ ZjZhMzQwNjE1MjRmOTc3NmUzYzg4MzM4NWFkOWFlNThkMDA3N2Q0OTQ1YTEx
15
+ YWJhZjlhMTliZTNjNTI2NTY4YmFhYjg1YzRjYWFiZTYxMTg0ZGU=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ #--color
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - 1.9
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in radiation.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jan Mayer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Radiation
2
+
3
+ This gem provides easy access to energies and intensities from the decay of radioactive nuclei.
4
+ Currently two data sources are accessible: Internal (see bib files in `./data/`) and recommended values
5
+ by [Laboratoire National Henri Becquerel](http://www.nucleide.org/DDEP_WG/DDEPdata.htm)
6
+
7
+ ## Example Usage
8
+
9
+ Radiation::Source.new(nuclide: "Ra-226").energies.collect{|e| e.value}
10
+
11
+
12
+ ## Planned features
13
+
14
+ Energy and efficiency calibration for given peaks or spectra.
15
+
16
+
17
+ ## Installation
18
+
19
+ Requirement is a (local) ruby with rubygems. Using rvm is recommended
20
+
21
+ $ \curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ gem 'radiation'
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install radiation
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/data/Eu-152.bib ADDED
@@ -0,0 +1,9 @@
1
+ @book{IAEATECDOC619,
2
+ title = "X-ray and gamma-ray standards for detector calibration",
3
+ journal = "IAEA TECDOC",
4
+ volume = "619",
5
+ year = "1991",
6
+ issn = "1011-4289"
7
+ url = "http://www-pub.iaea.org/books/iaeabooks/875/X-ray-and-Gamma-ray-Standards-for-Detector-Calibration",
8
+ author = "A. Lorenz and H.D. Leram"
9
+ }
data/data/Eu-152.csv ADDED
@@ -0,0 +1,15 @@
1
+ 121.8;0.2837;0.0013
2
+ 123.1;0.412;0.005
3
+ 244.7;0.0753;0.0004
4
+ 344.3;0.2657;0.0011
5
+ 411.1;0.02238;0.0001
6
+ 444.0;0.03125;0.00014
7
+ 778.9;0.1297;0.0006
8
+ 867.4;0.04214;0.00025
9
+ 964.0;0.1463;0.0006
10
+ 1085.9;0.1013;0.0005
11
+ 1089.7;0.01731;0.00009
12
+ 1112.1;0.1354;0.0006
13
+ 1212.9;0.01412;0.00008
14
+ 1299.1;0.01626;0.00011
15
+ 1408.0;0.2085;0.0009
data/data/Ra-226.bib ADDED
@@ -0,0 +1,13 @@
1
+ @article{Delgado2002137,
2
+ title = "Measurements of photon emission probabilities from the decay of 226Ra and daughters ",
3
+ journal = "Applied Radiation and Isotopes ",
4
+ volume = "56",
5
+ number = "1–2",
6
+ pages = "137 - 143",
7
+ year = "2002",
8
+ note = "<ce:title>Proceedings of the Conference on Radionuclide Metrology and its A pplications, ICRM'01</ce:title> ",
9
+ issn = "0969-8043",
10
+ doi = "10.1016/S0969-8043(01)00179-8",
11
+ url = "http://www.sciencedirect.com/science/article/pii/S0969804301001798",
12
+ author = "José U Delgado and Jean Morel and Michel Etcheverry"
13
+ }
data/data/Ra-226.csv ADDED
@@ -0,0 +1,34 @@
1
+ 186.2;3.502;0.8
2
+ 242.0;7.13;0.7
3
+ 258.8;0.525;1.0
4
+ 274.2;0.472;1.2
5
+ 295.2;18.09;0.7
6
+ 351.9;35.04;0.7
7
+ 388.0;0.690;1.5
8
+ 455.0;0.287;2.0
9
+ 480.5;0.336;1.4
10
+ 487.1;0.431;1.4
11
+ 580.3;0.369;1.5
12
+ 609.3;44.83;0.7
13
+ 665.4;1.506;0.8
14
+ 768.4;4.78;0.8
15
+ 785.8;1.097;1.1
16
+ 806.2;1.250;1.0
17
+ 934.1;3.041;0.8
18
+ 1120.3;14.66;0.7
19
+ 1155.2;1.611;1.2
20
+ 1238.1;5.75;0.8
21
+ 1281.0;1.411;1.1
22
+ 1377.7;3.895;0.8
23
+ 1385.3;0.782;1.2
24
+ 1401.5;1.311;0.9
25
+ 1408.0;2.346;0.8
26
+ 1509.2;2.065;1.5
27
+ 1661.3;1.063;1.6
28
+ 1729.6;2.791;0.8
29
+ 1764.5;15.03;0.7
30
+ 1847.4;1.994;1.0
31
+ 2118.5;1.137;1.0
32
+ 2204.1;4.82;0.8
33
+ 2293.36;0.298;2.6
34
+ 2447.7;1.525;0.9
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'csv'
3
+
4
+ class Radiation::Source
5
+ class Resource
6
+ private
7
+ def datasource_internal(nuclide)
8
+ begin
9
+ path = File.join(File.dirname(__FILE__), "../../../../data")
10
+ @data[:nuclide] = nuclide.to_s
11
+ @data[:lines] = CSV.read("#{path}/#{nuclide}.csv", {col_sep: ';', converters: :numeric}).collect{|row| {:energy => row[0].pm(0), :intensity => row[1].pm(row[2])} }
12
+ rescue
13
+ raise "No Data for #{nuclide}"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ require 'plusminus'
3
+
4
+ require 'open-uri'
5
+ require 'open-uri/cached'
6
+ require 'tmpdir'
7
+
8
+
9
+ class Radiation::Source
10
+ class Resource
11
+
12
+ private
13
+ def datasource_nukleideorg(nuclide)
14
+ nuclide = "Ra-226D" if nuclide == "Ra-226" #Ra-226 in equlibrium with daughters
15
+ begin
16
+ @data[:nuclide] = nuclide.to_s
17
+ OpenURI::Cache.cache_path = "#{Dir.tmpdir}/radiation/"
18
+ uri = open("http://www.nucleide.org/DDEP_WG/Nuclides/#{nuclide}.lara.txt").readlines
19
+ start = 0
20
+ uri.each_with_index do |line, lineno|
21
+ if line.start_with?("------")
22
+ start = lineno + 2
23
+ break
24
+ end
25
+ end
26
+ return @data[:lines] = [] if start == 0 or uri.count < start
27
+ @data[:lines] = uri[start...-1].collect{|line| line.split(' ; ')}.select!{|row| row[4] == "g"}.collect do |row|
28
+ {:energy => row[0].to_f.pm(row[1].to_f), :intensity => row[2].to_f.pm(row[3].to_f)}
29
+ end
30
+ rescue
31
+ raise "No Data for #{nuclide}"
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'radiation/source/resource/internal'
3
+ require 'radiation/source/resource/nucleideorg'
4
+
5
+ class Radiation::Source
6
+ class Resource
7
+
8
+ def initialize(resource)
9
+ @resource = resource
10
+ end
11
+
12
+ def data(nuclide)
13
+ @data = {}
14
+ case @resource
15
+ when "internal" then datasource_internal(nuclide)
16
+ when "nucleide.org" then datasource_nukleideorg(nuclide)
17
+ else raise "Unknown Datasource"
18
+ end
19
+ return @data
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require 'radiation/source/resource'
3
+
4
+ class Radiation::Source
5
+ attr_reader :data
6
+
7
+ def initialize(options={})
8
+ @resource = options.key?(:resource) ? options[:resource].to_s : "internal"
9
+ fetch(options[:nuclide].to_s) if options.key?(:nuclide)
10
+ end
11
+
12
+ def fetch(nuclide)
13
+ raise "Nuclide :#{nuclide} is not valid." unless is_nuclide?(nuclide)
14
+ @data = Resource.new(@resource).data(nuclide)
15
+ end
16
+
17
+ def nuclide
18
+ @data[:nuclide]
19
+ end
20
+
21
+ def energies
22
+ @data[:lines].collect{|line| line[:energy]}
23
+ end
24
+
25
+ def intensities
26
+ @data[:lines].select{|line| line[:intensity] > 0}.collect{|line| {:energy => line[:energy], :intensity => line[:intensity]} }
27
+ end
28
+
29
+ def is_nuclide?(nuclide)
30
+ !!(nuclide =~ /\A[a-zA-Z]{1,2}-\d{1,3}\z/)
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Radiation
2
+ VERSION = "0.0.1"
3
+ end
data/lib/radiation.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "radiation/version"
2
+ require "radiation/source"
3
+
4
+ module Radiation
5
+ # Your code goes here...
6
+ end
data/radiation.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'radiation/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "radiation"
8
+ spec.version = Radiation::VERSION
9
+ spec.authors = ["Jan Mayer"]
10
+ spec.email = ["jan.mayer@ikp.uni-koeln.de"]
11
+ spec.description = %q{Decay Radiation}
12
+ spec.summary = %q{This gem provides easy access to energies and intensities from the decay of radioactive nuclei}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "plusminus"
22
+ spec.add_dependency "open-uri-cached"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ require 'radiation'
3
+ require 'csv'
4
+
5
+ puts ["E_ɣ", "ΔE_ɣ", "I_ɣ", "ΔI_ɣ"].join("\t")
6
+ puts Radiation::Source.new(nuclide: "Ra-226", resource: "nucleide.org").intensities.collect{|l| [l[:energy].value, l[:energy].delta, l[:intensity].value, l[:intensity].delta].join("\t") }
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Radiation do
5
+ describe Radiation::Source do
6
+
7
+ describe "Features" do
8
+ name = "Ra-226"
9
+ source = Radiation::Source.new(nuclide: name)
10
+
11
+
12
+ it "provides information about itself" do
13
+ source.nuclide.should eq(name)
14
+ #source.reference.should be_a_kind_of(String)
15
+ #source.halflive.should be_a_kind_of(Plusminus::PlusminusFloat)
16
+ end
17
+
18
+ it "returns an array with gamma-ray energies for a given source" do
19
+ source.energies.should be_a_kind_of(Array)
20
+ source.energies.length.should be > 0
21
+ source.energies[0].should be_a_kind_of(Plusminus::PlusminusFloat)
22
+ end
23
+
24
+ it "returns intensities for energies" do
25
+ source.intensities.should be_a_kind_of(Array)
26
+ source.intensities.first.should be_a_kind_of(Hash)
27
+ source.intensities.length.should be > 0
28
+ end
29
+
30
+ it "can access different data resources" do
31
+ expect { Radiation::Source.new(nuclide: "Ra-226") }.to_not raise_error
32
+ expect { Radiation::Source.new(nuclide: "Ra-226", resource: "nucleide.org") }.to_not raise_error
33
+ end
34
+
35
+ end
36
+
37
+ describe "Errors" do
38
+ it "cheks for valid nuclei" do
39
+ Radiation::Source.new.is_nuclide?("Nukular9000").should be false
40
+ Radiation::Source.new.is_nuclide?("226Ra-226").should be false
41
+ Radiation::Source.new.is_nuclide?("Ra-226").should be true
42
+ Radiation::Source.new.is_nuclide?("C-14").should be true
43
+ Radiation::Source.new.is_nuclide?("H-1").should be true
44
+ expect { Radiation::Source.new(nuclide: "Nukular9000") }.to raise_error
45
+ expect { Radiation::Source.new(nuclide: "Ra-226") }.to_not raise_error
46
+ end
47
+
48
+ it "gives an error if no record is found" do
49
+ expect { Radiation::Source.new(nuclide: "Ra-15") }.to raise_error
50
+ expect { Radiation::Source.new(nuclide: "Ra-15", resource: "nucleide.org") }.to raise_error
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,2 @@
1
+ require 'radiation'
2
+ require 'plusminus'
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jan Mayer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: plusminus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: open-uri-cached
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Decay Radiation
84
+ email:
85
+ - jan.mayer@ikp.uni-koeln.de
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - data/Eu-152.bib
99
+ - data/Eu-152.csv
100
+ - data/Ra-226.bib
101
+ - data/Ra-226.csv
102
+ - lib/radiation.rb
103
+ - lib/radiation/source.rb
104
+ - lib/radiation/source/resource.rb
105
+ - lib/radiation/source/resource/internal.rb
106
+ - lib/radiation/source/resource/nucleideorg.rb
107
+ - lib/radiation/version.rb
108
+ - radiation.gemspec
109
+ - samples/get_some_data.rb
110
+ - spec/radiation_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: ''
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.0.3
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: This gem provides easy access to energies and intensities from the decay
136
+ of radioactive nuclei
137
+ test_files:
138
+ - spec/radiation_spec.rb
139
+ - spec/spec_helper.rb