radiation 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +6 -14
- data/.gitignore +17 -17
- data/.rspec +1 -1
- data/.travis.yml +7 -9
- data/CHANGELOG.md +12 -12
- data/Gemfile +5 -5
- data/LICENSE.txt +22 -22
- data/README.md +45 -45
- data/Rakefile +6 -6
- data/lib/radiation/cli.rb +22 -0
- data/lib/radiation/resource/internal.rb +20 -0
- data/lib/radiation/resource/nucleideorg.rb +43 -0
- data/lib/radiation/resource.rb +14 -0
- data/lib/radiation/source.rb +47 -31
- data/lib/radiation/spectrum.rb +78 -61
- data/lib/radiation/version.rb +3 -3
- data/lib/radiation.rb +10 -7
- data/radiation.gemspec +32 -32
- data/samples/B0-Ra226.xml +4721 -4721
- data/samples/efficiencies.rb +10 -0
- data/spec/radiation_spec.rb +14 -4
- metadata +24 -23
- data/lib/radiation/source/resource/internal.rb +0 -17
- data/lib/radiation/source/resource/nucleideorg.rb +0 -36
- data/lib/radiation/source/resource.rb +0 -25
@@ -0,0 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'radiation'
|
3
|
+
|
4
|
+
file = "./B0-Ra226.xml"
|
5
|
+
source = Radiation::Source.new(nuclide: "Ra-226", resource: "nucleide.org")
|
6
|
+
|
7
|
+
puts ["E_ɣ", "I_ɣ", "ΔI_ɣ", "e", "Δe"].join("\t")
|
8
|
+
Radiation::Spectrum.new(source: source).parse_hdtv(file).calibrate.efficiencies.select{|p| p[:intensity] > 0.3}.sort_by{|k| k[:energy]}.each do |p|
|
9
|
+
puts "#{p[:energy].to_f.round(1)}\t#{p[:intensity].value}\t#{p[:intensity].delta}\t#{p[:efficiency].value.round(1)}\t#{p[:efficiency].delta.round(1)}"
|
10
|
+
end
|
data/spec/radiation_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Radiation do
|
|
9
9
|
it "provides information about itself" do
|
10
10
|
source.nuclide.should eq(name)
|
11
11
|
#source.reference.should be_a_kind_of(String)
|
12
|
-
#source.
|
12
|
+
#source.halflife.should be_a_kind_of(Plusminus::PlusminusFloat)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns an array with gamma-ray energies for a given source" do
|
@@ -23,12 +23,13 @@ describe Radiation do
|
|
23
23
|
source.intensities.first.should be_a_kind_of(Hash)
|
24
24
|
source.intensities.length.should be > 0
|
25
25
|
end
|
26
|
+
|
26
27
|
it "can access different data resources" do
|
27
28
|
expect { Radiation::Source.new(nuclide: "Ra-226") }.to_not raise_error
|
28
29
|
expect { Radiation::Source.new(nuclide: "Ra-226", resource: "nucleide.org") }.to_not raise_error
|
29
30
|
end
|
30
31
|
|
31
|
-
it "
|
32
|
+
it "checks for valid nuclei" do
|
32
33
|
Radiation::Source.new.is_nuclide?("Nukular9000").should be false
|
33
34
|
Radiation::Source.new.is_nuclide?("226Ra-226").should be false
|
34
35
|
Radiation::Source.new.is_nuclide?("Ra-226").should be true
|
@@ -37,10 +38,15 @@ describe Radiation do
|
|
37
38
|
expect { Radiation::Source.new(nuclide: "Nukular9000") }.to raise_error
|
38
39
|
expect { Radiation::Source.new(nuclide: "Ra-226") }.to_not raise_error
|
39
40
|
end
|
41
|
+
|
40
42
|
it "gives an error if no record is found" do
|
41
43
|
expect { Radiation::Source.new(nuclide: "Ra-15") }.to raise_error
|
42
44
|
expect { Radiation::Source.new(nuclide: "Ra-15", resource: "nucleide.org") }.to raise_error
|
43
45
|
end
|
46
|
+
|
47
|
+
it "can access nuclide halflife" do
|
48
|
+
Radiation::Source.new(nuclide: "Ra-226", resource: "nucleide.org").halflife.to_f.should be_within(0.001).of(50.49E9)
|
49
|
+
end
|
44
50
|
end
|
45
51
|
|
46
52
|
describe Radiation::Spectrum do
|
@@ -63,8 +69,12 @@ describe Radiation do
|
|
63
69
|
|
64
70
|
it "can read peaks from hdtv xml data" do
|
65
71
|
expect { Radiation::Spectrum.new(source: source ).parse_hdtv("./samples/B0-Ra226.xml") }.to_not raise_error
|
66
|
-
Radiation::Spectrum.new(source: source ).parse_hdtv("./samples/B0-Ra226.xml").calibrate.calibration[1].
|
72
|
+
Radiation::Spectrum.new(source: source ).parse_hdtv("./samples/B0-Ra226.xml").calibrate.calibration[1].to_f.should be_within(0.001).of(0.1)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "can calculate detection efficiencies" do
|
76
|
+
Radiation::Spectrum.new(source: source).parse_hdtv("./samples/B0-Ra226.xml").calibrate.efficiencies.select{|p| p[:energy].to_f.to_i == 295}.first[:efficiency].should be_a_kind_of(Plusminus::PlusminusFloat)
|
67
77
|
end
|
68
78
|
|
69
79
|
end
|
70
|
-
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plusminus
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: open-uri-cached
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: combinatorics
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: linefit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: xml-simple
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -112,28 +112,28 @@ dependencies:
|
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: Decay Radiation
|
@@ -159,10 +159,10 @@ files:
|
|
159
159
|
- data/Ra-226.csv
|
160
160
|
- lib/radiation.rb
|
161
161
|
- lib/radiation/cli.rb
|
162
|
+
- lib/radiation/resource.rb
|
163
|
+
- lib/radiation/resource/internal.rb
|
164
|
+
- lib/radiation/resource/nucleideorg.rb
|
162
165
|
- lib/radiation/source.rb
|
163
|
-
- lib/radiation/source/resource.rb
|
164
|
-
- lib/radiation/source/resource/internal.rb
|
165
|
-
- lib/radiation/source/resource/nucleideorg.rb
|
166
166
|
- lib/radiation/spectrum.rb
|
167
167
|
- lib/radiation/version.rb
|
168
168
|
- radiation.gemspec
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- samples/B0-Ra226.xml
|
171
171
|
- samples/calibrate_a_spectrum.rb
|
172
172
|
- samples/calibration_from_hdtv_xml.rb
|
173
|
+
- samples/efficiencies.rb
|
173
174
|
- samples/get_some_data.rb
|
174
175
|
- spec/radiation_spec.rb
|
175
176
|
- spec/spec_helper.rb
|
@@ -183,12 +184,12 @@ require_paths:
|
|
183
184
|
- lib
|
184
185
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
186
|
requirements:
|
186
|
-
- -
|
187
|
+
- - '>='
|
187
188
|
- !ruby/object:Gem::Version
|
188
189
|
version: '0'
|
189
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
191
|
requirements:
|
191
|
-
- -
|
192
|
+
- - '>='
|
192
193
|
- !ruby/object:Gem::Version
|
193
194
|
version: '0'
|
194
195
|
requirements: []
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,36 +0,0 @@
|
|
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 equilibrium 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
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'radiation/source/resource/internal'
|
3
|
-
require 'radiation/source/resource/nucleideorg'
|
4
|
-
|
5
|
-
module Radiation
|
6
|
-
class Source
|
7
|
-
class Resource
|
8
|
-
|
9
|
-
def initialize(resource)
|
10
|
-
@resource = resource
|
11
|
-
end
|
12
|
-
|
13
|
-
def data(nuclide)
|
14
|
-
@data = {}
|
15
|
-
case @resource
|
16
|
-
when "internal" then datasource_internal(nuclide)
|
17
|
-
when "nucleide.org" then datasource_nukleideorg(nuclide)
|
18
|
-
else raise "Unknown Datasource"
|
19
|
-
end
|
20
|
-
return @data
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|