radiation 0.1.1 → 0.1.2
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 +4 -4
- data/.gitignore +17 -17
- data/.rspec +1 -1
- 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 +1 -1
- data/lib/radiation/resource/nucleideorg.rb +2 -1
- data/lib/radiation/spectrum.rb +4 -2
- data/lib/radiation/version.rb +1 -1
- data/radiation.gemspec +32 -32
- data/samples/B0-Ra226.xml +4721 -4721
- data/samples/efficiencies_fit.rb +47 -0
- metadata +3 -2
@@ -0,0 +1,47 @@
|
|
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
|
+
peaks = Radiation::Spectrum.new(source: source).parse_hdtv(file).calibrate.efficiencies.peaks.select{|p| p[:intensity] > 0.3}.sort_by{|k| k[:energy]}
|
9
|
+
peaks.each do |p|
|
10
|
+
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)}"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
require 'open3'
|
15
|
+
require 'tmpdir'
|
16
|
+
|
17
|
+
variables = ["a","b","c"]
|
18
|
+
|
19
|
+
gnuplot_commands = <<"End"
|
20
|
+
# Activate fit errors
|
21
|
+
set fit errorvariables
|
22
|
+
# Disable fit logging
|
23
|
+
set fit quiet
|
24
|
+
set fit logfile "#{Dir.tmpdir}/radiation/fit.log"
|
25
|
+
# Redirect print output to stdout
|
26
|
+
set print "-"
|
27
|
+
# Prepare fit
|
28
|
+
a = #{peaks.first[:efficiency]}
|
29
|
+
b = 0.2
|
30
|
+
c = #{peaks.first[:efficiency]}
|
31
|
+
d = 0.2
|
32
|
+
f(x) = a*exp(-b*b*x)+c#*exp(-d*d*x)
|
33
|
+
fit f(x) "-" via a,b,c#,d
|
34
|
+
End
|
35
|
+
|
36
|
+
peaks.each do |p|
|
37
|
+
gnuplot_commands << "#{p[:energy]} #{p[:efficiency]}\n"
|
38
|
+
end
|
39
|
+
gnuplot_commands << "e\n"
|
40
|
+
|
41
|
+
variables.each do |v|
|
42
|
+
gnuplot_commands << "print #{v}, #{v}_err\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
values, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
|
46
|
+
|
47
|
+
puts values
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-08-
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plusminus
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- samples/calibrate_a_spectrum.rb
|
174
174
|
- samples/calibration_from_hdtv_xml.rb
|
175
175
|
- samples/efficiencies.rb
|
176
|
+
- samples/efficiencies_fit.rb
|
176
177
|
- samples/get_some_data.rb
|
177
178
|
- spec/radiation_spec.rb
|
178
179
|
- spec/spec_helper.rb
|