radiation 0.0.2 → 0.0.3
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 +8 -8
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +4 -1
- data/lib/radiation/spectrum.rb +11 -1
- data/lib/radiation/version.rb +1 -1
- data/radiation.gemspec +2 -1
- data/samples/B0-Ra226.spc +0 -0
- data/samples/B0-Ra226.xml +4721 -0
- data/samples/calibration_from_hdtv_xml.rb +8 -0
- data/spec/radiation_spec.rb +5 -1
- metadata +23 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDQxMmMyNzdkMmY0NzUxMTE0NmQ4NzQ2ZTYwMTBiNzhlZWI5ZTViMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjU3MzFhMTA1YzA2ODgyZTJlYzhhNjRlYjhmMjQ1MjQ4MzRkZTM1OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjJhYzU4ZmZmYjY1NTUyM2I5MzU4ZWRkOWY0ODViZjM4NGVmY2U4MGJlY2Q1
|
10
|
+
MTU5ZGNmZTY2ZjQwY2QyZGIyYjcxNWRhYWExMjdmZTgyOWUzODBiZTBlMjQy
|
11
|
+
OGY0MmIxZjBkMzM5NzhjMzcyZGMzOGIyZGYzZWUzYjI2ZTdkYjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDBkZTg1OWY1Y2IxYzQzMWEzMjJhODU0YmExNWJkNTczOWMwMGZiY2FjMjI4
|
14
|
+
MTYwN2M5MTczNzc5NGRiMmZmMzM2NTJmMTFkNDkxNzQ2YWY0MDBkNzQwZGQx
|
15
|
+
ZmZlODEwYzlmM2JiYjAyY2MzNjlmMjljOTVlNTljMzYwYzIwMmM=
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# Radiation
|
1
|
+
# Radiation
|
2
|
+
[](http://badge.fury.io/rb/radiation)
|
3
|
+
[](https://travis-ci.org/janmayer/radiation)
|
4
|
+
[](https://codeclimate.com/github/janmayer/radiation)
|
2
5
|
|
3
6
|
This gem provides easy access to energies and intensities from the decay of radioactive nuclei.
|
4
7
|
Currently two data sources are accessible: Internal (see bib files in `./data/`) and recommended values
|
data/lib/radiation/spectrum.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "linefit"
|
3
3
|
require "plusminus"
|
4
|
+
require "xmlsimple"
|
4
5
|
|
5
6
|
class Radiation::Spectrum
|
6
7
|
attr_accessor :peaks, :source, :calibration
|
@@ -39,7 +40,7 @@ class Radiation::Spectrum
|
|
39
40
|
def match_channels(energies=@source.energies, rounding=4)
|
40
41
|
@peaks.each do |peak|
|
41
42
|
energies.each do |energy|
|
42
|
-
peak[:energy] = energy if channel_energy(peak[:channel]).approx_equal?(energy, rounding)
|
43
|
+
peak[:energy] = energy if channel_energy(peak[:channel]).to_f.approx_equal?(energy, rounding)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
return self
|
@@ -58,6 +59,15 @@ class Radiation::Spectrum
|
|
58
59
|
@calibration[0] + @calibration[1]*chn
|
59
60
|
end
|
60
61
|
|
62
|
+
def parse_hdtv(file)
|
63
|
+
xml = XmlSimple.xml_in(file, { 'KeyAttr' => 'name' })
|
64
|
+
@peaks = xml["fit"].collect{|p| p["peak"]}.flatten.collect{|p| p["uncal"]}.flatten.collect do |p|
|
65
|
+
{:channel => p["pos"].first["value"].first.to_f.pm(p["pos"].first["error"].first.to_f),
|
66
|
+
:counts => p["vol"].first["value"].first.to_f.pm(p["vol"].first["error"].first.to_f) }
|
67
|
+
end
|
68
|
+
return self
|
69
|
+
end
|
70
|
+
|
61
71
|
end
|
62
72
|
|
63
73
|
|
data/lib/radiation/version.rb
CHANGED
data/radiation.gemspec
CHANGED
@@ -21,7 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "plusminus"
|
22
22
|
spec.add_dependency "open-uri-cached"
|
23
23
|
spec.add_dependency "combinatorics"
|
24
|
-
spec.add_dependency "linefit"
|
24
|
+
spec.add_dependency "linefit"
|
25
|
+
spec.add_dependency "xml-simple"
|
25
26
|
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
Binary file
|